Search in sources :

Example 11 with Concept

use of ai.grakn.concept.Concept in project grakn by graknlabs.

the class TxObserver method getConcept.

private void getConcept(GrpcConcept.ConceptId conceptId) {
    Optional<Concept> concept = Optional.ofNullable(tx().getConcept(GrpcUtil.convert(conceptId)));
    TxResponse response = TxResponse.newBuilder().setOptionalConcept(GrpcUtil.convertOptionalConcept(concept)).build();
    responseObserver.onNext(response);
}
Also used : Concept(ai.grakn.concept.Concept) GrpcConcept(ai.grakn.rpc.generated.GrpcConcept) TxResponse(ai.grakn.rpc.generated.GrpcGrakn.TxResponse)

Example 12 with Concept

use of ai.grakn.concept.Concept in project grakn by graknlabs.

the class TxObserver method getSchemaConcept.

private void getSchemaConcept(GrpcConcept.Label label) {
    Optional<Concept> concept = Optional.ofNullable(tx().getSchemaConcept(GrpcUtil.convert(label)));
    TxResponse response = TxResponse.newBuilder().setOptionalConcept(GrpcUtil.convertOptionalConcept(concept)).build();
    responseObserver.onNext(response);
}
Also used : Concept(ai.grakn.concept.Concept) GrpcConcept(ai.grakn.rpc.generated.GrpcConcept) TxResponse(ai.grakn.rpc.generated.GrpcGrakn.TxResponse)

Example 13 with Concept

use of ai.grakn.concept.Concept in project grakn by graknlabs.

the class RemoteGraknTxTest method whenPuttingRole_EnsureCorrectRequestIsSent.

@Test
public void whenPuttingRole_EnsureCorrectRequestIsSent() {
    ConceptId id = ConceptId.of(V123.getValue());
    Label label = Label.of("foo");
    try (RemoteGraknTx tx = RemoteGraknTx.create(session, GrpcUtil.openRequest(KEYSPACE, GraknTxType.READ))) {
        // The open request
        verify(server.requests()).onNext(any());
        Concept concept = RemoteConcepts.createRole(tx, id);
        server.setResponse(GrpcUtil.putRoleRequest(label), GrpcUtil.conceptResponse(concept));
        assertEquals(concept, tx.putRole(label));
    }
}
Also used : GrpcConcept(ai.grakn.rpc.generated.GrpcConcept) Concept(ai.grakn.concept.Concept) Label(ai.grakn.concept.Label) ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 14 with Concept

use of ai.grakn.concept.Concept in project grakn by graknlabs.

the class RemoteGraknTxTest method whenGettingSchemaConceptViaLabel_EnsureCorrectRequestIsSent.

@Test
public void whenGettingSchemaConceptViaLabel_EnsureCorrectRequestIsSent() {
    Label label = Label.of("foo");
    ConceptId id = ConceptId.of(V123.getValue());
    try (RemoteGraknTx tx = RemoteGraknTx.create(session, GrpcUtil.openRequest(KEYSPACE, GraknTxType.READ))) {
        // The open request
        verify(server.requests()).onNext(any());
        Concept concept = RemoteConcepts.createAttributeType(tx, id);
        server.setResponse(GrpcUtil.getSchemaConceptRequest(label), GrpcUtil.optionalConceptResponse(Optional.of(concept)));
        assertEquals(concept, tx.getSchemaConcept(label));
    }
}
Also used : GrpcConcept(ai.grakn.rpc.generated.GrpcConcept) Concept(ai.grakn.concept.Concept) Label(ai.grakn.concept.Label) ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 15 with Concept

use of ai.grakn.concept.Concept in project grakn by graknlabs.

the class RemoteGraknTxTest method whenPuttingRelationshipType_EnsureCorrectRequestIsSent.

@Test
public void whenPuttingRelationshipType_EnsureCorrectRequestIsSent() {
    ConceptId id = ConceptId.of(V123.getValue());
    Label label = Label.of("foo");
    try (RemoteGraknTx tx = RemoteGraknTx.create(session, GrpcUtil.openRequest(KEYSPACE, GraknTxType.READ))) {
        // The open request
        verify(server.requests()).onNext(any());
        Concept concept = RemoteConcepts.createRelationshipType(tx, id);
        server.setResponse(GrpcUtil.putRelationshipTypeRequest(label), GrpcUtil.conceptResponse(concept));
        assertEquals(concept, tx.putRelationshipType(label));
    }
}
Also used : GrpcConcept(ai.grakn.rpc.generated.GrpcConcept) Concept(ai.grakn.concept.Concept) Label(ai.grakn.concept.Label) ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Aggregations

Concept (ai.grakn.concept.Concept)91 Test (org.junit.Test)56 ConceptId (ai.grakn.concept.ConceptId)26 GraknTx (ai.grakn.GraknTx)25 Answer (ai.grakn.graql.admin.Answer)25 SchemaConcept (ai.grakn.concept.SchemaConcept)19 Label (ai.grakn.concept.Label)18 GrpcConcept (ai.grakn.rpc.generated.GrpcConcept)18 QueryBuilder (ai.grakn.graql.QueryBuilder)17 Var (ai.grakn.graql.Var)15 Set (java.util.Set)15 Role (ai.grakn.concept.Role)14 QueryAnswer (ai.grakn.graql.internal.query.QueryAnswer)14 HashSet (java.util.HashSet)13 List (java.util.List)12 AttributeType (ai.grakn.concept.AttributeType)11 EntityType (ai.grakn.concept.EntityType)11 Schema (ai.grakn.util.Schema)10 Collectors (java.util.stream.Collectors)10 Stream (java.util.stream.Stream)10