use of org.neo4j.driver.v1.types.Entity in project structr by structr.
the class EntityWrapper method assertNotStale.
// ----- protected methods -----
protected synchronized void assertNotStale() {
if (stale) {
// invalidate caches
onRemoveFromCache();
// if a node/rel was deleted in a previous transaction but the caller keeps a
// reference to this entity, we need to make sure that the reference is fresh.
final SessionTransaction tx = db.getCurrentTransaction();
final Map<String, Object> map = new HashMap<>();
map.put("id", id);
try {
// update data
data.clear();
update(tx.getEntity(getQueryPrefix() + " WHERE ID(n) = {id} RETURN n", map).asMap());
} catch (NoSuchRecordException nex) {
throw new NotFoundException(nex);
}
stale = false;
}
}
use of org.neo4j.driver.v1.types.Entity in project cypher-for-gremlin by opencypher.
the class GremlinCypherValueConverter method toCypherPath.
@SuppressWarnings("unchecked")
private static Value toCypherPath(List p) {
boolean isNode = true;
Entity[] objects = new Entity[p.size()];
for (int i = 0; i < p.size(); i++) {
if (isNode) {
objects[i] = toCypherNode((Map<?, ?>) p.get(i));
} else {
objects[i] = toCypherRelationship((Map<?, ?>) p.get(i));
}
isNode = !isNode;
}
return new InternalPath(objects).asValue();
}
use of org.neo4j.driver.v1.types.Entity 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