use of ai.grakn.concept.Thing in project grakn by graknlabs.
the class TransitivityChainKB method buildExtensionalDB.
private void buildExtensionalDB(GraknTx graph, int n) {
Role qfrom = graph.getRole("Q-from");
Role qto = graph.getRole("Q-to");
EntityType aEntity = graph.getEntityType("a-entity");
RelationshipType q = graph.getRelationshipType("Q");
Thing aInst = putEntityWithResource(graph, "a", graph.getEntityType("entity2"), key);
ConceptId[] aInstanceIds = new ConceptId[n];
for (int i = 0; i < n; i++) {
aInstanceIds[i] = putEntityWithResource(graph, "a" + i, aEntity, key).getId();
}
q.addRelationship().addRolePlayer(qfrom, aInst).addRolePlayer(qto, graph.getConcept(aInstanceIds[0]));
for (int i = 0; i < n - 1; i++) {
q.addRelationship().addRolePlayer(qfrom, graph.getConcept(aInstanceIds[i])).addRolePlayer(qto, graph.getConcept(aInstanceIds[i + 1]));
}
}
use of ai.grakn.concept.Thing in project grakn by graknlabs.
the class EntityTest method whenDeletingLastRolePlayerInRelation_TheRelationIsDeleted.
@Test
public void whenDeletingLastRolePlayerInRelation_TheRelationIsDeleted() throws GraknTxOperationException {
EntityType type = tx.putEntityType("Concept Type");
RelationshipType relationshipType = tx.putRelationshipType("relationTypes");
Role role1 = tx.putRole("role1");
Thing rolePlayer1 = type.addEntity();
Relationship relationship = relationshipType.addRelationship().addRolePlayer(role1, rolePlayer1);
assertNotNull(tx.getConcept(relationship.getId()));
rolePlayer1.delete();
assertNull(tx.getConcept(relationship.getId()));
}
Aggregations