use of ai.grakn.concept.Label in project grakn by graknlabs.
the class AbstractSchemaConceptGenerator method generateFromTx.
@Override
protected final T generateFromTx() {
Collection<T> schemaConcepts;
if (!includeNonMeta()) {
schemaConcepts = Sets.newHashSet(otherMetaSchemaConcepts());
schemaConcepts.add(metaSchemaConcept());
} else {
schemaConcepts = (Collection<T>) metaSchemaConcept().subs().collect(toSet());
}
schemaConcepts = schemaConcepts.stream().filter(this::filter).collect(toSet());
if (!includeMeta()) {
schemaConcepts.remove(metaSchemaConcept());
schemaConcepts.removeAll(otherMetaSchemaConcepts());
}
if (schemaConcepts.isEmpty() && includeNonMeta()) {
Label label = genFromTx(Labels.class).mustBeUnused().generate(random, status);
assert tx().getSchemaConcept(label) == null;
return newSchemaConcept(label);
} else {
return random.choose(schemaConcepts);
}
}
use of ai.grakn.concept.Label in project grakn by graknlabs.
the class EntityTest method checkKeyCreatesCorrectResourceStructure.
@Test
public void checkKeyCreatesCorrectResourceStructure() {
Label resourceLabel = Label.of("A Attribute Thing");
EntityType entityType = tx.putEntityType("A Thing");
AttributeType<String> attributeType = tx.putAttributeType(resourceLabel, AttributeType.DataType.STRING);
entityType.key(attributeType);
Entity entity = entityType.addEntity();
Attribute attribute = attributeType.putAttribute("A attribute thing");
entity.attribute(attribute);
Relationship relationship = entity.relationships().iterator().next();
checkImplicitStructure(attributeType, relationship, entity, Schema.ImplicitType.KEY, Schema.ImplicitType.KEY_OWNER, Schema.ImplicitType.KEY_VALUE);
}
Aggregations