- private void copyElevation(WriteGraph graph, DistrictNetworkResource DN, Resource sourceElement, Resource targetElement, boolean cut) throws DatabaseException {
- double sourceElevation = graph.getRelatedValue(sourceElement, DN.Vertex_HasElevation, Bindings.DOUBLE);
- double targetElevation = graph.getRelatedValue(targetElement, DN.Vertex_HasElevation, Bindings.DOUBLE);
- if (cut) {
- graph.deny(sourceElement, DN.Vertex_HasElevation);
- graph.claimLiteral(sourceElement, DN.Vertex_HasElevation, targetElevation, Bindings.DOUBLE);
- }
- graph.deny(targetElement, DN.Vertex_HasElevation);
- graph.claimLiteral(targetElement, DN.Vertex_HasElevation, sourceElevation, Bindings.DOUBLE);
- }
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+
+ Resource diagram = graph.getSingleObject(sourceElement, L0.PartOf);
+ Resource newTarget = doCopy(graph, diagram, targetElement, sourceElement);
+ if (cut) {
+ Resource newSource = doCopy(graph, diagram, sourceElement, targetElement);
+ copyVertexInverses(graph, sourceElement, newSource);
+ deleteExistingTarget(graph, sourceElement);
+ }
+ copyVertexInverses(graph, targetElement, newTarget);
+ deleteExistingTarget(graph, targetElement);
+ }
+ });
+ } catch (DatabaseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }, 500, TimeUnit.MILLISECONDS);
+
+// ThreadUtils.getNonBlockingWorkExecutor().schedule(() -> {
+// Simantics.getSession().asyncRequest(new WriteRequest() {
+//
+// @Override
+// public void perform(WriteGraph graph) throws DatabaseException {
+// DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+// //copyMapping(graph, DN, sourceElement, targetElement);
+// copyLocation(graph, DN, sourceElement, targetElement, cut);
+// copyVertexInverses(graph, DN, sourceElement, targetElement, cut);
+// copyElevation(graph, DN, sourceElement, targetElement, cut);
+// }
+//
+// private void copyMapping(WriteGraph graph, DistrictNetworkResource DN, Resource sourceElement, Resource targetElement) throws DatabaseException {
+// Resource sourceMapping = graph.getSingleObject(sourceElement, DN.Mapping);
+// Resource targetMapping = graph.getSingleObject(targetElement, DN.Mapping);
+// if (cut) {
+// graph.deny(sourceElement, DN.Mapping);
+// graph.claim(sourceElement, DN.Mapping, targetMapping);
+// }
+// graph.deny(targetElement, DN.Mapping);
+// graph.claim(targetElement, DN.Mapping, sourceMapping);
+// }
+//
+// private void copyElevation(WriteGraph graph, DistrictNetworkResource DN, Resource sourceElement, Resource targetElement, boolean cut) throws DatabaseException {
+// double sourceElevation = graph.getRelatedValue(sourceElement, DN.Vertex_HasElevation, Bindings.DOUBLE);
+// double targetElevation = graph.getRelatedValue(targetElement, DN.Vertex_HasElevation, Bindings.DOUBLE);
+// if (cut) {
+// graph.deny(sourceElement, DN.Vertex_HasElevation);
+// graph.claimLiteral(sourceElement, DN.Vertex_HasElevation, targetElevation, Bindings.DOUBLE);
+// }
+// graph.deny(targetElement, DN.Vertex_HasElevation);
+// graph.claimLiteral(targetElement, DN.Vertex_HasElevation, sourceElevation, Bindings.DOUBLE);
+// }
+//
+// private void copyLocation(WriteGraph graph, DistrictNetworkResource DN, Resource sourceElement, Resource targetElement, boolean cut) throws DatabaseException {
+// DiagramResource DIA = DiagramResource.getInstance(graph);
+// double[] sourceLocation = graph.getRelatedValue(sourceElement, DIA.HasLocation, Bindings.DOUBLE_ARRAY);
+// double[] targetLocation = graph.getRelatedValue(targetElement, DIA.HasLocation, Bindings.DOUBLE_ARRAY);
+// if (cut) {
+// graph.deny(sourceElement, DIA.HasLocation);
+// graph.claimLiteral(sourceElement, DIA.HasLocation, targetLocation, Bindings.DOUBLE_ARRAY);
+// }
+// graph.deny(targetElement, DIA.HasLocation);
+// graph.claimLiteral(targetElement, DIA.HasLocation, sourceLocation, Bindings.DOUBLE_ARRAY);
+// }
+//
+
+//
+//
+// });
+// }, 500, TimeUnit.MILLISECONDS);