use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class SchemaConstraintsIT method createLabelUniquenessPropertyConstraint.
private ConstraintDefinition createLabelUniquenessPropertyConstraint(String labelName, String propertyKey) {
try (Transaction tx = graphdb().beginTx()) {
ConstraintDefinition constraintDefinition = graphdb().schema().constraintFor(label(labelName)).assertPropertyIsUnique(propertyKey).create();
tx.success();
return constraintDefinition;
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class GraphDbHelper method getRelationship.
public Relationship getRelationship(long relationshipId) {
try (Transaction tx = database.getGraph().beginTransaction(implicit, AnonymousContext.read())) {
Relationship relationship = database.getGraph().getRelationshipById(relationshipId);
tx.success();
return relationship;
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class GraphDbHelper method getIndexedRelationships.
public Collection<Long> getIndexedRelationships(String indexName, String key, Object value) {
try (Transaction tx = database.getGraph().beginTransaction(implicit, AnonymousContext.write())) {
Collection<Long> result = new ArrayList<>();
for (Relationship relationship : database.getGraph().index().forRelationships(indexName).get(key, value)) {
result.add(relationship.getId());
}
tx.success();
return result;
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class GraphDbHelper method createPropertyUniquenessConstraint.
public ConstraintDefinition createPropertyUniquenessConstraint(String labelName, List<String> propertyKeys) {
try (Transaction tx = database.getGraph().beginTransaction(implicit, AUTH_DISABLED)) {
ConstraintCreator creator = database.getGraph().schema().constraintFor(label(labelName));
for (String propertyKey : propertyKeys) {
creator = creator.assertPropertyIsUnique(propertyKey);
}
ConstraintDefinition result = creator.create();
tx.success();
return result;
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class GraphDbHelper method addRelationshipToIndex.
public void addRelationshipToIndex(String indexName, String key, String value, long relationshipId) {
try (Transaction tx = database.getGraph().beginTransaction(implicit, AUTH_DISABLED)) {
Index<Relationship> index = database.getGraph().index().forRelationships(indexName);
index.add(database.getGraph().getRelationshipById(relationshipId), key, value);
tx.success();
}
}
Aggregations