Dieser Commit ist enthalten in:
Ursprung
6a6483235c
Commit
ad43512d30
@ -55,7 +55,6 @@ public class SchematicNode {
|
|||||||
|
|
||||||
private static final SelectStatement<SchematicNode> byId = table.select(Table.PRIMARY);
|
private static final SelectStatement<SchematicNode> byId = table.select(Table.PRIMARY);
|
||||||
private static final SelectStatement<SchematicNode> byOwnerNameParent = table.select("OwnerNameParent");
|
private static final SelectStatement<SchematicNode> byOwnerNameParent = table.select("OwnerNameParent");
|
||||||
private static final SelectStatement<SchematicNode> byOwnerNameParent_null = new SelectStatement<>(table, nodeSelectCreator("") + "WHERE NodeOwner = ? AND NodeName = ? AND ParentNode is NULL");
|
|
||||||
private static final SelectStatement<SchematicNode> byParent = new SelectStatement<>(table, nodeSelectCreator("") + "WHERE ParentNode <=> ? ORDER BY NodeName");
|
private static final SelectStatement<SchematicNode> byParent = new SelectStatement<>(table, nodeSelectCreator("") + "WHERE ParentNode <=> ? ORDER BY NodeName");
|
||||||
private static final SelectStatement<SchematicNode> dirsByParent = new SelectStatement<>(table, nodeSelectCreator("") + "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? AND NodeType is NULL ORDER BY NodeName");
|
private static final SelectStatement<SchematicNode> dirsByParent = new SelectStatement<>(table, nodeSelectCreator("") + "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? AND NodeType is NULL ORDER BY NodeName");
|
||||||
private static final SelectStatement<SchematicNode> byOwnerType = new SelectStatement<>(table, nodeSelectCreator("") + "WHERE NodeOwner = ? AND NodeType = ? ORDER BY NodeName");
|
private static final SelectStatement<SchematicNode> byOwnerType = new SelectStatement<>(table, nodeSelectCreator("") + "WHERE NodeOwner = ? AND NodeType = ? ORDER BY NodeName");
|
||||||
@ -130,13 +129,6 @@ public class SchematicNode {
|
|||||||
this.nodeFormat = nodeFormat;
|
this.nodeFormat = nodeFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Integer nullOrNotNul(Integer i) {
|
|
||||||
if(i == null || i == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicNode> getAll(SteamwarUser user) {
|
public static List<SchematicNode> getAll(SteamwarUser user) {
|
||||||
return all.listSelect(user);
|
return all.listSelect(user);
|
||||||
}
|
}
|
||||||
@ -146,11 +138,11 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<SchematicNode> list(SteamwarUser user, Integer schematicId) {
|
public static List<SchematicNode> 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) {
|
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<SchematicNode> accessibleByUserType(SteamwarUser user, SchematicType type) {
|
public static List<SchematicNode> accessibleByUserType(SteamwarUser user, SchematicType type) {
|
||||||
@ -166,7 +158,7 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<SchematicNode> accessibleByUserTypeParent(SteamwarUser user, SchematicType type, Integer parentId) {
|
public static List<SchematicNode> 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) {
|
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) {
|
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);
|
return byOwnerNameParent.select(owner, name, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,18 +205,11 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<SchematicNode> getSchematicNodeInNode(Integer parent) {
|
public static List<SchematicNode> getSchematicNodeInNode(Integer parent) {
|
||||||
if(parent == null || parent == 0) {
|
return byParent.listSelect(parent);
|
||||||
rootWarning();
|
|
||||||
}
|
|
||||||
|
|
||||||
return byParent.listSelect(nullOrNotNul(parent));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SchematicNode> getSchematicDirectoryInNode(Integer parent) {
|
public static List<SchematicNode> getSchematicDirectoryInNode(Integer parent) {
|
||||||
if(parent == null || parent == 0) {
|
return dirsByParent.listSelect(parent);
|
||||||
rootWarning();
|
|
||||||
}
|
|
||||||
return dirsByParent.listSelect(nullOrNotNul(parent));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -240,10 +223,7 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SchematicNode getSchematicNode(String name, Integer parent) {
|
public static SchematicNode getSchematicNode(String name, Integer parent) {
|
||||||
if(parent == null || parent == 0) {
|
return byParentName.select(name, parent);
|
||||||
rootWarning();
|
|
||||||
}
|
|
||||||
return byParentName.select(name, nullOrNotNul(parent));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SchematicNode getSchematicNode(int id) {
|
public static SchematicNode getSchematicNode(int id) {
|
||||||
@ -588,10 +568,4 @@ public class SchematicNode {
|
|||||||
TAB_CACHE.computeIfAbsent(user.getId(), integer -> new HashMap<>()).putIfAbsent(cacheKey, list);
|
TAB_CACHE.computeIfAbsent(user.getId(), integer -> new HashMap<>()).putIfAbsent(cacheKey, list);
|
||||||
return 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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren