Search in sources :

Example 11 with AtomSetException

use of fr.lirmm.graphik.graal.api.core.AtomSetException in project graal by graphik-team.

the class AbstractRdbmsStore method remove.

@Override
public boolean remove(Atom atom) {
    boolean res = true;
    Statement statement = null;
    try {
        statement = this.createStatement();
        this.remove(statement, atom);
        statement.executeBatch();
        this.getConnection().commit();
    } catch (SQLException e) {
        res = false;
    } catch (AtomSetException e) {
        res = false;
    } finally {
        if (statement != null) {
            try {
                statement.close();
            } catch (SQLException e) {
                res = false;
            }
        }
    }
    return res;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException)

Example 12 with AtomSetException

use of fr.lirmm.graphik.graal.api.core.AtomSetException in project graal by graphik-team.

the class RDF4jStore method match.

@Override
public CloseableIterator<Atom> match(Atom atom) throws AtomSetException {
    ConjunctiveQuery query = DefaultConjunctiveQueryFactory.instance().create(atom);
    StringWriter s = new StringWriter();
    SparqlConjunctiveQueryWriter w = new SparqlConjunctiveQueryWriter(s, this.utils.getURIzer());
    try {
        w.write(query);
        w.close();
    } catch (IOException e1) {
        throw new AtomSetException("Error while converting to SPARQL " + atom, e1);
    }
    TupleQuery sparqlQuery = this.connection.prepareTupleQuery(s.toString());
    TupleQueryResult result = sparqlQuery.evaluate();
    return new TupleQueryResultAtomIterator(result, atom, utils);
}
Also used : StringWriter(java.io.StringWriter) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) TupleQuery(org.eclipse.rdf4j.query.TupleQuery) IOException(java.io.IOException) TupleQueryResult(org.eclipse.rdf4j.query.TupleQueryResult) ConjunctiveQuery(fr.lirmm.graphik.graal.api.core.ConjunctiveQuery) SparqlConjunctiveQueryWriter(fr.lirmm.graphik.graal.io.sparql.SparqlConjunctiveQueryWriter)

Example 13 with AtomSetException

use of fr.lirmm.graphik.graal.api.core.AtomSetException in project graal by graphik-team.

the class RDF4jStore method getPredicates.

@Override
public Set<Predicate> getPredicates() throws AtomSetException {
    TreeSet<Predicate> set = new TreeSet<Predicate>();
    CloseableIterator<Predicate> it = this.predicatesIterator();
    try {
        while (it.hasNext()) {
            set.add(it.next());
        }
    } catch (IteratorException e) {
        throw new AtomSetException("An error occurs during iteration over predicates", e);
    }
    return set;
}
Also used : IteratorException(fr.lirmm.graphik.util.stream.IteratorException) TreeSet(java.util.TreeSet) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Example 14 with AtomSetException

use of fr.lirmm.graphik.graal.api.core.AtomSetException in project graal by graphik-team.

the class RDF4jStore method getTerms.

@Override
public Set<Term> getTerms() throws AtomSetException {
    TreeSet<Term> set = new TreeSet<Term>();
    CloseableIterator<Term> it = this.termsIterator();
    try {
        while (it.hasNext()) {
            set.add(it.next());
        }
    } catch (IteratorException e) {
        throw new AtomSetException("An error occurs during iteration over terms", e);
    }
    return set;
}
Also used : IteratorException(fr.lirmm.graphik.util.stream.IteratorException) TreeSet(java.util.TreeSet) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) Term(fr.lirmm.graphik.graal.api.core.Term)

Example 15 with AtomSetException

use of fr.lirmm.graphik.graal.api.core.AtomSetException in project graal by graphik-team.

the class Neo4jStore method removeAll.

@Override
public boolean removeAll(CloseableIterator<? extends Atom> it) throws AtomSetException {
    boolean isChanged = false;
    this.checkTransaction();
    try {
        while (it.hasNext()) {
            isChanged = this.remove(it.next(), null) || isChanged;
        }
        this.successTransaction();
    } catch (IteratorException e) {
        throw new AtomSetException("An errors occurs while iterating atoms to remove", e);
    } finally {
        this.reloadTransaction();
    }
    return isChanged;
}
Also used : IteratorException(fr.lirmm.graphik.util.stream.IteratorException) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException)

Aggregations

AtomSetException (fr.lirmm.graphik.graal.api.core.AtomSetException)69 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)26 SQLException (java.sql.SQLException)26 Atom (fr.lirmm.graphik.graal.api.core.Atom)25 Term (fr.lirmm.graphik.graal.api.core.Term)23 HomomorphismException (fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException)12 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)11 Statement (java.sql.Statement)11 DBTable (fr.lirmm.graphik.graal.store.rdbms.util.DBTable)10 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)9 BacktrackException (fr.lirmm.graphik.graal.homomorphism.BacktrackException)9 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)7 TreeSet (java.util.TreeSet)7 SQLQuery (fr.lirmm.graphik.graal.store.rdbms.util.SQLQuery)6 CloseableIteratorAdapter (fr.lirmm.graphik.util.stream.CloseableIteratorAdapter)6 RuleApplicationException (fr.lirmm.graphik.graal.api.forward_chaining.RuleApplicationException)5 LinkedListAtomSet (fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet)5 TreeMap (java.util.TreeMap)5 AtomSet (fr.lirmm.graphik.graal.api.core.AtomSet)4 Variable (fr.lirmm.graphik.graal.api.core.Variable)4