From: Marko Luukkainen Date: Fri, 9 Aug 2019 09:40:53 +0000 (+0300) Subject: ListUtils.create(g,elements) creates a list without element inverses X-Git-Tag: v1.43.0~136^2~119 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F83%2F3083%2F1;p=simantics%2Fplatform.git ListUtils.create(g,elements) creates a list without element inverses Added new ListUtils.createWithInverses for lists with default element inverse relations. gitlab #336 Change-Id: I246d5bb170ff91d8f59aa656d6b0279f9b2b11b1 (cherry picked from commit d17ee3b8f3720f59c08780ced525d670a83844b0) --- 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 a197de880..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 @@ -55,9 +55,14 @@ public class ListUtils { */ public static Resource create(WriteGraph g, Iterable elements) throws DatabaseException { Layer0 L0 = Layer0.getInstance(g); - return ListUtils.create(g,L0.List, L0.List_ElementWithInverse, L0.List_ElementWithInverse_Inverse, elements); + 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}. */ @@ -85,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; }