]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph.db/src/org/simantics/graph/db/TGToGraphMap.java
(refs #7563) Mark parents of new resource optional in graph.tg
[simantics/platform.git] / bundles / org.simantics.graph.db / src / org / simantics / graph / db / TGToGraphMap.java
index bc1c4eb5223ae12cda19f542b5536384f5cd8ae5..ca79b1ee5aabf35771ca1ea44a982d44fd848044 100644 (file)
@@ -16,6 +16,7 @@ import org.simantics.graph.representation.External;
 import org.simantics.graph.representation.Identity;
 import org.simantics.graph.representation.IdentityDefinition;
 import org.simantics.graph.representation.Internal;
+import org.simantics.graph.representation.Optional;
 import org.simantics.graph.representation.Root;
 import org.simantics.graph.representation.TransferableGraph1;
 import org.simantics.graph.representation.Value;
@@ -123,6 +124,17 @@ public class TGToGraphMap {
                        else if(definition instanceof Root) {
                                resources[identity.resource] = RootLibrary;             
                        }
+                       else if(definition instanceof Optional) {
+                               Optional def = (Optional)definition;
+                               Resource parent = resources[def.parent];
+                               if(parent == null)
+                                       continue;
+                               Resource child = graph.syncRequest(
+                                               new UnescapedChildMapOfResource(parent),
+                                               new TransientCacheAsyncListener<Map<String, Resource>>())
+                                               .get(def.name);
+                               resources[identity.resource] = child; // might be null
+                       }
                }
        }