From: luukkainen Date: Wed, 30 May 2012 15:21:00 +0000 (+0000) Subject: refs #3483 X-Git-Tag: v1.31.0~86 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=bd7152b9aaac10befa93c6c1fd9e4f1f9fd15c4a;p=simantics%2Finterop.git refs #3483 git-svn-id: https://www.simantics.org/svn/simantics/interoperability/trunk@25076 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.interop.mapping/.classpath b/org.simantics.interop.mapping/.classpath new file mode 100644 index 0000000..8a8f166 --- /dev/null +++ b/org.simantics.interop.mapping/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.simantics.interop.mapping/.project b/org.simantics.interop.mapping/.project new file mode 100644 index 0000000..3303d01 --- /dev/null +++ b/org.simantics.interop.mapping/.project @@ -0,0 +1,28 @@ + + + org.simantics.interop.mapping + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/org.simantics.interop.mapping/.settings/org.eclipse.jdt.core.prefs b/org.simantics.interop.mapping/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f287d53 --- /dev/null +++ b/org.simantics.interop.mapping/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.simantics.interop.mapping/META-INF/MANIFEST.MF b/org.simantics.interop.mapping/META-INF/MANIFEST.MF new file mode 100644 index 0000000..45b38ed --- /dev/null +++ b/org.simantics.interop.mapping/META-INF/MANIFEST.MF @@ -0,0 +1,20 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Mapping +Bundle-SymbolicName: org.simantics.interop.mapping +Bundle-Version: 0.0.1.qualifier +Bundle-Activator: org.simantics.interop.mapping.internal.Activator +Bundle-Vendor: VTT +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.simantics.db;bundle-version="1.1.0", + org.simantics.db.common;bundle-version="1.1.0", + org.simantics.scl.types;bundle-version="0.1.0", + org.simantics.diagram;bundle-version="1.1.1", + org.apache.log4j;bundle-version="1.2.15", + org.simantics.db.layer0;bundle-version="1.1.0", + org.simantics.ui;bundle-version="1.0.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Export-Package: org.simantics.interop.mapping, + org.simantics.interop.mapping.data diff --git a/org.simantics.interop.mapping/build.properties b/org.simantics.interop.mapping/build.properties new file mode 100644 index 0000000..41eb6ad --- /dev/null +++ b/org.simantics.interop.mapping/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/CancelException.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/CancelException.java new file mode 100644 index 0000000..98dcbae --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/CancelException.java @@ -0,0 +1,28 @@ +package org.simantics.interop.mapping; + +public class CancelException extends Exception{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public CancelException() { + super(); + } + + public CancelException(String message, Throwable cause) { + super(message, cause); + } + + public CancelException(String message) { + super(message); + } + + public CancelException(Throwable cause) { + super(cause); + } + + + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/ConnectionGenerationRule.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/ConnectionGenerationRule.java new file mode 100644 index 0000000..322a3b5 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/ConnectionGenerationRule.java @@ -0,0 +1,13 @@ +package org.simantics.interop.mapping; + +import org.simantics.db.WriteGraph; +import org.simantics.interop.mapping.data.GraphNode; +import org.simantics.interop.mapping.data.Identifiable; +import org.simantics.interop.mapping.data.Link; + +public interface ConnectionGenerationRule { + + + public void generate(WriteGraph g, GraphNode inputNode1, GraphNode inputNode2, Link link) throws Exception; + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/ConnectionIdentificationRule.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/ConnectionIdentificationRule.java new file mode 100644 index 0000000..808bd1c --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/ConnectionIdentificationRule.java @@ -0,0 +1,11 @@ +package org.simantics.interop.mapping; + +import org.simantics.db.ReadGraph; +import org.simantics.interop.mapping.data.GraphNode; +import org.simantics.interop.mapping.data.Identifiable; +import org.simantics.interop.mapping.data.Link; + +public interface ConnectionIdentificationRule { + + boolean mathces(ReadGraph g, GraphNode inputNode1, GraphNode inputNode2, Link link); +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/GenerationRule.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/GenerationRule.java new file mode 100644 index 0000000..e6907f5 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/GenerationRule.java @@ -0,0 +1,20 @@ +package org.simantics.interop.mapping; + + + +import org.simantics.db.WriteGraph; +import org.simantics.interop.mapping.data.GraphNode; +import org.simantics.interop.mapping.data.Identifiable; + +public interface GenerationRule extends MappingRule{ + + /** + * Generates Apros model from a single comos object + * @param g + * @param inputNode Node that is going to be mapped + * @param env used Mapping Environment + * @throws Exception + */ + public boolean generate(WriteGraph g, GraphNode inputNode) throws Exception; + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/IdentificationRule.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/IdentificationRule.java new file mode 100644 index 0000000..a723d48 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/IdentificationRule.java @@ -0,0 +1,10 @@ +package org.simantics.interop.mapping; + +import org.simantics.db.ReadGraph; +import org.simantics.interop.mapping.data.GraphNode; +import org.simantics.interop.mapping.data.Identifiable; + +public interface IdentificationRule { + + boolean matches(ReadGraph g, GraphNode node); +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/InitializedRule.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/InitializedRule.java new file mode 100644 index 0000000..7300a71 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/InitializedRule.java @@ -0,0 +1,16 @@ +package org.simantics.interop.mapping; + +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.DatabaseException; + +/** + * Interface for Generation- ModifiactionRules for initialization. + * + * + * @author Marko Luukkainen + * + */ +public interface InitializedRule { + public void initialize(WriteGraph g, Resource model) throws DatabaseException; +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/Logger.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/Logger.java new file mode 100644 index 0000000..8ec1c07 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/Logger.java @@ -0,0 +1,133 @@ +package org.simantics.interop.mapping; + +import java.util.Properties; + +import org.simantics.diagram.LogManager; + +public class Logger { + + + public static final boolean ECHO = false; + public static final boolean TRACE = false; + public static final Properties defaultProperties = new Properties(); + static { + defaultProperties.put("log4j.rootCategory", "INFO, default"); + defaultProperties.put("log4j.appender.default", "org.apache.log4j.FileAppender"); + defaultProperties.put("log4j.appender.default.File", "mapping.log"); + defaultProperties.put("log4j.appender.default.append", "false"); + defaultProperties.put("log4j.appender.default.layout", "org.apache.log4j.PatternLayout"); + defaultProperties.put("log4j.appender.default.layout.ConversionPattern", "%-6r %-5p - %m%n"); + //defaultProperties.put("log4j.appender.default.layout.ConversionPattern", "%-6r [%15.15t] %-5p %30.30c - %m%n"); + } + private static LogManager defaultLogManager = new LogManager(defaultProperties); + private static final Logger defaultErrorLogger = new Logger(LogManager.class); + private org.apache.log4j.Logger logger; + + Logger(Class clazz) { + logger = defaultLogManager.getLogger(clazz); + } + + /** + * Log a trace event. + * + * @param message message of the trace + * @param exception the exception, or null + */ + public void logTrace(String message, Throwable exception) { + // Errors are much more useful with a stack trace! + if (TRACE) { + if (exception == null) + exception = new RuntimeException(); + } + logger.trace(message, exception); + } + + /** + * Log an info event. + * + * @param message message of the info + * @param exception the exception, or null + */ + public void logInfo(String message, Throwable exception) { + // Errors are much more useful with a stack trace! + if (TRACE) { + if (exception == null) + exception = new RuntimeException(); + } + logger.info(message, exception); + } + + /** + * Log an warning event. + * @param message + * @param exception + */ + public void logWarning(String message, Throwable exception) { + // Errors are much more useful with a stack trace! + if (TRACE) { + if (exception == null) + exception = new RuntimeException(); + } + logger.warn(message, exception); + } + + + /** + * Log an error event. + * + * @param message message of the error + * @param exception the exception, or null + */ + public void logError(String message, Throwable exception) { + // Errors are much more useful with a stack trace! + if (TRACE) { + if (exception == null) + exception = new RuntimeException(); + } + logger.error(message, exception); + } + + public static Logger getDefault() { + return defaultErrorLogger; + } + + public static LogManager getDefaultLogManager() { + return defaultLogManager; + } + + public static void setDefaultThreshold(String level) { + getDefaultLogManager().setThreshold(level); + } + + public static void defaultLogError(Throwable exception) { + getDefault().logError(exception.getLocalizedMessage(), exception); + if(ECHO) exception.printStackTrace(); + } + public static void defaultLogError(String message) { + getDefault().logError(message, null); + if(ECHO) + System.err.println(message); + } + public static void defaultLogError(String message, Throwable exception) { + getDefault().logError(message, exception); + if(ECHO) + System.err.println(message); + } + public static void defaultLogInfo(String message) { + getDefault().logInfo(message, null); + if(ECHO) + System.err.println(message); + } + + public static void defaultLogWarning(String message) { + getDefault().logWarning(message, null); + if(ECHO) + System.err.println(message); + } + + public static void defaultLogTrace(String message) { + getDefault().logTrace(message, null); + if(ECHO) + System.err.println(message); + } +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/Mapper.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/Mapper.java new file mode 100644 index 0000000..6f700d3 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/Mapper.java @@ -0,0 +1,772 @@ +package org.simantics.interop.mapping; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.Session; +import org.simantics.db.VirtualGraph; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.ReadRequest; +import org.simantics.db.common.request.WriteRequest; +import org.simantics.db.common.request.WriteResultRequest; +import org.simantics.db.common.utils.NameUtils; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.exception.ServiceException; +import org.simantics.db.layer0.util.SessionGarbageCollection; +import org.simantics.db.request.Read; +import org.simantics.interop.mapping.data.GraphNode; +import org.simantics.interop.mapping.data.Identifiable; +import org.simantics.interop.mapping.data.Link; +import org.simantics.interop.mapping.data.ResourceIdentifiable; +import org.simantics.ui.jobs.SessionGarbageCollectorJob; +import org.simantics.utils.datastructures.MapList; +import org.simantics.utils.datastructures.Pair; + +/** + * + * @author Marko Luukkainen + * + */ +public class Mapper { + + public static final boolean USE_SPLIT_TRANSACTIONS = false; // Split transactions + public static int OBJECTS_PER_TRANSACTION = 5000; // number of objects handled per transaction (split mode) + private static boolean SLEEP_BETWEEN_WRITES = false; // sleep between transactions (split mode) + private static int SLEEP_TIME = 10; // time to sleep (ms) + private static boolean COLLECT_BETWEEN_WRITES = false; // Run SessionGC between split transactions + private static boolean COLLECT_WITHIN_TRANSACTIONS = true; // Run Collect within transactions (both modes) + public static int OBJECTS_BEFORE_COLLECT = 5000; // number of objects that are handled before collect (non-split mode) + + private List initializedRules = new ArrayList(); + private List>> generationRules; + private List> globalModificationRules; + private List>> modificationRules; + private List> connectionRules; + + int maxGenPass = 0; + + public Mapper() { + long maxMemory = Runtime.getRuntime().maxMemory(); + maxMemory /= (1024*1024); // Convert to MB; + int use = 290; // Estimated memory usage of the system + int freeMem = (int)maxMemory-use; // Free memory for mappings + OBJECTS_BEFORE_COLLECT = (freeMem * freeMem) / 1000; //600M heap -> 84, 3000M heap -> 5645 + if (OBJECTS_BEFORE_COLLECT < 2) + OBJECTS_BEFORE_COLLECT = 2; + OBJECTS_PER_TRANSACTION = OBJECTS_BEFORE_COLLECT; + + + generationRules = new ArrayList>>(); + modificationRules = new ArrayList>>(); + globalModificationRules = new ArrayList>(); + connectionRules = new ArrayList>(); + } + + public void addRule(int pass, IdentificationRule idRule, GenerationRule genRule) { + if (idRule == null || genRule == null) throw new NullPointerException(); + generationRules.add(new Pair>(idRule, new Pair(pass,genRule))); + maxGenPass = Math.max(maxGenPass, pass); + if (genRule instanceof InitializedRule) + initializedRules.add((InitializedRule)genRule); + } + + public void addRule(IdentificationRule idRule, MappingRule mappingRule) { + addRule(0,idRule,mappingRule); + } + + public void addRule(int pass, IdentificationRule idRule, MappingRule mappingRule) { + if (idRule == null || mappingRule == null) throw new NullPointerException(); + if (mappingRule instanceof ModificationRule) { + while (pass >= modificationRules.size()) { + modificationRules.add(new ArrayList>()); + } + List> priList = modificationRules.get(pass); + priList.add(new Pair(idRule, (ModificationRule)mappingRule)); + } + if (mappingRule instanceof GenerationRule) + generationRules.add(new Pair>(idRule, new Pair(pass,(GenerationRule)mappingRule))); + if (mappingRule instanceof InitializedRule) + initializedRules.add((InitializedRule)mappingRule); + } + + public void addRule(IdentificationRule idRule, ModificationRule... modRules) { + addRule(0, idRule, modRules); + } + + public void addRule(int pass, IdentificationRule idRule, ModificationRule... modRules) { + if (idRule == null) throw new NullPointerException(); + + while (pass >= modificationRules.size()) { + modificationRules.add(new ArrayList>()); + } + List> priList = modificationRules.get(pass); + + for (ModificationRule modRule : modRules){ + if (modRule == null) throw new NullPointerException(); + priList.add(new Pair(idRule, modRule)); + if (modRule instanceof InitializedRule) + initializedRules.add((InitializedRule)modRule); + } + } + public void addRule(ModificationRule modRule) { + addRule(0, modRule); + } + + public void addRule(int pass, ModificationRule modRule) { + if (modRule == null) throw new NullPointerException(); + while (pass >= globalModificationRules.size()) { + globalModificationRules.add(new ArrayList()); + } + List priList = globalModificationRules.get(pass); + priList.add(modRule); + if (modRule instanceof InitializedRule) + initializedRules.add((InitializedRule)modRule); + } + + public void addRule(ConnectionIdentificationRule idRule, ConnectionGenerationRule genRule) { + if (idRule == null || genRule == null) throw new NullPointerException(); + connectionRules.add(new Pair(idRule, genRule)); + if (genRule instanceof InitializedRule) + initializedRules.add((InitializedRule)genRule); + } + + /** + * Runs the mapping procedure. Disposes nodes after mapping is done. + * @param g + * @param model + * @param nodes + * @param monitor + * @throws Exception + */ + public void map(WriteGraph g, Resource model, Collection> nodes, IProgressMonitor monitor) throws Exception { + startMapping(null); + try { + if (monitor == null) + monitor = new NullProgressMonitor(); + + for (InitializedRule rule : initializedRules) + rule.initialize(g, model); + + applyModifications(g, nodes, monitor); + monitor.worked(1); + applyGenerations(g,nodes,monitor); + monitor.worked(1); + applyConnections(g,nodes,monitor); + monitor.worked(1); + } finally { + MappingTools.disposeNodes(nodes); + endMapping(); + } + + } + + /** + * Runs the mapping procedure. Disposes nodes after mapping is done. + * @param session + * @param model + * @param nodes + * @param monitor + * @throws Exception + */ + public void map(Session session, Resource model, Collection> nodes, IProgressMonitor monitor) throws Exception { + map(session, model, null, nodes, monitor); + } + + /** + * Runs the mapping procedure. Disposes nodes after mapping is done. + * @param session + * @param model + * @param vg + * @param nodes + * @param monitor + * @throws Exception + */ + public void map(Session session, Resource model, VirtualGraph vg, Collection> nodes, IProgressMonitor monitor) throws Exception { + startMapping(vg); + try { + long time = System.currentTimeMillis(); + if (monitor == null) + monitor = new NullProgressMonitor(); + + initializeRules(session, vg, model); + if (USE_SPLIT_TRANSACTIONS) { + applyModifications(session, nodes, monitor); + monitor.worked(1); + applyGenerations(session, vg, nodes, monitor); + monitor.worked(1); + applyConnections(session, vg, nodes, monitor); + monitor.worked(1); + } else { + applyModifications2(session, nodes, monitor); + monitor.worked(1); + applyGenerations2(session, vg, nodes, monitor); + monitor.worked(1); + applyConnections2(session, vg, nodes, monitor); + monitor.worked(1); + } + long time2 = System.currentTimeMillis(); + System.out.println("Mapping took " + ((time2-time)/1000) + " seconds"); + } finally { + MappingTools.disposeNodes(nodes); + if (COLLECT_BETWEEN_WRITES) { + + SessionGarbageCollection.gc(null, session, true, null); + } + endMapping(); + } + + } + + + //private boolean autosaveEndabled = false; + private VirtualGraph vg; + + protected void startMapping(VirtualGraph vg) { + SessionGarbageCollectorJob.getInstance().setEnabled(false); + //autosaveEndabled = AutosaveCommands.getInstance().isEnabled(); + //AutosaveCommands.getInstance().setEnabled(false); + this.vg = vg; + } + + protected void endMapping() { + SessionGarbageCollectorJob.getInstance().setEnabled(true).scheduleAfterQuietTime(); + // AutosaveCommands.getInstance().setEnabled(autosaveEndabled); + vg = null; + } + + private void applyModifications(ReadGraph g, Collection> nodes, IProgressMonitor monitor) throws Exception { + + // Apply global modification rules first + + int passCount = Math.max(globalModificationRules.size(),modificationRules.size()); + + for (int pass = 0; pass < passCount; pass++) { + if (globalModificationRules.size() > pass) { + int count = 0; + List modRules = globalModificationRules.get(pass); + int size = modRules.size(); + monitor.subTask("Running global modification rules: pass (" + (pass+1) + "/" + passCount + "), rule ("+ (++count) + "/" + size + ")"); + for (ModificationRule r : modRules) { + Collection> ruleModified = r.modify(g, nodes); + if (ruleModified == null) + continue; + for (GraphNode m : ruleModified) { + if (m.isDisposed()) { + nodes.remove(m); + } + else if (!nodes.contains(m)) { + nodes.add(m); + } + } + monitor.subTask("Running global modification rules: pass (" + (pass+1) + "/" + passCount + "), rule ("+ (++count) + "/" + size + ")"); + if(monitor.isCanceled()) { + throw new CancelException("Cancel requested."); + } + if (COLLECT_WITHIN_TRANSACTIONS) + collect(g); + } + } if (modificationRules.size() > pass) { + int count = 0; + List> modRules = modificationRules.get(pass); + int size = modRules.size(); + monitor.subTask("Running object modification rules: pass (" + (pass+1) + "/" + passCount + "), rule ("+ (++count) + "/" + size + ")"); + // Apply per object modification rules + for (Pair modRule : modRules) { + Collection> ruleModified = new ArrayList>(); + for (GraphNode n : nodes) { + applyModifications(g, n, modRule, ruleModified); + if (COLLECT_WITHIN_TRANSACTIONS) + collect2(g); + } + + for (GraphNode m : ruleModified) { + if (m.isDisposed()) { + nodes.remove(m); + } + else if (!nodes.contains(m)) { + nodes.add(m); + } + } + monitor.subTask("Running object modification rules: pass (" + (pass+1) + "/" + passCount + "), rule ("+ (++count) + "/" + size + ")"); + if(monitor.isCanceled()) { + throw new CancelException("Cancel requested."); + } + + } + } + } + + } + + + + private void applyGenerations(WriteGraph graph, Collection> nodes, IProgressMonitor monitor) throws Exception { + + int size = nodes.size(); + int count = 0; + monitor.subTask("Assigning generation rules ("+ count + "/" + size + ")"); + // populate generation rules + for (GraphNode n : nodes) { + + for (Pair> r : generationRules) { + if (r.first.matches(graph, n)) { + MappingTools.assignGenerationRule(n, r.second.first,r.second.second); + } + } + monitor.subTask("Assigning generation rules ("+ (++count) + "/" + size + ")"); + if(monitor.isCanceled()) { + throw new CancelException("Cancel requested."); + } + if (COLLECT_WITHIN_TRANSACTIONS) + collect2(graph); + } + + count = 0; + monitor.subTask("Generating objects ("+ count + "/" + size + ")"); + + // apply generation rules. + //WriteWrapper g = new WriteWrapper(graph); + + //Collection usedRules = new ArrayList(); + for (int stage = 0; stage <= maxGenPass; stage++) { + count = 0; + for (GraphNode n : nodes) { + + MapList priRules = n.getHint(MappingHints.KEY_GENERATION_RULES); + List rules = priRules.getValues(stage); + for (GenerationRule r : rules) { + r.generate(graph, n); + } + + monitor.subTask("Generating objects, stage " + stage + " : ("+ (++count) + "/" + size + ")"); + if(monitor.isCanceled()) { + throw new CancelException("Cancel requested."); + } + if (COLLECT_WITHIN_TRANSACTIONS) + collect2(graph); + } + } + } + + private void applyConnections(WriteGraph g, Collection> nodes, IProgressMonitor monitor) throws Exception { + int size = nodes.size(); + int count = 0; + + monitor.subTask("Generating connections ("+ count + "/" + size + ")"); + + for (GraphNode node : nodes) { + applyConnections(g, node); + monitor.subTask("Generating connections ("+ (++count) + "/" + size + ")"); + if(monitor.isCanceled()) { + throw new CancelException("Cancel requested."); + } + if (COLLECT_WITHIN_TRANSACTIONS) + collect2(g); + } + } + + + + protected String getName(ReadGraph g, Identifiable res) throws DatabaseException { + if (res instanceof ResourceIdentifiable) + return NameUtils.getSafeName(g, ((ResourceIdentifiable)res).getResource()); + else + return res.toString(); + } + + public class WriteWrapper extends WriteGraphProxy { + + + private Collection createdResources = new ArrayList(); + + public WriteWrapper(WriteGraph graph) { + super(graph); + } + + public Collection getCreatedResources() { + return createdResources; + } + + public void clearCreated() { + createdResources = new ArrayList(); + } + + @Override + public Resource newResource() throws ServiceException { + Resource res = graph.newResource(); + createdResources.add(res); + return res; + } + + @Override + public Resource newResource(long clusterId) throws ServiceException { + Resource res = graph.newResource(clusterId); + createdResources.add(res); + return res; + } + + + } + + private void initializeRules(Session session, VirtualGraph vg, final Resource model ) throws DatabaseException{ + session.syncRequest(new WriteRequest(vg) { + @Override + public void perform(WriteGraph g) throws DatabaseException { + for (InitializedRule rule : initializedRules) + rule.initialize(g, model); + + } + }); + + } + + private void collect(ReadGraph g) throws DatabaseException { + if (vg != null) + return; + SessionGarbageCollection.gc(g, 0, -1); + } + + int collect = 0; + + private void collect2(ReadGraph g) throws DatabaseException { + if (vg != null) + return; + + if (collect == OBJECTS_BEFORE_COLLECT) { + SessionGarbageCollection.gc(g, 0, -1); + collect = 0; + } else { + collect++; + } + } + + private void applyModifications(Session session, final Collection> nodes, final IProgressMonitor monitor) throws Exception { + + + + int passCount = Math.max(globalModificationRules.size(),modificationRules.size()); + + for (int pass = 0; pass pass) { + int count = 0; + List modRules = globalModificationRules.get(pass); + int size = modRules.size(); + monitor.subTask("Running global modification rules: pass (" + (pass+1) + "/" + passCount + "), rule ("+ (++count) + "/" + size + ")"); + for (final ModificationRule r : modRules) { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph g) throws DatabaseException { + try { + Collection> ruleModified = r.modify(g, nodes); + + if (ruleModified == null) + return; + for (GraphNode m : ruleModified) { + if (m.isDisposed()) { + nodes.remove(m); + } + else if (!nodes.contains(m)) { + nodes.add(m); + } + } + if (COLLECT_WITHIN_TRANSACTIONS) + collect(g); + } catch (Exception e) { + throw new DatabaseException(e); + } + + } + }); + //SessionGarbageCollection.gc(null, session, true, null); + monitor.subTask("Running global modification rules: pass (" + (pass+1) + "/" + passCount + "), rule ("+ (++count) + "/" + size + ")"); + if(monitor.isCanceled()) { + throw new CancelException("Cancel requested."); + } + } + } + if (modificationRules.size() > pass) { + int count = 0; + List> modRules = modificationRules.get(pass); + int size = modRules.size(); + monitor.subTask("Running object modification rules: pass (" + (pass+1) + "/" + passCount + "), rule ("+ (++count) + "/" + size + ")"); + + // Apply per object modification rules + for (final Pair modRule : modRules) { + final Iterator> iter = nodes.iterator(); + final Collection> ruleModified = new ArrayList>(); + while (iter.hasNext()) { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph g) throws DatabaseException { + try { + + int j = 0; + //for (GraphNode n : nodes) { + while (iter.hasNext() && j < OBJECTS_PER_TRANSACTION) { + GraphNode n = iter.next(); + applyModifications(g, n, modRule, ruleModified); + j++; + } + if (COLLECT_WITHIN_TRANSACTIONS) + collect(g); + + } catch (Exception e) { + throw new DatabaseException(e); + } + + } + }); + } + for (GraphNode m : ruleModified) { + if (m.isDisposed()) { + nodes.remove(m); + } + else if (!nodes.contains(m)) { + nodes.add(m); + } + } + ruleModified.clear(); + + //SessionGarbageCollection.gc(null, session, true, null); + monitor.subTask("Running object modification rules: pass (" + (pass+1) + "/" + passCount + "), rule ("+ (++count) + "/" + size + ")"); + if(monitor.isCanceled()) { + throw new CancelException("Cancel requested."); + } + } + } + } + + } + + private void applyModifications2(Session session, final Collection> nodes, final IProgressMonitor monitor) throws Exception { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph g) throws DatabaseException { + try { + applyModifications(g, nodes, monitor); + } catch (Exception e) { + throw new DatabaseException(e); + } + + } + }); + } + + private void applyGenerations(Session session, VirtualGraph vg, Collection> nodes, IProgressMonitor monitor) throws Exception { + + int size = nodes.size(); + int count = 0; + monitor.subTask("Assigning generation rules ("+ count + "/" + size + ")"); + // populate generation rules + + { + final Iterator> iter = nodes.iterator(); + while (iter.hasNext()) { + int c = session.syncRequest(new Read() { + + @Override + public Integer perform(ReadGraph graph) + throws DatabaseException { + int j = 0; + while (iter.hasNext() && j < OBJECTS_PER_TRANSACTION) { + GraphNode n = iter.next(); + for (Pair> r : generationRules) { + if (r.first.matches(graph, n)) { + MapList rules = n.getHint(MappingHints.KEY_GENERATION_RULES); + if (rules == null) { + rules = new MapList(); + } + rules.add(r.second.first,r.second.second); + n.setHint(MappingHints.KEY_GENERATION_RULES, rules); + } + } + j++; + } + if (COLLECT_WITHIN_TRANSACTIONS) + collect(graph); + return j; + + } + }); + collect(session); + monitor.subTask("Assigning generation rules ("+ (count+=c) + "/" + size + ")"); + if(monitor.isCanceled()) { + throw new CancelException("Cancel requested."); + } + sleep(); + } + } + + count = 0; + monitor.subTask("Generating objects ("+ (count) + "/" + size + ")"); + + // apply generation rules. + + { + for (int stage = 0; stage <= maxGenPass; stage++) { + final int fStage = stage; + count = 0; + final Iterator> iter = nodes.iterator(); + while (iter.hasNext()) { + int c = session.syncRequest(new WriteResultRequest(vg) { + + @Override + public Integer perform(WriteGraph graph) throws DatabaseException { + int j = 0; + try { + while (iter.hasNext() && j < OBJECTS_PER_TRANSACTION) { + GraphNode n = iter.next(); + + MapList priRules = n.getHint(MappingHints.KEY_GENERATION_RULES); + if (priRules == null) { + j++; + continue; + } + final List rules = priRules.getValues(fStage); + + if (fStage == 0 && rules.size() == 0) + System.out.println(); + for (GenerationRule r : rules) { + r.generate(graph, n); + + } + + + j++; + + } + if (COLLECT_WITHIN_TRANSACTIONS) + collect(graph); + return j; + + } catch (Exception e) { + throw new DatabaseException(e); + } + }}); + collect(session); + monitor.subTask("Generating objects, stage " + stage + " : ("+ (count+=c) + "/" + size + ")"); + if(monitor.isCanceled()) { + throw new CancelException("Cancel requested."); + } + sleep(); + } + } + } + } + + private void applyGenerations2(Session session, VirtualGraph vg, final Collection> nodes, final IProgressMonitor monitor) throws Exception { + session.syncRequest(new WriteRequest(vg) { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + try { + applyGenerations(graph, nodes, monitor); + } catch (Exception e) { + throw new DatabaseException(e); + } + + } + }); + } + + private void collect(Session session) { + if (COLLECT_BETWEEN_WRITES) + SessionGarbageCollection.gc(null, session, true, null); + } + + + private void sleep() { + if (SLEEP_BETWEEN_WRITES) { + try { + Thread.sleep(SLEEP_TIME); + } catch (InterruptedException e) { + + } + } + } + + private void applyConnections(Session session, VirtualGraph vg, Collection> nodes, IProgressMonitor monitor) throws Exception { + int size = nodes.size(); + int count = 0; + + monitor.subTask("Generating connections ("+ count + "/" + size + ")"); + + final Iterator> iter = nodes.iterator(); + while (iter.hasNext()) { + int c = session.syncRequest(new WriteResultRequest(vg) { + + @Override + public Integer perform(WriteGraph g) throws DatabaseException { + int j = 0; + try { + while (iter.hasNext() && j < OBJECTS_PER_TRANSACTION) { + GraphNode node = iter.next(); + applyConnections(g, node); + j++; + } + if (COLLECT_WITHIN_TRANSACTIONS) + collect(g); + return j; + + } catch (Exception e) { + throw new DatabaseException(e); + } + } + }); + collect(session); + monitor.subTask("Generating connections ("+ (count+=c) + "/" + size + ")"); + if(monitor.isCanceled()) { + throw new CancelException("Cancel requested."); + } + sleep(); + } + } + + private void applyConnections2(Session session, VirtualGraph vg, final Collection> nodes, final IProgressMonitor monitor) throws Exception { + session.syncRequest(new WriteRequest(vg) { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + try { + applyConnections(graph, nodes, monitor); + } catch (Exception e) { + throw new DatabaseException(e); + } + + } + }); + } + + private void applyModifications(ReadGraph g, GraphNode n, Pair modRule, Collection> ruleModified) throws Exception { + if (!n.isDisposed() && modRule.first.matches(g, n)) { // we have to check + Collection> perRule = new ArrayList>(); + perRule.add(n); + ruleModified.addAll(modRule.second.modify(g, perRule)); + } + } + + private void applyConnections(WriteGraph g, GraphNode node) throws Exception { + for (Link link : node.getLinks()) { + if (link.isMain()) { + + for (Pair r : connectionRules) { + if (r.first.mathces(g, node, link.to(), link)) { + Logger.defaultLogInfo("Connecting " + getName(g, node.getData()) + " to " + getName(g, link.to().getData()) + " " + link.getName() + "/"+link.getInverseName()); + r.second.generate(g, node, link.to(), link); + break; + } + } + } + } + } +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/MappingHints.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/MappingHints.java new file mode 100644 index 0000000..b33965a --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/MappingHints.java @@ -0,0 +1,48 @@ +package org.simantics.interop.mapping; + +import java.awt.geom.Point2D; +import java.util.Collection; +import java.util.Map; + +import org.simantics.db.Resource; +import org.simantics.interop.mapping.data.GraphNode; +import org.simantics.utils.datastructures.MapList; +import org.simantics.utils.datastructures.hints.IHintContext.Key; +import org.simantics.utils.datastructures.hints.IHintContext.KeyOf; + + +public class MappingHints { + + // type of symbol to be created. + public static final Key KEY_GENERATE_TYPE = new KeyOf(Resource.class); + + // Module Resolver (symbol type and terminals) + public static final Key KEY_RESOLVER = new KeyOf(ModuleResolver.class); + + // generated symbol. + //public static final Key KEY_GENERATED_SYMBOL = new KeyOf(Symbol.class); + + public static final Key KEY_GENERATION_RULES = new KeyOf(MapList.class); // Generation Rules + + //public static final Key KEY_DIAGRAM = new KeyOf(Diagram.class); // Diagram where node's symbol(s) are generated. + public static final Key KEY_PATH_DIAGRAM = new KeyOf(Map.class); // Diagram where node's symbol(s) by path are generated. + public static final Key KEY_PARENT_NODE = new KeyOf(GraphNode.class); // Parent Node (device) used with automation symbols. + public static final Key KEY_CHILD_NODE = new KeyOf(Collection.class); // Child Node (device). > + + public static final Key KEY_CONNECTION_TERMINAL = new KeyOf(Resource.class); // Connection terminal (in Apros symbol) + + public static final Key KEY_CONNECTION_TYPE = new KeyOf(String.class); // Connection Type + public static final Key KEY_CONNECTION_LABEL = new KeyOf(String.class); + public static final Key KEY_CONNECTION_NOT = new KeyOf(Boolean.class); // Is inverse (Binary signal) + + + public static final Key KEY_FLAG_POSITION = new KeyOf(Point2D.class); + public static final Key KEY_FLAG_NAME = new KeyOf(String.class); + + + public static final Key KEY_SPLIT_NAME = new KeyOf(String.class); + public static final Key KEY_SPLIT_COUNT = new KeyOf(Integer.class); + public static final Key KEY_SPLIT_PERCENTAGE = new KeyOf(Double.class); + + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/MappingRule.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/MappingRule.java new file mode 100644 index 0000000..ae7e51c --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/MappingRule.java @@ -0,0 +1,5 @@ +package org.simantics.interop.mapping; + +public interface MappingRule { + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/MappingTools.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/MappingTools.java new file mode 100644 index 0000000..03ea947 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/MappingTools.java @@ -0,0 +1,118 @@ +package org.simantics.interop.mapping; + +import java.util.ArrayList; +import java.util.Collection; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.interop.mapping.data.GraphNode; +import org.simantics.interop.mapping.data.Identifiable; +import org.simantics.interop.mapping.data.Link; +import org.simantics.utils.datastructures.MapList; + +public class MappingTools { + + public static Resource getSymbolType(ReadGraph g, GraphNode node) throws DatabaseException { + Resource type = node.getHint(MappingHints.KEY_GENERATE_TYPE); + if (type == null) { + ModuleResolver resolver = node.getHint(MappingHints.KEY_RESOLVER); + if (resolver != null) + type = resolver.getSymbolType(g); + + } + return type; + } + + public static Resource getTerminal(ReadGraph g, Link link) throws DatabaseException { + Resource terminal = link.getHint(MappingHints.KEY_CONNECTION_TERMINAL); + if (terminal == null) { + ModuleResolver resolver = link.from().getHint(MappingHints.KEY_RESOLVER); + if (resolver != null) + terminal = resolver.getTerminal(g, link); + + } + return terminal; + } + + public static void assignGenerationRule(GraphNode node, int index, GenerationRule rule) { + MapList rules = node.getHint(MappingHints.KEY_GENERATION_RULES); + if (rules == null) { + rules = new MapList(); + node.setHint(MappingHints.KEY_GENERATION_RULES, rules); + } + rules.add(index,rule); + + } + + public static void createEmptyGenerationRules(GraphNode node) { + node.setHint(MappingHints.KEY_GENERATION_RULES, new MapList()); + } + + public static void copyGenerationRules(GraphNode from, GraphNode to) { + MapList rules = from.getHint(MappingHints.KEY_GENERATION_RULES); + if (rules == null) + return; + MapList toRules = to.getHint(MappingHints.KEY_GENERATION_RULES); + if (toRules == null) { + toRules = new MapList(); + to.setHint(MappingHints.KEY_GENERATION_RULES, toRules); + } + for (Integer i : rules.getKeys()) { + for (GenerationRule r : rules.getValues(i)) + toRules.add(i,r); + } + } + + public static void copyHints(GraphNode from, GraphNode to) { + to.setHints(from.getHints()); + createEmptyGenerationRules(to); + copyGenerationRules(from, to); + reconnectParent(from, to); + } + + public static void copyDefaultHints(GraphNode from, GraphNode to) { + to.setHints(from.getHints()); + createEmptyGenerationRules(to); + reconnectParent(from, to); + } + + private static void reconnectParent(GraphNode from, GraphNode to) { + GraphNode parent = from.getHint(MappingHints.KEY_PARENT_NODE); + if (parent != null) { + setParentNode(parent, to); + + } + } + +// public static boolean hasModuleTypeAssigned(GraphNode node) { +// return (node.containsHint(MappingHints.KEY_RESOLVER) || node.containsHint(MappingHints.KEY_GENERATE_TYPE) || node.containsHint(MappingHints.KEY_GENERATED_SYMBOL)); +// } + + public static void disposeNodes(Collection> nodes) { + for (GraphNode node : nodes) { + node.destroy(); + } + nodes.clear(); + } + + public static void setParentNode(GraphNode parent, GraphNode child) { + child.setHint(MappingHints.KEY_PARENT_NODE, parent); + Collection> children = parent.getHint(MappingHints.KEY_CHILD_NODE); + if (children == null) { + children = new ArrayList>(); + parent.setHint(MappingHints.KEY_CHILD_NODE, children); + } + children.add(child); + } + + public static void unsetParentNode(GraphNode child) { + GraphNode parent = child.getHint(MappingHints.KEY_PARENT_NODE); + if (parent == null) + return; + + Collection> children = parent.getHint(MappingHints.KEY_CHILD_NODE); + children.remove(child); + child.removeHint(MappingHints.KEY_PARENT_NODE); + } +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/ModificationRule.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/ModificationRule.java new file mode 100644 index 0000000..ab88265 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/ModificationRule.java @@ -0,0 +1,13 @@ +package org.simantics.interop.mapping; + +import java.util.Collection; + +import org.simantics.db.ReadGraph; +import org.simantics.interop.mapping.data.GraphNode; +import org.simantics.interop.mapping.data.Identifiable; + +public interface ModificationRule extends MappingRule{ + + Collection> modify(ReadGraph g, Collection> nodes) throws Exception; + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/ModuleResolver.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/ModuleResolver.java new file mode 100644 index 0000000..f5b483b --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/ModuleResolver.java @@ -0,0 +1,15 @@ +package org.simantics.interop.mapping; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.interop.mapping.data.Identifiable; +import org.simantics.interop.mapping.data.Link; + +public interface ModuleResolver { + + public Resource getSymbolType(ReadGraph g) throws DatabaseException; + + public Resource getTerminal(ReadGraph g, Link link) throws DatabaseException; + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/SplittingWriteGraph.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/SplittingWriteGraph.java new file mode 100644 index 0000000..fb73ebd --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/SplittingWriteGraph.java @@ -0,0 +1,6167 @@ +package org.simantics.interop.mapping; + +import java.util.Collection; +import java.util.Set; +import java.util.TreeMap; + +import org.simantics.databoard.accessor.Accessor; +import org.simantics.databoard.binding.Binding; +import org.simantics.databoard.type.Datatype; +import org.simantics.databoard.util.binary.RandomAccessBinary; +import org.simantics.db.Metadata; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.Session; +import org.simantics.db.Statement; +import org.simantics.db.VirtualGraph; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.ReadRequest; +import org.simantics.db.common.request.WriteRequest; +import org.simantics.db.common.request.WriteResultRequest; +import org.simantics.db.exception.AdaptionException; +import org.simantics.db.exception.AssumptionException; +import org.simantics.db.exception.BindingException; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.exception.DoesNotContainValueException; +import org.simantics.db.exception.ManyObjectsForFunctionalRelationException; +import org.simantics.db.exception.NoInverseException; +import org.simantics.db.exception.NoSingleResultException; +import org.simantics.db.exception.ResourceNotFoundException; +import org.simantics.db.exception.ServiceException; +import org.simantics.db.exception.ServiceNotFoundException; +import org.simantics.db.exception.ValidationException; +import org.simantics.db.procedure.AsyncListener; +import org.simantics.db.procedure.AsyncMultiListener; +import org.simantics.db.procedure.AsyncMultiProcedure; +import org.simantics.db.procedure.AsyncProcedure; +import org.simantics.db.procedure.AsyncSetListener; +import org.simantics.db.procedure.Listener; +import org.simantics.db.procedure.MultiListener; +import org.simantics.db.procedure.MultiProcedure; +import org.simantics.db.procedure.Procedure; +import org.simantics.db.procedure.SetListener; +import org.simantics.db.procedure.SyncListener; +import org.simantics.db.procedure.SyncMultiListener; +import org.simantics.db.procedure.SyncMultiProcedure; +import org.simantics.db.procedure.SyncProcedure; +import org.simantics.db.procedure.SyncSetListener; +import org.simantics.db.request.AsyncMultiRead; +import org.simantics.db.request.AsyncRead; +import org.simantics.db.request.DelayedWrite; +import org.simantics.db.request.DelayedWriteResult; +import org.simantics.db.request.ExternalRead; +import org.simantics.db.request.MultiRead; +import org.simantics.db.request.Read; +import org.simantics.db.request.ReadInterface; +import org.simantics.db.request.Write; +import org.simantics.db.request.WriteInterface; +import org.simantics.db.request.WriteOnly; +import org.simantics.db.request.WriteOnlyResult; +import org.simantics.db.request.WriteResult; +import org.simantics.db.request.WriteTraits; +import org.simantics.scl.types.Type; +import org.simantics.utils.datastructures.Callback; + +/** + * This is insane. + * + * @author Marko Luukkainen + * + */ +public class SplittingWriteGraph implements WriteGraph { + + protected Session session; + + + @Override + public T getRelatedValue2(final Resource subject, final Resource relation) + throws DatabaseException { + return session.syncRequest(new Read() { + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getRelatedValue2(subject, relation); + } + }); + + } + + @Override + public T getRelatedValue2(final Resource subject, final Resource relation, final Binding binding) throws DatabaseException { + return session.syncRequest(new Read() { + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getRelatedValue2(subject, relation, binding); + } + }); + } + + @Override + public T getRelatedValue2(final Resource subject, final Resource relation, final Object context) throws DatabaseException { + return session.syncRequest(new Read() { + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getRelatedValue2(subject, relation, context); + } + }); + } + + @Override + public T getRelatedValue2(final Resource subject, final Resource relation, final Object context, final Binding binding) throws DatabaseException { + return session.syncRequest(new Read() { + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getRelatedValue2(subject, relation, context, binding); + } + }); + } + + @Override + public T getPossibleRelatedValue2(final Resource subject, final Resource relation) + throws DatabaseException { + return session.syncRequest(new Read() { + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleRelatedValue2(subject, relation); + } + }); + } + + @Override + public T getPossibleRelatedValue2(final Resource subject, final Resource relation, final Binding binding) throws DatabaseException { + return session.syncRequest(new Read() { + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleRelatedValue2(subject, relation, binding); + } + }); + } + + @Override + public T getPossibleRelatedValue2(final Resource subject, final Resource relation, final Object context) throws DatabaseException { + return session.syncRequest(new Read() { + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleRelatedValue2(subject, relation, context); + } + }); + } + + @Override + public T getPossibleRelatedValue2(final Resource subject, final Resource relation, final Object context, final Binding binding) throws DatabaseException { + return session.syncRequest(new Read() { + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleRelatedValue2(subject, relation, context, binding); + } + }); + } + + @Override + public void async(final ReadInterface r, final AsyncListener procedure) { + session.async(r, procedure); + + } + + @Override + public void async(final ReadInterface r, final AsyncProcedure procedure) { + session.async(r, procedure); + } + + @Override + public void async(final ReadInterface r, final Listener procedure) { + session.async(r, procedure); + } + + @Override + public void async(final ReadInterface r, final Procedure procedure) { + session.async(r, procedure); + } + + @Override + public void async(final ReadInterface r, final SyncListener procedure) { + session.async(r, procedure); + } + + @Override + public void async(final ReadInterface r, final SyncProcedure procedure) { + session.async(r, procedure); + } + + @Override + public void async(final WriteInterface r) { + session.async(r); + } + + @Override + public void async(final WriteInterface r, final Procedure procedure) { + session.async(r, procedure); + } + + @Override + public T sync(final ReadInterface r) throws DatabaseException { + return session.sync(r); + } + + @Override + public T sync(final WriteInterface r) throws DatabaseException { + return session.sync(r); + } + + @Override + public Resource getRootLibrary() { + try { + return session.syncRequest(new Read() { + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + return graph.getRootLibrary(); + } + }); + } catch (DatabaseException e) { + return null; + } + } + + + @Override + public void clearUndoList(final WriteTraits writeTraits) { + throw new RuntimeException("Not supported."); + } + + @Override + public void combineWithPrevious(WriteTraits writeTraits) { + throw new RuntimeException("Not supported."); + } + + @Override + public TreeMap getMetadata() { + try { + return session.syncRequest(new WriteResultRequest>() { + + @Override + public TreeMap perform(WriteGraph graph) throws DatabaseException { + return graph.getMetadata(); + } + }); + } catch (DatabaseException e) { + return null; + } + } + + @Override + public T getMetadata(final Class clazz) + throws ServiceException { + try { + return session.syncRequest(new WriteResultRequest() { + + @Override + public T perform(WriteGraph graph) throws DatabaseException { + return graph.getMetadata(clazz); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Type getRelatedValueType(final Resource subject, final Resource relation) + throws DatabaseException { + + return session.syncRequest(new Read() { + + @Override + public Type perform(ReadGraph graph) throws DatabaseException { + return graph.getRelatedValueType(subject, relation); + } + }); + + } + + @Override + public void deny(final Resource subject, final Resource predicate, final Resource inverse, final Resource object, final VirtualGraph vgraph) throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.deny(subject, predicate, inverse, object, vgraph); + + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + + + + @Override + public T adaptRelated(final Resource resource, final Resource relation, + final Class clazz) throws AdaptionException, NoSingleResultException, + ValidationException, ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.adaptRelated(resource, relation, clazz); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T getPossibleRelatedAdapter(final Resource resource, + final Resource relation, final Class clazz) throws ValidationException, + ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleRelatedAdapter(resource, relation, clazz); + } + }); + } catch (DatabaseException e) { + throw new ValidationException(e); + } + } + + @Override + public void inc() { + throw new RuntimeException("Not supported."); + } + + @Override + public void dec() { + throw new RuntimeException("Not supported."); + } + + @Override + public Collection getObjects(final Resource subject, final Resource relation) throws ServiceException + { + try { + return session.syncRequest(new Read>() { + + @Override + public Collection perform(ReadGraph graph) throws DatabaseException { + return graph.getObjects(subject, relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public T newLiteral(final Resource resource, + final Resource predicate, final Datatype datatype, final Object initialValue) + throws DatabaseException { + return session.syncRequest(new WriteResultRequest() { + + @Override + public T perform(WriteGraph graph) throws DatabaseException { + return graph.newLiteral(resource, predicate, datatype, initialValue); + } + }); + } + + @Override + public RandomAccessBinary newLiteral4RandomAccessBinary + (final Resource resource, final Resource predicate, final Datatype datatype, final Object initialvalue) + throws DatabaseException { + return session.syncRequest(new WriteResultRequest() { + @Override + public RandomAccessBinary perform(WriteGraph graph) throws DatabaseException { + return graph.newLiteral4RandomAccessBinary(resource, predicate, datatype, initialvalue); + } + }); + } + + public T adaptContextual(final Resource resource, final C context, final java.lang.Class contextClass, final java.lang.Class clazz) throws AdaptionException ,NoSingleResultException ,ValidationException ,ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.adaptContextual(resource, context, contextClass, clazz); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + }; + + public T getPossibleContextualAdapter(final Resource resource, final C context, final java.lang.Class contextClass, final java.lang.Class clazz) throws ValidationException ,ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleContextualAdapter(resource, context, contextClass, clazz); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + }; + + + public SplittingWriteGraph(Session session) { + this.session = session; + } + + @Override + public Resource newResource() throws ServiceException { + try { + return session.syncRequest(new WriteResultRequest() { + + @Override + public Resource perform(WriteGraph graph) throws DatabaseException { + return graph.newResource(); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public Resource newResource(final long clusterId) throws ServiceException { + try { + return session.syncRequest(new WriteResultRequest() { + + @Override + public Resource perform(WriteGraph graph) throws DatabaseException { + return graph.newResource(clusterId); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T adapt(final Resource resource, final Class clazz) + throws AdaptionException, ValidationException, ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.adapt(resource, clazz); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T adaptUnique(final Resource resource, final Class clazz) + throws AdaptionException, ValidationException, ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.adaptUnique(resource, clazz); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public void addLiteral(final Resource resource, final Resource predicate, + final Resource inverse, final Object value, final Binding binding) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.addLiteral(resource, predicate, inverse, value, binding); + + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public void addLiteral(final Resource resource, final Resource predicate, + final Resource inverse, final Resource type, final Object value, final Binding binding) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.addLiteral(resource, predicate, inverse, type, value, binding); + + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public void addMetadata(Metadata data) throws ServiceException { + throw new RuntimeException("Not supported."); + } + + @Override + @Deprecated + public void addValue(final Resource resource, final Resource predicate, + final Resource inverse, final Resource type, final Object value, final Binding binding) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.addValue(resource, predicate, inverse, type, value, binding); + + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public void asyncRequest(final AsyncMultiRead request) { + session.asyncRequest(request); + } + + @Override + public void asyncRequest(AsyncMultiRead request, + AsyncMultiListener procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncMultiRead request, + AsyncMultiProcedure procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncMultiRead request, + MultiListener procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncMultiRead request, + MultiProcedure procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncMultiRead request, + SyncMultiListener procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncMultiRead request, + SyncMultiProcedure procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncRead request) { + session.asyncRequest(request); + } + + @Override + public void asyncRequest(AsyncRead request, + AsyncListener procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncRead request, + AsyncProcedure procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncRead request, Listener procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncRead request, + Procedure procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncRead request, + SyncListener procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncRead request, + SyncProcedure procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(DelayedWrite request) { + session.asyncRequest(request); + } + + @Override + public void asyncRequest(DelayedWrite request, + Callback callback) { + session.asyncRequest(request,callback); + } + + @Override + public void asyncRequest(DelayedWriteResult r, + Procedure procedure) { + session.asyncRequest(r,procedure); + } + + @Override + public void asyncRequest(ExternalRead request) { + session.asyncRequest(request); + } + + @Override + public void asyncRequest(ExternalRead request, + Listener procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(ExternalRead request, + Procedure procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(MultiRead request) { + session.asyncRequest(request); + } + + @Override + public void asyncRequest(MultiRead request, + AsyncMultiListener procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(MultiRead request, + AsyncMultiProcedure procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(MultiRead request, + MultiListener procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(MultiRead request, + MultiProcedure procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(MultiRead request, + SyncMultiListener procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(MultiRead request, + SyncMultiProcedure procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Read request) { + session.asyncRequest(request); + } + + @Override + public void asyncRequest(Read request, AsyncListener procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Read request, + AsyncProcedure procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Read request, Listener procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Read request, Procedure procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Read request, SyncListener procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Read request, SyncProcedure procedure) { + session.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Write request) { + session.asyncRequest(request); + } + + @Override + public void asyncRequest(Write request, + Callback callback) { + session.asyncRequest(request, callback); + } + + @Override + public void asyncRequest(WriteOnly r) { + session.asyncRequest(r); + } + + @Override + public void asyncRequest(WriteOnly r, + Callback callback) { + session.asyncRequest(r,callback); + } + + @Override + public void asyncRequest(WriteOnlyResult r, + Procedure procedure) { + session.asyncRequest(r,procedure); + } + + @Override + public void asyncRequest(WriteResult r, Procedure procedure) { + session.asyncRequest(r,procedure); + } + + + + @Override + public void claim(final Resource subject, final Resource predicate, + final Resource inverse, final Resource object) throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.claim(subject, predicate, inverse, object); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public void claim(final Resource subject, final Resource predicate, final Resource object) + throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.claim(subject, predicate, object); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + + @Override + public void claimLiteral(final Resource resource, final Resource predicate, + final Object value) throws ManyObjectsForFunctionalRelationException, + ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.claimLiteral(resource, predicate, value); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void claimLiteral(final Resource resource, final Resource predicate, + final Object value, final Binding binding) throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.claimLiteral(resource, predicate, value, binding); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void claimLiteral(final Resource resource, final Resource predicate, + final Resource inverse, final Resource type, final Object value) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.claimLiteral(resource, predicate, inverse, type, value); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void claimLiteral(final Resource resource, final Resource predicate, + final Resource inverse, final Resource type, final Object value, final Binding binding) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.claimLiteral(resource, predicate, inverse, type, value, binding); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void claimLiteral(final Resource resource, final Resource predicate, + final Resource type, final Object value) throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.claimLiteral(resource, predicate, type, value); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void claimLiteral(final Resource resource, final Resource predicate, + final Resource type, final Object value, final Binding binding) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.claimLiteral(resource, predicate, type, value, binding); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void claimValue(final Resource resource, final Object value) + throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.claimValue(resource, value); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void claimValue(final Resource resource, final Object value, final Binding binding) + throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.claimValue(resource, value, binding); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @SuppressWarnings("deprecation") + @Override + public void claimValue(final Resource resource, final Resource predicate, + final Object value) throws ManyObjectsForFunctionalRelationException, + ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.claimValue(resource, predicate, value); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @SuppressWarnings("deprecation") + @Override + public void claimValue(final Resource resource, final Resource predicate, + final Object value, final Binding binding) throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.claimValue(resource, predicate, value, binding); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @SuppressWarnings("deprecation") + @Override + public void claimValue(final Resource resource, final Resource predicate, + final Resource inverse, final Resource type, final Object value, final Binding binding) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.claimValue(resource, predicate, inverse, type, value, binding); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void deny(final Resource subject) throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.deny(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void deny(final Resource subject, final Resource predicate) + throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.deny(subject, predicate); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void deny(final Resource subject, final Resource predicate, + final Resource inverse, final Resource object) throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.deny(subject, predicate, inverse, object); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void deny(final Resource subject, final Resource predicate, final Resource object) + throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.deny(subject, predicate, object); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void deny(final Statement statement) throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.deny(statement); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + + @Override + public void denyStatement(final Resource subject, final Resource predicate, + final Resource object) throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.denyStatement(subject, predicate, object); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void denyValue(final Resource resource) throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.denyValue(resource); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void denyValue(final Resource resource, final Resource predicate) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.denyValue(resource, predicate); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public void flushCluster() throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.flushCluster(); + + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public void flushCluster(final Resource r) throws ServiceException { + try { + session.syncRequest(new WriteRequest() { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.flushCluster(r); + + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public void forAdapted(final Resource resource, final Class clazz, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + + } + + @Override + public void forAdapted(final Resource resource, final Class clazz, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forAdapted(final Resource resource, final Class clazz, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forAdapted(final Resource resource, final Class clazz, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + + } + + @Override + public void forAdapted(final Resource resource, final Class clazz, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + + } + + @Override + public void forAdapted(final Resource resource, final Class clazz, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forAssertedObjectSet(final Resource subject, final Resource relation, + final AsyncSetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forAssertedObjectSet(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + + } + + @Override + public void forAssertedObjectSet(final Resource subject, final Resource relation, + final SetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forAssertedObjectSet(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forAssertedObjectSet(final Resource subject, final Resource relation, + final SyncSetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forAssertedObjectSet(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forAssertedStatementSet(final Resource subject, + final Resource relation, final AsyncSetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forAssertedStatementSet(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forAssertedStatementSet(final Resource subject, + final Resource relation, final SetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forAssertedStatementSet(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forAssertedStatementSet(final Resource subject, + final Resource relation, final SyncSetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forAssertedStatementSet(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forBuiltin(final String id, final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forBuiltin(id, procedure); + } + }); + } catch (DatabaseException e) { + + } + + } + + @Override + public void forBuiltin(final String id, final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forBuiltin(id, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forBuiltin(final String id, final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forBuiltin(id, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forBuiltin(final String id, final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forBuiltin(id, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forBuiltin(final String id, final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forBuiltin(id, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forBuiltin(final String id, final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forBuiltin(id, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forDirectSuperrelations(final Resource subject, + final AsyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forDirectSuperrelations(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachAssertedObject(final Resource subject, final Resource relation, + final AsyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachAssertedObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachAssertedObject(final Resource subject, final Resource relation, + final MultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachAssertedObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachAssertedObject(final Resource subject, final Resource relation, + final SyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachAssertedObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachAssertedStatement(final Resource subject, + final Resource relation, final AsyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachAssertedStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachAssertedStatement(final Resource subject, + final Resource relation, final MultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachAssertedStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachAssertedStatement(final Resource subject, + final Resource relation, final SyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachAssertedStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachDirectObject(final Resource subject, final Resource relation, + final AsyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachDirectObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachDirectObject(final Resource subject, final Resource relation, + final MultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachDirectObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachDirectObject(final Resource subject, final Resource relation, + final SyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachDirectObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachDirectPredicate(final Resource subject, + final AsyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachDirectPredicate(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachDirectPredicate(final Resource subject, + final MultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachDirectPredicate(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachDirectPredicate(final Resource subject, + final SyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachDirectPredicate(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachObject(final Resource subject, final Resource relation, + final AsyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachObject(final Resource subject, final Resource relation, + final MultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachObject(final Resource subject, final Resource relation, + final SyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachPredicate(final Resource subject, + final AsyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachPredicate(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachPredicate(final Resource subject, + final MultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachPredicate(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachPredicate(final Resource subject, + final SyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachPredicate(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachPrincipalType(final Resource subject, + final AsyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachPrincipalType(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachPrincipalType(final Resource subject, + final MultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachPrincipalType(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachPrincipalType(final Resource subject, + final SyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachPrincipalType(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachStatement(final Resource subject, final Resource relation, + final AsyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachStatement(final Resource subject, final Resource relation, + final MultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forEachStatement(final Resource subject, final Resource relation, + final SyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forEachStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + + } + + @Override + public void forHasStatement(final Resource subject, final Resource relation, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, final Resource relation, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, final Resource relation, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, final Resource relation, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, final Resource relation, + final Resource object, final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, relation, object, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, final Resource relation, + final Resource object, final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, relation, object, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, final Resource relation, + final Resource object, final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, relation, object, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, final Resource relation, + final Resource object, final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, relation, object, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, final Resource relation, + final Resource object, final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, relation, object, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, final Resource relation, + final Resource object, final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, relation, object, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, final Resource relation, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, final Resource relation, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasStatement(final Resource subject, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasStatement(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasValue(final Resource subject, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasValue(final Resource subject, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasValue(final Resource subject, final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasValue(final Resource subject, final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasValue(final Resource subject, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forHasValue(final Resource subject, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forHasValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forInverse(final Resource relation, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forInverse(relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public T getService(Class api) throws ServiceNotFoundException { + return session.getService(api); + } + + @Override + public T peekService(Class api) { + return session.peekService(api); + } + + @Override + public boolean hasService(Class api) { + return session.hasService(api); + } + + @Override + public void registerService(Class api, T service) { + session.registerService(api, service); + } + + @Override + public String getURI(final Resource resource) + throws ValidationException, + ServiceException, AssumptionException { + try { + return session.syncRequest(new Read() { + + @Override + public String perform(ReadGraph graph) throws DatabaseException { + return graph.getURI(resource); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + + } + + @Override + public String getPossibleURI(final Resource resource) + throws ValidationException, + ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public String perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleURI(resource); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Resource getResource(final String uri) + throws ResourceNotFoundException, ValidationException, + ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + return graph.getResource(uri); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Resource getPossibleResource(final String uri) + throws ResourceNotFoundException, ValidationException, + ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleResource(uri); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Collection getStatements(final Resource subject, + final Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + try { + return session.syncRequest(new Read>() { + + @Override + public Collection perform(ReadGraph graph) throws DatabaseException { + return graph.getStatements(subject, relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Collection getAssertedStatements(final Resource subject, + final Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + try { + return session.syncRequest(new Read>() { + + @Override + public Collection perform(ReadGraph graph) throws DatabaseException { + return graph.getAssertedStatements(subject, relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Collection getPredicates(final Resource subject) + throws ServiceException { + try { + return session.syncRequest(new Read>() { + + @Override + public Collection perform(ReadGraph graph) throws DatabaseException { + return graph.getPredicates(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Collection getPrincipalTypes(final Resource subject) + throws ServiceException { + try { + return session.syncRequest(new Read>() { + + @Override + public Collection perform(ReadGraph graph) throws DatabaseException { + return graph.getPrincipalTypes(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Set getTypes(final Resource subject) throws ServiceException { + try { + return session.syncRequest(new Read>() { + + @Override + public Set perform(ReadGraph graph) throws DatabaseException { + return graph.getTypes(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Set getSupertypes(final Resource subject) + throws ServiceException { + try { + return session.syncRequest(new Read>() { + + @Override + public Set perform(ReadGraph graph) throws DatabaseException { + return graph.getSupertypes(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Set getSuperrelations(final Resource subject) + throws ServiceException { + try { + return session.syncRequest(new Read>() { + + @Override + public Set perform(ReadGraph graph) throws DatabaseException { + return graph.getSuperrelations(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + +// @Override +// public Collection getObjects(final Resource subject, +// Resource relation) +// throws ManyObjectsForFunctionalRelationException, +// ServiceException { +// return graph.getObjects(subject, relation); +// } + + @Override + public Collection getAssertedObjects(final Resource subject, final Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + try { + return session.syncRequest(new Read>() { + + @Override + public Collection perform(ReadGraph graph) throws DatabaseException { + return graph.getAssertedObjects(subject, relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Resource getInverse(final Resource relation) + throws NoInverseException, + ManyObjectsForFunctionalRelationException, ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + return graph.getInverse(relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Resource getSingleObject(final Resource subject, final Resource relation) + throws NoSingleResultException, + ManyObjectsForFunctionalRelationException, ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + return graph.getSingleObject(subject, relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Statement getSingleStatement(final Resource subject, final Resource relation) + throws NoSingleResultException, + ManyObjectsForFunctionalRelationException, ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Statement perform(ReadGraph graph) throws DatabaseException { + return graph.getSingleStatement(subject, relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Resource getSingleType(final Resource subject) + throws NoSingleResultException, ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + return graph.getSingleType(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Resource getSingleType(final Resource subject, final Resource baseType) + throws NoSingleResultException, ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + return graph.getSingleType(subject, baseType); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T getValue(final Resource subject) + throws DoesNotContainValueException, ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getValue(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T getValue(final Resource subject, final Binding binding) + throws DoesNotContainValueException, BindingException, + ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getValue(subject, binding); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T getRelatedValue(final Resource subject, final Resource relation) + throws NoSingleResultException, DoesNotContainValueException, + ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getRelatedValue(subject, relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T getRelatedValue(final Resource subject, final Resource relation, + final Binding binding) throws NoSingleResultException, + DoesNotContainValueException, BindingException, + ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getRelatedValue(subject, relation, binding); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Resource getPossibleInverse(final Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleInverse(relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Resource getPossibleObject(final Resource subject, final Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleObject(subject, relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Statement getPossibleStatement(final Resource subject, + final Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Statement perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleStatement(subject, relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Resource getPossibleType(final Resource subject, final Resource baseType) + throws ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleType(subject, baseType); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T getPossibleValue(final Resource subject) throws ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleValue(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T getPossibleValue(final Resource subject, final Binding binding) + throws BindingException, ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleValue(subject, binding); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T getPossibleRelatedValue(final Resource subject, final Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleRelatedValue(subject, relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T getPossibleRelatedValue(final Resource subject, + final Resource relation, final Binding binding) + throws ManyObjectsForFunctionalRelationException, + BindingException, ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleRelatedValue(subject, relation, binding); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T getPossibleAdapter(final Resource resource, final Class clazz) + throws ValidationException, ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleAdapter(resource, clazz); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T getPossibleUniqueAdapter(final Resource resource, final Class clazz) + throws ValidationException, ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getPossibleUniqueAdapter(resource, clazz); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public boolean isInstanceOf(final Resource resource, final Resource type) + throws ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Boolean perform(ReadGraph graph) throws DatabaseException { + return graph.isInstanceOf(resource, type); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public boolean isInheritedFrom(final Resource resource, final Resource type) + throws ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Boolean perform(ReadGraph graph) throws DatabaseException { + return graph.isInheritedFrom(resource, type); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public boolean isSubrelationOf(final Resource resource, final Resource relation) + throws ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Boolean perform(ReadGraph graph) throws DatabaseException { + return graph.isSubrelationOf(resource, relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public boolean hasStatement(final Resource subject) throws ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Boolean perform(ReadGraph graph) throws DatabaseException { + return graph.hasStatement(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public boolean hasStatement(final Resource subject, final Resource relation) + throws ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Boolean perform(ReadGraph graph) throws DatabaseException { + return graph.hasStatement(subject, relation); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public boolean hasStatement(final Resource subject, final Resource relation, + final Resource object) throws ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Boolean perform(ReadGraph graph) throws DatabaseException { + return graph.hasStatement(subject, relation, object); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public boolean hasValue(final Resource subject) throws ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Boolean perform(ReadGraph graph) throws DatabaseException { + return graph.hasValue(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public Datatype getDataType(final Resource subject) throws DatabaseException { + try { + return session.syncRequest(new Read() { + + @Override + public Datatype perform(ReadGraph graph) throws DatabaseException { + return graph.getDataType(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T getAccessor(final Resource subject) + throws DatabaseException { + try { + return session.syncRequest(new Read() { + + @Override + public T perform(ReadGraph graph) throws DatabaseException { + return graph.getAccessor(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public RandomAccessBinary getRandomAccessBinary(final Resource subject) + throws DatabaseException { + try { + return session.syncRequest(new Read() { + @Override + public RandomAccessBinary perform(ReadGraph graph) throws DatabaseException { + return graph.getRandomAccessBinary(subject); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public T syncRequest(Read request) throws DatabaseException { + return session.syncRequest(request); + } + + @Override + public T syncRequest(Read request, AsyncListener procedure) + throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public T syncRequest(Read request, SyncListener procedure) + throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public T syncRequest(Read request, Listener procedure) + throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public T syncRequest(Read request, AsyncProcedure procedure) + throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public T syncRequest(Read request, SyncProcedure procedure) + throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public T syncRequest(Read request, Procedure procedure) + throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public T syncRequest(AsyncRead request) throws DatabaseException { + return session.syncRequest(request); + } + + @Override + public T syncRequest(AsyncRead request, + AsyncListener procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public T syncRequest(AsyncRead request, SyncListener procedure) + throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public T syncRequest(AsyncRead request, Listener procedure) + throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public T syncRequest(AsyncRead request, + AsyncProcedure procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public T syncRequest(AsyncRead request, + SyncProcedure procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public T syncRequest(AsyncRead request, Procedure procedure) + throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(MultiRead request) + throws DatabaseException { + return session.syncRequest(request); + } + + @Override + public Collection syncRequest(MultiRead request, + AsyncMultiListener procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(MultiRead request, + SyncMultiListener procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(MultiRead request, + MultiListener procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(MultiRead request, + AsyncMultiProcedure procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(MultiRead request, + SyncMultiProcedure procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(MultiRead request, + MultiProcedure procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(AsyncMultiRead request) + throws DatabaseException { + return session.syncRequest(request); + } + + @Override + public Collection syncRequest(AsyncMultiRead request, + AsyncMultiListener procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(AsyncMultiRead request, + SyncMultiListener procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(AsyncMultiRead request, + MultiListener procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(AsyncMultiRead request, + AsyncMultiProcedure procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(AsyncMultiRead request, + SyncMultiProcedure procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(AsyncMultiRead request, + MultiProcedure procedure) throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public T syncRequest(ExternalRead request) + throws DatabaseException { + return session.syncRequest(request); + } + + @Override + public T syncRequest(ExternalRead request, Listener procedure) + throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public T syncRequest(ExternalRead request, Procedure procedure) + throws DatabaseException { + return session.syncRequest(request, procedure); + } + + @Override + public void syncRequest(Write request) throws DatabaseException { + session.syncRequest(request); + } + + @Override + public void syncRequest(DelayedWrite request) throws DatabaseException { + session.syncRequest(request); + } + + @Override + public void syncRequest(WriteOnly r) throws DatabaseException { + session.syncRequest(r); + } + + @Override + public T syncRequest(WriteResult request) + throws DatabaseException { + return session.syncRequest(request); + } + + @Override + public T syncRequest(DelayedWriteResult request) + throws DatabaseException { + return session.syncRequest(request); + } + + @Override + public T syncRequest(WriteOnlyResult r) throws DatabaseException { + return session.syncRequest(r); + } + + @Override + public void forURI(final Resource resource, final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forURI(resource, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forURI(final Resource resource, final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forURI(resource, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forURI(final Resource resource, final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forURI(resource, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forURI(final Resource resource, final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forURI(resource, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forURI(final Resource resource, final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forURI(resource, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forURI(final Resource resource, final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forURI(resource, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forResource(final String id, final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forResource(id, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forResource(final String id, final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forResource(id, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forResource(final String id, final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forResource(id, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forResource(final String id, final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forResource(id, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forResource(final String id, final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forResource(id, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forResource(final String id, final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forResource(id, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forStatementSet(final Resource subject, final Resource relation, + final AsyncSetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forStatementSet(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forStatementSet(final Resource subject, final Resource relation, + final SyncSetListener procedure) { + + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forStatementSet(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forStatementSet(final Resource subject, final Resource relation, + final SetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forStatementSet(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPredicateSet(final Resource subject, + final AsyncSetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPredicateSet(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPredicateSet(final Resource subject, + final SyncSetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPredicateSet(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPredicateSet(final Resource subject, + final SetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPredicateSet(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPrincipalTypeSet(final Resource subject, + final AsyncSetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPrincipalTypeSet(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPrincipalTypeSet(final Resource subject, + final SyncSetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPrincipalTypeSet(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPrincipalTypeSet(final Resource subject, + final SetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPrincipalTypeSet(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forTypes(final Resource subject, + final AsyncListener> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forTypes(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forTypes(final Resource subject, + final SyncListener> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forTypes(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forTypes(final Resource subject, final Listener> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forTypes(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forTypes(final Resource subject, + final AsyncProcedure> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forTypes(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forTypes(final Resource subject, + final SyncProcedure> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forTypes(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forTypes(final Resource subject, + final Procedure> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forTypes(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSupertypes(final Resource subject, + final AsyncListener> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSupertypes(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSupertypes(final Resource subject, + final SyncListener> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSupertypes(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSupertypes(final Resource subject, + final Listener> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSupertypes(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSupertypes(final Resource subject, + final AsyncProcedure> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSupertypes(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSupertypes(final Resource subject, + final SyncProcedure> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSupertypes(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSupertypes(final Resource subject, + final Procedure> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSupertypes(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleSuperrelation(final Resource subject, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleSuperrelation(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSuperrelations(final Resource subject, + final AsyncListener> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSuperrelations(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSuperrelations(final Resource subject, + final SyncListener> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSuperrelations(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSuperrelations(final Resource subject, + final Listener> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSuperrelations(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSuperrelations(final Resource subject, + final AsyncProcedure> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSuperrelations(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSuperrelations(final Resource subject, + final SyncProcedure> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSuperrelations(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSuperrelations(final Resource subject, + final Procedure> procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSuperrelations(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forObjectSet(final Resource subject, final Resource relation, + final AsyncSetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forObjectSet(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forObjectSet(final Resource subject, final Resource relation, + final SyncSetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forObjectSet(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forObjectSet(final Resource subject, final Resource relation, + final SetListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forObjectSet(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forInverse(final Resource relation, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forInverse(relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forInverse(final Resource relation, final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forInverse(relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forInverse(final Resource relation, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forInverse(relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forInverse(final Resource relation, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forInverse(relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forInverse(final Resource relation, final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forInverse(relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleObject(final Resource subject, final Resource relation, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleObject(final Resource subject, final Resource relation, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleObject(final Resource subject, final Resource relation, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleObject(final Resource subject, final Resource relation, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleObject(final Resource subject, final Resource relation, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleObject(final Resource subject, final Resource relation, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleStatement(final Resource subject, final Resource relation, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleStatement(final Resource subject, final Resource relation, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleStatement(final Resource subject, final Resource relation, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + + } + + @Override + public void forSingleStatement(final Resource subject, final Resource relation, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleStatement(final Resource subject, final Resource relation, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleStatement(final Resource subject, final Resource relation, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleType(final Resource subject, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleType(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleType(final Resource subject, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleType(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleType(final Resource subject, final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleType(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleType(final Resource subject, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleType(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleType(final Resource subject, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleType(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleType(final Resource subject, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleType(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleType(final Resource subject, final Resource baseType, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleType(subject, baseType, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleType(final Resource subject, final Resource baseType, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleType(subject, baseType, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleType(final Resource subject, final Resource baseType, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleType(subject, baseType, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleType(final Resource subject, final Resource baseType, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleType(subject, baseType, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleType(final Resource subject, final Resource baseType, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleType(subject, baseType, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forSingleType(final Resource subject, final Resource baseType, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forSingleType(subject, baseType, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forValue(final Resource subject, final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forValue(final Resource subject, final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forValue(final Resource subject, final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forValue(final Resource subject, final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forValue(final Resource subject, final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forValue(final Resource subject, final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forValue(final Resource subject, final Binding binding, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forValue(subject, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forValue(final Resource subject, final Binding binding, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forValue(subject, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forValue(final Resource subject, final Binding binding, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forValue(subject, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forValue(final Resource subject, final Binding binding, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forValue(subject, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forValue(final Resource subject, final Binding binding, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forValue(subject, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forValue(final Resource subject, final Binding binding, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forValue(subject, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forRelatedValue(final Resource subject, final Resource relation, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forRelatedValue(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forRelatedValue(final Resource subject, final Resource relation, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forRelatedValue(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forRelatedValue(final Resource subject, final Resource relation, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forRelatedValue(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forRelatedValue(final Resource subject, final Resource relation, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forRelatedValue(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forRelatedValue(final Resource subject, final Resource relation, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forRelatedValue(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forRelatedValue(final Resource subject, final Resource relation, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forRelatedValue(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forRelatedValue(final Resource subject, final Resource relation, + final Binding binding, final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forRelatedValue(subject, relation, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forRelatedValue(final Resource subject, final Resource relation, + final Binding binding, final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forRelatedValue(subject, relation, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forRelatedValue(final Resource subject, final Resource relation, + final Binding binding, final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forRelatedValue(subject, relation, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forRelatedValue(final Resource subject, final Resource relation, + final Binding binding, final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forRelatedValue(subject, relation, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forRelatedValue(final Resource subject, final Resource relation, + final Binding binding, final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forRelatedValue(subject, relation, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forRelatedValue(final Resource subject, final Resource relation, + final Binding binding, final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forRelatedValue(subject, relation, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forUniqueAdapted(final Resource resource, final Class clazz, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forUniqueAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forUniqueAdapted(final Resource resource, final Class clazz, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forUniqueAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forUniqueAdapted(final Resource resource, final Class clazz, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forUniqueAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forUniqueAdapted(final Resource resource, final Class clazz, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forUniqueAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forUniqueAdapted(final Resource resource, final Class clazz, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forUniqueAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forUniqueAdapted(final Resource resource, final Class clazz, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forUniqueAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleInverse(final Resource relation, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleInverse(relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleInverse(final Resource relation, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleInverse(relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleInverse(final Resource relation, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleInverse(relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleInverse(final Resource relation, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleInverse(relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleInverse(final Resource relation, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleInverse(relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleInverse(final Resource relation, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleInverse(relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleObject(final Resource subject, final Resource relation, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleObject(final Resource subject, final Resource relation, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleObject(final Resource subject, final Resource relation, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleObject(final Resource subject, final Resource relation, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleObject(final Resource subject, final Resource relation, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleObject(final Resource subject, final Resource relation, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleObject(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleStatement(final Resource subject, final Resource relation, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleStatement(final Resource subject, final Resource relation, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleStatement(final Resource subject, final Resource relation, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleStatement(final Resource subject, final Resource relation, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleStatement(final Resource subject, final Resource relation, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleStatement(final Resource subject, final Resource relation, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleStatement(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleType(final Resource subject, final Resource baseType, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleType(subject, baseType, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleType(final Resource subject, final Resource baseType, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleType(subject, baseType, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleType(final Resource subject, final Resource baseType, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleType(subject, baseType, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleType(final Resource subject, final Resource baseType, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleType(subject, baseType, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleType(final Resource subject, final Resource baseType, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleType(subject, baseType, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleType(final Resource subject, final Resource baseType, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleType(subject, baseType, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleValue(final Resource subject, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleValue(final Resource subject, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleValue(final Resource subject, final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleValue(final Resource subject, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleValue(final Resource subject, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleValue(final Resource subject, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleValue(final Resource subject, final Binding binding, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleValue(final Resource subject, final Binding binding, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleValue(final Resource subject, final Binding binding, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleValue(final Resource subject, final Binding binding, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleValue(final Resource subject, final Binding binding, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleValue(final Resource subject, final Binding binding, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleValue(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleRelatedValue(final Resource subject, + final Resource relation, final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleRelatedValue(final Resource subject, + final Resource relation, final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleRelatedValue(final Resource subject, + final Resource relation, final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleRelatedValue(final Resource subject, + final Resource relation, final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleRelatedValue(final Resource subject, + final Resource relation, final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleRelatedValue(final Resource subject, + final Resource relation, final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleRelatedValue(final Resource subject, + final Resource relation, final Binding binding, final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleRelatedValue(subject, relation, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleRelatedValue(final Resource subject, + final Resource relation, final Binding binding, final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleRelatedValue(final Resource subject, + final Resource relation, final Binding binding, final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleRelatedValue(subject, relation, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleRelatedValue(final Resource subject, + final Resource relation, final Binding binding, final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleRelatedValue(subject, relation, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleRelatedValue(final Resource subject, + final Resource relation, final Binding binding, final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleRelatedValue(subject, relation, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleRelatedValue(final Resource subject, + final Resource relation, final Binding binding, final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleRelatedValue(subject, relation, binding, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleAdapted(final Resource resource, final Class clazz, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleAdapted(final Resource resource, final Class clazz, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleAdapted(final Resource resource, final Class clazz, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleAdapted(final Resource resource, final Class clazz, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleAdapted(final Resource resource, final Class clazz, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleAdapted(final Resource resource, final Class clazz, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleUniqueAdapted(final Resource resource, + final Class clazz, final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleUniqueAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleUniqueAdapted(final Resource resource, + final Class clazz, final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleUniqueAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleUniqueAdapted(final Resource resource, + final Class clazz, final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleUniqueAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleUniqueAdapted(final Resource resource, + final Class clazz, final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleUniqueAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleUniqueAdapted(final Resource resource, + final Class clazz, final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleUniqueAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forPossibleUniqueAdapted(final Resource resource, + final Class clazz, final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forPossibleUniqueAdapted(resource, clazz, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsInstanceOf(final Resource resource, final Resource type, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsInstanceOf(resource, type, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsInstanceOf(final Resource resource, final Resource type, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsInstanceOf(resource, type, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsInstanceOf(final Resource resource, final Resource type, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsInstanceOf(resource, type, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsInstanceOf(final Resource resource, final Resource type, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsInstanceOf(resource, type, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsInstanceOf(final Resource resource, final Resource type, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsInstanceOf(resource, type, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsInstanceOf(final Resource resource, final Resource type, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsInstanceOf(resource, type, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsInheritedFrom(final Resource resource, final Resource type, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsInheritedFrom(resource, type, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsInheritedFrom(final Resource resource, final Resource type, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsInheritedFrom(resource, type, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsInheritedFrom(final Resource resource, final Resource type, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsInheritedFrom(resource, type, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsInheritedFrom(final Resource resource, final Resource type, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsInheritedFrom(resource, type, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsInheritedFrom(final Resource resource, final Resource type, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsInheritedFrom(resource, type, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsInheritedFrom(final Resource resource, final Resource type, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsInheritedFrom(resource, type, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsSubrelationOf(final Resource resource, final Resource relation, + final AsyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsSubrelationOf(resource, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsSubrelationOf(final Resource resource, final Resource relation, + final SyncListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsSubrelationOf(resource, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsSubrelationOf(final Resource resource, final Resource relation, + final Listener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsSubrelationOf(resource, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsSubrelationOf(final Resource resource, final Resource relation, + final AsyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsSubrelationOf(resource, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsSubrelationOf(final Resource resource, final Resource relation, + final SyncProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsSubrelationOf(resource, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forIsSubrelationOf(final Resource resource, final Resource relation, + final Procedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forIsSubrelationOf(resource, relation, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forOrderedSet(final Resource subject, + final AsyncMultiListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forOrderedSet(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forOrderedSet(final Resource subject, + final SyncMultiListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forOrderedSet(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forOrderedSet(final Resource subject, + final MultiListener procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forOrderedSet(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forOrderedSet(final Resource subject, + final AsyncMultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forOrderedSet(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forOrderedSet(final Resource subject, + final SyncMultiProcedure procedure) { + + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forOrderedSet(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public void forOrderedSet(final Resource subject, + final MultiProcedure procedure) { + try { + session.syncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + graph.forOrderedSet(subject, procedure); + } + }); + } catch (DatabaseException e) { + + } + } + + @Override + public int thread() { + return -1; + } + + @Override + public Session getSession() { + return session; + } + + @Override + public Resource getBuiltin(final String id) throws ResourceNotFoundException, + ServiceException { + try { + return session.syncRequest(new Read() { + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + return graph.getBuiltin(id); + } + }); + } catch (DatabaseException e) { + throw new ServiceException(e); + } + } + + @Override + public VirtualGraph getProvider() { + return null; + } + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/WriteGraphProxy.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/WriteGraphProxy.java new file mode 100644 index 0000000..96ee011 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/WriteGraphProxy.java @@ -0,0 +1,2732 @@ +package org.simantics.interop.mapping; + +import java.util.Collection; +import java.util.Set; +import java.util.TreeMap; + +import org.simantics.databoard.accessor.Accessor; +import org.simantics.databoard.binding.Binding; +import org.simantics.databoard.type.Datatype; +import org.simantics.databoard.util.binary.RandomAccessBinary; +import org.simantics.db.Metadata; +import org.simantics.db.Resource; +import org.simantics.db.Session; +import org.simantics.db.Statement; +import org.simantics.db.VirtualGraph; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.AdaptionException; +import org.simantics.db.exception.AssumptionException; +import org.simantics.db.exception.BindingException; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.exception.DoesNotContainValueException; +import org.simantics.db.exception.ManyObjectsForFunctionalRelationException; +import org.simantics.db.exception.NoInverseException; +import org.simantics.db.exception.NoSingleResultException; +import org.simantics.db.exception.ResourceNotFoundException; +import org.simantics.db.exception.ServiceException; +import org.simantics.db.exception.ServiceNotFoundException; +import org.simantics.db.exception.ValidationException; +import org.simantics.db.procedure.AsyncListener; +import org.simantics.db.procedure.AsyncMultiListener; +import org.simantics.db.procedure.AsyncMultiProcedure; +import org.simantics.db.procedure.AsyncProcedure; +import org.simantics.db.procedure.AsyncSetListener; +import org.simantics.db.procedure.Listener; +import org.simantics.db.procedure.MultiListener; +import org.simantics.db.procedure.MultiProcedure; +import org.simantics.db.procedure.Procedure; +import org.simantics.db.procedure.SetListener; +import org.simantics.db.procedure.SyncListener; +import org.simantics.db.procedure.SyncMultiListener; +import org.simantics.db.procedure.SyncMultiProcedure; +import org.simantics.db.procedure.SyncProcedure; +import org.simantics.db.procedure.SyncSetListener; +import org.simantics.db.request.AsyncMultiRead; +import org.simantics.db.request.AsyncRead; +import org.simantics.db.request.DelayedWrite; +import org.simantics.db.request.DelayedWriteResult; +import org.simantics.db.request.ExternalRead; +import org.simantics.db.request.MultiRead; +import org.simantics.db.request.Read; +import org.simantics.db.request.ReadInterface; +import org.simantics.db.request.Write; +import org.simantics.db.request.WriteInterface; +import org.simantics.db.request.WriteOnly; +import org.simantics.db.request.WriteOnlyResult; +import org.simantics.db.request.WriteResult; +import org.simantics.db.request.WriteTraits; +import org.simantics.scl.types.Type; +import org.simantics.utils.datastructures.Callback; + +/** + * + * @author Marko Luukkainen + * + */ +public class WriteGraphProxy implements WriteGraph { + + protected WriteGraph graph; + + + @Override + public T getRelatedValue2(Resource subject, Resource relation) + throws DatabaseException { + return graph.getRelatedValue2(subject, relation); + } + + @Override + public T getRelatedValue2(Resource subject, Resource relation, + Binding binding) throws DatabaseException { + return graph.getRelatedValue2(subject, relation, binding); + } + + @Override + public T getRelatedValue2(Resource subject, Resource relation, + Object context) throws DatabaseException { + return graph.getRelatedValue2(subject, relation, context); + } + + @Override + public T getRelatedValue2(Resource subject, Resource relation, + Object context, Binding binding) throws DatabaseException { + return graph.getRelatedValue2(subject, relation, context, binding); + } + + @Override + public T getPossibleRelatedValue2(Resource subject, Resource relation) + throws DatabaseException { + return graph.getPossibleRelatedValue2(subject, relation); + } + + @Override + public T getPossibleRelatedValue2(Resource subject, Resource relation, + Binding binding) throws DatabaseException { + return graph.getPossibleRelatedValue2(subject, relation, binding); + } + + @Override + public T getPossibleRelatedValue2(Resource subject, Resource relation, + Object context) throws DatabaseException { + return graph.getPossibleRelatedValue2(subject, relation, context); + } + + @Override + public T getPossibleRelatedValue2(Resource subject, Resource relation, + Object context, Binding binding) throws DatabaseException { + return getPossibleRelatedValue2(subject, relation, context, binding); + } + + @Override + public void async(ReadInterface r, AsyncListener procedure) { + graph.async(r,procedure); + } + + @Override + public void async(ReadInterface r, AsyncProcedure procedure) { + graph.async(r, procedure); + } + + @Override + public void async(ReadInterface r, Listener procedure) { + graph.async(r, procedure); + } + + @Override + public void async(ReadInterface r, Procedure procedure) { + graph.async(r, procedure); + } + + @Override + public void async(ReadInterface r, SyncListener procedure) { + graph.async(r, procedure); + } + + @Override + public void async(ReadInterface r, SyncProcedure procedure) { + graph.async(r, procedure); + } + + @Override + public void async(WriteInterface r) { + graph.async(r); + } + + @Override + public void async(WriteInterface r, Procedure procedure) { + graph.async(r, procedure); + } + + @Override + public T sync(ReadInterface r) throws DatabaseException { + return graph.sync(r); + } + + @Override + public T sync(WriteInterface r) throws DatabaseException { + return graph.sync(r); + } + + @Override + public Resource getRootLibrary() { + return graph.getRootLibrary(); + } + + + @Override + public void clearUndoList(WriteTraits writeTraits) { + graph.clearUndoList(writeTraits); + } + + @Override + public void combineWithPrevious(WriteTraits writeTraits) { + graph.combineWithPrevious(writeTraits); + } + + @Override + public TreeMap getMetadata() { + return graph.getMetadata(); + } + + @Override + public T getMetadata(Class clazz) + throws ServiceException { + return graph.getMetadata(clazz); + } + + @Override + public Type getRelatedValueType(Resource subject, Resource relation) + throws DatabaseException { + return graph.getRelatedValueType(subject, relation); + } + + @Override + public void deny(Resource subject, Resource predicate, Resource inverse, + Resource object, VirtualGraph graph) throws ServiceException { + this.graph.deny(subject, predicate, inverse, object, graph); + } + + + + + @Override + public T adaptRelated(Resource resource, Resource relation, + Class clazz) throws AdaptionException, NoSingleResultException, + ValidationException, ServiceException { + return graph.adaptRelated(resource, relation, clazz); + } + + @Override + public T getPossibleRelatedAdapter(Resource resource, + Resource relation, Class clazz) throws ValidationException, + ServiceException { + return graph.getPossibleRelatedAdapter(resource, relation, clazz); + } + + @Override + public void inc() { + graph.inc(); + } + + @Override + public void dec() { + graph.dec(); + } + + @Override + public Collection getObjects(Resource subject, Resource relation) throws ServiceException + { + return graph.getObjects(subject, relation); + } + + @Override + public T newLiteral(Resource resource, + Resource predicate, Datatype datatype, Object initialValue) + throws DatabaseException { + return graph.newLiteral(resource, predicate, datatype, initialValue); + } + + @Override + public RandomAccessBinary newLiteral4RandomAccessBinary + (Resource resource, Resource predicate, Datatype datatype, Object initialValue) + throws DatabaseException { + return graph.newLiteral4RandomAccessBinary(resource, predicate, datatype, initialValue); + } +// @Override +// public void claimFile(Resource resource, Object content, Binding binding) +// throws DatabaseException { +// graph.claimFile(resource, content, binding); +// } +// +// @Override +// public void denyFile(Resource resource) throws DatabaseException { +// graph.denyFile(resource); +// } + + public T adaptContextual(Resource resource, C context, java.lang.Class contextClass, java.lang.Class clazz) throws AdaptionException ,NoSingleResultException ,ValidationException ,ServiceException { + return graph.adaptContextual(resource, context, contextClass, clazz); + }; + + public T getPossibleContextualAdapter(Resource resource, C context, java.lang.Class contextClass, java.lang.Class clazz) throws ValidationException ,ServiceException { + return graph.getPossibleContextualAdapter(resource, context, contextClass, clazz); + }; + + + public WriteGraphProxy(WriteGraph graph) { + this.graph = graph; + } + + @Override + public Resource newResource() throws ServiceException { + return graph.newResource(); + } + + @Override + public Resource newResource(long clusterId) throws ServiceException { + return graph.newResource(clusterId); + } + + @Override + public T adapt(Resource resource, Class clazz) + throws AdaptionException, ValidationException, ServiceException { + return graph.adapt(resource, clazz); + } + + @Override + public T adaptUnique(Resource resource, Class clazz) + throws AdaptionException, ValidationException, ServiceException { + return adaptUnique(resource, clazz); + } + + @Override + public void addLiteral(Resource resource, Resource predicate, + Resource inverse, Object value, Binding binding) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + graph.addLiteral(resource, predicate, inverse, value, binding); + } + + @Override + public void addLiteral(Resource resource, Resource predicate, + Resource inverse, Resource type, Object value, Binding binding) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + graph.addLiteral(resource, predicate, inverse, type, value, binding); + } + + @Override + public void addMetadata(Metadata data) throws ServiceException { + graph.addMetadata(data); + } + + @SuppressWarnings("deprecation") + @Override + public void addValue(Resource resource, Resource predicate, + Resource inverse, Resource type, Object value, Binding binding) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + graph.addValue(resource, predicate, inverse, type, value, binding); + } + + @Override + public void asyncRequest(AsyncMultiRead request) { + graph.asyncRequest(request); + } + + @Override + public void asyncRequest(AsyncMultiRead request, + AsyncMultiListener procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncMultiRead request, + AsyncMultiProcedure procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncMultiRead request, + MultiListener procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncMultiRead request, + MultiProcedure procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncMultiRead request, + SyncMultiListener procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncMultiRead request, + SyncMultiProcedure procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncRead request) { + graph.asyncRequest(request); + } + + @Override + public void asyncRequest(AsyncRead request, + AsyncListener procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncRead request, + AsyncProcedure procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncRead request, Listener procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncRead request, + Procedure procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncRead request, + SyncListener procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(AsyncRead request, + SyncProcedure procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(DelayedWrite request) { + graph.asyncRequest(request); + } + + @Override + public void asyncRequest(DelayedWrite request, + Callback callback) { + graph.asyncRequest(request,callback); + } + + @Override + public void asyncRequest(DelayedWriteResult r, + Procedure procedure) { + graph.asyncRequest(r,procedure); + } + + @Override + public void asyncRequest(ExternalRead request) { + graph.asyncRequest(request); + } + + @Override + public void asyncRequest(ExternalRead request, + Listener procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(ExternalRead request, + Procedure procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(MultiRead request) { + graph.asyncRequest(request); + } + + @Override + public void asyncRequest(MultiRead request, + AsyncMultiListener procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(MultiRead request, + AsyncMultiProcedure procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(MultiRead request, + MultiListener procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(MultiRead request, + MultiProcedure procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(MultiRead request, + SyncMultiListener procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(MultiRead request, + SyncMultiProcedure procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Read request) { + graph.asyncRequest(request); + } + + @Override + public void asyncRequest(Read request, AsyncListener procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Read request, + AsyncProcedure procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Read request, Listener procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Read request, Procedure procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Read request, SyncListener procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Read request, SyncProcedure procedure) { + graph.asyncRequest(request,procedure); + } + + @Override + public void asyncRequest(Write request) { + graph.asyncRequest(request); + } + + @Override + public void asyncRequest(Write request, + Callback callback) { + graph.asyncRequest(request, callback); + } + + @Override + public void asyncRequest(WriteOnly r) { + graph.asyncRequest(r); + } + + @Override + public void asyncRequest(WriteOnly r, + Callback callback) { + graph.asyncRequest(r,callback); + } + + @Override + public void asyncRequest(WriteOnlyResult r, + Procedure procedure) { + graph.asyncRequest(r,procedure); + } + + @Override + public void asyncRequest(WriteResult r, Procedure procedure) { + graph.asyncRequest(r,procedure); + } + + + + @Override + public void claim(Resource subject, Resource predicate, + Resource inverse, Resource object) throws ServiceException { + graph.claim(subject, predicate, inverse, object); + } + + @Override + public void claim(Resource subject, Resource predicate, Resource object) + throws ServiceException { + graph.claim(subject, predicate, object); + } + + + @Override + public void claimLiteral(Resource resource, Resource predicate, + Object value) throws ManyObjectsForFunctionalRelationException, + ServiceException { + graph.claimLiteral(resource, predicate, value); + } + + @Override + public void claimLiteral(Resource resource, Resource predicate, + Object value, Binding binding) throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + graph.claimLiteral(resource, predicate, value, binding); + } + + @Override + public void claimLiteral(Resource resource, Resource predicate, + Resource inverse, Resource type, Object value) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + graph.claimLiteral(resource, predicate, inverse, type, value); + } + + @Override + public void claimLiteral(Resource resource, Resource predicate, + Resource inverse, Resource type, Object value, Binding binding) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + graph.claimLiteral(resource, predicate, inverse, type, value, binding); + } + + @Override + public void claimLiteral(Resource resource, Resource predicate, + Resource type, Object value) throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + graph.claimLiteral(resource, predicate, type, value); + } + + @Override + public void claimLiteral(Resource resource, Resource predicate, + Resource type, Object value, Binding binding) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + graph.claimLiteral(resource, predicate, type, value, binding); + } + + @Override + public void claimValue(Resource resource, Object value) + throws ServiceException { + graph.claimValue(resource, value); + } + + @Override + public void claimValue(Resource resource, Object value, Binding binding) + throws ServiceException { + graph.claimValue(resource, value, binding); + } + + @SuppressWarnings("deprecation") + @Override + public void claimValue(Resource resource, Resource predicate, + Object value) throws ManyObjectsForFunctionalRelationException, + ServiceException { + graph.claimValue(resource, predicate, value); + } + + @SuppressWarnings("deprecation") + @Override + public void claimValue(Resource resource, Resource predicate, + Object value, Binding binding) throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + graph.claimValue(resource, predicate, value, binding); + } + + @SuppressWarnings("deprecation") + @Override + public void claimValue(Resource resource, Resource predicate, + Resource inverse, Resource type, Object value, Binding binding) + throws BindingException, + ManyObjectsForFunctionalRelationException, ServiceException { + graph.claimValue(resource, predicate, inverse, type, value, binding); + } + + @Override + public void deny(Resource subject) throws ServiceException { + graph.deny(subject); + } + + @Override + public void deny(Resource subject, Resource predicate) + throws ServiceException { + graph.deny(subject, predicate); + } + + @Override + public void deny(Resource subject, Resource predicate, + Resource inverse, Resource object) throws ServiceException { + graph.deny(subject, predicate, inverse, object); + } + + @Override + public void deny(Resource subject, Resource predicate, Resource object) + throws ServiceException { + graph.deny(subject, predicate, object); + } + + @Override + public void deny(Statement statement) throws ServiceException { + graph.deny(statement); + } + + + @Override + public void denyStatement(Resource subject, Resource predicate, + Resource object) throws ServiceException { + graph.denyStatement(subject, predicate, object); + } + + @Override + public void denyValue(Resource resource) throws ServiceException { + graph.denyValue(resource); + } + + @Override + public void denyValue(Resource resource, Resource predicate) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + graph.denyValue(resource, predicate); + } + + @Override + public void flushCluster() throws ServiceException { + graph.flushCluster(); + } + + @Override + public void flushCluster(Resource r) throws ServiceException { + graph.flushCluster(r); + } + + @Override + public void forAdapted(Resource resource, Class clazz, + AsyncListener procedure) { + graph.forAdapted(resource, clazz, procedure); + } + + @Override + public void forAdapted(Resource resource, Class clazz, + AsyncProcedure procedure) { + graph.forAdapted(resource, clazz, procedure); + } + + @Override + public void forAdapted(Resource resource, Class clazz, + Listener procedure) { + graph.forAdapted(resource, clazz, procedure); + } + + @Override + public void forAdapted(Resource resource, Class clazz, + Procedure procedure) { + graph.forAdapted(resource, clazz, procedure); + } + + @Override + public void forAdapted(Resource resource, Class clazz, + SyncListener procedure) { + graph.forAdapted(resource, clazz, procedure); + } + + @Override + public void forAdapted(Resource resource, Class clazz, + SyncProcedure procedure) { + graph.forAdapted(resource, clazz, procedure); + } + + @Override + public void forAssertedObjectSet(Resource subject, Resource relation, + AsyncSetListener procedure) { + graph.forAssertedObjectSet(subject, relation, procedure); + } + + @Override + public void forAssertedObjectSet(Resource subject, Resource relation, + SetListener procedure) { + graph.forAssertedObjectSet(subject, relation, procedure); + } + + @Override + public void forAssertedObjectSet(Resource subject, Resource relation, + SyncSetListener procedure) { + graph.forAssertedObjectSet(subject, relation, procedure); + } + + @Override + public void forAssertedStatementSet(Resource subject, + Resource relation, AsyncSetListener procedure) { + graph.forAssertedStatementSet(subject, relation, procedure); + } + + @Override + public void forAssertedStatementSet(Resource subject, + Resource relation, SetListener procedure) { + graph.forAssertedStatementSet(subject, relation, procedure); + } + + @Override + public void forAssertedStatementSet(Resource subject, + Resource relation, SyncSetListener procedure) { + graph.forAssertedStatementSet(subject, relation, procedure); + } + + @Override + public void forBuiltin(String id, AsyncListener procedure) { + graph.forBuiltin(id, procedure); + } + + @Override + public void forBuiltin(String id, Listener procedure) { + graph.forBuiltin(id, procedure); + } + + @Override + public void forBuiltin(String id, AsyncProcedure procedure) { + graph.forBuiltin(id, procedure); + } + + @Override + public void forBuiltin(String id, Procedure procedure) { + graph.forBuiltin(id, procedure); + } + + @Override + public void forBuiltin(String id, SyncListener procedure) { + graph.forBuiltin(id, procedure); + } + + @Override + public void forBuiltin(String id, SyncProcedure procedure) { + graph.forBuiltin(id, procedure); + } + + @Override + public void forDirectSuperrelations(Resource subject, + AsyncMultiProcedure procedure) { + graph.forDirectSuperrelations(subject, procedure); + } + + @Override + public void forEachAssertedObject(Resource subject, Resource relation, + AsyncMultiProcedure procedure) { + graph.forEachAssertedObject(subject, relation, procedure); + } + + @Override + public void forEachAssertedObject(Resource subject, Resource relation, + MultiProcedure procedure) { + graph.forEachAssertedObject(subject, relation, procedure); + } + + @Override + public void forEachAssertedObject(Resource subject, Resource relation, + SyncMultiProcedure procedure) { + graph.forEachAssertedObject(subject, relation, procedure); + } + + @Override + public void forEachAssertedStatement(Resource subject, + Resource relation, AsyncMultiProcedure procedure) { + graph.forEachAssertedStatement(subject, relation, procedure); + } + + @Override + public void forEachAssertedStatement(Resource subject, + Resource relation, MultiProcedure procedure) { + graph.forEachAssertedStatement(subject, relation, procedure); + } + + @Override + public void forEachAssertedStatement(Resource subject, + Resource relation, SyncMultiProcedure procedure) { + graph.forEachAssertedStatement(subject, relation, procedure); + } + + @Override + public void forEachDirectObject(Resource subject, Resource relation, + AsyncMultiProcedure procedure) { + graph.forEachDirectObject(subject, relation, procedure); + } + + @Override + public void forEachDirectObject(Resource subject, Resource relation, + MultiProcedure procedure) { + graph.forEachDirectObject(subject, relation, procedure); + } + + @Override + public void forEachDirectObject(Resource subject, Resource relation, + SyncMultiProcedure procedure) { + graph.forEachDirectObject(subject, relation, procedure); + } + + @Override + public void forEachDirectPredicate(Resource subject, + AsyncMultiProcedure procedure) { + graph.forEachDirectPredicate(subject, procedure); + } + + @Override + public void forEachDirectPredicate(Resource subject, + MultiProcedure procedure) { + graph.forEachDirectPredicate(subject, procedure); + } + + @Override + public void forEachDirectPredicate(Resource subject, + SyncMultiProcedure procedure) { + graph.forEachDirectPredicate(subject, procedure); + } + + @Override + public void forEachObject(Resource subject, Resource relation, + AsyncMultiProcedure procedure) { + graph.forEachObject(subject, relation, procedure); + } + + @Override + public void forEachObject(Resource subject, Resource relation, + MultiProcedure procedure) { + graph.forEachObject(subject, relation, procedure); + } + + @Override + public void forEachObject(Resource subject, Resource relation, + SyncMultiProcedure procedure) { + graph.forEachObject(subject, relation, procedure); + } + + @Override + public void forEachPredicate(Resource subject, + AsyncMultiProcedure procedure) { + graph.forEachPredicate(subject, procedure); + } + + @Override + public void forEachPredicate(Resource subject, + MultiProcedure procedure) { + graph.forEachPredicate(subject, procedure); + } + + @Override + public void forEachPredicate(Resource subject, + SyncMultiProcedure procedure) { + graph.forEachPredicate(subject, procedure); + } + + @Override + public void forEachPrincipalType(Resource subject, + AsyncMultiProcedure procedure) { + graph.forEachPrincipalType(subject, procedure); + } + + @Override + public void forEachPrincipalType(Resource subject, + MultiProcedure procedure) { + graph.forEachPrincipalType(subject, procedure); + } + + @Override + public void forEachPrincipalType(Resource subject, + SyncMultiProcedure procedure) { + graph.forEachPrincipalType(subject, procedure); + } + + @Override + public void forEachStatement(Resource subject, Resource relation, + AsyncMultiProcedure procedure) { + graph.forEachStatement(subject, relation, procedure); + } + + @Override + public void forEachStatement(Resource subject, Resource relation, + MultiProcedure procedure) { + graph.forEachStatement(subject, relation, procedure); + } + + @Override + public void forEachStatement(Resource subject, Resource relation, + SyncMultiProcedure procedure) { + graph.forEachStatement(subject, relation, procedure); + } + + @Override + public void forHasStatement(Resource subject, + AsyncListener procedure) { + graph.forHasStatement(subject, procedure); + } + + @Override + public void forHasStatement(Resource subject, + AsyncProcedure procedure) { + graph.forHasStatement(subject, procedure); + } + + @Override + public void forHasStatement(Resource subject, + Listener procedure) { + graph.forHasStatement(subject, procedure); + } + + @Override + public void forHasStatement(Resource subject, + Procedure procedure) { + graph.forHasStatement(subject, procedure); + } + + @Override + public void forHasStatement(Resource subject, Resource relation, + AsyncListener procedure) { + graph.forHasStatement(subject, relation, procedure); + } + + @Override + public void forHasStatement(Resource subject, Resource relation, + AsyncProcedure procedure) { + graph.forHasStatement(subject, relation, procedure); + } + + @Override + public void forHasStatement(Resource subject, Resource relation, + Listener procedure) { + graph.forHasStatement(subject, relation, procedure); + } + + @Override + public void forHasStatement(Resource subject, Resource relation, + Procedure procedure) { + graph.forHasStatement(subject, relation, procedure); + } + + @Override + public void forHasStatement(Resource subject, Resource relation, + Resource object, AsyncListener procedure) { + graph.forHasStatement(subject, relation, object, procedure); + } + + @Override + public void forHasStatement(Resource subject, Resource relation, + Resource object, AsyncProcedure procedure) { + graph.forHasStatement(subject, relation, object, procedure); + } + + @Override + public void forHasStatement(Resource subject, Resource relation, + Resource object, Listener procedure) { + graph.forHasStatement(subject, relation, object, procedure); + } + + @Override + public void forHasStatement(Resource subject, Resource relation, + Resource object, Procedure procedure) { + graph.forHasStatement(subject, relation, object, procedure); + } + + @Override + public void forHasStatement(Resource subject, Resource relation, + Resource object, SyncListener procedure) { + graph.forHasStatement(subject, relation, object, procedure); + } + + @Override + public void forHasStatement(Resource subject, Resource relation, + Resource object, SyncProcedure procedure) { + graph.forHasStatement(subject, relation, object, procedure); + } + + @Override + public void forHasStatement(Resource subject, Resource relation, + SyncListener procedure) { + graph.forHasStatement(subject, relation, procedure); + } + + @Override + public void forHasStatement(Resource subject, Resource relation, + SyncProcedure procedure) { + graph.forHasStatement(subject, relation, procedure); + } + + @Override + public void forHasStatement(Resource subject, + SyncListener procedure) { + graph.forHasStatement(subject, procedure); + } + + @Override + public void forHasStatement(Resource subject, + SyncProcedure procedure) { + graph.forHasStatement(subject, procedure); + } + + @Override + public void forHasValue(Resource subject, + AsyncListener procedure) { + graph.forHasValue(subject, procedure); + } + + @Override + public void forHasValue(Resource subject, + AsyncProcedure procedure) { + graph.forHasValue(subject, procedure); + } + + @Override + public void forHasValue(Resource subject, Listener procedure) { + graph.forHasValue(subject, procedure); + } + + @Override + public void forHasValue(Resource subject, Procedure procedure) { + graph.forHasValue(subject, procedure); + } + + @Override + public void forHasValue(Resource subject, + SyncListener procedure) { + graph.forHasValue(subject, procedure); + } + + @Override + public void forHasValue(Resource subject, + SyncProcedure procedure) { + graph.forHasValue(subject, procedure); + } + + @Override + public void forInverse(Resource relation, + AsyncListener procedure) { + graph.forInverse(relation, procedure); + } + + @Override + public T getService(Class api) throws ServiceNotFoundException { + return graph.getService(api); + } + + @Override + public T peekService(Class api) { + return graph.peekService(api); + } + + @Override + public boolean hasService(Class api) { + return graph.hasService(api); + } + + @Override + public void registerService(Class api, T service) { + graph.registerService(api, service); + } + + @Override + public String getURI(Resource resource) + throws ValidationException, + ServiceException, AssumptionException { + return graph.getURI(resource); + } + + @Override + public String getPossibleURI(Resource resource) + throws ValidationException, + ServiceException { + return graph.getPossibleURI(resource); + } + + @Override + public Resource getResource(String uri) + throws ResourceNotFoundException, ValidationException, + ServiceException { + return graph.getResource(uri); + } + + @Override + public Resource getPossibleResource(String uri) + throws ResourceNotFoundException, ValidationException, + ServiceException { + return graph.getPossibleResource(uri); + } + + @Override + public Collection getStatements(Resource subject, + Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + return graph.getStatements(subject, relation); + } + + @Override + public Collection getAssertedStatements(Resource subject, + Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + return graph.getAssertedStatements(subject, relation); + } + + @Override + public Collection getPredicates(Resource subject) + throws ServiceException { + return graph.getPredicates(subject); + } + + @Override + public Collection getPrincipalTypes(Resource subject) + throws ServiceException { + return graph.getPrincipalTypes(subject); + } + + @Override + public Set getTypes(Resource subject) throws ServiceException { + return graph.getTypes(subject); + } + + @Override + public Set getSupertypes(Resource subject) + throws ServiceException { + return graph.getSupertypes(subject); + } + + @Override + public Set getSuperrelations(Resource subject) + throws ServiceException { + return graph.getSuperrelations(subject); + } + +// @Override +// public Collection getObjects(Resource subject, +// Resource relation) +// throws ManyObjectsForFunctionalRelationException, +// ServiceException { +// return graph.getObjects(subject, relation); +// } + + @Override + public Collection getAssertedObjects(Resource subject, + Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + return graph.getAssertedObjects(subject, relation); + } + + @Override + public Resource getInverse(Resource relation) + throws NoInverseException, + ManyObjectsForFunctionalRelationException, ServiceException { + return graph.getInverse(relation); + } + + @Override + public Resource getSingleObject(Resource subject, Resource relation) + throws NoSingleResultException, + ManyObjectsForFunctionalRelationException, ServiceException { + return graph.getSingleObject(subject, relation); + } + + @Override + public Statement getSingleStatement(Resource subject, Resource relation) + throws NoSingleResultException, + ManyObjectsForFunctionalRelationException, ServiceException { + return graph.getSingleStatement(subject, relation); + } + + @Override + public Resource getSingleType(Resource subject) + throws NoSingleResultException, ServiceException { + return graph.getSingleType(subject); + } + + @Override + public Resource getSingleType(Resource subject, Resource baseType) + throws NoSingleResultException, ServiceException { + return graph.getSingleType(subject, baseType); + } + + @Override + public T getValue(Resource subject) + throws DoesNotContainValueException, ServiceException { + return graph.getValue(subject); + } + + @Override + public T getValue(Resource subject, Binding binding) + throws DoesNotContainValueException, BindingException, + ServiceException { + return graph.getValue(subject, binding); + } + + @Override + public T getRelatedValue(Resource subject, Resource relation) + throws NoSingleResultException, DoesNotContainValueException, + ServiceException { + return graph.getRelatedValue(subject, relation); + } + + @Override + public T getRelatedValue(Resource subject, Resource relation, + Binding binding) throws NoSingleResultException, + DoesNotContainValueException, BindingException, + ServiceException { + return graph.getRelatedValue(subject, relation, binding); + } + + @Override + public Resource getPossibleInverse(Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + return graph.getPossibleInverse(relation); + } + + @Override + public Resource getPossibleObject(Resource subject, Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + return graph.getPossibleObject(subject, relation); + } + + @Override + public Statement getPossibleStatement(Resource subject, + Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + return graph.getPossibleStatement(subject, relation); + } + + @Override + public Resource getPossibleType(Resource subject, Resource baseType) + throws ServiceException { + return graph.getPossibleType(subject, baseType); + } + + @Override + public T getPossibleValue(Resource subject) throws ServiceException { + return graph.getPossibleValue(subject); + } + + @Override + public T getPossibleValue(Resource subject, Binding binding) + throws BindingException, ServiceException { + return graph.getPossibleValue(subject, binding); + } + + @Override + public T getPossibleRelatedValue(Resource subject, Resource relation) + throws ManyObjectsForFunctionalRelationException, + ServiceException { + return graph.getPossibleRelatedValue(subject, relation); + } + + @Override + public T getPossibleRelatedValue(Resource subject, + Resource relation, Binding binding) + throws ManyObjectsForFunctionalRelationException, + BindingException, ServiceException { + return graph.getPossibleRelatedValue(subject, relation, binding); + } + + @Override + public T getPossibleAdapter(Resource resource, Class clazz) + throws ValidationException, ServiceException { + return graph.getPossibleAdapter(resource, clazz); + } + + @Override + public T getPossibleUniqueAdapter(Resource resource, Class clazz) + throws ValidationException, ServiceException { + return graph.getPossibleUniqueAdapter(resource, clazz); + } + + @Override + public boolean isInstanceOf(Resource resource, Resource type) + throws ServiceException { + return graph.isInstanceOf(resource, type); + } + + @Override + public boolean isInheritedFrom(Resource resource, Resource type) + throws ServiceException { + return graph.isInheritedFrom(resource, type); + } + + @Override + public boolean isSubrelationOf(Resource resource, Resource relation) + throws ServiceException { + return graph.isSubrelationOf(resource, relation); + } + + @Override + public boolean hasStatement(Resource subject) throws ServiceException { + return graph.hasStatement(subject); + } + + @Override + public boolean hasStatement(Resource subject, Resource relation) + throws ServiceException { + return graph.hasStatement(subject, relation); + } + + @Override + public boolean hasStatement(Resource subject, Resource relation, + Resource object) throws ServiceException { + return graph.hasStatement(subject, relation, object); + } + + @Override + public boolean hasValue(Resource subject) throws ServiceException { + return graph.hasValue(subject); + } + + @Override + public Datatype getDataType(Resource subject) throws DatabaseException { + return graph.getDataType(subject); + } + + @Override + public T getAccessor(Resource subject) + throws DatabaseException { + return graph.getAccessor(subject); + } + + @Override + public RandomAccessBinary getRandomAccessBinary(Resource subject) + throws DatabaseException { + return graph.getRandomAccessBinary(subject); + } + + @Override + public T syncRequest(Read request) throws DatabaseException { + return graph.syncRequest(request); + } + + @Override + public T syncRequest(Read request, AsyncListener procedure) + throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public T syncRequest(Read request, SyncListener procedure) + throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public T syncRequest(Read request, Listener procedure) + throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public T syncRequest(Read request, AsyncProcedure procedure) + throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public T syncRequest(Read request, SyncProcedure procedure) + throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public T syncRequest(Read request, Procedure procedure) + throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public T syncRequest(AsyncRead request) throws DatabaseException { + return graph.syncRequest(request); + } + + @Override + public T syncRequest(AsyncRead request, + AsyncListener procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public T syncRequest(AsyncRead request, SyncListener procedure) + throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public T syncRequest(AsyncRead request, Listener procedure) + throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public T syncRequest(AsyncRead request, + AsyncProcedure procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public T syncRequest(AsyncRead request, + SyncProcedure procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public T syncRequest(AsyncRead request, Procedure procedure) + throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(MultiRead request) + throws DatabaseException { + return graph.syncRequest(request); + } + + @Override + public Collection syncRequest(MultiRead request, + AsyncMultiListener procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(MultiRead request, + SyncMultiListener procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(MultiRead request, + MultiListener procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(MultiRead request, + AsyncMultiProcedure procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(MultiRead request, + SyncMultiProcedure procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(MultiRead request, + MultiProcedure procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(AsyncMultiRead request) + throws DatabaseException { + return graph.syncRequest(request); + } + + @Override + public Collection syncRequest(AsyncMultiRead request, + AsyncMultiListener procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(AsyncMultiRead request, + SyncMultiListener procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(AsyncMultiRead request, + MultiListener procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(AsyncMultiRead request, + AsyncMultiProcedure procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(AsyncMultiRead request, + SyncMultiProcedure procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public Collection syncRequest(AsyncMultiRead request, + MultiProcedure procedure) throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public T syncRequest(ExternalRead request) + throws DatabaseException { + return graph.syncRequest(request); + } + + @Override + public T syncRequest(ExternalRead request, Listener procedure) + throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public T syncRequest(ExternalRead request, Procedure procedure) + throws DatabaseException { + return graph.syncRequest(request, procedure); + } + + @Override + public void syncRequest(Write request) throws DatabaseException { + graph.syncRequest(request); + } + + @Override + public void syncRequest(DelayedWrite request) throws DatabaseException { + graph.syncRequest(request); + } + + @Override + public void syncRequest(WriteOnly r) throws DatabaseException { + graph.syncRequest(r); + } + + @Override + public T syncRequest(WriteResult request) + throws DatabaseException { + return graph.syncRequest(request); + } + + @Override + public T syncRequest(DelayedWriteResult request) + throws DatabaseException { + return graph.syncRequest(request); + } + + @Override + public T syncRequest(WriteOnlyResult r) throws DatabaseException { + return graph.syncRequest(r); + } + + @Override + public void forURI(Resource resource, AsyncListener procedure) { + graph.forURI(resource, procedure); + } + + @Override + public void forURI(Resource resource, SyncListener procedure) { + graph.forURI(resource, procedure); + } + + @Override + public void forURI(Resource resource, Listener procedure) { + graph.forURI(resource, procedure); + } + + @Override + public void forURI(Resource resource, AsyncProcedure procedure) { + graph.forURI(resource, procedure); + } + + @Override + public void forURI(Resource resource, SyncProcedure procedure) { + graph.forURI(resource, procedure); + } + + @Override + public void forURI(Resource resource, Procedure procedure) { + graph.forURI(resource, procedure); + } + + @Override + public void forResource(String id, AsyncListener procedure) { + graph.forResource(id, procedure); + } + + @Override + public void forResource(String id, SyncListener procedure) { + graph.forResource(id, procedure); + } + + @Override + public void forResource(String id, Listener procedure) { + graph.forResource(id, procedure); + } + + @Override + public void forResource(String id, AsyncProcedure procedure) { + graph.forResource(id, procedure); + } + + @Override + public void forResource(String id, SyncProcedure procedure) { + graph.forResource(id, procedure); + } + + @Override + public void forResource(String id, Procedure procedure) { + graph.forResource(id, procedure); + } + + @Override + public void forStatementSet(Resource subject, Resource relation, + AsyncSetListener procedure) { + graph.forStatementSet(subject, relation, procedure); + } + + @Override + public void forStatementSet(Resource subject, Resource relation, + SyncSetListener procedure) { + graph.forStatementSet(subject, relation, procedure); + } + + @Override + public void forStatementSet(Resource subject, Resource relation, + SetListener procedure) { + graph.forStatementSet(subject, relation, procedure); + } + + @Override + public void forPredicateSet(Resource subject, + AsyncSetListener procedure) { + graph.forPredicateSet(subject, procedure); + } + + @Override + public void forPredicateSet(Resource subject, + SyncSetListener procedure) { + graph.forPredicateSet(subject, procedure); + } + + @Override + public void forPredicateSet(Resource subject, + SetListener procedure) { + graph.forPredicateSet(subject, procedure); + } + + @Override + public void forPrincipalTypeSet(Resource subject, + AsyncSetListener procedure) { + graph.forPrincipalTypeSet(subject, procedure); + } + + @Override + public void forPrincipalTypeSet(Resource subject, + SyncSetListener procedure) { + graph.forPrincipalTypeSet(subject, procedure); + } + + @Override + public void forPrincipalTypeSet(Resource subject, + SetListener procedure) { + graph.forPrincipalTypeSet(subject, procedure); + } + + @Override + public void forTypes(Resource subject, + AsyncListener> procedure) { + graph.forTypes(subject, procedure); + } + + @Override + public void forTypes(Resource subject, + SyncListener> procedure) { + graph.forTypes(subject, procedure); + } + + @Override + public void forTypes(Resource subject, Listener> procedure) { + graph.forTypes(subject, procedure); + } + + @Override + public void forTypes(Resource subject, + AsyncProcedure> procedure) { + graph.forTypes(subject, procedure); + } + + @Override + public void forTypes(Resource subject, + SyncProcedure> procedure) { + graph.forTypes(subject, procedure); + } + + @Override + public void forTypes(Resource subject, + Procedure> procedure) { + graph.forTypes(subject, procedure); + } + + @Override + public void forSupertypes(Resource subject, + AsyncListener> procedure) { + graph.forSupertypes(subject, procedure); + } + + @Override + public void forSupertypes(Resource subject, + SyncListener> procedure) { + graph.forSupertypes(subject, procedure); + } + + @Override + public void forSupertypes(Resource subject, + Listener> procedure) { + graph.forSupertypes(subject, procedure); + } + + @Override + public void forSupertypes(Resource subject, + AsyncProcedure> procedure) { + graph.forSupertypes(subject, procedure); + } + + @Override + public void forSupertypes(Resource subject, + SyncProcedure> procedure) { + graph.forSupertypes(subject, procedure); + } + + @Override + public void forSupertypes(Resource subject, + Procedure> procedure) { + graph.forSupertypes(subject, procedure); + } + + @Override + public void forPossibleSuperrelation(Resource subject, + AsyncProcedure procedure) { + graph.forPossibleSuperrelation(subject, procedure); + } + + @Override + public void forSuperrelations(Resource subject, + AsyncListener> procedure) { + graph.forSuperrelations(subject, procedure); + } + + @Override + public void forSuperrelations(Resource subject, + SyncListener> procedure) { + graph.forSuperrelations(subject, procedure); + } + + @Override + public void forSuperrelations(Resource subject, + Listener> procedure) { + graph.forSuperrelations(subject, procedure); + } + + @Override + public void forSuperrelations(Resource subject, + AsyncProcedure> procedure) { + graph.forSuperrelations(subject, procedure); + } + + @Override + public void forSuperrelations(Resource subject, + SyncProcedure> procedure) { + graph.forSuperrelations(subject, procedure); + } + + @Override + public void forSuperrelations(Resource subject, + Procedure> procedure) { + graph.forSuperrelations(subject, procedure); + } + + @Override + public void forObjectSet(Resource subject, Resource relation, + AsyncSetListener procedure) { + graph.forObjectSet(subject, relation, procedure); + } + + @Override + public void forObjectSet(Resource subject, Resource relation, + SyncSetListener procedure) { + graph.forObjectSet(subject, relation, procedure); + } + + @Override + public void forObjectSet(Resource subject, Resource relation, + SetListener procedure) { + graph.forObjectSet(subject, relation, procedure); + } + + @Override + public void forInverse(Resource relation, + SyncListener procedure) { + graph.forInverse(relation, procedure); + } + + @Override + public void forInverse(Resource relation, Listener procedure) { + graph.forInverse(relation, procedure); + } + + @Override + public void forInverse(Resource relation, + AsyncProcedure procedure) { + graph.forInverse(relation, procedure); + } + + @Override + public void forInverse(Resource relation, + SyncProcedure procedure) { + graph.forInverse(relation, procedure); + } + + @Override + public void forInverse(Resource relation, Procedure procedure) { + graph.forInverse(relation, procedure); + } + + @Override + public void forSingleObject(Resource subject, Resource relation, + AsyncListener procedure) { + graph.forSingleObject(subject, relation, procedure); + } + + @Override + public void forSingleObject(Resource subject, Resource relation, + SyncListener procedure) { + graph.forSingleObject(subject, relation, procedure); + } + + @Override + public void forSingleObject(Resource subject, Resource relation, + Listener procedure) { + graph.forSingleObject(subject, relation, procedure); + } + + @Override + public void forSingleObject(Resource subject, Resource relation, + AsyncProcedure procedure) { + graph.forSingleObject(subject, relation, procedure); + } + + @Override + public void forSingleObject(Resource subject, Resource relation, + SyncProcedure procedure) { + graph.forSingleObject(subject, relation, procedure); + } + + @Override + public void forSingleObject(Resource subject, Resource relation, + Procedure procedure) { + graph.forSingleObject(subject, relation, procedure); + } + + @Override + public void forSingleStatement(Resource subject, Resource relation, + AsyncListener procedure) { + graph.forSingleStatement(subject, relation, procedure); + } + + @Override + public void forSingleStatement(Resource subject, Resource relation, + SyncListener procedure) { + graph.forSingleStatement(subject, relation, procedure); + } + + @Override + public void forSingleStatement(Resource subject, Resource relation, + Listener procedure) { + graph.forSingleStatement(subject, relation, procedure); + } + + @Override + public void forSingleStatement(Resource subject, Resource relation, + AsyncProcedure procedure) { + graph.forSingleStatement(subject, relation, procedure); + } + + @Override + public void forSingleStatement(Resource subject, Resource relation, + SyncProcedure procedure) { + graph.forSingleStatement(subject, relation, procedure); + } + + @Override + public void forSingleStatement(Resource subject, Resource relation, + Procedure procedure) { + graph.forSingleStatement(subject, relation, procedure); + } + + @Override + public void forSingleType(Resource subject, + AsyncListener procedure) { + graph.forSingleType(subject, procedure); + } + + @Override + public void forSingleType(Resource subject, + SyncListener procedure) { + graph.forSingleType(subject, procedure); + } + + @Override + public void forSingleType(Resource subject, Listener procedure) { + graph.forSingleType(subject, procedure); + } + + @Override + public void forSingleType(Resource subject, + AsyncProcedure procedure) { + graph.forSingleType(subject, procedure); + } + + @Override + public void forSingleType(Resource subject, + SyncProcedure procedure) { + graph.forSingleType(subject, procedure); + } + + @Override + public void forSingleType(Resource subject, + Procedure procedure) { + graph.forSingleType(subject, procedure); + } + + @Override + public void forSingleType(Resource subject, Resource baseType, + AsyncListener procedure) { + graph.forSingleType(subject, baseType, procedure); + } + + @Override + public void forSingleType(Resource subject, Resource baseType, + SyncListener procedure) { + graph.forSingleType(subject, baseType, procedure); + } + + @Override + public void forSingleType(Resource subject, Resource baseType, + Listener procedure) { + graph.forSingleType(subject, baseType, procedure); + } + + @Override + public void forSingleType(Resource subject, Resource baseType, + AsyncProcedure procedure) { + graph.forSingleType(subject, baseType, procedure); + } + + @Override + public void forSingleType(Resource subject, Resource baseType, + SyncProcedure procedure) { + graph.forSingleType(subject, baseType, procedure); + } + + @Override + public void forSingleType(Resource subject, Resource baseType, + Procedure procedure) { + graph.forSingleType(subject, baseType, procedure); + } + + @Override + public void forValue(Resource subject, AsyncListener procedure) { + graph.forValue(subject, procedure); + } + + @Override + public void forValue(Resource subject, SyncListener procedure) { + graph.forValue(subject, procedure); + } + + @Override + public void forValue(Resource subject, Listener procedure) { + graph.forValue(subject, procedure); + } + + @Override + public void forValue(Resource subject, AsyncProcedure procedure) { + graph.forValue(subject, procedure); + } + + @Override + public void forValue(Resource subject, SyncProcedure procedure) { + graph.forValue(subject, procedure); + } + + @Override + public void forValue(Resource subject, Procedure procedure) { + graph.forValue(subject, procedure); + } + + @Override + public void forValue(Resource subject, Binding binding, + AsyncListener procedure) { + graph.forValue(subject, binding, procedure); + } + + @Override + public void forValue(Resource subject, Binding binding, + SyncListener procedure) { + graph.forValue(subject, binding, procedure); + } + + @Override + public void forValue(Resource subject, Binding binding, + Listener procedure) { + graph.forValue(subject, binding, procedure); + } + + @Override + public void forValue(Resource subject, Binding binding, + AsyncProcedure procedure) { + graph.forValue(subject, binding, procedure); + } + + @Override + public void forValue(Resource subject, Binding binding, + SyncProcedure procedure) { + graph.forValue(subject, binding, procedure); + } + + @Override + public void forValue(Resource subject, Binding binding, + Procedure procedure) { + graph.forValue(subject, binding, procedure); + } + + @Override + public void forRelatedValue(Resource subject, Resource relation, + AsyncListener procedure) { + graph.forRelatedValue(subject, relation, procedure); + } + + @Override + public void forRelatedValue(Resource subject, Resource relation, + SyncListener procedure) { + graph.forRelatedValue(subject, relation, procedure); + } + + @Override + public void forRelatedValue(Resource subject, Resource relation, + Listener procedure) { + graph.forRelatedValue(subject, relation, procedure); + } + + @Override + public void forRelatedValue(Resource subject, Resource relation, + AsyncProcedure procedure) { + graph.forRelatedValue(subject, relation, procedure); + } + + @Override + public void forRelatedValue(Resource subject, Resource relation, + SyncProcedure procedure) { + graph.forRelatedValue(subject, relation, procedure); + } + + @Override + public void forRelatedValue(Resource subject, Resource relation, + Procedure procedure) { + graph.forRelatedValue(subject, relation, procedure); + } + + @Override + public void forRelatedValue(Resource subject, Resource relation, + Binding binding, AsyncListener procedure) { + graph.forRelatedValue(subject, relation, binding, procedure); + } + + @Override + public void forRelatedValue(Resource subject, Resource relation, + Binding binding, SyncListener procedure) { + graph.forRelatedValue(subject, relation, binding, procedure); + } + + @Override + public void forRelatedValue(Resource subject, Resource relation, + Binding binding, Listener procedure) { + graph.forRelatedValue(subject, relation, binding, procedure); + } + + @Override + public void forRelatedValue(Resource subject, Resource relation, + Binding binding, AsyncProcedure procedure) { + graph.forRelatedValue(subject, relation, binding, procedure); + } + + @Override + public void forRelatedValue(Resource subject, Resource relation, + Binding binding, SyncProcedure procedure) { + graph.forRelatedValue(subject, relation, binding, procedure); + } + + @Override + public void forRelatedValue(Resource subject, Resource relation, + Binding binding, Procedure procedure) { + graph.forRelatedValue(subject, relation, binding, procedure); + } + + @Override + public void forUniqueAdapted(Resource resource, Class clazz, + AsyncListener procedure) { + graph.forUniqueAdapted(resource, clazz, procedure); + } + + @Override + public void forUniqueAdapted(Resource resource, Class clazz, + SyncListener procedure) { + graph.forUniqueAdapted(resource, clazz, procedure); + } + + @Override + public void forUniqueAdapted(Resource resource, Class clazz, + Listener procedure) { + graph.forUniqueAdapted(resource, clazz, procedure); + } + + @Override + public void forUniqueAdapted(Resource resource, Class clazz, + AsyncProcedure procedure) { + graph.forUniqueAdapted(resource, clazz, procedure); + } + + @Override + public void forUniqueAdapted(Resource resource, Class clazz, + SyncProcedure procedure) { + graph.forUniqueAdapted(resource, clazz, procedure); + } + + @Override + public void forUniqueAdapted(Resource resource, Class clazz, + Procedure procedure) { + graph.forUniqueAdapted(resource, clazz, procedure); + } + + @Override + public void forPossibleInverse(Resource relation, + AsyncListener procedure) { + graph.forPossibleInverse(relation, procedure); + } + + @Override + public void forPossibleInverse(Resource relation, + SyncListener procedure) { + graph.forPossibleInverse(relation, procedure); + } + + @Override + public void forPossibleInverse(Resource relation, + Listener procedure) { + graph.forPossibleInverse(relation, procedure); + } + + @Override + public void forPossibleInverse(Resource relation, + AsyncProcedure procedure) { + graph.forPossibleInverse(relation, procedure); + } + + @Override + public void forPossibleInverse(Resource relation, + SyncProcedure procedure) { + graph.forPossibleInverse(relation, procedure); + } + + @Override + public void forPossibleInverse(Resource relation, + Procedure procedure) { + graph.forPossibleInverse(relation, procedure); + } + + @Override + public void forPossibleObject(Resource subject, Resource relation, + AsyncListener procedure) { + graph.forPossibleObject(subject, relation, procedure); + } + + @Override + public void forPossibleObject(Resource subject, Resource relation, + SyncListener procedure) { + graph.forPossibleObject(subject, relation, procedure); + } + + @Override + public void forPossibleObject(Resource subject, Resource relation, + Listener procedure) { + graph.forPossibleObject(subject, relation, procedure); + } + + @Override + public void forPossibleObject(Resource subject, Resource relation, + AsyncProcedure procedure) { + graph.forPossibleObject(subject, relation, procedure); + } + + @Override + public void forPossibleObject(Resource subject, Resource relation, + SyncProcedure procedure) { + graph.forPossibleObject(subject, relation, procedure); + } + + @Override + public void forPossibleObject(Resource subject, Resource relation, + Procedure procedure) { + graph.forPossibleObject(subject, relation, procedure); + } + + @Override + public void forPossibleStatement(Resource subject, Resource relation, + AsyncListener procedure) { + graph.forPossibleStatement(subject, relation, procedure); + } + + @Override + public void forPossibleStatement(Resource subject, Resource relation, + SyncListener procedure) { + graph.forPossibleStatement(subject, relation, procedure); + } + + @Override + public void forPossibleStatement(Resource subject, Resource relation, + Listener procedure) { + graph.forPossibleStatement(subject, relation, procedure); + } + + @Override + public void forPossibleStatement(Resource subject, Resource relation, + AsyncProcedure procedure) { + graph.forPossibleStatement(subject, relation, procedure); + } + + @Override + public void forPossibleStatement(Resource subject, Resource relation, + SyncProcedure procedure) { + graph.forPossibleStatement(subject, relation, procedure); + } + + @Override + public void forPossibleStatement(Resource subject, Resource relation, + Procedure procedure) { + graph.forPossibleStatement(subject, relation, procedure); + } + + @Override + public void forPossibleType(Resource subject, Resource baseType, + AsyncListener procedure) { + graph.forPossibleType(subject, baseType, procedure); + } + + @Override + public void forPossibleType(Resource subject, Resource baseType, + SyncListener procedure) { + graph.forPossibleType(subject, baseType, procedure); + } + + @Override + public void forPossibleType(Resource subject, Resource baseType, + Listener procedure) { + graph.forPossibleType(subject, baseType, procedure); + } + + @Override + public void forPossibleType(Resource subject, Resource baseType, + AsyncProcedure procedure) { + graph.forPossibleType(subject, baseType, procedure); + } + + @Override + public void forPossibleType(Resource subject, Resource baseType, + SyncProcedure procedure) { + graph.forPossibleType(subject, baseType, procedure); + } + + @Override + public void forPossibleType(Resource subject, Resource baseType, + Procedure procedure) { + graph.forPossibleType(subject, baseType, procedure); + } + + @Override + public void forPossibleValue(Resource subject, + AsyncListener procedure) { + graph.forPossibleValue(subject, procedure); + } + + @Override + public void forPossibleValue(Resource subject, + SyncListener procedure) { + graph.forPossibleValue(subject, procedure); + } + + @Override + public void forPossibleValue(Resource subject, Listener procedure) { + graph.forPossibleValue(subject, procedure); + } + + @Override + public void forPossibleValue(Resource subject, + AsyncProcedure procedure) { + graph.forPossibleValue(subject, procedure); + } + + @Override + public void forPossibleValue(Resource subject, + SyncProcedure procedure) { + graph.forPossibleValue(subject, procedure); + } + + @Override + public void forPossibleValue(Resource subject, + Procedure procedure) { + graph.forPossibleValue(subject, procedure); + } + + @Override + public void forPossibleValue(Resource subject, Binding binding, + AsyncListener procedure) { + graph.forPossibleValue(subject, procedure); + } + + @Override + public void forPossibleValue(Resource subject, Binding binding, + SyncListener procedure) { + graph.forPossibleValue(subject, procedure); + } + + @Override + public void forPossibleValue(Resource subject, Binding binding, + Listener procedure) { + graph.forPossibleValue(subject, procedure); + } + + @Override + public void forPossibleValue(Resource subject, Binding binding, + AsyncProcedure procedure) { + graph.forPossibleValue(subject, procedure); + } + + @Override + public void forPossibleValue(Resource subject, Binding binding, + SyncProcedure procedure) { + graph.forPossibleValue(subject, procedure); + } + + @Override + public void forPossibleValue(Resource subject, Binding binding, + Procedure procedure) { + graph.forPossibleValue(subject, procedure); + } + + @Override + public void forPossibleRelatedValue(Resource subject, + Resource relation, AsyncListener procedure) { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + + @Override + public void forPossibleRelatedValue(Resource subject, + Resource relation, SyncListener procedure) { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + + @Override + public void forPossibleRelatedValue(Resource subject, + Resource relation, Listener procedure) { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + + @Override + public void forPossibleRelatedValue(Resource subject, + Resource relation, AsyncProcedure procedure) { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + + @Override + public void forPossibleRelatedValue(Resource subject, + Resource relation, SyncProcedure procedure) { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + + @Override + public void forPossibleRelatedValue(Resource subject, + Resource relation, Procedure procedure) { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + + @Override + public void forPossibleRelatedValue(Resource subject, + Resource relation, Binding binding, AsyncListener procedure) { + graph.forPossibleRelatedValue(subject, relation, binding, procedure); + } + + @Override + public void forPossibleRelatedValue(Resource subject, + Resource relation, Binding binding, SyncListener procedure) { + graph.forPossibleRelatedValue(subject, relation, procedure); + } + + @Override + public void forPossibleRelatedValue(Resource subject, + Resource relation, Binding binding, Listener procedure) { + graph.forPossibleRelatedValue(subject, relation, binding, procedure); + } + + @Override + public void forPossibleRelatedValue(Resource subject, + Resource relation, Binding binding, AsyncProcedure procedure) { + graph.forPossibleRelatedValue(subject, relation, binding, procedure); + } + + @Override + public void forPossibleRelatedValue(Resource subject, + Resource relation, Binding binding, SyncProcedure procedure) { + graph.forPossibleRelatedValue(subject, relation, binding, procedure); + } + + @Override + public void forPossibleRelatedValue(Resource subject, + Resource relation, Binding binding, Procedure procedure) { + graph.forPossibleRelatedValue(subject, relation, binding, procedure); + } + + @Override + public void forPossibleAdapted(Resource resource, Class clazz, + AsyncListener procedure) { + graph.forPossibleAdapted(resource, clazz, procedure); + } + + @Override + public void forPossibleAdapted(Resource resource, Class clazz, + SyncListener procedure) { + graph.forPossibleAdapted(resource, clazz, procedure); + } + + @Override + public void forPossibleAdapted(Resource resource, Class clazz, + Listener procedure) { + graph.forPossibleAdapted(resource, clazz, procedure); + } + + @Override + public void forPossibleAdapted(Resource resource, Class clazz, + AsyncProcedure procedure) { + graph.forPossibleAdapted(resource, clazz, procedure); + } + + @Override + public void forPossibleAdapted(Resource resource, Class clazz, + SyncProcedure procedure) { + graph.forPossibleAdapted(resource, clazz, procedure); + } + + @Override + public void forPossibleAdapted(Resource resource, Class clazz, + Procedure procedure) { + graph.forPossibleAdapted(resource, clazz, procedure); + } + + @Override + public void forPossibleUniqueAdapted(Resource resource, + Class clazz, AsyncListener procedure) { + graph.forPossibleUniqueAdapted(resource, clazz, procedure); + } + + @Override + public void forPossibleUniqueAdapted(Resource resource, + Class clazz, SyncListener procedure) { + graph.forPossibleUniqueAdapted(resource, clazz, procedure); + } + + @Override + public void forPossibleUniqueAdapted(Resource resource, + Class clazz, Listener procedure) { + graph.forPossibleUniqueAdapted(resource, clazz, procedure); + } + + @Override + public void forPossibleUniqueAdapted(Resource resource, + Class clazz, AsyncProcedure procedure) { + graph.forPossibleUniqueAdapted(resource, clazz, procedure); + } + + @Override + public void forPossibleUniqueAdapted(Resource resource, + Class clazz, SyncProcedure procedure) { + graph.forPossibleUniqueAdapted(resource, clazz, procedure); + } + + @Override + public void forPossibleUniqueAdapted(Resource resource, + Class clazz, Procedure procedure) { + graph.forPossibleUniqueAdapted(resource, clazz, procedure); + } + + @Override + public void forIsInstanceOf(Resource resource, Resource type, + AsyncListener procedure) { + graph.forIsInstanceOf(resource, type, procedure); + } + + @Override + public void forIsInstanceOf(Resource resource, Resource type, + SyncListener procedure) { + graph.forIsInstanceOf(resource, type, procedure); + } + + @Override + public void forIsInstanceOf(Resource resource, Resource type, + Listener procedure) { + graph.forIsInstanceOf(resource, type, procedure); + } + + @Override + public void forIsInstanceOf(Resource resource, Resource type, + AsyncProcedure procedure) { + graph.forIsInstanceOf(resource, type, procedure); + } + + @Override + public void forIsInstanceOf(Resource resource, Resource type, + SyncProcedure procedure) { + graph.forIsInstanceOf(resource, type, procedure); + } + + @Override + public void forIsInstanceOf(Resource resource, Resource type, + Procedure procedure) { + graph.forIsInstanceOf(resource, type, procedure); + } + + @Override + public void forIsInheritedFrom(Resource resource, Resource type, + AsyncListener procedure) { + graph.forIsInheritedFrom(resource, type, procedure); + } + + @Override + public void forIsInheritedFrom(Resource resource, Resource type, + SyncListener procedure) { + graph.forIsInheritedFrom(resource, type, procedure); + } + + @Override + public void forIsInheritedFrom(Resource resource, Resource type, + Listener procedure) { + graph.forIsInheritedFrom(resource, type, procedure); + } + + @Override + public void forIsInheritedFrom(Resource resource, Resource type, + AsyncProcedure procedure) { + graph.forIsInheritedFrom(resource, type, procedure); + } + + @Override + public void forIsInheritedFrom(Resource resource, Resource type, + SyncProcedure procedure) { + graph.forIsInheritedFrom(resource, type, procedure); + } + + @Override + public void forIsInheritedFrom(Resource resource, Resource type, + Procedure procedure) { + graph.forIsInheritedFrom(resource, type, procedure); + } + + @Override + public void forIsSubrelationOf(Resource resource, Resource relation, + AsyncListener procedure) { + graph.forIsSubrelationOf(resource, relation, procedure); + } + + @Override + public void forIsSubrelationOf(Resource resource, Resource relation, + SyncListener procedure) { + graph.forIsSubrelationOf(resource, relation, procedure); + } + + @Override + public void forIsSubrelationOf(Resource resource, Resource relation, + Listener procedure) { + graph.forIsSubrelationOf(resource, relation, procedure); + } + + @Override + public void forIsSubrelationOf(Resource resource, Resource relation, + AsyncProcedure procedure) { + graph.forIsSubrelationOf(resource, relation, procedure); + } + + @Override + public void forIsSubrelationOf(Resource resource, Resource relation, + SyncProcedure procedure) { + graph.forIsSubrelationOf(resource, relation, procedure); + } + + @Override + public void forIsSubrelationOf(Resource resource, Resource relation, + Procedure procedure) { + graph.forIsSubrelationOf(resource, relation, procedure); + } + + @Override + public void forOrderedSet(Resource subject, + AsyncMultiListener procedure) { + graph.forOrderedSet(subject, procedure); + } + + @Override + public void forOrderedSet(Resource subject, + SyncMultiListener procedure) { + graph.forOrderedSet(subject, procedure); + } + + @Override + public void forOrderedSet(Resource subject, + MultiListener procedure) { + graph.forOrderedSet(subject, procedure); + } + + @Override + public void forOrderedSet(Resource subject, + AsyncMultiProcedure procedure) { + graph.forOrderedSet(subject, procedure); + } + + @Override + public void forOrderedSet(Resource subject, + SyncMultiProcedure procedure) { + graph.forOrderedSet(subject, procedure); + } + + @Override + public void forOrderedSet(Resource subject, + MultiProcedure procedure) { + graph.forOrderedSet(subject, procedure); + } + + @Override + public int thread() { + return graph.thread(); + } + + @Override + public Session getSession() { + return graph.getSession(); + } + + @Override + public Resource getBuiltin(String id) throws ResourceNotFoundException, + ServiceException { + return graph.getBuiltin(id); + } + + @Override + public VirtualGraph getProvider() { + return graph.getProvider(); + } + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/DistanceComparator.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/DistanceComparator.java new file mode 100644 index 0000000..7ea8dc8 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/DistanceComparator.java @@ -0,0 +1,28 @@ +package org.simantics.interop.mapping.data; + +import java.util.Comparator; + +public class DistanceComparator implements Comparator> { + + private String rel; + private String inv; + + public DistanceComparator(String rel, String inv) { + this.rel = rel; + this.inv = inv; + } + + @Override + public int compare(GraphNode arg0, GraphNode arg1) { + int dist = arg0.distanceTo(arg1, rel, inv); + if (dist < 0) { + dist = arg0.distanceTo(arg1, inv, rel); + if (dist < 0) + return 0; + return -dist; + } else { + return dist; + } + + } +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/GraphNode.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/GraphNode.java new file mode 100644 index 0000000..c775e8b --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/GraphNode.java @@ -0,0 +1,820 @@ +package org.simantics.interop.mapping.data; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.simantics.interop.mapping.Logger; +import org.simantics.utils.datastructures.hints.HintContext; + + +/** + * + * + * @author Marko Luukkainen + * + * @param + */ +public class GraphNode extends HintContext { + protected T data; + private List> nodes = new ArrayList>(); + + private boolean disposed = false; + + public GraphNode(T data) { + this.data = data; + } + + /** + * Returns data. + * @return + */ + public T getData() { + return data; + } + + + @Override + public void setHint(Key key, Object value) { + _checkDisposed(); + if (value == null) + return; + super.setHint(key, value); + } + + + + + /** + * Adds link to the other node. + * @param relationName name of the link from this node to the other node. + * @param inverseRelationName nam,e of the link from the other node to this node. + * @param node the other node. + * @return the created link. Returns null if the link cannot be created. + */ + public Link addLink(String relationName, String inverseRelationName,GraphNode node) { + _checkDisposed(); + Logger.defaultLogInfo("Node link " + data + " " + node.data + " " + relationName + " " + inverseRelationName +"\n"); + if(containsLink(relationName, node) && node.containsLink(inverseRelationName, this)) { + Logger.defaultLogWarning("Node " + getData() + " has already given child " + node.getData() + " ,with name " + relationName + " / " + inverseRelationName); + return null; + } + Link rel = _addLink(relationName,node); + Link inv = node._addLink(inverseRelationName,this); + rel.setInverseLink(inv); + inv.setMainLink(rel); + return rel; + } + + /** + * Adds link to the other node, with
null
link name from the other node to this node. + * @param relationName + * @param node name of the link from this node to the other node + * @return the created link. Returns null if the link cannot be created. + */ + public Link addLink(String relationName,GraphNode node) { + _checkDisposed(); + if(containsLink(relationName, node)) { + Logger.defaultLogWarning("Node " + getData() + " has already given child " + node.getData() + " ,with name " + relationName ); + return null; + } + Link rel = _addLink(relationName,node); + Link inv = node._addLink(null,this); + rel.setInverseLink(inv); + inv.setMainLink(rel); + return rel; + } + + /** + * Adds link to the other node, with copying link properties from given link. + * @param link + * @param node name of the link from this node to the other node + * @return the created link. Returns null if the link cannot be created. + */ + public Link addLink(Link link ,GraphNode node) { + _checkDisposed(); + if(containsLink(link.getName(), node) && node.containsLink(link.getInverseName(), this)) { + Logger.defaultLogWarning("Node " + getData() + " has already given child " + node.getData() + " ,with name " + link.getName() + " / " + link.getInverseName()); + return null; + } + Link rel = _addLink(link.getName(),node); + Link inv = node._addLink(link.getInverseName(),this); + rel.setInverseLink(inv); + inv.setMainLink(rel); + rel.setHints(link.getHints()); + inv.setHints(link.getInverse().getHints()); + return rel; + } + + protected Link _addLink(String relation, GraphNode node) { + Link link = new Link(this, relation,node); + nodes.add(link); + return link; + } + + protected Link _removeLink(String relation,String inverse, GraphNode node) { + for (int i = 0; i < nodes.size(); i++) { + Link link = nodes.get(i); + if (node.equals(link.to()) && equals(relation,link.getName()) && equals(inverse,link.getInverseName())) { + return nodes.remove(i); + } + } + return null; + } + + protected Link _removeLink(String relation) { + for (int i = 0; i < nodes.size(); i++) { + Link link = nodes.get(i); + if (equals(relation,link.getName())) { + return nodes.remove(i); + } + } + return null; + } + + protected Link _removeLink(String relation, String inverse) { + for (int i = 0; i < nodes.size(); i++) { + Link link = nodes.get(i); + if (equals(relation,link.getName()) && equals(inverse,link.getInverseName())) { + return nodes.remove(i); + } + } + return null; + } + + protected Link _removeLink(String relation, GraphNode node) { + for (int i = 0; i < nodes.size(); i++) { + Link link = nodes.get(i); + if (node.equals(link.to()) && equals(relation,link.getName())) { + return nodes.remove(i); + } + } + return null; + } + + protected Link _removeLink(GraphNode node) { + for (int i = 0; i < nodes.size(); i++ ) { + Link link = nodes.get(i); + if (node.equals(link.to())) { + return nodes.remove(i); + } + } + return null; + } + + protected boolean _removeLink(Link link) { + return nodes.remove(link); + } + + /** + * Removes the given link. + * @param link + * @return true if the link was removed. + */ + public boolean removeLink(Link link) { + _checkDisposed(); + if (_removeLink(link)) { + if (link.hasInverse()) { + link.to()._removeLink(link.getInverse()); + } + return true; + } + return false; + } + + /** + * Removes a link (or multiple links). + * @param relation the name of the link from this node. + * @return true if a link was removed. + */ + public boolean removeLink(String relation) { + _checkDisposed(); + boolean deleted = false; + while (true) { + Link removed = _removeLink(relation); + if (removed == null) + break; + if (removed.hasInverse()) { + removed.to()._removeLink(removed.getInverse()); + deleted = true; + } + } + return deleted; + } + + /** + * Removes a link (or multiple links). + * @param relation the name of the link from this node. + * @return true if the link was removed. + */ + public boolean removeLink(String relation, String inverse) { + _checkDisposed(); + boolean deleted = false; + while (true) { + Link removed = _removeLink(relation, inverse); + if (removed == null) + break; + if (removed.hasInverse()) { + removed.to()._removeLink(removed.getInverse()); + deleted = true; + } + } + return deleted; + } + + /** + * Removes a link. + * @param relation the name of the link from this node to the other node. + * @param node the other node. + * @return true if the link was removed. + */ + public boolean removeLink(String relation, GraphNode node) { + _checkDisposed(); + + boolean deleted = false; + while (true) { + Link removed = _removeLink(relation, node); + if (removed == null) + break; + if (removed.hasInverse()) { + removed.to()._removeLink(removed.getInverse()); + deleted = true; + } + } + return deleted; + } + + /** + * Removes all links from this node to the other node. + * @param node the other node. + * @return + */ + public boolean removeLink(GraphNode node) { + _checkDisposed(); + boolean deleted = false; + while (true) { + Link removed = _removeLink(node); + if (removed == null) + break; + if (removed.hasInverse()) { + removed.to()._removeLink(removed.getInverse()); + deleted = true; + } + } + return deleted; + } + + /** + * Removes a link. + * @param relation the name of the link from this node to the other node. + * @param inverse the name of the link from the other node to this node. + * @param node the other node. + * @return true if the link was removed. + */ + public boolean removeLink(String relation, String inverse, GraphNode node) { + _checkDisposed(); + Link removed = _removeLink(relation, inverse, node); + if (removed != null && removed.hasInverse()) { + removed.to()._removeLink(removed.getInverse()); + return true; + } + return false; + } + + public boolean containsLink(GraphNode node) { + _checkDisposed(); + for (Link link : nodes) { + if (node.equals(link.to())) + return true; + } + return false; + } + + public boolean containsLink(String relationName, GraphNode node) { + _checkDisposed(); + if (relationName == null) + return false; + for (Link link : nodes) { + if (node.equals(link.to()) && equals(relationName,link.getName())) + return true; + } + return false; + } + + public boolean containsLink(String relationName, String inverseName, GraphNode node) { + _checkDisposed(); + for (Link link : nodes) { + if (node.equals(link.to()) && equals(relationName,link.getName()) && equals(inverseName,link.getInverseName())) + return true; + } + return false; + } + + public Collection> getLinks() { + _checkDisposed(); + Collection> coll = new ArrayList>(nodes); + return coll; + } + + public Collection> getNodes(String rel) { + _checkDisposed(); + Collection> result = new ArrayList>(); + + for (Link link : nodes) { + if (equals(rel,link.getName())) + result.add(link.to()); + } + + return result; + } + + public Collection> getLinks(String rel) { + _checkDisposed(); + Collection> result = new ArrayList>(); + + for (Link link : nodes) { + if (equals(rel,link.getName())) + result.add(link); + } + + return result; + } + + public Collection> getLinks(String rel, GraphNode node) { + _checkDisposed(); + Collection> result = new ArrayList>(); + + for (Link link : nodes) { + if (equals(rel,link.getName()) && link.to().equals(node)) + result.add(link); + } + + return result; + } + + public Collection> getLinks(String rel, String inverse) { + _checkDisposed(); + Collection> result = new ArrayList>(); + + for (Link link : nodes) { + if (equals(rel,link.getName()) && equals(inverse, link.getInverseName())) + result.add(link); + } + + return result; + } + + public Collection> getLinks(String rel, String inverse, GraphNode node) { + _checkDisposed(); + Collection> result = new ArrayList>(); + + for (Link link : nodes) { + if (equals(rel,link.getName()) && equals(inverse, link.getInverseName()) && link.to().equals(node)) + result.add(link); + } + + return result; + } + + public Collection> getNodesWithInv(String inv) { + _checkDisposed(); + Collection> result = new ArrayList>(); + + for (Link link : nodes) { + if (equals(inv,link.getInverseName())) + result.add(link.to()); + } + + return result; + } + + public Collection> getNodes(String rel, String inv) { + _checkDisposed(); + Collection> result = new ArrayList>(); + + for (Link link : nodes) { + if (equals(rel,link.getName()) && equals(inv,link.getInverseName())) + result.add(link.to()); + } + + return result; + } + + public static boolean equals(String s1, String s2) { + if (s1 != null) + return s1.equals(s2); + if (s2 != null) + return s2.equals(s1); + return true; // both null + } + + + /** + * Returns links from this node to the given node. + * @param node + * @return + */ + public Collection> getLinks(GraphNode node) { + _checkDisposed(); + Collection> result = new ArrayList>(); + for (Link link : nodes) { + if (link.to().equals(node)) + result.add(link); + } + return result; + } + + /** + * Returns names of links from this node to the given node. Does not return null names. + * @param node + * @return + */ + public Collection getRelations(GraphNode node) { + _checkDisposed(); + Collection result = new ArrayList(); + for (Link link : nodes) { + if (link.to().equals(node) && link.getName() != null) + result.add(link.getName()); + } + return result; + } + + /** + * Returns links from given node to this node. + * @param node + * @return + */ + public Collection> getInverseLinks(GraphNode node) { + _checkDisposed(); + Collection> result = new ArrayList>(); + for (Link link : nodes) { + if (link.to().equals(node)) + result.add(link.getInverse()); + } + return result; + } + + /** + * Returns names of links from given node to this node. Does not return null names. + * @param node + * @return + */ + public Collection getInverses(GraphNode node) { + _checkDisposed(); + Collection result = new ArrayList(); + for (Link link : nodes) { + if (link.to().equals(node) && link.getInverseName() != null) + result.add(link.getInverseName()); + } + return result; + } + + + + @Override + public int hashCode() { + return data.hashCode(); + } + + @Override + public boolean equals(Object arg0) { + if (!arg0.getClass().equals(getClass())) + return false; + GraphNode other = (GraphNode)arg0; + if (this == other) + return true; + if (this.data == null || other.data == null) + return false; + if (!data.equals(other.data)) + return false; + + return true; + } + + /** + * Merges given nodes to new node. + * Does not copy hints! + * @param other + */ + public GraphNode merge(GraphNode other, T mergedData) { + _checkDisposed(); + GraphNode mergedNode = new GraphNode(mergedData); + copyLinks(this, mergedNode); + copyLinks(other, mergedNode); + + //mergedNode.setHints(other.getHints()); + //mergedNode.setHints(this.getHints()); + + this.destroy(); + other.destroy(); + + return mergedNode; + } + + + + + + /** + * Copies a link to other node. + * @param from the node containing original link + * @param to the node where link is copied to + * @param l the link that is copied. + * @return created link, if copy is successful. Otherwise returns null. + */ + public static Link copyLink(GraphNode from, GraphNode to, Link l) { + if (l.from() != from) + throw new IllegalArgumentException("Link is not starting from " + from + " node."); + if (l.to() == to) + return null; + if (to.containsLink(l.getName(), l.getInverseName(),l.to())) + return null; + if (l.isMain()) { + Link newLink = to.addLink(l.getName(),l.getInverseName(),l.to()); + if (newLink != null) { + newLink.setHints(l.getHints()); + newLink.getInverse().setHints(l.getInverse().getHints()); + return newLink; + } else { + return null; + } + } else { + Link newLink = l.to().addLink(l.getInverseName(), l.getName(),to); + if (newLink != null) { + newLink.setHints(l.getInverse().getHints()); + newLink.getInverse().setHints(l.getHints()); + return newLink.getInverse(); + } else { + return null; + } + } + + } + + /** + * Copies a link to other node, but inverts its direction. + * @param from the node containing original link + * @param to the node where link is copied to + * @param l the link that is copied. + * @return created link, if copy is successful. Otherwise returns null. + */ + public static Link copyLinkInverse(GraphNode from, GraphNode to, Link l) { + if (l.from() != from) + throw new IllegalArgumentException("Link is not starting from " + from + " node."); + if (l.to() == to) + return null; + if (to.containsLink(l.getInverseName(), l.getName(),l.to())) + return null; + if (l.isMain()) { + Link newLink = l.to().addLink(l.getName(),l.getInverseName(),to); + if (newLink != null) { + newLink.setHints(l.getHints()); + newLink.getInverse().setHints(l.getInverse().getHints()); + return newLink; + } else { + return null; + } + } else { + Link newLink = to.addLink(l.getInverseName(), l.getName(),l.to()); + if (newLink != null) { + newLink.setHints(l.getInverse().getHints()); + newLink.getInverse().setHints(l.getHints()); + return newLink.getInverse(); + } else { + return null; + } + } + + } + + public static void copyLinks(GraphNode from, GraphNode to, Collection> links) { + for (Link l : links) { + copyLink(from, to, l); + } + } + + + public static void copyLinks(GraphNode from, GraphNode to) { + for (Link l : from.getLinks()) { + copyLink(from, to, l); + } + } + + /** + * Copies a link to other node and removes the original link. If move is not successful, the original link is not removed. + * @param from the node containing original link + * @param to the node where link is copied to + * @param l the link that is moved. + * @return created link, if move is successful. Otherwise returns null. + */ + public static Link moveLink(GraphNode from, GraphNode to, Link l) { + Link newLink = copyLink(from, to, l); + if (newLink != null) { + from.removeLink(l); + return newLink; + } + return null; + } + + public static void moveLinks(GraphNode from, GraphNode to, Collection> links) { + for (Link l : links) { + Link newLink = copyLink(from, to, l); + if (newLink != null) { + from.removeLink(l); + } + } + } + + public static void moveLinkInverses(GraphNode from, GraphNode to, Collection> links) { + for (Link l : links) { + Link newLink = copyLinkInverse(from, to, l); + if (newLink != null) { + from.removeLink(l); + } + } + } + + public static void moveLinks(GraphNode from, GraphNode to) { + for (Link l : from.getLinks()) { + Link newLink = copyLink(from, to, l); + if (newLink != null) { + from.removeLink(l); + } + } + } + + /** + * Replaces a link with a link going first to given node, and the to the original destination. + * The link names and hints are copied to the created links. + * + * Example: link is 'a' -> 'b'. With insert attribute 'c', the result is 'a' -> 'c' -> 'b'. + * + * @param link + * @param insert + * @return Array containing created links (2). + */ + @SuppressWarnings("unchecked") + public static Link[] insert(Link link, GraphNode insert) { + GraphNode a = link.from(); + Link c_b = moveLink(a, insert, link); + Link a_c = a.addLink(c_b, insert); + return new Link[]{a_c,c_b}; + } + + + + /** + * Finds all nodes that have the same relations to the same nodes as this node. + * @return + */ + public Collection> getFullSimilars() { + _checkDisposed(); + Collection> result = new ArrayList>(); + Set> potential = new HashSet>(); + for (Link link : nodes) { + for (Link link2 : link.to().nodes) { + if (!link2.to().equals(this)) + potential.add(link2.to()); + } + } + for (GraphNode node : potential) { + if (node.nodes.containsAll(nodes)) + result.add(node); + } + + return result; + } + + /** + * Finds all nodes that have at least one similar relation to the same nodes as this node. + * @return + */ + public Collection> getSemiSimilars() { + _checkDisposed(); + Collection> result = new ArrayList>(); + Set> potential = new HashSet>(); + for (Link link : nodes) { + for (Link link2 : link.to().nodes) { + if (!link2.to().equals(this)) + potential.add(link2.to()); + } + } + for (GraphNode node : potential) { + for (Link link : nodes) { + if (node.nodes.contains(link)) + result.add(node); + } + } + + return result; + } + + + /** + * Disposes this node. Removes all the links that connect to thi snode. + */ + public void destroy() { + if (disposed) + return; + Logger.defaultLogInfo("Node destroy " + data + " " + this); + Collection> coll = new ArrayList>(); + coll.addAll(nodes); + nodes.clear(); + for (Link link : coll) { + link.to()._removeLink(this); + } + nodes = null; + disposed = true; + } + + /** + * Removes this node from the graph, and reconnects parents and children of this node. + */ + public void remove() { + if (disposed) + return; + // FIXME: link.to may be *this. + Logger.defaultLogInfo("Node remove " + data + " " + this); + if (nodes.size() == 1) { + Link link = nodes.get(0); + link.to().removeLink(link.getInverseName(), link.getName(), this); + } else { + for (int i = 0; i < nodes.size() -1 ; i++) { + Link link1 = nodes.get(i); + link1.to().removeLink(link1.getInverseName(), link1.getName(), this); + for (int j = i; j < nodes.size(); j++) { + Link link2 = nodes.get(j); + link2.to().removeLink(link2.getInverseName(), link2.getName(), this); + if (link1.to().equals(link2.to())) + continue; + link1.to().addLink(link1.getInverseName(),link2.getInverseName(),link2.to()); + } + + } + } + + nodes.clear(); + nodes = null; + disposed = true; + + } + + /** + * + * @return true if the node has been disposed and cannot be used anymore. + */ + public boolean isDisposed() { + return disposed; + } + + /** + * Disposed the node and all nodes that are in the same graph. + */ + public void dispose() { + if (disposed) + return; + Collection> links = new ArrayList>(); + links.addAll(nodes); + nodes.clear(); + for (Link l : links) + l.to().dispose(); + links.clear(); + nodes = null; + disposed = true; + } + + + protected void _checkDisposed() { + if (disposed) { + Logger.defaultLogError("Remove Node, disposed " + this); + throw new RuntimeException("Node " + this + " is disposed."); + } + } + + + public int distanceTo(GraphNode node, String rel, String inv) { + if (node.equals(this)) + return 0; + int count = 0; + Set> processed = new HashSet>(); + Set> next = new HashSet>(); + next.add(this); + while (true) { + if (next.size() == 0) + return -1; + count++; + processed.addAll(next); + Set> nextNext = new HashSet>(); + for (GraphNode n : next) { + for (GraphNode nn : n.getNodes(rel, inv)) + if (!processed.contains(nn)) + nextNext.add(nn); + } + next = nextNext; + if (next.contains(node)) + return count; + } + } +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/Identifiable.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/Identifiable.java new file mode 100644 index 0000000..ceb4bc7 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/Identifiable.java @@ -0,0 +1,27 @@ +package org.simantics.interop.mapping.data; + +/** + * + * + * @author Marko Luukkainen + * + */ +public interface Identifiable { + + /** + * Returns object of given class, or null. + * + * Used classes: + * Resource + * Resource[] + * String + * + * @param + * @param clazz + * @return + */ + public T getAdapter(Class clazz); + + public Identifiable merge(Identifiable other); + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/Link.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/Link.java new file mode 100644 index 0000000..f03f10f --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/Link.java @@ -0,0 +1,95 @@ +package org.simantics.interop.mapping.data; + + +import org.simantics.utils.datastructures.hints.HintContext; + +public class Link extends HintContext { + private GraphNode from; + private GraphNode to; + private String name; + + private Link inverseLink; + private Link mainLink; + + Link(GraphNode from, String name, GraphNode to) { + this.from = from; + this.to = to; + this.name = name; + } + + public GraphNode from() { + return from; + } + + public GraphNode to() { + return to; + } + + public String getName() { + return name; + } + + void setInverseLink(Link inverseLink) { + this.inverseLink = inverseLink; + } + + void setMainLink(Link mainLink) { + this.mainLink = mainLink; + } + + public String getInverseName() { + if (inverseLink != null) + return inverseLink.getName(); + if (mainLink != null) + return mainLink.getName(); + return null; + } + + public boolean hasInverse() { + return inverseLink != null || mainLink != null; + } + + public Link getInverse() { + if (inverseLink != null) + return inverseLink; + if (mainLink != null) + return mainLink; + return null; + } + + public boolean isInverse() { + return mainLink != null; + } + + public boolean isMain() { + return inverseLink != null; + } + + @Override + public boolean equals(Object obj) { + if (!obj.getClass().equals(getClass())) + return false; + Link other = (Link)obj; + if (!from.equals(other.from)) + return false; + if (!to.equals(other.to)) + return false; + if (!GraphNode.equals(name,other.name)) + return false; + return true; + + } + + @Override + public int hashCode() { + return from.hashCode() * to.hashCode() + name.hashCode(); + } + + @Override + public void setHint(Key key, Object value) { + if (value == null) + return; + super.setHint(key, value); + } + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ObjectIdentifiable.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ObjectIdentifiable.java new file mode 100644 index 0000000..5723423 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ObjectIdentifiable.java @@ -0,0 +1,57 @@ +package org.simantics.interop.mapping.data; + +import java.util.ArrayList; +import java.util.Collection; + + +public class ObjectIdentifiable implements Identifiable { + + private Object obj; + + public ObjectIdentifiable(Object obj) { + this.obj = obj; + } + + public Object getObject() { + return obj; + } + + @SuppressWarnings("unchecked") + @Override + public T getAdapter(Class clazz) { + if (clazz == String.class) + return (T)obj.toString(); + return null; + } + + @Override + public int hashCode() { + return obj.hashCode(); + } + + @Override + public boolean equals(Object arg0) { + if (arg0 == null) + return false; + if (this.getClass() != arg0.getClass()) + return false; + ObjectIdentifiable other = (ObjectIdentifiable)arg0; + return obj.equals(other.obj); + } + + @Override + public Identifiable merge(Identifiable other) { + if (other instanceof ObjectIdentifiable) { + ObjectSetIdentifiable i = new ObjectSetIdentifiable(this.obj,((ObjectIdentifiable)other).obj); + return i; + } else if (other instanceof ObjectSetIdentifiable) { + Collection coll = new ArrayList(); + coll.add(this.obj); + coll.addAll(((ObjectSetIdentifiable)other).getObjects()); + ObjectSetIdentifiable i = new ObjectSetIdentifiable(coll); + return i; + } + return null; + } + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ObjectSetIdentifiable.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ObjectSetIdentifiable.java new file mode 100644 index 0000000..2494470 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ObjectSetIdentifiable.java @@ -0,0 +1,79 @@ +package org.simantics.interop.mapping.data; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + + +public class ObjectSetIdentifiable implements Identifiable { + + private Set objs; + + public ObjectSetIdentifiable(Object obj) { + objs = new HashSet(); + objs.add(obj); + } + + public ObjectSetIdentifiable(Object... obj) { + this.objs = new HashSet(); + for (Object r : obj) + this.objs.add(r); + } + + public ObjectSetIdentifiable(Collection obj) { + this.objs = new HashSet(); + for (Object r : obj) + this.objs.add(r); + } + + public Set getObjects() { + return objs; + } + + @SuppressWarnings("unchecked") + @Override + public T getAdapter(Class clazz) { + if (clazz.equals(String.class)) { + String s = ""; + for (Object o : objs) + s += o.toString() + " "; + return (T)s; + } + return null; + } + + @Override + public int hashCode() { + return objs.hashCode(); + } + + @Override + public boolean equals(Object arg0) { + if (arg0 == null) + return false; + if (this.getClass() != arg0.getClass()) + return false; + ObjectSetIdentifiable other = (ObjectSetIdentifiable)arg0; + return objs.equals(other.objs); + } + + @Override + public Identifiable merge(Identifiable other) { + if (other instanceof ObjectIdentifiable) { + Collection coll = new ArrayList(); + coll.addAll(this.objs); + coll.add(((ObjectIdentifiable)other).getObject()); + ObjectSetIdentifiable i = new ObjectSetIdentifiable(coll); + return i; + } else if (other instanceof ObjectSetIdentifiable) { + Collection coll = new ArrayList(); + coll.addAll(this.objs); + coll.addAll(((ObjectSetIdentifiable)other).getObjects()); + ObjectSetIdentifiable i = new ObjectSetIdentifiable(coll); + return i; + } + return null; + } + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceIdentifiable.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceIdentifiable.java new file mode 100644 index 0000000..4791d5b --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceIdentifiable.java @@ -0,0 +1,68 @@ +package org.simantics.interop.mapping.data; + +import java.util.ArrayList; +import java.util.Collection; + +import org.simantics.db.Resource; + +public class ResourceIdentifiable implements Identifiable { + + protected Resource resource; + + public ResourceIdentifiable(Resource resource) { + this.resource = resource; + } + + public Resource getResource() { + return resource; + } + + @Override + public int hashCode() { + return resource.hashCode(); + } + + @SuppressWarnings("unchecked") + public T getAdapter(Class clazz) { + if (clazz.equals(Resource.class)) + return (T)resource; + if (clazz.equals(Resource[].class)) + return (T) new Resource[]{resource}; + if (clazz.equals(String.class)) { + // TODO : have to use org.simantics.db.common.utils.Transaction to get access to ReadGraph. + return (T)resource.toString();//NameUtils.getSafeName(g,resource); + } + return null; + } + + @Override + public boolean equals(Object arg0) { + if (arg0 == null) + return false; + if (this.getClass() != arg0.getClass()) + return false; + ResourceIdentifiable other = (ResourceIdentifiable)arg0; + return resource.equals(other.resource); + } + + @Override + public Identifiable merge(Identifiable other) { + if (other instanceof ResourceIdentifiable) { + ResourceSetIdentifiable i = new ResourceSetIdentifiable(this.resource,((ResourceIdentifiable)other).resource); + return i; + } else if (other instanceof ResourceSetIdentifiable) { + Collection coll = new ArrayList(); + coll.add(this.resource); + coll.addAll(((ResourceSetIdentifiable)other).getResources()); + ResourceSetIdentifiable i = new ResourceSetIdentifiable(resource,coll); + return i; + } + return null; + } + + @Override + public String toString() { + return resource.toString(); + } + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSetIdentifiable.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSetIdentifiable.java new file mode 100644 index 0000000..84a383b --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSetIdentifiable.java @@ -0,0 +1,110 @@ +package org.simantics.interop.mapping.data; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.simantics.db.Resource; + +public class ResourceSetIdentifiable implements Identifiable { + + private Resource primary; + private Set resources; + + public ResourceSetIdentifiable(Resource resource) { + this.resources = new HashSet(); + this.resources.add(resource); + this.primary = resource; + } + + public ResourceSetIdentifiable(Resource primary, Resource... resource) { + this.resources = new HashSet(); + for (Resource r : resource) + this.resources.add(r); + this.resources.add(primary); + this.primary = primary; + } + + public ResourceSetIdentifiable(Resource primary, Collection resource) { + this.resources = new HashSet(); + for (Resource r : resource) + this.resources.add(r); + this.resources.add(primary); + this.primary = primary; + } + + public ResourceSetIdentifiable(Collection resource) { + this.resources = new HashSet(); + for (Resource r : resource) + this.resources.add(r); + this.primary = resource.iterator().next(); + } + + public Resource getPrimary() { + return primary; + } + + public Set getResources() { + return resources; + } + + @Override + public int hashCode() { + return resources.hashCode(); + } + + @SuppressWarnings("unchecked") + public T getAdapter(Class clazz) { + if (clazz.equals(Resource.class)) + return (T)primary; + if (clazz.equals(Resource[].class)) + return (T)resources.toArray(new Resource[resources.size()]); + if (clazz.equals(String.class)) { + String s = ""; + for (Resource r : resources) + s += r.toString() + " "; + // TODO : have to use org.simantics.db.common.utils.Transaction to get access to ReadGraph. + return (T)s;//NameUtils.getSafeName(g,resource); + } + return null; + } + + @Override + public boolean equals(Object arg0) { + if (arg0 == null) + return false; + if (this.getClass() != arg0.getClass()) + return false; + ResourceSetIdentifiable other = (ResourceSetIdentifiable)arg0; + return resources.equals(other.resources); + } + + @Override + public Identifiable merge(Identifiable other) { + if (other instanceof ResourceIdentifiable) { + Collection coll = new ArrayList(); + coll.addAll(this.resources); + coll.add(((ResourceIdentifiable)other).getResource()); + ResourceSetIdentifiable i = new ResourceSetIdentifiable(primary,coll); + return i; + } else if (other instanceof ResourceSetIdentifiable) { + Collection coll = new ArrayList(); + coll.addAll(this.resources); + coll.addAll(((ResourceSetIdentifiable)other).getResources()); + ResourceSetIdentifiable i = new ResourceSetIdentifiable(primary,coll); + return i; + } + return null; + } + + @Override + public String toString() { + String s = "("; + for (Resource r : resources) { + s += r.toString() + " "; + } + s = s.substring(0,s.length()-1) + ")"; + return s; + } +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSetSplitIdentifiable.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSetSplitIdentifiable.java new file mode 100644 index 0000000..0a120a8 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSetSplitIdentifiable.java @@ -0,0 +1,86 @@ +package org.simantics.interop.mapping.data; + + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.simantics.db.Resource; + +public class ResourceSetSplitIdentifiable extends ResourceSetIdentifiable { + + private static int counter = 0; + + private int identifier; + private int index; + + + ResourceSetSplitIdentifiable(Resource resource, int index, int identifier) { + super(resource); + this.index = index; + this.identifier = identifier; + } + + public ResourceSetSplitIdentifiable(int index, int identifier, Resource primary, Resource... resource) { + super(primary,resource); + this.index = index; + this.identifier = identifier; + } + + public ResourceSetSplitIdentifiable(Resource primary, Collection resources,int index, int identifier) { + super(primary,resources); + this.index = index; + this.identifier = identifier; + } + + public static List createIdentifiables(ResourceSetIdentifiable identifiable, int count) { + List result = new ArrayList(count); + int identifier = counter++; + for (int i = 0; i < count; i++) { + result.add(new ResourceSetSplitIdentifiable(identifiable.getPrimary(),identifiable.getResources(), i, identifier)); + } + return result; + } + + public static List createIdentifiables(Identifiable identifiable, int count) { + Resource res = identifiable.getAdapter(Resource.class); + if (res == null) + return null; + + Resource resources[] = identifiable.getAdapter(Resource[].class); + if (resources.length > 1) { + List result = new ArrayList(count); + int identifier = counter++; + for (int i = 0; i < count; i++) { + result.add(new ResourceSetSplitIdentifiable(i, identifier, res, resources)); + } + return result; + } else { + return ResourceSplitIdentifiable.createIdentifiables(identifiable, count); + } + + + } + + @Override + public boolean equals(Object arg0) { + if (arg0 == null) + return false; + if (this.getClass() != arg0.getClass()) + return false; + ResourceSetSplitIdentifiable other = (ResourceSetSplitIdentifiable)arg0; + if (identifier != other.identifier) + return false; + if (index != other.index) + return false; + return super.equals(arg0); + } + + @Override + public Identifiable merge(Identifiable other) { + throw new RuntimeException("Cannot be merged"); + } + + + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSetSplitIdentifiable2.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSetSplitIdentifiable2.java new file mode 100644 index 0000000..fa5841d --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSetSplitIdentifiable2.java @@ -0,0 +1,91 @@ +package org.simantics.interop.mapping.data; + + +import java.util.ArrayList; +import java.util.Collection; + +import org.simantics.db.Resource; + +public class ResourceSetSplitIdentifiable2 extends ResourceSetIdentifiable { + + private String identifier; + + + public ResourceSetSplitIdentifiable2(Resource resource, String identifier) { + super(resource); + this.identifier =identifier; + } + + public ResourceSetSplitIdentifiable2(String identifier, Resource primary, Resource... resource) { + super(primary,resource); + this.identifier = identifier; + } + + public ResourceSetSplitIdentifiable2(Resource primary, Collection resources, String identifier) { + super(primary,resources); + this.identifier = identifier; + } + + public static Identifiable createIdentifiable(ResourceSetIdentifiable identifiable, String identifier) { + return new ResourceSetSplitIdentifiable2(identifiable.getPrimary(),identifiable.getResources(), identifier); + } + + public static Identifiable createIdentifiable(Identifiable identifiable, String identifier) { + Resource res = identifiable.getAdapter(Resource.class); + if (res == null) + return null; + + Resource resources[] = identifiable.getAdapter(Resource[].class); + if (resources.length > 1) { + return new ResourceSetSplitIdentifiable2(identifier, res, resources); + + } else { + return ResourceSplitIdentifiable2.createIdentifiable(identifiable, identifier); + } + + + } + + public String getIdentifier() { + return identifier; + } + + @Override + public boolean equals(Object arg0) { + if (arg0 == null) + return false; + if (this.getClass() != arg0.getClass()) + return false; + ResourceSetSplitIdentifiable2 other = (ResourceSetSplitIdentifiable2)arg0; + if (!identifier.equals(other.identifier)) + return false; + return super.equals(arg0); + } + + @Override + public Identifiable merge(Identifiable other) { + if (other instanceof ResourceSplitIdentifiable2) { + ResourceSplitIdentifiable2 o = (ResourceSplitIdentifiable2)other; + if (!o.getIdentifier().equals(identifier)) + throw new RuntimeException("Cannot be merged, Identifiers do not match " + identifier + " " + o.getIdentifier()); + Collection resources = new ArrayList(); + resources.addAll(getResources()); + resources.add(o.getResource()); + ResourceSetSplitIdentifiable2 id = new ResourceSetSplitIdentifiable2(getPrimary(), resources,identifier); + return id; + } + if (other instanceof ResourceSetSplitIdentifiable2) { + ResourceSetSplitIdentifiable2 o = (ResourceSetSplitIdentifiable2)other; + if (!o.getIdentifier().equals(identifier)) + throw new RuntimeException("Cannot be merged, Identifiers do not match " + identifier + " " + o.getIdentifier()); + Collection resources = new ArrayList(); + resources.addAll(getResources()); + resources.addAll(o.getResources()); + ResourceSetSplitIdentifiable2 id = new ResourceSetSplitIdentifiable2(getPrimary(), resources,identifier); + return id; + } + throw new RuntimeException("Cannot be merged"); + } + + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSplitIdentifiable.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSplitIdentifiable.java new file mode 100644 index 0000000..1b62899 --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSplitIdentifiable.java @@ -0,0 +1,74 @@ +package org.simantics.interop.mapping.data; + + +import java.util.ArrayList; +import java.util.List; + +import org.simantics.db.Resource; + +public class ResourceSplitIdentifiable extends ResourceIdentifiable { + + private static int counter = 0; + + //private Resource resource; + private int identifier; + private int index; + + + ResourceSplitIdentifiable(Resource resource, int index, int identifier) { + super(resource); + this.index = index; + this.identifier = identifier; + } + + public static List createIdentifiables(ResourceIdentifiable identifiable, int count) { + List result = new ArrayList(count); + int identifier = counter++; + for (int i = 0; i < count; i++) { + result.add(new ResourceSplitIdentifiable(identifiable.getResource(), i, identifier)); + } + return result; + } + + public static List createIdentifiables(Identifiable identifiable, int count) { + Resource res = identifiable.getAdapter(Resource.class); + if (res == null) + return null; + + Resource resources[] = identifiable.getAdapter(Resource[].class); + + if (resources.length > 1) { + return ResourceSetSplitIdentifiable.createIdentifiables(identifiable, count); + } else { + List result = new ArrayList(count); + int identifier = counter++; + for (int i = 0; i < count; i++) { + result.add(new ResourceSplitIdentifiable(res, i, identifier)); + } + return result; + } + + } + + @Override + public boolean equals(Object arg0) { + if (arg0 == null) + return false; + if (this.getClass() != arg0.getClass()) + return false; + ResourceSplitIdentifiable other = (ResourceSplitIdentifiable)arg0; + if (identifier != other.identifier) + return false; + if (index != other.index) + return false; + return resource.equals(other.resource); + } + + @Override + public Identifiable merge(Identifiable other) { + throw new RuntimeException("Cannot be merged"); + } + + + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSplitIdentifiable2.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSplitIdentifiable2.java new file mode 100644 index 0000000..a9094ec --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/data/ResourceSplitIdentifiable2.java @@ -0,0 +1,72 @@ +package org.simantics.interop.mapping.data; + + +import org.simantics.db.Resource; + +public class ResourceSplitIdentifiable2 extends ResourceIdentifiable { + + + private String identifier; + + + public ResourceSplitIdentifiable2(Resource resource, String identifier) { + super(resource); + this.identifier = identifier; + } + + public static Identifiable createIdentifiable(ResourceIdentifiable identifiable, String identifier) { + return new ResourceSplitIdentifiable2(identifiable.getResource(), identifier); + + } + + public static Identifiable createIdentifiable(Identifiable identifiable, String identifier) { + Resource res = identifiable.getAdapter(Resource.class); + if (res == null) + return null; + + Resource resources[] = identifiable.getAdapter(Resource[].class); + + if (resources.length > 1) { + return ResourceSetSplitIdentifiable2.createIdentifiable(identifiable, identifier); + } else { + return new ResourceSplitIdentifiable2(res, identifier); + } + + } + + @Override + public boolean equals(Object arg0) { + if (arg0 == null) + return false; + if (this.getClass() != arg0.getClass()) + return false; + ResourceSplitIdentifiable2 other = (ResourceSplitIdentifiable2)arg0; + if (!identifier.equals(other.identifier)) + return false; + return resource.equals(other.resource); + } + + public String getIdentifier() { + return identifier; + } + + @Override + public Identifiable merge(Identifiable other) { + if (other instanceof ResourceSplitIdentifiable2) { + ResourceSplitIdentifiable2 o = (ResourceSplitIdentifiable2)other; + if (!o.identifier.equals(identifier)) + throw new RuntimeException("Cannot be merged, Identifiers do not match " + identifier + " " + o.identifier); + ResourceSetSplitIdentifiable2 id = new ResourceSetSplitIdentifiable2(identifier, resource, o.resource); + return id; + } + if (other instanceof ResourceSetSplitIdentifiable2) { + ResourceSetSplitIdentifiable2 o = (ResourceSetSplitIdentifiable2)other; + if (!o.getIdentifier().equals(identifier)) + throw new RuntimeException("Cannot be merged, Identifiers do not match " + identifier + " " + o.getIdentifier()); + ResourceSetSplitIdentifiable2 id = new ResourceSetSplitIdentifiable2(resource, o.getResources(),identifier); + return id; + } + throw new RuntimeException("Cannot be merged"); + } + +} diff --git a/org.simantics.interop.mapping/src/org/simantics/interop/mapping/internal/Activator.java b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/internal/Activator.java new file mode 100644 index 0000000..66f486a --- /dev/null +++ b/org.simantics.interop.mapping/src/org/simantics/interop/mapping/internal/Activator.java @@ -0,0 +1,50 @@ +package org.simantics.interop.mapping.internal; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.simantics.interop.mapping"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +}