Search in sources :

Example 16 with Label

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

the class TxObserver method putAttributeType.

private void putAttributeType(PutAttributeType putAttributeType) {
    Label label = GrpcUtil.convert(putAttributeType.getLabel());
    AttributeType.DataType<?> dataType = GrpcUtil.convert(putAttributeType.getDataType());
    AttributeType<?> attributeType = tx().putAttributeType(label, dataType);
    responseObserver.onNext(GrpcUtil.conceptResponse(attributeType));
}
Also used : AttributeType(ai.grakn.concept.AttributeType) PutAttributeType(ai.grakn.rpc.generated.GrpcGrakn.PutAttributeType) Label(ai.grakn.concept.Label)

Example 17 with Label

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

the class TxObserver method putRule.

private void putRule(PutRule putRule) {
    Label label = GrpcUtil.convert(putRule.getLabel());
    Pattern when = GrpcUtil.convert(putRule.getWhen());
    Pattern then = GrpcUtil.convert(putRule.getThen());
    Rule rule = tx().putRule(label, when, then);
    responseObserver.onNext(GrpcUtil.conceptResponse(rule));
}
Also used : Pattern(ai.grakn.graql.Pattern) Label(ai.grakn.concept.Label) Rule(ai.grakn.concept.Rule) PutRule(ai.grakn.rpc.generated.GrpcGrakn.PutRule)

Example 18 with Label

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

the class ConceptControllerTest method whenCallingTypeEndpointAndRequestingJSON_ReturnJSON.

@Test
public void whenCallingTypeEndpointAndRequestingJSON_ReturnJSON() {
    Label label = MetaSchema.ENTITY.getLabel();
    given().accept(ContentType.JSON).pathParam("keyspace", keyspace.getValue()).pathParam("label", label.getValue()).when().get("/kb/{keyspace}/type/{label}").then().statusCode(SC_OK).contentType(ContentType.JSON);
}
Also used : Label(ai.grakn.concept.Label) Test(org.junit.Test)

Example 19 with Label

use of ai.grakn.concept.Label 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 20 with Label

use of ai.grakn.concept.Label 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)

Aggregations

Label (ai.grakn.concept.Label)87 Test (org.junit.Test)41 Role (ai.grakn.concept.Role)25 GraknTx (ai.grakn.GraknTx)22 ConceptId (ai.grakn.concept.ConceptId)21 Concept (ai.grakn.concept.Concept)20 Set (java.util.Set)20 RelationshipType (ai.grakn.concept.RelationshipType)19 SchemaConcept (ai.grakn.concept.SchemaConcept)19 AttributeType (ai.grakn.concept.AttributeType)17 EntityType (ai.grakn.concept.EntityType)17 Relationship (ai.grakn.concept.Relationship)14 HashSet (java.util.HashSet)14 Collectors (java.util.stream.Collectors)13 Type (ai.grakn.concept.Type)12 Stream (java.util.stream.Stream)12 VarPatternAdmin (ai.grakn.graql.admin.VarPatternAdmin)11 Schema (ai.grakn.util.Schema)11 Collection (java.util.Collection)11 Pattern (ai.grakn.graql.Pattern)10