use of fr.lirmm.graphik.graal.api.store.WrongArityException in project graal by graphik-team.
the class RDF4jUtils method atomToStatement.
// /////////////////////////////////////////////////////////////////////////
// PUBLIC METHODS
// /////////////////////////////////////////////////////////////////////////
public Statement atomToStatement(Atom atom) throws WrongArityException, MalformedLangStringException {
if (atom.getPredicate().getArity() != 2) {
throw new WrongArityException("Error on " + atom + ": arity " + atom.getPredicate().getArity() + " is not supported by this store. ");
}
IRI predicate = this.createURI(atom.getPredicate());
IRI term0 = this.createURI(atom.getTerm(0));
Value term1 = this.createValue(atom.getTerm(1));
return valueFactory.createStatement(term0, predicate, term1);
}
use of fr.lirmm.graphik.graal.api.store.WrongArityException in project graal by graphik-team.
the class RDF4jStore method termsByPredicatePosition.
@Override
public CloseableIterator<Term> termsByPredicatePosition(Predicate p, int position) throws AtomSetException {
TupleQuery query = null;
TupleQueryResult results = null;
try {
if (position == 0) {
query = this.connection.prepareTupleQuery(QueryLanguage.SPARQL, "SELECT DISTINCT ?x WHERE { ?x <" + utils.createURI(p) + "> ?y }");
} else if (position == 1) {
query = this.connection.prepareTupleQuery(QueryLanguage.SPARQL, "SELECT DISTINCT ?x WHERE { ?y <" + utils.createURI(p) + "> ?x }");
} else {
throw new WrongArityException("Position should be 0 for subject or 1 for object.");
}
results = query.evaluate();
} catch (RepositoryException e) {
throw new AtomSetException(e);
} catch (MalformedQueryException e) {
throw new AtomSetException(e);
} catch (QueryEvaluationException e) {
throw new AtomSetException(e);
}
return new TermsIterator(results, "x", this.utils);
}
Aggregations