Fixing minor bugs
Dieser Commit ist enthalten in:
Ursprung
8ca2d97034
Commit
a2d8d1eb3a
@ -30,6 +30,7 @@ import java.sql.Blob;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class SchematicNode {
|
public class SchematicNode {
|
||||||
|
|
||||||
@ -184,7 +185,8 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<SchematicNode> getSchematicsOfType(int owner, String schemType, Integer parent) {
|
public static List<SchematicNode> getSchematicsOfType(int owner, String schemType, Integer parent) {
|
||||||
List<SchematicNode> schems = getAllSchematicsOfType(owner, schemType);
|
List<SchematicNode> schems = getAllSchematicsAccessibleByUser(owner);
|
||||||
|
schems.removeIf(node -> !node.getType().equals(schemType));
|
||||||
Map<Integer, SchematicNode> nodesInParent = new LinkedHashMap<>();
|
Map<Integer, SchematicNode> nodesInParent = new LinkedHashMap<>();
|
||||||
for (SchematicNode schematicNode : schems) {
|
for (SchematicNode schematicNode : schems) {
|
||||||
SchematicNode currentNode = schematicNode;
|
SchematicNode currentNode = schematicNode;
|
||||||
@ -222,7 +224,7 @@ public class SchematicNode {
|
|||||||
throw new SecurityException("Failed listing schematics", e);
|
throw new SecurityException("Failed listing schematics", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SchematicNode> getAllSchematicsAccessibleByUser(int user) {
|
public static List<SchematicNode> getAllSchematicsAccessibleByUser(int user) {
|
||||||
@ -237,15 +239,29 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<SchematicNode> deepGet(Integer parent, Predicate<SchematicNode> filter) {
|
||||||
|
List<SchematicNode> finalList = new ArrayList<>();
|
||||||
|
List<SchematicNode> nodes = SchematicNode.getSchematicNodeInNode(parent);
|
||||||
|
nodes.forEach(node -> {
|
||||||
|
if(node.isDir()) {
|
||||||
|
finalList.addAll(deepGet(node.getId(), filter));
|
||||||
|
}else {
|
||||||
|
if(filter.test(node))
|
||||||
|
finalList.add(node);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return finalList;
|
||||||
|
}
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
private final int owner;
|
private final int owner;
|
||||||
private String name;
|
private String name;
|
||||||
private int parent;
|
private Integer parent;
|
||||||
private String item;
|
private String item;
|
||||||
private String type;
|
private String type;
|
||||||
private boolean schemFormat;
|
private boolean schemFormat;
|
||||||
private int rank;
|
private int rank;
|
||||||
private boolean isDir;
|
private final boolean isDir;
|
||||||
|
|
||||||
private SchematicNode(ResultSet set) throws SQLException {
|
private SchematicNode(ResultSet set) throws SQLException {
|
||||||
id = set.getInt("NodeId");
|
id = set.getInt("NodeId");
|
||||||
@ -353,7 +369,7 @@ public class SchematicNode {
|
|||||||
|
|
||||||
private void updateDB() {
|
private void updateDB() {
|
||||||
SQL.update("UPDATE SchematicNode SET NodeName = ?, NodeOwner = ?, ParentNode = ?, NodeItem = ?, NodeType = ?, NodeRank = ? WHERE NodeId = ?",
|
SQL.update("UPDATE SchematicNode SET NodeName = ?, NodeOwner = ?, ParentNode = ?, NodeItem = ?, NodeType = ?, NodeRank = ? WHERE NodeId = ?",
|
||||||
name, owner, parent, item, type, rank, id);
|
name, owner, parent == 0?null:parent, item, type, rank, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren