use of org.neo4j.driver.v1.types.Relationship in project open-kilda by telstra.
the class PathComputerTest method testGetFlowInfo.
@Test
public void testGetFlowInfo() {
try (Transaction tx = graphDb.beginTx()) {
Node node1, node2;
node1 = graphDb.createNode(Label.label("switch"));
node1.setProperty("name", "00:03");
node2 = graphDb.createNode(Label.label("switch"));
node2.setProperty("name", "00:04");
Relationship rel1 = node1.createRelationshipTo(node2, RelationshipType.withName("flow"));
rel1.setProperty("flowid", "f1");
rel1.setProperty("cookie", 3);
rel1.setProperty("meter_id", 2);
rel1.setProperty("transit_vlan", 1);
rel1.setProperty("src_switch", "00:03");
tx.success();
}
Driver driver = GraphDatabase.driver("bolt://localhost:7878", AuthTokens.basic("neo4j", "password"));
NeoDriver nd = new NeoDriver(driver);
List<FlowInfo> fi = nd.getFlowInfo();
Assert.assertEquals(fi.get(0).getFlowId(), "f1");
Assert.assertEquals(fi.get(0).getCookie(), 3);
Assert.assertEquals(fi.get(0).getMeterId(), 2);
Assert.assertEquals(fi.get(0).getTransitVlanId(), 1);
Assert.assertEquals(fi.get(0).getSrcSwitchId(), "00:03");
}
use of org.neo4j.driver.v1.types.Relationship in project structr by structr.
the class SessionTransaction method close.
@Override
public void close() {
if (!success) {
// be sure that they contain the correct values after a rollback.
for (final EntityWrapper entity : modifiedEntities) {
entity.stale();
}
} else {
// so that the relationship caches are rebuilt.
for (final EntityWrapper entity : modifiedEntities) {
entity.clearCaches();
}
}
// mark this transaction as closed BEFORE trying to actually close it
// so that it is closed in case of a failure
closed = true;
try {
tx.close();
session.close();
} catch (TransientException tex) {
// transient exceptions can be retried
throw new RetryException(tex);
} finally {
// so that the relationship caches are rebuilt.
for (final EntityWrapper entity : modifiedEntities) {
entity.onClose();
}
// make sure that the resources are freed
if (session.isOpen()) {
session.close();
}
}
}
Aggregations