use of fr.lirmm.graphik.graal.api.core.Predicate 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;
}
use of fr.lirmm.graphik.graal.api.core.Predicate 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);
}
}
use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.
the class StoreTest method removeAllTest.
@Theory
public void removeAllTest(AtomSet store) throws AtomSetException, IteratorException {
// given
store.add(DlgpParser.parseAtom("<P>(b,a)."));
store.add(DlgpParser.parseAtom("<P>(a,a)."));
store.add(DlgpParser.parseAtom("<P>(b,b)."));
store.add(DlgpParser.parseAtom("<P>(a,c)."));
store.add(DlgpParser.parseAtom("<Q>(a,a)."));
store.add(DlgpParser.parseAtom("<Q>(a,b)."));
// when
try {
store.removeAll(DlgpParser.parseAtomSet("<P>(a,c), <Q>(a,a)."));
} catch (MethodNotImplementedError e) {
return;
}
// then
Assert.assertFalse(store.contains(DlgpParser.parseAtom("<P>(a,c).")));
Assert.assertFalse(store.contains(DlgpParser.parseAtom("<Q>(a,a).")));
Assert.assertEquals(3, Iterators.count(store.atomsByPredicate(new Predicate("P", 2))));
Assert.assertEquals(1, Iterators.count(store.atomsByPredicate(new Predicate("Q", 2))));
}
use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.
the class StoreTest method removeTest.
@Theory
public void removeTest(AtomSet store) throws AtomSetException, IteratorException {
// given
store.add(DlgpParser.parseAtom("<P>(b,a)."));
store.add(DlgpParser.parseAtom("<P>(a,a)."));
store.add(DlgpParser.parseAtom("<P>(b,b)."));
store.add(DlgpParser.parseAtom("<P>(a,c)."));
store.add(DlgpParser.parseAtom("<Q>(a,a)."));
store.add(DlgpParser.parseAtom("<Q>(a,b)."));
// when
try {
store.remove(DlgpParser.parseAtom("<P>(a,c)."));
} catch (MethodNotImplementedError e) {
return;
}
// then
Assert.assertFalse(store.contains(DlgpParser.parseAtom("<P>(a,c).")));
Assert.assertEquals(3, Iterators.count(store.atomsByPredicate(new Predicate("P", 2))));
Assert.assertEquals(2, Iterators.count(store.atomsByPredicate(new Predicate("Q", 2))));
}
use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.
the class StoreTest method caseSensitivityTest.
@Theory
public void caseSensitivityTest(AtomSet store) throws AtomSetException, IteratorException, ParseException, SQLException {
Assume.assumeTrue(!(store instanceof RdbmsStore) || ((RdbmsStore) store).getDriver().isCaseSensitive());
Atom toAdd = DlgpParser.parseAtom("<P>(a,b).");
Atom toCheck = DlgpParser.parseAtom("<p>(a,b).");
Predicate predicateToCheck = new Predicate("p", 2);
store.add(toAdd);
Assert.assertTrue(store.contains(toAdd));
Assert.assertFalse(store.contains(toCheck));
CloseableIterator<?> it = store.termsByPredicatePosition(predicateToCheck, 0);
Assert.assertFalse(it.hasNext());
it = store.atomsByPredicate(predicateToCheck);
Assert.assertFalse(it.hasNext());
it = store.match(DlgpParser.parseAtom("<p>(X,Y)."));
Assert.assertFalse(it.hasNext());
}
Aggregations