X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Futil%2FTGRepresentation.java;h=0f9ffa0a73730314f7ba6d56a655f507d28d9b0c;hb=6573b29e111ea03c3fa88bf1565d47d0fc4faabd;hp=9e8012caf07605b8555768326a183db79aacb487;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TGRepresentation.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TGRepresentation.java index 9e8012caf..0f9ffa0a7 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TGRepresentation.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TGRepresentation.java @@ -1,78 +1,78 @@ -package org.simantics.db.layer0.util; - -import java.util.Arrays; -import java.util.Map; - -import org.simantics.db.ReadGraph; -import org.simantics.db.RequestProcessor; -import org.simantics.db.Resource; -import org.simantics.db.common.request.UniqueRead; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.util.SimanticsClipboard.Representation; -import org.simantics.graph.db.TransferableGraphs; -import org.simantics.graph.representation.TransferableGraph1; -import org.simantics.utils.datastructures.hints.IHintContext.Key; - -public class TGRepresentation implements Representation { - - protected boolean ignoreVirtualResources = false; - protected Resource[] resources; - private TransferableGraph1 value = null; - private TransferableGraphConfiguration2 configuration; - - public TGRepresentation(Resource ... resources) { - this.resources = resources; - } - - public TGRepresentation(boolean ignoreVirtualResources, Resource ... resources) { - this.ignoreVirtualResources = ignoreVirtualResources; - this.resources = resources; - } - - public TGRepresentation(TransferableGraphConfiguration2 configuration) { - this.configuration = configuration; - } - - public TGRepresentation(TransferableGraph1 value) { - this.value = value; - } - - @Override - public Key getKey() { - return SimanticsKeys.KEY_TRANSFERABLE_GRAPH; - } - - public TransferableGraph1 compute(ReadGraph graph, Map hints) throws DatabaseException { - - if(configuration == null) { - configuration = new TransferableGraphConfiguration2(graph, Arrays.asList(resources), ignoreVirtualResources, false); - configuration.exclusionFunction = TGRepresentationUtils.computeExclusionFunction(graph, resources, hints); - } - - ModelTransferableGraphSource source = graph.syncRequest(new ModelTransferableGraphSourceRequest(configuration)); - return TransferableGraphs.create(graph, source); - - } - - @SuppressWarnings("unchecked") - @Override - public T getValue(RequestProcessor processor, Map hints) throws DatabaseException { - - if(value == null) { - - value = processor.syncRequest(new UniqueRead() { - - @Override - public TransferableGraph1 perform(ReadGraph graph) throws DatabaseException { - return compute(graph, hints); - } - - }); - - } - - return (T)value; - - } - +package org.simantics.db.layer0.util; + +import java.util.Arrays; +import java.util.Map; + +import org.simantics.db.ReadGraph; +import org.simantics.db.RequestProcessor; +import org.simantics.db.Resource; +import org.simantics.db.common.request.UniqueRead; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.util.SimanticsClipboard.Representation; +import org.simantics.graph.db.TransferableGraphs; +import org.simantics.graph.representation.TransferableGraph1; +import org.simantics.utils.datastructures.hints.IHintContext.Key; + +public class TGRepresentation implements Representation { + + protected boolean ignoreVirtualResources = false; + protected Resource[] resources; + private TransferableGraph1 value = null; + private TransferableGraphConfiguration2 configuration; + + public TGRepresentation(Resource ... resources) { + this.resources = resources; + } + + public TGRepresentation(boolean ignoreVirtualResources, Resource ... resources) { + this.ignoreVirtualResources = ignoreVirtualResources; + this.resources = resources; + } + + public TGRepresentation(TransferableGraphConfiguration2 configuration) { + this.configuration = configuration; + } + + public TGRepresentation(TransferableGraph1 value) { + this.value = value; + } + + @Override + public Key getKey() { + return SimanticsKeys.KEY_TRANSFERABLE_GRAPH; + } + + public TransferableGraph1 compute(ReadGraph graph, Map hints) throws DatabaseException { + + if(configuration == null) { + configuration = new TransferableGraphConfiguration2(graph, Arrays.asList(resources), ignoreVirtualResources, false); + configuration.exclusionFunction = TGRepresentationUtils.computeExclusionFunction(graph, resources, hints); + } + + ModelTransferableGraphSource source = graph.syncRequest(new ModelTransferableGraphSourceRequest(configuration)); + return TransferableGraphs.create(graph, source); + + } + + @SuppressWarnings("unchecked") + @Override + public T getValue(RequestProcessor processor, Map hints) throws DatabaseException { + + if(value == null) { + + value = processor.syncRequest(new UniqueRead() { + + @Override + public TransferableGraph1 perform(ReadGraph graph) throws DatabaseException { + return compute(graph, hints); + } + + }); + + } + + return (T)value; + + } + } \ No newline at end of file