use of ai.grakn.concept.ConceptId in project grakn by graknlabs.
the class SubProperty method mapToAtom.
@Override
public Atomic mapToAtom(VarPatternAdmin var, Set<VarPatternAdmin> vars, ReasonerQuery parent) {
Var varName = var.var().asUserDefined();
VarPatternAdmin typeVar = this.superType();
Var typeVariable = typeVar.var().asUserDefined();
IdPredicate predicate = getIdPredicate(typeVariable, typeVar, vars, parent);
ConceptId predicateId = predicate != null ? predicate.getPredicate() : null;
return SubAtom.create(varName, typeVariable, predicateId, parent);
}
use of ai.grakn.concept.ConceptId in project grakn by graknlabs.
the class AbstractIsaProperty method mapToAtom.
@Nullable
@Override
public final Atomic mapToAtom(VarPatternAdmin var, Set<VarPatternAdmin> vars, ReasonerQuery parent) {
// IsaProperty is unique within a var, so skip if this is a relation
if (var.hasProperty(RelationshipProperty.class))
return null;
Var varName = var.var().asUserDefined();
VarPatternAdmin typePattern = this.type();
Var typeVariable = typePattern.var();
IdPredicate predicate = getIdPredicate(typeVariable, typePattern, vars, parent);
ConceptId predicateId = predicate != null ? predicate.getPredicate() : null;
// isa part
VarPatternAdmin isaVar = varPatternForAtom(varName, typeVariable).admin();
return IsaAtom.create(isaVar, typeVariable, predicateId, parent);
}
use of ai.grakn.concept.ConceptId in project grakn by graknlabs.
the class GrpcServerTest method whenGettingANonExistentConcept_ReturnNothing.
@Test
public void whenGettingANonExistentConcept_ReturnNothing() throws InterruptedException {
ConceptId id = ConceptId.of("V123456");
when(tx.getConcept(id)).thenReturn(null);
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(openRequest(MYKS, GraknTxType.READ));
tx.receive().ok();
tx.send(GrpcUtil.getConceptRequest(id));
GrpcConcept.OptionalConcept response = tx.receive().ok().getOptionalConcept();
assertEquals(GrpcConcept.OptionalConcept.ValueCase.ABSENT, response.getValueCase());
}
}
use of ai.grakn.concept.ConceptId in project grakn by graknlabs.
the class ElementFactory method buildConcept.
public <X extends Concept> X buildConcept(VertexElement vertexElement) {
Schema.BaseType type;
try {
type = getBaseType(vertexElement);
} catch (IllegalStateException e) {
throw TemporaryWriteException.indexOverlap(vertexElement.element(), e);
}
ConceptId conceptId = ConceptId.of(vertexElement.property(Schema.VertexProperty.ID));
if (!tx.txCache().isConceptCached(conceptId)) {
Concept concept;
switch(type) {
case RELATIONSHIP:
concept = RelationshipImpl.create(RelationshipReified.get(vertexElement));
break;
case TYPE:
concept = new TypeImpl(vertexElement);
break;
case ROLE:
concept = RoleImpl.get(vertexElement);
break;
case RELATIONSHIP_TYPE:
concept = RelationshipTypeImpl.get(vertexElement);
break;
case ENTITY:
concept = EntityImpl.get(vertexElement);
break;
case ENTITY_TYPE:
concept = EntityTypeImpl.get(vertexElement);
break;
case ATTRIBUTE_TYPE:
concept = AttributeTypeImpl.get(vertexElement);
break;
case ATTRIBUTE:
concept = AttributeImpl.get(vertexElement);
break;
case RULE:
concept = RuleImpl.get(vertexElement);
break;
default:
throw GraknTxOperationException.unknownConcept(type.name());
}
tx.txCache().cacheConcept(concept);
}
return tx.txCache().getCachedConcept(conceptId);
}
use of ai.grakn.concept.ConceptId in project grakn by graknlabs.
the class ElementFactory method buildConcept.
public <X extends Concept> X buildConcept(EdgeElement edgeElement) {
Schema.EdgeLabel label = Schema.EdgeLabel.valueOf(edgeElement.label().toUpperCase(Locale.getDefault()));
ConceptId conceptId = ConceptId.of(edgeElement.id().getValue());
if (!tx.txCache().isConceptCached(conceptId)) {
Concept concept;
switch(label) {
case ATTRIBUTE:
concept = RelationshipImpl.create(RelationshipEdge.get(edgeElement));
break;
default:
throw GraknTxOperationException.unknownConcept(label.name());
}
tx.txCache().cacheConcept(concept);
}
return tx.txCache().getCachedConcept(conceptId);
}
Aggregations