-package fi.vtt.simantics.procore.internal;\r
-\r
-import gnu.trove.list.array.TByteArrayList;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.VirtualGraph;\r
-import org.simantics.db.WriteOnlyGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.exception.RuntimeDatabaseException;\r
-import org.simantics.db.impl.ResourceImpl;\r
-import org.simantics.db.impl.graph.WriteGraphImpl;\r
-import org.simantics.db.impl.graph.WriteSupport;\r
-import org.simantics.db.service.ClusterBuilder2;\r
-import org.simantics.db.service.SerialisationSupport;\r
-\r
-public class VirtualClusterBuilderImpl2 implements ClusterBuilder2 {\r
-\r
- final private SessionImplSocket session;\r
- final private VirtualGraph vg;\r
-// final private ClusterSupport cs;\r
- final private SerialisationSupport ss;\r
-// final private ClusterStream stream;\r
-// final private WriteSupport support;\r
-// final private WriteSupport support;\r
- @SuppressWarnings("unused")\r
- final private boolean allowImmutables;\r
- \r
- VirtualClusterBuilderImpl2(SessionImplSocket session, VirtualGraph vg, boolean allowImmutables) {\r
- this.session = session;\r
- this.vg = vg;\r
- this.allowImmutables = allowImmutables;\r
- ss = session.getService(SerialisationSupport.class);\r
- }\r
- \r
- private WriteSupport getSupport() {\r
- WriteGraphImpl graph = session.writeState.getGraph();\r
- return graph.writeSupport;\r
- }\r
-\r
- @Override\r
- public void newCluster() throws DatabaseException {\r
- // Do nothing\r
- }\r
-\r
- @Override\r
- public void selectCluster(long cluster) throws DatabaseException {\r
- // Do nothing\r
- }\r
- \r
- @Override\r
- public void newCluster(int setHandle) throws DatabaseException {\r
- // Do nothing\r
- }\r
- \r
- @Override\r
- public void createClusterSet(int resource) throws DatabaseException {\r
- // Do nothing\r
- }\r
- \r
- @Override\r
- public int newResource() throws DatabaseException {\r
- Resource result = getSupport().createResource(vg); \r
- return handle(result);\r
- }\r
-\r
- @Override\r
- public int newResource(int set) throws DatabaseException {\r
- Resource result = getSupport().createResource(vg, resource(set));\r
- return handle(result);\r
- }\r
- \r
- @Override\r
- public int resource(Resource res) throws DatabaseException {\r
- ResourceImpl r = (ResourceImpl)res;\r
- return r.id;\r
- }\r
-\r
- @Override\r
- public void addStatement(WriteOnlyGraph graph, int subject, int predicate, int object) throws DatabaseException {\r
- getSupport().claim(vg, subject, predicate, object);\r
- }\r
- \r
-// public void applyPredicate(ClusterImpl impl, int predicate) {\r
-// \r
-// int clusterKey = ClusterTraitsBase.getClusterKeyFromResourceKeyNoThrow(predicate);\r
-// ClusterImpl cluster = clusterArray[clusterKey]; \r
-// \r
-// impl.change.addStatementIndex1(predicate, cluster.clusterUID, (byte)0, impl.foreignLookup);\r
-// \r
-// }\r
-//\r
-// public void applyObject(ClusterImpl impl, int object) {\r
-//\r
-// int clusterKey = ClusterTraitsBase.getClusterKeyFromResourceKeyNoThrow(object);\r
-// ClusterImpl cluster = clusterArray[clusterKey]; \r
-// \r
-// impl.change.addStatementIndex2(object, cluster.clusterUID, (byte)0, impl.foreignLookup);\r
-// \r
-// }\r
-\r
- @Override\r
- public Resource resource(int key) {\r
- try {\r
- return ss.getResource(key);\r
- } catch (DatabaseException e) {\r
- throw new RuntimeDatabaseException(e);\r
- }\r
- }\r
- \r
- @Override\r
- public int handle(Resource r) {\r
- return ((ResourceImpl)r).id;\r
- }\r
-\r
-\r
- TByteArrayList valueBytes = new TByteArrayList();\r
- \r
-// byte[] buffer = new byte[65536];\r
-// int bufferOffset = 0;\r
- int valueSubject = 0;\r
-// int valueOffset = 0;\r
- \r
- @Override\r
- public void beginValue(int subject) {\r
- valueBytes.clear();\r
- valueSubject = subject;\r
- }\r
- \r
- @Override\r
- public void appendValue(int byteValue) throws DatabaseException {\r
- valueBytes.add((byte)byteValue);\r
- }\r
-\r
- @Override\r
- public void endValue() throws DatabaseException {\r
- byte[] bytes = valueBytes.toArray();\r
- getSupport().claimValue(vg, valueSubject, bytes, bytes.length);\r
- }\r
- \r
-}\r
+package fi.vtt.simantics.procore.internal;
+
+import gnu.trove.list.array.TByteArrayList;
+
+import org.simantics.db.Resource;
+import org.simantics.db.VirtualGraph;
+import org.simantics.db.WriteOnlyGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.exception.RuntimeDatabaseException;
+import org.simantics.db.impl.ResourceImpl;
+import org.simantics.db.impl.graph.WriteGraphImpl;
+import org.simantics.db.impl.graph.WriteSupport;
+import org.simantics.db.service.ClusterBuilder2;
+import org.simantics.db.service.SerialisationSupport;
+
+public class VirtualClusterBuilderImpl2 implements ClusterBuilder2 {
+
+ final private SessionImplSocket session;
+ final private VirtualGraph vg;
+// final private ClusterSupport cs;
+ final private SerialisationSupport ss;
+// final private ClusterStream stream;
+// final private WriteSupport support;
+// final private WriteSupport support;
+ @SuppressWarnings("unused")
+ final private boolean allowImmutables;
+
+ VirtualClusterBuilderImpl2(SessionImplSocket session, VirtualGraph vg, boolean allowImmutables) {
+ this.session = session;
+ this.vg = vg;
+ this.allowImmutables = allowImmutables;
+ ss = session.getService(SerialisationSupport.class);
+ }
+
+ private WriteSupport getSupport() {
+ WriteGraphImpl graph = session.writeState.getGraph();
+ return graph.writeSupport;
+ }
+
+ @Override
+ public void newCluster() throws DatabaseException {
+ // Do nothing
+ }
+
+ @Override
+ public void selectCluster(long cluster) throws DatabaseException {
+ // Do nothing
+ }
+
+ @Override
+ public void newCluster(int setHandle) throws DatabaseException {
+ // Do nothing
+ }
+
+ @Override
+ public void createClusterSet(int resource) throws DatabaseException {
+ // Do nothing
+ }
+
+ @Override
+ public int newResource() throws DatabaseException {
+ Resource result = getSupport().createResource(vg);
+ return handle(result);
+ }
+
+ @Override
+ public int newResource(int set) throws DatabaseException {
+ Resource result = getSupport().createResource(vg, resource(set));
+ return handle(result);
+ }
+
+ @Override
+ public int resource(Resource res) throws DatabaseException {
+ ResourceImpl r = (ResourceImpl)res;
+ return r.id;
+ }
+
+ @Override
+ public void addStatement(WriteOnlyGraph graph, int subject, int predicate, int object) throws DatabaseException {
+ getSupport().claim(vg, subject, predicate, object);
+ }
+
+// public void applyPredicate(ClusterImpl impl, int predicate) {
+//
+// int clusterKey = ClusterTraitsBase.getClusterKeyFromResourceKeyNoThrow(predicate);
+// ClusterImpl cluster = clusterArray[clusterKey];
+//
+// impl.change.addStatementIndex1(predicate, cluster.clusterUID, (byte)0, impl.foreignLookup);
+//
+// }
+//
+// public void applyObject(ClusterImpl impl, int object) {
+//
+// int clusterKey = ClusterTraitsBase.getClusterKeyFromResourceKeyNoThrow(object);
+// ClusterImpl cluster = clusterArray[clusterKey];
+//
+// impl.change.addStatementIndex2(object, cluster.clusterUID, (byte)0, impl.foreignLookup);
+//
+// }
+
+ @Override
+ public Resource resource(int key) {
+ try {
+ return ss.getResource(key);
+ } catch (DatabaseException e) {
+ throw new RuntimeDatabaseException(e);
+ }
+ }
+
+ @Override
+ public int handle(Resource r) {
+ return ((ResourceImpl)r).id;
+ }
+
+
+ TByteArrayList valueBytes = new TByteArrayList();
+
+// byte[] buffer = new byte[65536];
+// int bufferOffset = 0;
+ int valueSubject = 0;
+// int valueOffset = 0;
+
+ @Override
+ public void beginValue(int subject) {
+ valueBytes.clear();
+ valueSubject = subject;
+ }
+
+ @Override
+ public void appendValue(int byteValue) throws DatabaseException {
+ valueBytes.add((byte)byteValue);
+ }
+
+ @Override
+ public void endValue() throws DatabaseException {
+ byte[] bytes = valueBytes.toArray();
+ getSupport().claimValue(vg, valueSubject, bytes, bytes.length);
+ }
+
+}