From b28a9d30e47693246404bac50c7e031c1146c273 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Fri, 9 Aug 2019 12:40:53 +0300 Subject: [PATCH] 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) --- .../src/org/simantics/db/common/utils/ListUtils.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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; } -- 2.43.2