private long executeModify() { List<STMT> added = null, removed = null; if (clause.getInsert() != null) { added = getTriples(clause.getInsert(), clause.getPattern()); } if (clause.getDelete() != null) { removed = getTriples(clause.getDelete(), clause.getPattern()); } connection.update(removed, added); return 0l; }
private long executeDelete() { List<STMT> stmts = getTriples(clause.getTemplate(), clause.getPattern()); connection.update(stmts, null); return 0l; }
@Override public Void visit(PatternBlock expr, Void context) { handle(expr.getSubject()); handle(expr.getPredicate()); handle(expr.getObject()); handle(expr.getContext()); return null; }
@Override public <RT> RT execute(RDFConnectionCallback<RT> operation) { RDFConnection connection = openConnection(); try { try { return operation.doInConnection(connection); } finally { connection.close(); } } catch (IOException io) { throw new RepositoryException(io); } }
@Override public LID getLID(ID id) { STMT stmt = find(id, CORE.localId, null); String lid; if (stmt != null) { lid = stmt.getObject().getValue(); } else { lid = String.valueOf(connection.getNextLocalId()); add(id, CORE.localId, new LIT(lid)); } return new LID(lid); }
public void removeStatements(Collection<STMT> stmts) { for (STMT stmt : stmts) { if (removeIndexed(stmt.getSubject(), stmt, subjects)) { if (objects != null && stmt.getObject().isResource()) { removeIndexed((ID) stmt.getObject(), stmt, objects); } } } }
@Override public void rollback() { try { for (RDFBeanTransaction tx : transactions) { tx.rollback(); } } finally { connection.cleanUpAfterCommit(); } }
public SPARQLUpdateClause(RDFConnection connection, String clause) { try { this.connection = connection; this.clause = new SPARQLUpdateParser().parse(clause); } catch (IOException e) { throw new RepositoryException(e); } }
@Override public RDFBeanTransaction beginTransaction(boolean readOnly, int txTimeout, int isolationLevel) { RDFBeanTransaction[] transactions = new RDFBeanTransaction[connections.length]; for (int i = 0; i < transactions.length; i++) { transactions[i] = connections[i].beginTransaction(readOnly, txTimeout, isolationLevel); } this.readonlyTnx = readOnly; localTxn = new MultiTransaction(this, transactions); return localTxn; }
@Override public Void visit(GroupBlock expr, Void context) { handle(expr.getBlocks()); handle(expr.getFilters()); return null; }
private UpdateClause load() throws IOException { // LOAD <remoteURI> [ INTO <uri> ] UID remoteURI = uri(); nextChar(); if (ch > -1) { skipWhileIn(WS, INTO); UID into = uri(); return new UpdateClause(prefixes, UpdateClause.Type.LOAD, remoteURI, into); } else { return new UpdateClause(prefixes, UpdateClause.Type.LOAD, remoteURI); } }
public static PatternBlock pattern(Object subject, Object predicate, Object object) { return new PatternBlock( convert(ID.class, subject), convert(UID.class, predicate), convert(NODE.class, object)); }
private long executeInsert() { List<STMT> stmts = getTriples(clause.getTemplate(), clause.getPattern()); connection.update(null, stmts); return 0l; }
private UpdateClause clear() throws IOException { // CLEAR [ GRAPH <uri> ] skipWhitespace(); nextChar(); if (ch > -1 && ch < 65535) { // FIXME skipWhileIn(GRAPH, WS); UID uid = uri(); return new UpdateClause(prefixes, UpdateClause.Type.CLEAR, uid); } else { return new UpdateClause(prefixes, UpdateClause.Type.CLEAR); } }