@Override public void onCommit() { if (tx != null && isTransactionInProgress) { tx.success(); tx.finish(); nodeIds.clear(); processedNodes.clear(); } isTransactionInProgress = false; }
@Override public void onRollback() { if (tx != null && isTransactionInProgress) { tx.failure(); tx.finish(); nodeIds.clear(); processedNodes.clear(); } tx = null; isTransactionInProgress = false; }
@Override protected void txCompleted( Transaction tx ) { tx.finish(); }
Transaction tx = graphDb.beginTx(); try { // do your work here tx.success(); } finally { tx.finish(); } graphdb.shutdown();
/** * Test method for * {@link com.impetus.client.neo4j.GraphEntityMapper#getEntityFromNode(org.neo4j.graphdb.Node, com.impetus.kundera.metadata.model.EntityMetadata)} * . */ @Test public void testGetEntityFromNode() { Transaction tx = graphDb.beginTx(); Node node = graphDb.createNode(); node.setProperty("ACTOR_ID", 1); node.setProperty("ACTOR_NAME", "Amresh Singh"); Actor actor = (Actor) mapper.getEntityFromNode(node, KunderaMetadataManager.getEntityMetadata(kunderaMetadata, Actor.class)); Assert.assertNotNull(actor); Assert.assertEquals(1, actor.getId()); Assert.assertEquals("Amresh Singh", actor.getName()); node.delete(); tx.success(); tx.finish(); }
/** * Test method for * {@link com.impetus.client.neo4j.GraphEntityMapper#getNodeFromEntity(java.lang.Object, Object, org.neo4j.graphdb.GraphDatabaseService, com.impetus.kundera.metadata.model.EntityMetadata, boolean)} * . */ @Test public void testGetNodeFromEntity() { Actor actor = new Actor(); actor.setId(1); actor.setName("Keenu Reeves"); Transaction tx = graphDb.beginTx(); Node node = mapper.getNodeFromEntity(actor, 1, graphDb, KunderaMetadataManager.getEntityMetadata(kunderaMetadata, Actor.class), false); Assert.assertNotNull(node); Assert.assertEquals(1, node.getProperty("ACTOR_ID")); Assert.assertEquals("Keenu Reeves", node.getProperty("ACTOR_NAME")); node.delete(); tx.success(); tx.finish(); }
/** * Test method for * {@link com.impetus.client.neo4j.GraphEntityMapper#createProxyNode(java.lang.Object, java.lang.Object, org.neo4j.graphdb.GraphDatabaseService, com.impetus.kundera.metadata.model.EntityMetadata, com.impetus.kundera.metadata.model.EntityMetadata)} * . */ @Test public void testCreateProxyNode() { EntityMetadata sourceM = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, Actor.class); EntityMetadata targetM = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, Movie.class); Transaction tx = graphDb.beginTx(); Node proxyNode = mapper.createProxyNode(1, "A", graphDb, sourceM, targetM); Assert.assertNotNull(proxyNode); Assert.assertEquals(1, proxyNode.getProperty("ACTOR_ID")); Assert.assertEquals("A", proxyNode.getProperty("MOVIE_ID")); Assert.assertEquals("$PROXY_NODE$", proxyNode.getProperty("$NODE_TYPE$")); proxyNode.delete(); tx.success(); tx.finish(); }
private ByteArrayInputStream getNeo4jContent(GraphDatabaseService graphDatabaseService) { Transaction tx = graphDatabaseService.beginTx(); ByteArrayInputStream neo4jGraphMlRepresentation = null; try { GraphMLWriter graphMLWriter = new GraphMLWriter(graphDatabaseService); neo4jGraphMlRepresentation = readNeo4jData(graphMLWriter); tx.success(); } finally { tx.finish(); } return neo4jGraphMlRepresentation; }
private ByteArrayInputStream getNeo4jContent(GraphDatabaseService graphDatabaseService) { Transaction tx = graphDatabaseService.beginTx(); ByteArrayInputStream neo4jGraphMlRepresentation = null; try { GraphMLWriter graphMLWriter = new GraphMLWriter(graphDatabaseService); neo4jGraphMlRepresentation = readNeo4jData(graphMLWriter); tx.success(); } finally { tx.finish(); } return neo4jGraphMlRepresentation; }
public TimelineNodeIndex( String indexName, GraphDatabaseService db, Map<String, String> config ) { this.indexName = indexName; Transaction tx = db.beginTx(); Node underlyingNode = getOrCreateStartNode(db, config); timeline = new Timeline( indexName, underlyingNode, false, db ); tx.success(); tx.finish(); }
@Override public void insert(Neo4jConnectionCallback connection, InputStream dataset) throws Throwable { GraphDatabaseService graphDatabaseService = connection.graphDatabaseService(); Transaction tx = graphDatabaseService.beginTx(); GraphMLReader graphMLReader = new GraphMLReader(graphDatabaseService); try { graphMLReader.read(dataset); tx.success(); } finally { tx.finish(); } }
@After public void commitTx() { if ( tx != null ) { tx.success(); tx.finish(); tx = null; } }
@Override public void insert(Neo4jConnectionCallback connection, InputStream dataset) throws Throwable { GraphDatabaseService graphDatabaseService = connection.graphDatabaseService(); Transaction tx = graphDatabaseService.beginTx(); GraphMLReader graphMLReader = new GraphMLReader(graphDatabaseService); try { graphMLReader.read(dataset); tx.success(); } finally { tx.finish(); } }
public void addPropertiesToUserNodes() { Transaction tx = graphDb.beginTx(); try { user1.setProperty("name", "John Johnson"); user2.setProperty("name", "Kate Smith"); user3.setProperty("name", "Jack Jeffries"); tx.success(); } finally { tx.finish(); } }
public void addMorePropertiesToUsers() { Transaction tx = graphDb.beginTx(); try { user1.setProperty("year_of_birth", 1982); user2.setProperty("locked", true); user3.setProperty("cars_owned", new String[]{"BMW", "Audi"}); tx.success(); } finally { tx.finish(); } }
@After public void doAfter() { tx.success(); tx.finish(); }
@Override public void clear(final Listener monitor) { removeAll(false, new NullListener()); Transaction tx = database.beginTx(); try { initIndexRoot(); initIndexMetadata(); tx.success(); } finally { tx.finish(); } }
public void setPropertyWithTx(String propertyName, Object propertyValue) { if (propertyName != null && propertyValue != null) { Transaction transaction = getUnderlyingNode().getGraphDatabase().beginTx(); try { getUnderlyingNode().setProperty(propertyName, propertyValue); transaction.success(); } finally { transaction.finish(); } } }
/** * Test method for * {@link com.impetus.client.neo4j.GraphEntityMapper#getEntityFromRelationship(org.neo4j.graphdb.Relationship, com.impetus.kundera.metadata.model.EntityMetadata, com.impetus.kundera.metadata.model.Relation)} * . */ @Test public void testGetEntityFromRelationship() { Transaction tx = graphDb.beginTx(); Node sourceNode = graphDb.createNode(); sourceNode.setProperty("ACTOR_ID", 1); sourceNode.setProperty("ACTOR_NAME", "Amresh Singh"); Node targetNode = graphDb.createNode(); targetNode.setProperty("MOVIE_ID", "M1"); targetNode.setProperty("TITLE", "Matrix Reloaded"); targetNode.setProperty("YEAR", 1999); Relationship rel = sourceNode.createRelationshipTo(targetNode, DynamicRelationshipType.withName("ACTS_IN")); rel.setProperty("ROLE_NAME", "Neo"); rel.setProperty("ROLE_TYPE", "Lead Actor"); Role role = (Role) mapper.getEntityFromRelationship(rel, KunderaMetadataManager.getEntityMetadata(kunderaMetadata, Actor.class), KunderaMetadataManager.getEntityMetadata(kunderaMetadata, Actor.class).getRelation("movies")); Assert.assertNotNull(role); Assert.assertEquals("Neo", role.getRoleName()); Assert.assertEquals("Lead Actor", role.getRoleType()); rel.delete(); sourceNode.delete(); targetNode.delete(); tx.success(); tx.finish(); }
protected void newTransaction() { tx.success(); tx.finish(); tx = graphDb().beginTx(); }