|
@@ -110,7 +110,8 @@ public class LoadController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * distribute the Edges
|
|
|
+ * distribute the Edges
|
|
|
+ *
|
|
|
* @param edges
|
|
|
* @param json
|
|
|
* @param objDispatch
|
|
@@ -118,20 +119,28 @@ public class LoadController {
|
|
|
private void distEdges(List<String> edges, JsonObject json, HashMap<Integer, AbstractCpsObject> objDispatch) {
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
+ List<String> conn = new ArrayList<>();
|
|
|
+
|
|
|
for (String edge : edges) {
|
|
|
if (edge.contains("CVSEDGE"))
|
|
|
loadEdge(EDGETYPE.CANVAS, json.get(edge), objDispatch);
|
|
|
if (edge.contains("CONNEDGE"))
|
|
|
- loadEdge(EDGETYPE.CONNECTION, json.get(edge), objDispatch);
|
|
|
+ conn.add(edge);
|
|
|
if (edge.contains("NODE"))
|
|
|
loadEdge(EDGETYPE.NODE, json.get(edge), objDispatch);
|
|
|
if (edge.contains("OLD"))
|
|
|
loadEdge(EDGETYPE.OLD, json.get(edge), objDispatch);
|
|
|
}
|
|
|
+
|
|
|
+ for (String edge : conn) {
|
|
|
+ loadEdge(EDGETYPE.CONNECTION, json.get(edge), objDispatch);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Distribute the given keys for right processing
|
|
|
+ *
|
|
|
* @param keys
|
|
|
* @param json
|
|
|
* @param objDispatch
|
|
@@ -248,9 +257,10 @@ public class LoadController {
|
|
|
objDispatch.put(temp.getID(), temp);
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Load a given Element in Canvas by Deserialization
|
|
|
+ *
|
|
|
* @param jsonElement
|
|
|
* @param objDispatch
|
|
|
* @param eleDispatch
|
|
@@ -260,21 +270,22 @@ public class LoadController {
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
JsonObject object = jsonElement.getAsJsonObject();
|
|
|
-
|
|
|
+
|
|
|
HolonElement temp = gson.fromJson(object.get("properties"), HolonElement.class);
|
|
|
initElements(temp);
|
|
|
- //id which Object it was stored before
|
|
|
+ // id which Object it was stored before
|
|
|
int stored = object.get("ID").getAsInt();
|
|
|
- //lookup that object
|
|
|
+ // lookup that object
|
|
|
HolonObject temp2 = (HolonObject) objDispatch.get(stored);
|
|
|
- //add it
|
|
|
+ // add it
|
|
|
objC.addElement(temp2, temp);
|
|
|
- //store element also inside a table
|
|
|
+ // store element also inside a table
|
|
|
eleDispatch.put(temp.getId(), temp);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Load a given Edge by Deserialization
|
|
|
+ *
|
|
|
* @param type
|
|
|
* @param jsonElement
|
|
|
* @param objDispatch
|
|
@@ -284,7 +295,7 @@ public class LoadController {
|
|
|
JsonObject object = jsonElement.getAsJsonObject();
|
|
|
CpsEdge temp = gson.fromJson(object.get("properties"), CpsEdge.class);
|
|
|
initCpsEdge(temp);
|
|
|
- //look for A and B inside the Table
|
|
|
+ // look for A and B inside the Table
|
|
|
temp.setA(objDispatch.get(object.get("A").getAsInt()));
|
|
|
temp.setB(objDispatch.get(object.get("B").getAsInt()));
|
|
|
|
|
@@ -292,13 +303,11 @@ public class LoadController {
|
|
|
|
|
|
switch (type) {
|
|
|
case CANVAS:
|
|
|
- //if in canvas add it into the canvas but delete connection before
|
|
|
+ // if in canvas add it into the canvas but delete connection before
|
|
|
model.getEdgesOnCanvas().add(temp);
|
|
|
- temp.getA().getConnections().remove(temp);
|
|
|
- temp.getB().getConnections().remove(temp);
|
|
|
break;
|
|
|
case CONNECTION:
|
|
|
- //if no duplicates in connection store them into the given A and B
|
|
|
+ // if no duplicates in connection store them into the given A and B
|
|
|
if (!uppC.lookforDuplicates(temp.getA(), temp.getB(), temp.getA().getConnections()))
|
|
|
temp.getA().getConnections().add(temp);
|
|
|
if (!uppC.lookforDuplicates(temp.getA(), temp.getB(), temp.getB().getConnections()))
|
|
@@ -310,7 +319,7 @@ public class LoadController {
|
|
|
((CpsUpperNode) objDispatch.get(sav)).getNodeEdges().add(temp);
|
|
|
break;
|
|
|
case OLD:
|
|
|
- //same as above
|
|
|
+ // same as above
|
|
|
sav = object.get("ID").getAsInt();
|
|
|
((CpsUpperNode) objDispatch.get(sav)).getOldEdges().add(temp);
|
|
|
break;
|
|
@@ -318,10 +327,16 @@ public class LoadController {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
+ if (object.get("connection").getAsBoolean()) {
|
|
|
+ temp.getA().getConnections().add(temp);
|
|
|
+ temp.getB().getConnections().add(temp);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Load a Unitgraph by Deserialization
|
|
|
+ *
|
|
|
* @param type
|
|
|
* @param jsonElement
|
|
|
* @param objDispatch
|
|
@@ -338,7 +353,7 @@ public class LoadController {
|
|
|
|
|
|
LinkedList<Point> graphpoint = new LinkedList<>();
|
|
|
int sav = 0;
|
|
|
- //foreach Point in the graph restore it
|
|
|
+ // foreach Point in the graph restore it
|
|
|
for (String k : keys) {
|
|
|
if (!k.equals("ID")) {
|
|
|
p = object.get(k).getAsString();
|
|
@@ -347,7 +362,7 @@ public class LoadController {
|
|
|
y = Integer.parseInt(p.substring(mid + 1, p.length()));
|
|
|
graphpoint.add(new Point(x, y));
|
|
|
} else
|
|
|
- //else its an ID
|
|
|
+ // else its an ID
|
|
|
sav = object.get(k).getAsInt();
|
|
|
|
|
|
}
|