"0 wird nicht benutzt"
Dieser Commit ist enthalten in:
Ursprung
27d6e9accf
Commit
d30650bad3
@ -85,7 +85,7 @@ public class NodeMember {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setParentId(Integer parentId) {
|
public void setParentId(Integer parentId) {
|
||||||
this.parentId = parentId == null || parentId == 0 ? null : parentId;
|
this.parentId = parentId;
|
||||||
updateParent.update(this.parentId, nodeId, userId);
|
updateParent.update(this.parentId, nodeId, userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public class SchematicNode {
|
|||||||
private static final Statement update = table.update(Table.PRIMARY, "NodeName", "ParentNode", "NodeItem", "NodeType", "NodeRank", "ReplaceColor", "AllowReplay", "NodeFormat");
|
private static final Statement update = table.update(Table.PRIMARY, "NodeName", "ParentNode", "NodeItem", "NodeType", "NodeRank", "ReplaceColor", "AllowReplay", "NodeFormat");
|
||||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||||
|
|
||||||
private static final SelectStatement<SchematicNode> byId = table.select(Table.PRIMARY);
|
private static final SelectStatement<SchematicNode> byId = new SelectStatement<>(table, nodeSelector + "WHERE NodeId = ?");
|
||||||
private static final SelectStatement<SchematicNode> byOwnerNameParent = table.select("OwnerNameParent");
|
private static final SelectStatement<SchematicNode> byOwnerNameParent = table.select("OwnerNameParent");
|
||||||
private static final SelectStatement<SchematicNode> byParent = new SelectStatement<>(table, nodeSelector + "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? ORDER BY NodeName");
|
private static final SelectStatement<SchematicNode> byParent = new SelectStatement<>(table, nodeSelector + "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? ORDER BY NodeName");
|
||||||
private static final SelectStatement<SchematicNode> dirsByParent = new SelectStatement<>(table, nodeSelector + "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? AND NodeType is NULL ORDER BY NodeName");
|
private static final SelectStatement<SchematicNode> dirsByParent = new SelectStatement<>(table, nodeSelector + "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? AND NodeType is NULL ORDER BY NodeName");
|
||||||
@ -58,10 +58,10 @@ public class SchematicNode {
|
|||||||
private static final SelectStatement<SchematicNode> list = new SelectStatement<>(table, "SELECT * FROM EffectiveSchematicNode WHERE EffectiveOwner = ? AND ParentNode" + Statement.NULL_SAFE_EQUALS + "? ORDER BY NodeName");
|
private static final SelectStatement<SchematicNode> list = new SelectStatement<>(table, "SELECT * FROM EffectiveSchematicNode WHERE EffectiveOwner = ? AND ParentNode" + Statement.NULL_SAFE_EQUALS + "? ORDER BY NodeName");
|
||||||
private static final SelectStatement<SchematicNode> byParentName = new SelectStatement<>(table, "SELECT * FROM EffectiveSchematicNode WHERE EffectiveOwner = ? AND ParentNode" + Statement.NULL_SAFE_EQUALS + "? AND NodeName = ? ORDER BY NodeName");
|
private static final SelectStatement<SchematicNode> byParentName = new SelectStatement<>(table, "SELECT * FROM EffectiveSchematicNode WHERE EffectiveOwner = ? AND ParentNode" + Statement.NULL_SAFE_EQUALS + "? AND NodeName = ? ORDER BY NodeName");
|
||||||
private static final SelectStatement<SchematicNode> schematicAccessibleForUser = new SelectStatement<>(table, "SELECT COUNT(DISTINCT NodeId) FROM EffectiveSchematicNode WHERE EffectiveOwner = ? AND NodeId = ?");
|
private static final SelectStatement<SchematicNode> schematicAccessibleForUser = new SelectStatement<>(table, "SELECT COUNT(DISTINCT NodeId) FROM EffectiveSchematicNode WHERE EffectiveOwner = ? AND NodeId = ?");
|
||||||
private static final SelectStatement<SchematicNode> accessibleByUserTypeInParent = new SelectStatement<>(table, "WITH RECURSIVE RSN AS (SELECT NodeId, ParentNode FROM EffectiveSchematicNode WHERE NodeType = ? AND EffectiveOwner = ? UNION SELECT SN.NodeId, SN.ParentNode FROM RSN, EffectiveSchematicNode SN WHERE SN.NodeId = RSN.ParentNode AND EffectiveOwner = ?) SELECT SN.NodeId, SN.NodeOwner, ? AS EffectiveOwner, SN.NodeName, RSN.ParentNode, SN.LastUpdate, SN.NodeItem, SN.NodeType, SN.NodeRank FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId WHERE RSN.ParentNode" + Statement.NULL_SAFE_EQUALS + "?");
|
private static final SelectStatement<SchematicNode> accessibleByUserTypeInParent = new SelectStatement<>(table, "WITH RECURSIVE RSN AS (SELECT NodeId, ParentNode FROM EffectiveSchematicNode WHERE NodeType = ? AND EffectiveOwner = ? UNION SELECT SN.NodeId, SN.ParentNode FROM RSN, EffectiveSchematicNode SN WHERE SN.NodeId = RSN.ParentNode AND EffectiveOwner = ?) SELECT SN.NodeId, SN.NodeOwner, ? AS EffectiveOwner, SN.NodeName, RSN.ParentNode, SN.LastUpdate, SN.NodeItem, SN.NodeType, SN.NodeRank, SN.ReplaceColor, SN.AllowReplay, SN.NodeFormat FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId WHERE RSN.ParentNode" + Statement.NULL_SAFE_EQUALS + "?");
|
||||||
private static final SelectStatement<SchematicNode> accessibleByUserType = new SelectStatement<>(table, "SELECT * FROM EffectiveSchematicNode WHERE EffectiveOwner = ? AND NodeType = ?");
|
private static final SelectStatement<SchematicNode> accessibleByUserType = new SelectStatement<>(table, "SELECT * FROM EffectiveSchematicNode WHERE EffectiveOwner = ? AND NodeType = ?");
|
||||||
private static final SelectStatement<SchematicNode> byIdAndUser = new SelectStatement<>(table, "SELECT * FROM EffectiveSchematicNode WHERE EffectiveOwner = ? AND NodeId = ?");
|
private static final SelectStatement<SchematicNode> byIdAndUser = new SelectStatement<>(table, "SELECT * FROM EffectiveSchematicNode WHERE EffectiveOwner = ? AND NodeId = ?");
|
||||||
private static final SelectStatement<SchematicNode> allParentsOfNode = new SelectStatement<>(table, "WITH RECURSIVE R AS (SELECT NodeId, ParentNode FROM EffectiveSchematicNode WHERE NodeId = ? AND EffectiveOwner = ? UNION SELECT E.NodeId, E.ParentNode FROM R, EffectiveSchematicNode E WHERE R.ParentNode = E.NodeId AND E.EffectiveOwner = ?) SELECT SN.NodeId, SN.NodeOwner, ? AS EffectiveOwner, SN.NodeName, R.ParentNode, SN.LastUpdate, SN.NodeItem, SN.NodeType, SN.NodeRank FROM R INNER JOIN SchematicNode SN ON SN.NodeId = R.NodeId");
|
private static final SelectStatement<SchematicNode> allParentsOfNode = new SelectStatement<>(table, "WITH RECURSIVE R AS (SELECT NodeId, ParentNode FROM EffectiveSchematicNode WHERE NodeId = ? AND EffectiveOwner = ? UNION SELECT E.NodeId, E.ParentNode FROM R, EffectiveSchematicNode E WHERE R.ParentNode = E.NodeId AND E.EffectiveOwner = ?) SELECT SN.NodeId, SN.NodeOwner, ? AS EffectiveOwner, SN.NodeName, R.ParentNode, SN.LastUpdate, SN.NodeItem, SN.NodeType, SN.NodeRank, SN.ReplaceColor, SN.AllowReplay, SN.NodeFormat FROM R INNER JOIN SchematicNode SN ON SN.NodeId = R.NodeId");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
NodeMember.init();
|
NodeMember.init();
|
||||||
@ -71,7 +71,7 @@ public class SchematicNode {
|
|||||||
private final int nodeId;
|
private final int nodeId;
|
||||||
@Field(keys = {"OwnerNameParent"})
|
@Field(keys = {"OwnerNameParent"})
|
||||||
private final int nodeOwner;
|
private final int nodeOwner;
|
||||||
@Field
|
@Field(def = "0")
|
||||||
@Getter
|
@Getter
|
||||||
private final int effectiveOwner;
|
private final int effectiveOwner;
|
||||||
@Field(keys = {"OwnerNameParent"})
|
@Field(keys = {"OwnerNameParent"})
|
||||||
@ -161,7 +161,7 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<SchematicNode> parentsOfNode(SteamwarUser user, Integer id) {
|
public static List<SchematicNode> parentsOfNode(SteamwarUser user, Integer id) {
|
||||||
return allParentsOfNode.listSelect(id, user, user, user).stream().filter(n -> n.getId() != id).collect(Collectors.toList());
|
return allParentsOfNode.listSelect(id, user, user, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<Integer, List<SchematicNode>> map(List<SchematicNode> in) {
|
private static Map<Integer, List<SchematicNode>> map(List<SchematicNode> in) {
|
||||||
@ -290,7 +290,7 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
if (s.contains("/")) {
|
if (s.contains("/")) {
|
||||||
String[] layers = s.split("/");
|
String[] layers = s.split("/");
|
||||||
Optional<SchematicNode> currentNode = Optional.ofNullable(SchematicNode.byParentName(user, 0, layers[0]));
|
Optional<SchematicNode> currentNode = Optional.ofNullable(SchematicNode.byParentName(user, null, layers[0]));
|
||||||
for (int i = 1; i < layers.length; i++) {
|
for (int i = 1; i < layers.length; i++) {
|
||||||
int finalI = i;
|
int finalI = i;
|
||||||
Optional<SchematicNode> node = currentNode.map(effectiveSchematicNode -> SchematicNode.byParentName(user, effectiveSchematicNode.getId(), layers[finalI]));
|
Optional<SchematicNode> node = currentNode.map(effectiveSchematicNode -> SchematicNode.byParentName(user, effectiveSchematicNode.getId(), layers[finalI]));
|
||||||
@ -305,7 +305,7 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
return currentNode.orElse(null);
|
return currentNode.orElse(null);
|
||||||
} else {
|
} else {
|
||||||
return SchematicNode.byParentName(user, 0, s);
|
return SchematicNode.byParentName(user, null, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,14 +484,12 @@ public class SchematicNode {
|
|||||||
return ((SchematicNode) obj).getId() == nodeId;
|
return ((SchematicNode) obj).getId() == nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public String generateBreadcrumbs(SteamwarUser user) {
|
public String generateBreadcrumbs(SteamwarUser user) {
|
||||||
return generateBreadcrumbs();
|
return byIdAndUser(user, nodeId).generateBreadcrumbs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public String generateBreadcrumbs(String split, SteamwarUser user) {
|
public String generateBreadcrumbs(String split, SteamwarUser user) {
|
||||||
return generateBreadcrumbs(split);
|
return byIdAndUser(user, nodeId).generateBreadcrumbs(split);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String generateBreadcrumbs() {
|
public String generateBreadcrumbs() {
|
||||||
@ -556,7 +554,7 @@ public class SchematicNode {
|
|||||||
List<SchematicNode> nodes = SchematicNode.list(user, pa.getId());
|
List<SchematicNode> nodes = SchematicNode.list(user, pa.getId());
|
||||||
nodes.forEach(node -> list.add((sws ? "/" : "") + node.generateBreadcrumbs()));
|
nodes.forEach(node -> list.add((sws ? "/" : "") + node.generateBreadcrumbs()));
|
||||||
} else {
|
} else {
|
||||||
List<SchematicNode> nodes = SchematicNode.list(user, 0);
|
List<SchematicNode> nodes = SchematicNode.list(user, null);
|
||||||
nodes.forEach(node -> list.add((sws ? "/" : "") + node.getName() + (node.isDir() ? "/" : "")));
|
nodes.forEach(node -> list.add((sws ? "/" : "") + node.getName() + (node.isDir() ? "/" : "")));
|
||||||
}
|
}
|
||||||
list.remove("//copy");
|
list.remove("//copy");
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren