]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.common/src/org/simantics/db/common/utils/ListUtils.java
ListUtils.create(g,elements) creates a list without element inverses
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / utils / ListUtils.java
index 3631de4b38b7110c74f2bb0fab91796d9862d99c..656dfeb27550b8acfe8e1f1c8801cbebefe6e879 100644 (file)
@@ -54,15 +54,15 @@ public class ListUtils {
      * Creates a list containing the given {@code elements}.
      */
     public static Resource create(WriteGraph g, Iterable<Resource> elements) throws DatabaseException {
-        Layer0 L0 = Layer0.getInstance(g);
-        
-        Resource list = g.newResource();
-        g.claim(list, L0.InstanceOf, L0.List);
-        
-        insertBetween(g, L0, list, list, list, elements);
-        return list;
+       Layer0 L0 = Layer0.getInstance(g);
+       return ListUtils.create(g,L0.List, L0.List_Element, null, elements);
     }
-
+    
+    public static Resource createWithInverses(WriteGraph g, Iterable<Resource> elements) throws DatabaseException {
+       Layer0 L0 = Layer0.getInstance(g);
+       return ListUtils.create(g,L0.ListWithInverses, L0.List_ElementWithInverse, L0.List_ElementWithInverse_Inverse, elements);
+    }
+    
     /**
      * Creates a list of the given list type containing the given {@code elements}.
      */
@@ -90,6 +90,8 @@ public class ListUtils {
         Layer0 L0 = g.getService(Layer0.class);
         Resource list = g.newResource();
         g.claim(list, L0.InstanceOf, null, type);
+        if (!elementPredicate.equals(L0.List_Element))
+               g.claim(list, L0.List_ElementPredicate, L0.List_ElementPredicate_Inverse, elementPredicate);
         createExisting(g, list, elementPredicate, elementPredicateInverse, elements);
         return list;
     }