use of fr.lirmm.graphik.graal.api.core.UnsupportedAtomTypeException in project graal by graphik-team.
the class NaturalRDBMSStore method add.
// /////////////////////////////////////////////////////////////////////////
// PROTECTED AND PRIVATE METHODS
// /////////////////////////////////////////////////////////////////////////
@Override
protected Statement add(Statement statement, Atom atom) throws AtomSetException {
if (!this.check(atom)) {
// FIXME say why
throw new UnsupportedAtomTypeException("");
}
try {
DBTable table = this.createPredicateTableIfNotExist(atom.getPredicate());
Iterator<DBColumn> cols = table.getColumns().iterator();
Map<String, String> data = new TreeMap<String, String>();
for (Term t : atom.getTerms()) {
DBColumn col = cols.next();
data.put(col.getName(), this.getConjunctiveQueryTranslator().formatFromColumnType(col, t));
}
String query = this.getDriver().getInsertOrIgnoreQuery(table, data);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(atom.toString() + " : " + query);
}
statement.addBatch(query);
} catch (SQLException e) {
throw new AtomSetException(e);
}
return statement;
}
use of fr.lirmm.graphik.graal.api.core.UnsupportedAtomTypeException in project graal by graphik-team.
the class AdHocRdbmsStore method add.
// /////////////////////////////////////////////////////////////////////////
// PROTECTED METHODS
// /////////////////////////////////////////////////////////////////////////
/**
* @param statement
* @param atom
* @throws AtomSetException
*/
@Override
protected Statement add(Statement statement, Atom atom) throws AtomSetException {
if (!this.check(atom)) {
// FIXME say why
throw new UnsupportedAtomTypeException("");
}
try {
for (Term t : atom.getTerms()) {
if (this.getTerm(t.getLabel()) == null) {
// FIXME Quick fix for
// VARIABLE and
// CONSTANT with same
// label conflict
this.add(statement, t);
}
}
DBTable table = this.createPredicateTableIfNotExist(atom.getPredicate());
Map<String, String> data = new TreeMap<String, String>();
int i = -1;
for (Term t : atom.getTerms()) {
++i;
data.put("term" + i, '\'' + StringUtils.addSlashes(t.getIdentifier().toString()) + '\'');
}
String query = this.getDriver().getInsertOrIgnoreQuery(table, data);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(atom.toString() + " : " + query.toString());
}
statement.addBatch(query);
} catch (SQLException e) {
throw new AtomSetException(e);
}
return statement;
}
Aggregations