use of ai.grakn.concept.Thing in project grakn by graknlabs.
the class RelationshipImpl method reify.
/**
* Reifys and returns the {@link RelationshipReified}
*/
public RelationshipReified reify() {
if (relationshipStructure.isReified())
return relationshipStructure.reify();
// Get the role players to transfer
Map<Role, Set<Thing>> rolePlayers = structure().allRolePlayers();
// Now Reify
relationshipStructure = relationshipStructure.reify();
// Transfer relationships
rolePlayers.forEach((role, things) -> {
Thing thing = Iterables.getOnlyElement(things);
addRolePlayer(role, thing);
});
return relationshipStructure.reify();
}
use of ai.grakn.concept.Thing in project grakn by graknlabs.
the class MatchTest method testMatchAllResourcesUsingResourceName.
@Test
public void testMatchAllResourcesUsingResourceName() {
Match match = qb.match(var().has("title", "Godfather").has(Schema.MetaSchema.ATTRIBUTE.getLabel().getValue(), x));
Thing godfather = movieKB.tx().getAttributeType("title").getAttribute("Godfather").owner();
Set<Attribute<?>> expected = godfather.attributes().collect(toSet());
Set<Attribute<?>> results = match.get(x).map(Concept::asAttribute).collect(toSet());
assertEquals(expected, results);
}
use of ai.grakn.concept.Thing in project grakn by graknlabs.
the class QueryErrorTest method whenTryingToSetExistingInstanceType_Throw.
@Test
public void whenTryingToSetExistingInstanceType_Throw() {
Thing movie = rule.tx().getEntityType("movie").instances().iterator().next();
Type person = rule.tx().getEntityType("person");
exception.expect(GraqlQueryException.class);
exception.expectMessage(containsString("person"));
qb.match(var("x").id(movie.getId())).insert(var("x").isa(label(person.getLabel()))).execute();
}
use of ai.grakn.concept.Thing in project grakn by graknlabs.
the class GraqlPrinterTest method testResourceOutputWithResource.
// allOf accepts an array with generics
@SuppressWarnings("unchecked")
@Test
public void testResourceOutputWithResource() {
Printer printer = Printers.graql(true, rule.tx().getAttributeType("title"), rule.tx().getAttributeType("tmdb-vote-count"), rule.tx().getAttributeType("name"));
Thing godfather = rule.tx().getAttributeType("title").getAttribute("Godfather").owner();
String repr = printer.graqlString(godfather);
assertThat(repr, allOf(containsString("movie"), containsString("has"), containsString("title"), containsString("\"Godfather\""), containsString("tmdb-vote-count"), containsString("1000"), not(containsString("name"))));
}
use of ai.grakn.concept.Thing in project grakn by graknlabs.
the class GraqlPrinterTest method testResourceOutputNoResources.
@Test
public void testResourceOutputNoResources() {
Printer printer = Printers.graql(true);
Thing godfather = rule.tx().getAttributeType("title").getAttribute("Godfather").owner();
String repr = printer.graqlString(godfather);
assertThat(repr, allOf(containsString("movie"), not(containsString("title")), not(containsString("Godfather"))));
}
Aggregations