X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2FModelingUtils.java;h=e1494cf3201f3fd79fefe0efc9956d0c6e4ea5a8;hp=627f417803d805d5269979deb578cce8313527e5;hb=96bb7ef9cbe42d82eb58306;hpb=ae5bb63c5c88f6569518fed2a24df86fbd0570ff diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java index 627f41780..e1494cf32 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java @@ -2322,5 +2322,25 @@ public class ModelingUtils { return new File(fileName); } + + public static Resource createLibrary(WriteGraph graph, Resource parent) throws DatabaseException { + Layer0 l0 = Layer0.getInstance(graph); + return createLibrary(graph, parent, NameUtils.findFreshName(graph, "Library", parent, l0.ConsistsOf)); + } + + public static Resource createLibrary(WriteGraph graph, Resource parent, String name) throws DatabaseException { + graph.markUndoPoint(); + Layer0 l0 = Layer0.getInstance(graph); + + Resource library = graph.newResource(); + graph.claim(library, l0.InstanceOf, null, l0.Library); + graph.addLiteral(library, l0.HasName, l0.NameOf, l0.String, name, Bindings.STRING); + graph.claim(library, l0.PartOf, parent); + + Layer0Utils.addCommentMetadata(graph, "Created new Library named " + name + ", resource " + library); + + return library; + } + }