use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class ReasonerTest method testReasoningWithQueryWithNoRelationTypeWithRoles2.
@Test
public void testReasoningWithQueryWithNoRelationTypeWithRoles2() {
GraknTx graph = nonMaterialisedGeoKB.tx();
String queryString = "match $x isa city;$y isa country;(geo-entity: $x, $y); get;";
String queryString2 = "match $x isa city;$y isa country;" + "(geo-entity: $x, entity-location: $y) isa is-located-in; get;";
QueryBuilder iqb = graph.graql().infer(true);
GetQuery query = iqb.parse(queryString);
GetQuery query2 = iqb.parse(queryString2);
assertQueriesEqual(query, query2);
}
use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class ReasonerTest method testReasoningWithQueryWithNoRelationTypeWithRoles.
@Test
public void testReasoningWithQueryWithNoRelationTypeWithRoles() {
GraknTx graph = nonMaterialisedGeoKB.tx();
String queryString = "match $x isa city;$y isa country;(geo-entity: $x, $y);$y has name 'Poland'; get;";
String queryString2 = "match $x isa city;$y isa country;" + "(geo-entity: $x, entity-location: $y) isa is-located-in;$y has name 'Poland'; get;";
QueryBuilder iqb = graph.graql().infer(true);
GetQuery query = iqb.parse(queryString);
GetQuery query2 = iqb.parse(queryString2);
assertQueriesEqual(query, query2);
}
use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class ReasonerTest method testReasoningWithQueryContainingPlays2.
@Test
public void testReasoningWithQueryContainingPlays2() {
String queryString = "match $x isa person;$y isa $type;$type plays recommended-product;($x, $y) isa recommendation; get;";
String queryString2 = "match $x isa person;$y isa $type;{$type label 'product';} or {$type label 'tag';};($x, $y) isa recommendation; get;";
QueryBuilder iqb = snbKB.tx().graql().infer(true);
GetQuery query = iqb.parse(queryString);
GetQuery query2 = iqb.parse(queryString2);
assertQueriesEqual(query, query2);
}
use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class ReasonerTest method testReasoningWithQueryContainingRelationTypeVar.
@Test
public void testReasoningWithQueryContainingRelationTypeVar() {
GraknTx graph = nonMaterialisedGeoKB.tx();
String queryString = "match (geo-entity: $x) isa $type;$type label 'is-located-in'; get $x;";
String queryString2 = "match (geo-entity: $x, entity-location: $y)isa is-located-in; get $x;";
QueryBuilder iqb = graph.graql().infer(true);
GetQuery query = iqb.parse(queryString);
GetQuery query2 = iqb.parse(queryString2);
assertQueriesEqual(query, query2);
}
use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class MigrationCLI method printWholeCompletionMessage.
public static void printWholeCompletionMessage(MigrationOptions options) {
System.out.println("Migration complete.");
if (options.isVerbose()) {
System.out.println("Gathering information about migrated data. If in a hurry, you can ctrl+c now.");
GraknTx graph = Grakn.session(options.getUri(), options.getKeyspace()).open(GraknTxType.WRITE);
QueryBuilder qb = graph.graql();
StringBuilder builder = new StringBuilder();
builder.append("Graph schema contains:\n");
builder.append("\t ").append(graph.admin().getMetaEntityType().instances().count()).append(" entity types\n");
builder.append("\t ").append(graph.admin().getMetaRelationType().instances().count()).append(" relation types\n");
builder.append("\t ").append(graph.admin().getMetaRole().subs().count()).append(" roles\n\n");
builder.append("\t ").append(graph.admin().getMetaAttributeType().instances().count()).append(" resource types\n");
builder.append("\t ").append(graph.admin().getMetaRule().subs().count()).append(" rules\n\n");
builder.append("Graph data contains:\n");
builder.append("\t ").append(qb.match(var("x").isa(label(ENTITY.getLabel()))).aggregate(count()).execute()).append(" entities\n");
builder.append("\t ").append(qb.match(var("x").isa(label(RELATIONSHIP.getLabel()))).aggregate(count()).execute()).append(" relations\n");
builder.append("\t ").append(qb.match(var("x").isa(label(ATTRIBUTE.getLabel()))).aggregate(count()).execute()).append(" resources\n");
builder.append("\t ").append(qb.match(var("x").isa(label(RULE.getLabel()))).aggregate(count()).execute()).append(" rules\n\n");
System.out.println(builder);
graph.close();
}
}
Aggregations