use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Remote_PathQL_MultiGraphTests method test_50.
/**
* Test 50.
*/
@Test
@Order(50)
void test_50() {
try {
// Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph5>");
// source.removeGraph("<http://inova8.com/calc2graph/testGraph1>");
Graph graph = source.openGraph("<http://inova8.com/calc2graph/testGraph5>");
Thing myCountry = graph.getThing(":Country1");
String performanceCalculation = "2*3";
myCountry.addFact(":Attribute@:salesPerformance", performanceCalculation, SCRIPT.GROOVY);
ResourceResults results = myCountry.getFacts(":Attribute@:salesPerformance");
// if(results.hasNext()) {
for (Resource result : results) {
assertEquals("6", result.getValue().stringValue());
break;
}
// source.removeGraph("<http://inova8.com/calc2graph/testGraph>");
source.closeGraph("<http://inova8.com/calc2graph/testGraph5>");
// }else {
// fail();
// }
} catch (Exception e) {
fail();
}
}
use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Example2_Tests method example2_2.
/**
* Example 2 2.
*/
@Test
@Order(2)
void example2_2() {
try {
Thing personType = source.getThing(":Person");
ResourceResults persons = personType.getFacts("^rdf:type");
ArrayList<String> personValues = new ArrayList<String>();
;
for (Resource person : persons) {
personValues.add(person.getValue().stringValue());
}
assertEquals("[http://inova8.com/intelligentgraph/example2/Another1, http://inova8.com/intelligentgraph/example2/Another10, http://inova8.com/intelligentgraph/example2/Another11, http://inova8.com/intelligentgraph/example2/Another12, http://inova8.com/intelligentgraph/example2/Another2, http://inova8.com/intelligentgraph/example2/Another3, http://inova8.com/intelligentgraph/example2/Another4, http://inova8.com/intelligentgraph/example2/Another5, http://inova8.com/intelligentgraph/example2/Another6, http://inova8.com/intelligentgraph/example2/Another7, http://inova8.com/intelligentgraph/example2/Another8, http://inova8.com/intelligentgraph/example2/Another9, http://inova8.com/intelligentgraph/example2/aPerson]", personValues.toString());
} catch (Exception e) {
assertEquals("", e.getCause().getMessage());
}
}
use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Example2_Tests method example2_8.
/**
* Example 2 8.
*/
@Test
@Order(8)
void example2_8() {
try {
Thing person = source.getThing(":Person");
ResourceResults persons = person.getFacts("^rdf:type[:hasHeight [ ge '1.7'^^xsd:double ; le '1.8'^^xsd:double ]]");
ArrayList<String> personValues = new ArrayList<String>();
for (Resource person1 : persons) {
personValues.add(person1.getValue().stringValue());
}
assertEquals("[http://inova8.com/intelligentgraph/example2/Another12, http://inova8.com/intelligentgraph/example2/Another2, http://inova8.com/intelligentgraph/example2/Another4, http://inova8.com/intelligentgraph/example2/Another7, http://inova8.com/intelligentgraph/example2/Another9, http://inova8.com/intelligentgraph/example2/aPerson]", personValues.toString());
} catch (Exception e) {
assertEquals("", e.getCause().getMessage());
}
}
use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class IntelligentGraphRepository method getFacts.
public ResourceResults getFacts(String boundPredicatePattern, CustomQueryOptions customQueryOptions) {
logger.debug("getFacts{}\n", boundPredicatePattern);
// this.getEvaluationContext().getTracer().traceFacts(this, queryPattern);
SimpleDataset dataset = getDataset(customQueryOptions);
// dataset.addDefaultGraph(this.graphName);
org.eclipse.rdf4j.model.Resource[] contextArray = dataset.getDefaultGraphs().toArray(new org.eclipse.rdf4j.model.Resource[0]);
ResourceStatementResults results = null;
IRI predicate = preparePredicate(PATHQL.getFacts, boundPredicatePattern);
if (this.getRepository() == null) {
CloseableIteration<? extends Statement, QueryEvaluationException> localStatementIterator = this.getTripleSource().getStatements(null, predicate, null);
results = new ResourceStatementResults(localStatementIterator, this, null, customQueryOptions);
} else {
CloseableIteration<Statement, RepositoryException> statementIterator = this.getRepository().getConnection().getStatements(null, predicate, null, contextArray);
results = new ResourceStatementResults(statementIterator, this, null, customQueryOptions);
}
return results;
}
use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class IntelligentGraphRepository method getFact.
public com.inova8.intelligentgraph.model.Resource getFact(String boundPredicatePattern, CustomQueryOptions customQueryOptions) {
logger.debug("getFact{}\n", boundPredicatePattern);
ResourceResults factValues = getFacts(boundPredicatePattern, customQueryOptions);
if (factValues == null) {
// return new NullResource();
throw new NullValueReturnedException(String.format("No values found for pattern %s with customQueryOptions %s", boundPredicatePattern, customQueryOptions));
} else if (factValues.hasNext()) {
return factValues.next();
} else {
factValues.close();
// return new NullResource();
throw new NullValueReturnedException(String.format("No values found for pattern %s with customQueryOptions %s", boundPredicatePattern, customQueryOptions));
}
}
Aggregations