Skip to content

Commit 68e44fd

Browse files
committed
1.5.11
robust recovery from missing elements
1 parent 9faedc2 commit 68e44fd

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.marginallyclever</groupId>
66
<artifactId>nodegraphcore</artifactId>
7-
<version>1.5.10</version>
7+
<version>1.5.11</version>
88

99
<name>NodeGraphCore</name>
1010
<description>Flow based programming in Java.</description>

src/main/java/com/marginallyclever/nodegraphcore/Graph.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,6 @@ public void fromJSON(JSONObject jo) throws JSONException {
381381
// older files might be missing these values.
382382
if(!jo.has("name")) jo.put("name",getName());
383383
if(!jo.has("uniqueID")) jo.put("uniqueID",getUniqueID());
384-
if(!jo.has("label")) jo.put("label", getLabel());
385384
// proceed now that missing values are added.
386385
super.fromJSON(jo);
387386
parseAllNodesFromJSON(jo.getJSONArray("nodes"));

src/main/java/com/marginallyclever/nodegraphcore/Node.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,10 @@ public void moveRelative(int dx, int dy) {
288288
}
289289

290290
public void fromJSON(JSONObject jo) throws JSONException {
291-
String joName = jo.getString("name");
292-
if(!name.equals(joName)) throw new JSONException("Node types do not match: "+name+", "+joName);
291+
if(jo.has("name")) {
292+
String joName = jo.getString("name");
293+
if (!name.equals(joName)) throw new JSONException("Node types do not match: " + name + ", " + joName);
294+
}
293295

294296
Object uid = jo.get("uniqueID");
295297
uniqueID = (uid instanceof String) ? (String)uid : uid.toString();
@@ -298,11 +300,15 @@ public void fromJSON(JSONObject jo) throws JSONException {
298300
String s = jo.getString("label");
299301
if(!s.equals("null")) label = s;
300302
}
301-
// bounds
302-
RectangleDAO4JSON dao = new RectangleDAO4JSON();
303-
rectangle.setBounds(dao.fromJSON(jo.getJSONObject("rectangle")));
304-
// all ports
305-
parseAllPortsFromJSON(jo.getJSONArray("variables"));
303+
if(jo.has("rectangle")) {
304+
// get the rectangle
305+
RectangleDAO4JSON dao = new RectangleDAO4JSON();
306+
rectangle.setBounds(dao.fromJSON(jo.getJSONObject("rectangle")));
307+
}
308+
if(jo.has("ports")) {
309+
// all ports
310+
parseAllPortsFromJSON(jo.getJSONArray("variables"));
311+
}
306312
}
307313

308314
protected void parseAllPortsFromJSON(JSONArray vars) throws JSONException {

0 commit comments

Comments
 (0)