diff --git a/src/de/steamwar/sql/SchematicNode.java b/src/de/steamwar/sql/SchematicNode.java index 0dadeb0..594b20a 100644 --- a/src/de/steamwar/sql/SchematicNode.java +++ b/src/de/steamwar/sql/SchematicNode.java @@ -55,7 +55,6 @@ public class SchematicNode { private static final SelectStatement byId = table.select(Table.PRIMARY); private static final SelectStatement byOwnerNameParent = table.select("OwnerNameParent"); - private static final SelectStatement byOwnerNameParent_null = new SelectStatement<>(table, nodeSelectCreator("") + "WHERE NodeOwner = ? AND NodeName = ? AND ParentNode is NULL"); private static final SelectStatement byParent = new SelectStatement<>(table, nodeSelectCreator("") + "WHERE ParentNode <=> ? ORDER BY NodeName"); private static final SelectStatement dirsByParent = new SelectStatement<>(table, nodeSelectCreator("") + "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? AND NodeType is NULL ORDER BY NodeName"); private static final SelectStatement byOwnerType = new SelectStatement<>(table, nodeSelectCreator("") + "WHERE NodeOwner = ? AND NodeType = ? ORDER BY NodeName"); @@ -130,13 +129,6 @@ public class SchematicNode { this.nodeFormat = nodeFormat; } - private static Integer nullOrNotNul(Integer i) { - if(i == null || i == 0) { - return null; - } - return i; - } - public static List getAll(SteamwarUser user) { return all.listSelect(user); } @@ -146,11 +138,11 @@ public class SchematicNode { } public static List list(SteamwarUser user, Integer schematicId) { - return list.listSelect(user, nullOrNotNul(schematicId)); + return list.listSelect(user, schematicId); } public static SchematicNode byParentName(SteamwarUser user, Integer schematicId, String name) { - return byParentName.select(user, nullOrNotNul(schematicId), name); + return byParentName.select(user, schematicId, name); } public static List accessibleByUserType(SteamwarUser user, SchematicType type) { @@ -166,7 +158,7 @@ public class SchematicNode { } public static List accessibleByUserTypeParent(SteamwarUser user, SchematicType type, Integer parentId) { - return accessibleByUserTypeInParent.listSelect(type, user, user, user, nullOrNotNul(parentId)); + return accessibleByUserTypeInParent.listSelect(type, user, user, user, parentId); } public static SchematicNode byIdAndUser(SteamwarUser user, Integer id) { @@ -205,8 +197,6 @@ public class SchematicNode { } public static SchematicNode getSchematicNode(int owner, String name, Integer parent) { - if (parent == null || parent == 0) - return byOwnerNameParent_null.select(owner, name); return byOwnerNameParent.select(owner, name, parent); } @@ -215,18 +205,11 @@ public class SchematicNode { } public static List getSchematicNodeInNode(Integer parent) { - if(parent == null || parent == 0) { - rootWarning(); - } - - return byParent.listSelect(nullOrNotNul(parent)); + return byParent.listSelect(parent); } public static List getSchematicDirectoryInNode(Integer parent) { - if(parent == null || parent == 0) { - rootWarning(); - } - return dirsByParent.listSelect(nullOrNotNul(parent)); + return dirsByParent.listSelect(parent); } @Deprecated @@ -240,10 +223,7 @@ public class SchematicNode { } public static SchematicNode getSchematicNode(String name, Integer parent) { - if(parent == null || parent == 0) { - rootWarning(); - } - return byParentName.select(name, nullOrNotNul(parent)); + return byParentName.select(name, parent); } public static SchematicNode getSchematicNode(int id) { @@ -588,10 +568,4 @@ public class SchematicNode { TAB_CACHE.computeIfAbsent(user.getId(), integer -> new HashMap<>()).putIfAbsent(cacheKey, list); return list; } - - private static void rootWarning() { - ByteArrayOutputStream stacktraceOutput = new ByteArrayOutputStream(); - new Throwable().printStackTrace(new PrintStream(stacktraceOutput)); - SWException.log("PERFORMANCE!!! Getting all/weird subset of schematic nodes with parent NULL", stacktraceOutput.toString()); - } }