Search in sources :

Example 1 with RelationConstraint

use of com.vaticle.typedb.core.pattern.constraint.thing.RelationConstraint in project grakn by graknlabs.

the class ThingVariable method relation.

public RelationConstraint relation(LinkedHashSet<RelationConstraint.RolePlayer> rolePlayers) {
    RelationConstraint relationConstraint = new RelationConstraint(this, rolePlayers);
    constrain(relationConstraint);
    return relationConstraint;
}
Also used : RelationConstraint(com.vaticle.typedb.core.pattern.constraint.thing.RelationConstraint)

Example 2 with RelationConstraint

use of com.vaticle.typedb.core.pattern.constraint.thing.RelationConstraint in project grakn by graknlabs.

the class ConcludableTest method test_conjunction_concludables_contain_type_labels_with_anonymous_type_variable.

@Test
public void test_conjunction_concludables_contain_type_labels_with_anonymous_type_variable() {
    String conjunction = "{ $diag(patient-role-type: $per) isa diagnosis; $per isa person; }";
    Set<Concludable> concludables = Concludable.create(parseConjunction(conjunction));
    assertEquals(1, isaConcludablesCount(concludables));
    assertEquals(0, hasConcludablesCount(concludables));
    assertEquals(1, relationConcludablesCount(concludables));
    assertEquals(0, attributeConcludablesCount(concludables));
    RelationConstraint relationConstraint = concludables.stream().filter(Concludable::isRelation).findFirst().get().asRelation().relation();
    IsaConstraint relationIsaConstraint = relationConstraint.owner().isa().get();
    assertEquals("$_diagnosis", relationIsaConstraint.type().reference().asLabel().syntax());
    assertEquals("diagnosis", relationIsaConstraint.type().label().get().label());
    assertFalse(list(relationConstraint.players()).get(0).player().isa().isPresent());
}
Also used : RelationConstraint(com.vaticle.typedb.core.pattern.constraint.thing.RelationConstraint) IsaConstraint(com.vaticle.typedb.core.pattern.constraint.thing.IsaConstraint) Test(org.junit.Test)

Example 3 with RelationConstraint

use of com.vaticle.typedb.core.pattern.constraint.thing.RelationConstraint in project grakn by graknlabs.

the class ConcludableTest method test_conjunction_concludables_contain_type_labels_with_anonymous_type_and_relation_variable.

@Test
public void test_conjunction_concludables_contain_type_labels_with_anonymous_type_and_relation_variable() {
    String conjunction = "{ (patient-role-type: $per) isa diagnosis; $per isa person; }";
    Set<Concludable> concludables = Concludable.create(parseConjunction(conjunction));
    assertEquals(1, isaConcludablesCount(concludables));
    assertEquals(0, hasConcludablesCount(concludables));
    assertEquals(1, relationConcludablesCount(concludables));
    assertEquals(0, attributeConcludablesCount(concludables));
    RelationConstraint relationConstraint = concludables.stream().filter(Concludable::isRelation).findFirst().get().asRelation().relation();
    IsaConstraint relationIsaConstraint = relationConstraint.owner().isa().get();
    assertEquals("$_diagnosis", relationIsaConstraint.type().reference().asLabel().syntax());
    assertEquals("diagnosis", relationIsaConstraint.type().label().get().label());
    assertFalse(list(relationConstraint.players()).get(0).player().isa().isPresent());
}
Also used : RelationConstraint(com.vaticle.typedb.core.pattern.constraint.thing.RelationConstraint) IsaConstraint(com.vaticle.typedb.core.pattern.constraint.thing.IsaConstraint) Test(org.junit.Test)

Example 4 with RelationConstraint

use of com.vaticle.typedb.core.pattern.constraint.thing.RelationConstraint in project grakn by graknlabs.

the class ConcludableTest method test_conjunction_concludables_does_not_contain_type_labels.

@Test
public void test_conjunction_concludables_does_not_contain_type_labels() {
    String conjunction = "{ $diag(patient-role-type: $per) isa $diagnosis; $diagnosis type diagnosis-type;" + "$per isa $person; $person type person-type; }";
    Set<Concludable> concludables = Concludable.create(parseConjunction(conjunction));
    assertEquals(1, isaConcludablesCount(concludables));
    assertEquals(0, hasConcludablesCount(concludables));
    assertEquals(1, relationConcludablesCount(concludables));
    assertEquals(0, attributeConcludablesCount(concludables));
    RelationConstraint relationConstraint = concludables.stream().filter(Concludable::isRelation).findFirst().get().asRelation().relation();
    IsaConstraint relationIsaConstraint = relationConstraint.owner().isa().get();
    assertEquals("$diagnosis", relationIsaConstraint.type().reference().asName().syntax());
    assertFalse(relationIsaConstraint.type().label().isPresent());
    assertFalse(list(relationConstraint.players()).get(0).player().isa().isPresent());
}
Also used : RelationConstraint(com.vaticle.typedb.core.pattern.constraint.thing.RelationConstraint) IsaConstraint(com.vaticle.typedb.core.pattern.constraint.thing.IsaConstraint) Test(org.junit.Test)

Aggregations

RelationConstraint (com.vaticle.typedb.core.pattern.constraint.thing.RelationConstraint)4 IsaConstraint (com.vaticle.typedb.core.pattern.constraint.thing.IsaConstraint)3 Test (org.junit.Test)3