use of com.inova8.intelligentgraph.results.ResourceStatementResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Thing method getFacts.
/**
* Gets the facts.
*
* @param predicatePattern the predicate pattern
* @param customQueryOptions the custom query options
* @return the facts
*/
public ResourceResults getFacts(String predicatePattern, CustomQueryOptions customQueryOptions) {
logger.debug("getFacts{}\n", predicatePattern);
this.getEvaluationContext().getTracer().traceFacts(this, predicatePattern);
SimpleDataset dataset = IntelligentGraphRepository.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 = IntelligentGraphRepository.preparePredicate(PATHQL.getFacts, predicatePattern);
if (this.getSource().getRepository() == null) {
CloseableIteration<? extends Statement, QueryEvaluationException> localStatementIterator = this.getSource().getTripleSource().getStatements(this.getIRI(), predicate, null, contextArray);
results = new ResourceStatementResults(localStatementIterator, this, null, customQueryOptions);
} else {
CloseableIteration<Statement, RepositoryException> statementIterator = this.getSource().getRepository().getConnection().getStatements(this.getIRI(), predicate, null, contextArray);
results = new ResourceStatementResults(statementIterator, this, null, customQueryOptions);
}
return results;
}
use of com.inova8.intelligentgraph.results.ResourceStatementResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Thing method traceFact.
/**
* Trace fact.
*
* @param predicatePattern the predicate pattern
* @param customQueryOptions the custom query options
* @return the trace
*/
public Trace traceFact(String predicatePattern, CustomQueryOptions customQueryOptions) {
SimpleDataset dataset = IntelligentGraphRepository.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 = IntelligentGraphRepository.preparePredicate(PATHQL.traceFacts, predicatePattern);
CloseableIteration<Statement, RepositoryException> statementIterator = this.getSource().getRepository().getConnection().getStatements(this.getIRI(), predicate, null, contextArray);
results = new ResourceStatementResults(statementIterator, this, null, customQueryOptions);
for (Resource result : results) {
String resultString = result.stringValue();
results.close();
return new Trace(resultString);
}
results.close();
return new Trace("results");
}
use of com.inova8.intelligentgraph.results.ResourceStatementResults 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;
}
Aggregations