Search in sources :

Example 16 with AtomSetException

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

the class Neo4jStore method getTerms.

@Override
@Deprecated
public Set<Term> getTerms(Type type) throws AtomSetException {
    TreeSet<Term> set = new TreeSet<Term>();
    CloseableIterator<Term> it = this.termsIterator(type);
    try {
        while (it.hasNext()) {
            set.add(it.next());
        }
    } catch (IteratorException e) {
        throw new AtomSetException("An errors occurs while iterating 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 17 with AtomSetException

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

the class Neo4jStore method addAll.

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

Example 18 with AtomSetException

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

the class AbstractRdbmsBatchProcessor method commit.

@Override
public void commit() throws AtomSetException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("batch commit");
    }
    if (this.statement != null) {
        try {
            this.flush();
            this.connection.commit();
        } catch (Exception e) {
            throw new AtomSetException(e);
        }
    }
}
Also used : AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) SQLException(java.sql.SQLException) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException)

Example 19 with AtomSetException

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

the class AbstractRdbmsStore method clear.

@Override
public void clear() throws AtomSetException {
    CloseableIterator<Predicate> it = this.predicatesIterator();
    Statement stat = null;
    try {
        try {
            stat = this.createStatement();
            while (it.hasNext()) {
                Predicate p = it.next();
                this.removePredicate(stat, p);
            }
            this.getConnection().commit();
        } catch (IteratorException e) {
            this.getConnection().rollback();
            throw new AtomSetException(e);
        } catch (SQLException e) {
            this.getConnection().rollback();
            throw new AtomSetException(e);
        } finally {
            if (stat != null)
                stat.close();
        }
    } catch (SQLException e) {
        throw new AtomSetException(e);
    }
}
Also used : IteratorException(fr.lirmm.graphik.util.stream.IteratorException) SQLException(java.sql.SQLException) Statement(java.sql.Statement) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) Predicate(fr.lirmm.graphik.graal.api.core.Predicate)

Example 20 with AtomSetException

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

the class AbstractRdbmsStore method removePredicate.

protected void removePredicate(Statement stat, Predicate p) throws AtomSetException {
    try {
        DBTable table = this.getPredicateTable(p);
        String query = String.format("DROP TABLE %s", table.getName());
        stat.execute(query);
        this.predicateMap.remove(p);
    } catch (SQLException e) {
        throw new AtomSetException(e);
    }
}
Also used : DBTable(fr.lirmm.graphik.graal.store.rdbms.util.DBTable) SQLException(java.sql.SQLException) 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