OrientGraphConnectionHandlerIF connPool; @Inject public GraphTransactionManager(OrientGraphConnectionHandlerIF connHandler) { connPool = connHandler; }
public T runWithCommit(withGraphConnection<T> runnable) { FramedGraph<OrientGraph> graph = connPool.getFrameGraph(); T result = null; try { result = runnable.run(graph); graph.getBaseGraph().commit(); } catch(Exception e) { graph.getBaseGraph().rollback(); Logger.error(String.format("Error in graph transaction manager while running with commit: "), e); throw e; } finally { graph.getBaseGraph().shutdown(); } return result; }
@Override public DeletionDTO createDeletionFromInstance(String instanceId, DeletionDTO deletionDTO) throws Exception {
return handler.runWithCommit((graph) -> { //this is line 71
// create and map the initial values DeletionGraph deletionGraph = graph.addVertex( "class:DeletionGraph", DeletionGraph.class); // this is line 74
//set the status and ID (this will overwrite anything set in the DTO) deletionGraph.setUniqueIdentifier( deletionGraph.generateUniqueIdentifier() ); deletionGraph.setDeletionStage( DeletionStatus.NEW_UNCOMMITTED.getStatus());
//get the mandatory fields deletionGraph.setUniqueIdentifier( deletionGraph.getUniqueIdentifier()); deletionGraph.setDeletionType( deletionDTO.getDeletionType().toString()); deletionGraph.setDeletionApprovalDate( deletionDTO.getDeletionApprovalDate()); deletionGraph.setDDFReference( deletionDTO.getDDFReference()); deletionGraph.setDeletionDescription( deletionDTO.getDeletionDescription());
//add the actors deletionGraph.setCreatedBy(createActor(deletionDTO.getCreatedBy(), graph));
//assign the asset instance edge/adjacency Iterable<AssetInstanceGraph> foundAssetInstances = graph.getVertices( "AssetInstance." + UNIQUE_IDENTIFIER, instanceId, AssetInstanceGraph.class); AssetInstanceGraph assetInstance = foundAssetInstances.iterator().hasNext() ? foundAssetInstances.iterator().next() : null; deletionGraph.setDeletionFor( assetInstance );
return new DeletionDTO(deletionGraph); }); }
DB name="testdb" at com.orientechnologies.orient.core.record.impl.ODocument.validateField(ODocument.java:229) at com.orientechnologies.orient.core.record.impl.ODocument.validate(ODocument.java:2047) at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.save(ODatabaseDocumentTx.java:2733) at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.save(ODatabaseDocumentTx.java:102) at com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:1805) at com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:1796) at com.tinkerpop.blueprints.impls.orient.OrientElement.save(OrientElement.java:333) at com.tinkerpop.blueprints.impls.orient.OrientElement.save(OrientElement.java:315) at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.addVertex(OrientBaseGraph.java:571) at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.addVertex(OrientBaseGraph.java:503) at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.addVertex(OrientBaseGraph.java:75) at com.tinkerpop.frames.FramedGraph.addVertex(FramedGraph.java:242) at com.tinkerpop.frames.FramedGraph.addVertex(FramedGraph.java:258) at services.implementations.deletionservice.DeletionServiceImpl.lambda$createDeletionFromInstance$3(DeletionServiceImpl.java:74) at modules.database.graph.connection.GraphTransactionManager.runWithCommit(GraphTransactionManager.java:31) at services.implementations.deletionservice.DeletionServiceImpl.createDeletionFromInstance(DeletionServiceImpl.java:71)```