X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Futil%2FTransferableGraphConfiguration2.java;h=ec9c8b80c9e8fda57dd623660b6819f7b05e95aa;hp=2203ecaeb6bd792635aa1648495f20c3b5f03956;hb=refs%2Fchanges%2F02%2F1402%2F2;hpb=dbe0a77f0869111219b69d412d0bb90d17c391c1 diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TransferableGraphConfiguration2.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TransferableGraphConfiguration2.java index 2203ecaeb..ec9c8b80c 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TransferableGraphConfiguration2.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TransferableGraphConfiguration2.java @@ -16,44 +16,55 @@ import org.simantics.db.common.request.UniqueRead; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.adapter.SubgraphExtent.ExtentStatus; import org.simantics.db.layer0.util.DomainProcessor3.ExclusionDecision; +import org.simantics.db.layer0.util.TransferableGraphConfiguration2.SeedSpec.SeedSpecType; import org.simantics.scl.runtime.function.Function1; public class TransferableGraphConfiguration2 { - - public static class RootSpec { + + public static class SeedSpec { + + public static enum SeedSpecType { + INTERNAL, ROOT, SPECIAL_ROOT + } + public final Resource resource; public final String name; - public final boolean internal; + // Special roots are not normal seeds - e.g. %model + public final SeedSpecType specType; /** * Optional, may be null. */ public final String type; - public RootSpec(Resource resource, String name, boolean internal) { - this(resource, name, internal, null); + public SeedSpec(Resource resource, String name, SeedSpecType specType) { + this(resource, name, specType, null); } - public RootSpec(Resource resource, String name, boolean internal, String type) { + public SeedSpec(Resource resource, String name, SeedSpecType specType, String type) { if (resource == null) throw new NullPointerException("null resource"); if (name == null) throw new NullPointerException("null name"); this.resource = resource; this.name = name; - this.internal = internal; + this.specType = specType; this.type = type; } + public static SeedSpec internal(Resource resource) { + return new SeedSpec(resource, null, SeedSpecType.ROOT); + } + @Override public String toString() { - return "RootSpec[" + name + ", " + resource + ", " + internal + ", " + type + "]"; + return "SeedSpec[" + name + ", " + resource + ", " + specType + ", " + type + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + (internal ? 1231 : 1237); + result = prime * result + specType.hashCode(); result = prime * result + resource.hashCode(); result = prime * result + name.hashCode(); result = prime * result + (type != null ? type.hashCode() : 0); @@ -68,8 +79,8 @@ public class TransferableGraphConfiguration2 { return false; if (getClass() != obj.getClass()) return false; - RootSpec other = (RootSpec) obj; - return internal == other.internal && resource.equals(other.resource) && name.equals(other.name) + SeedSpec other = (SeedSpec) obj; + return specType.equals(other.specType) && resource.equals(other.resource) && name.equals(other.name) && objectEquals(type, other.type); } @@ -81,13 +92,13 @@ public class TransferableGraphConfiguration2 { } } - final public TreeMap baseExtensions = new TreeMap(); + final public TreeMap baseExtensions = new TreeMap<>(); final public Resource indexRoot; - final public Collection roots; + final public Collection seeds; final public Map preStatus; final public boolean ignoreVirtualResources; final public boolean validate; - + /** * true to export values, false to skip the actual * values and only write the resource id. @@ -97,25 +108,25 @@ public class TransferableGraphConfiguration2 { public Collection valueModifiers; public Function1 exclusionFunction; - public TransferableGraphConfiguration2(Resource indexRoot, Collection roots, Map preStatus, boolean ignoreVirtualResources, boolean validate) { + public TransferableGraphConfiguration2(Resource indexRoot, Collection seeds, Map preStatus, boolean ignoreVirtualResources, boolean validate) { this.indexRoot = indexRoot; - this.roots = roots; + this.seeds = seeds; this.preStatus = preStatus; this.ignoreVirtualResources = ignoreVirtualResources; this.validate = validate; this.valueModifiers = null; } - public TransferableGraphConfiguration2(Resource indexRoot, Collection roots, Map preStatus, boolean ignoreVirtualResources) { + public TransferableGraphConfiguration2(Resource indexRoot, Collection roots, Map preStatus, boolean ignoreVirtualResources) { this(indexRoot, roots, preStatus, ignoreVirtualResources, true); } - public TransferableGraphConfiguration2(Resource indexRoot, Collection roots, Map preStatus) { + public TransferableGraphConfiguration2(Resource indexRoot, Collection roots, Map preStatus) { this(indexRoot, roots, preStatus, true); } public TransferableGraphConfiguration2(TransferableGraphConfiguration2 conf) throws DatabaseException { - this(conf.indexRoot, conf.roots, conf.preStatus, conf.ignoreVirtualResources, conf.validate); + this(conf.indexRoot, conf.seeds, conf.preStatus, conf.ignoreVirtualResources, conf.validate); } public TransferableGraphConfiguration2(ReadGraph graph, Resource model, boolean ignoreVirtualResources, boolean validate) throws DatabaseException { @@ -133,12 +144,12 @@ public class TransferableGraphConfiguration2 { public TransferableGraphConfiguration2(ReadGraph graph, Resource model) throws DatabaseException { this(graph, model, true); } - - public TransferableGraphConfiguration2(ReadGraph graph, Collection roots, Collection resourceRoots, Collection exclusions) throws DatabaseException { + + public TransferableGraphConfiguration2(ReadGraph graph, Collection roots, Collection resourceRoots, Collection exclusions) throws DatabaseException { this(new TGConfigurer(graph, true).roots(roots).roots2(resourceRoots).exclusions(exclusions).create()); } - public TransferableGraphConfiguration2(ReadGraph graph, Collection roots, Collection resourceRoots, Collection exclusions, boolean ignoreVirtualResource, boolean validate) throws DatabaseException { + public TransferableGraphConfiguration2(ReadGraph graph, Collection roots, Collection resourceRoots, Collection exclusions, boolean ignoreVirtualResource, boolean validate) throws DatabaseException { this(new TGConfigurer(graph, ignoreVirtualResource, validate).roots(roots).roots2(resourceRoots).exclusions(exclusions).create()); } @@ -149,18 +160,18 @@ public class TransferableGraphConfiguration2 { public TransferableGraphConfiguration2 perform(ReadGraph graph) throws DatabaseException { return new TransferableGraphConfiguration2(graph, translate(roots), Collections.emptyList(), exclusions, ignoreVirtualResource, validate); } - + }); } - public static TransferableGraphConfiguration2 createWithNames2(RequestProcessor processor, final Collection roots, final Collection exclusions, final boolean ignoreVirtualResource, final boolean validate) throws DatabaseException { + public static TransferableGraphConfiguration2 createWithNames2(RequestProcessor processor, final Collection roots, final Collection exclusions, final boolean ignoreVirtualResource, final boolean validate) throws DatabaseException { return processor.sync(new UniqueRead() { @Override public TransferableGraphConfiguration2 perform(ReadGraph graph) throws DatabaseException { return new TransferableGraphConfiguration2(graph, roots, Collections.emptyList(), exclusions, ignoreVirtualResource, validate); } - + }); } @@ -173,9 +184,9 @@ public class TransferableGraphConfiguration2 { @Override public TransferableGraphConfiguration2 perform(ReadGraph graph) throws DatabaseException { - return new TransferableGraphConfiguration2(graph, Collections.emptyList(), roots, exclusions); + return new TransferableGraphConfiguration2(graph, Collections.emptyList(), roots, exclusions); } - + }); } @@ -183,10 +194,10 @@ public class TransferableGraphConfiguration2 { return createWithResources(processor, Collections.singletonList(model), Collections.emptyList()); } - private static Collection translate(Collection roots) { - ArrayList result = new ArrayList(); - for(NamedResource nr : roots) result.add(new RootSpec(nr.getResource(), nr.getName(), true)); + private static Collection translate(Collection roots) { + ArrayList result = new ArrayList<>(); + for(NamedResource nr : roots) result.add(new SeedSpec(nr.getResource(), nr.getName(), SeedSpecType.ROOT)); return result; } - + }