Search in sources :

Example 86 with Label

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);
    }
}
Also used : Label(ai.grakn.concept.Label)

Example 87 with Label

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);
}
Also used : EntityType(ai.grakn.concept.EntityType) Entity(ai.grakn.concept.Entity) Attribute(ai.grakn.concept.Attribute) Relationship(ai.grakn.concept.Relationship) Label(ai.grakn.concept.Label) 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