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));
}
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));
}
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);
}
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));
}
}
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));
}
}
Aggregations