X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.common%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fcommon%2Futils%2FListUtils.java;h=656dfeb27550b8acfe8e1f1c8801cbebefe6e879;hb=c00d1429bda8dc27461e1576f4be028b43149758;hp=3631de4b38b7110c74f2bb0fab91796d9862d99c;hpb=3e6b970912a5b3a61fc594c5464f1e2582ed0b3c;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/ListUtils.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/ListUtils.java index 3631de4b3..656dfeb27 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/ListUtils.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/ListUtils.java @@ -54,15 +54,15 @@ public class ListUtils { * Creates a list containing the given {@code elements}. */ public static Resource create(WriteGraph g, Iterable 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 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; }