Java Code Examples for org.eclipse.rdf4j.query.parser.ParsedUpdate#getDatasetMapping()
The following examples show how to use
org.eclipse.rdf4j.query.parser.ParsedUpdate#getDatasetMapping() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractQueryPreparer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void execute() throws UpdateExecutionException { ParsedUpdate parsedUpdate = getParsedUpdate(); List<UpdateExpr> updateExprs = parsedUpdate.getUpdateExprs(); Map<UpdateExpr, Dataset> datasetMapping = parsedUpdate.getDatasetMapping(); for (UpdateExpr updateExpr : updateExprs) { Dataset activeDataset = getMergedDataset(datasetMapping.get(updateExpr)); try { AbstractQueryPreparer.this.execute(updateExpr, activeDataset, getBindings(), getIncludeInferred(), getMaxExecutionTime()); } catch (UpdateExecutionException e) { if (!updateExpr.isSilent()) { throw e; } } } }
Example 2
Source File: SailConnectionUpdate.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void execute() throws UpdateExecutionException { ParsedUpdate parsedUpdate = getParsedUpdate(); List<UpdateExpr> updateExprs = parsedUpdate.getUpdateExprs(); Map<UpdateExpr, Dataset> datasetMapping = parsedUpdate.getDatasetMapping(); SailUpdateExecutor executor = new SailUpdateExecutor(con, vf, parserConfig); for (UpdateExpr updateExpr : updateExprs) { Dataset activeDataset = getMergedDataset(datasetMapping.get(updateExpr)); try { boolean localTransaction = isLocalTransaction(); if (localTransaction) { beginLocalTransaction(); } executor.executeUpdate(updateExpr, activeDataset, getBindings(), getIncludeInferred(), getMaxExecutionTime()); if (localTransaction) { commitLocalTransaction(); } } catch (RDF4JException | IOException e) { logger.warn("exception during update execution: ", e); if (!updateExpr.isSilent()) { throw new UpdateExecutionException(e); } } } }
Example 3
Source File: SailUpdate.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void execute() throws UpdateExecutionException { ParsedUpdate parsedUpdate = getParsedUpdate(); List<UpdateExpr> updateExprs = parsedUpdate.getUpdateExprs(); Map<UpdateExpr, Dataset> datasetMapping = parsedUpdate.getDatasetMapping(); SailUpdateExecutor executor = new SailUpdateExecutor(con.getSailConnection(), con.getValueFactory(), con.getParserConfig()); boolean localTransaction = false; try { if (!getConnection().isActive()) { localTransaction = true; beginLocalTransaction(); } for (UpdateExpr updateExpr : updateExprs) { Dataset activeDataset = getMergedDataset(datasetMapping.get(updateExpr)); try { executor.executeUpdate(updateExpr, activeDataset, getBindings(), getIncludeInferred(), getMaxExecutionTime()); } catch (RDF4JException | IOException e) { logger.warn("exception during update execution: ", e); if (!updateExpr.isSilent()) { throw new UpdateExecutionException(e); } } } if (localTransaction) { commitLocalTransaction(); localTransaction = false; } } finally { if (localTransaction) { rollbackLocalTransaction(); } } }
Example 4
Source File: SpinRenderer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void render(ParsedUpdate update, RDFHandler handler) throws RDFHandlerException { handler.startRDF(); for (Map.Entry<String, String> entry : update.getNamespaces().entrySet()) { handler.handleNamespace(entry.getKey(), entry.getValue()); } String[] sourceStrings = update.getSourceString().split("\\s*;\\s*"); List<UpdateExpr> updateExprs = update.getUpdateExprs(); Map<UpdateExpr, Dataset> datasets = update.getDatasetMapping(); for (int i = 0; i < updateExprs.size(); i++) { UpdateExpr updateExpr = updateExprs.get(i); Resource updateSubj = valueFactory.createBNode(); Dataset dataset = datasets.get(updateExpr); IRI updateClass; if (updateExpr instanceof Modify) { Modify modify = (Modify) updateExpr; if (modify.getInsertExpr() == null && modify.getWhereExpr().equals(modify.getDeleteExpr())) { updateClass = SP.DELETE_WHERE_CLASS; } else { updateClass = SP.MODIFY_CLASS; } } else if (updateExpr instanceof InsertData) { updateClass = SP.INSERT_DATA_CLASS; } else if (updateExpr instanceof DeleteData) { updateClass = SP.DELETE_DATA_CLASS; } else if (updateExpr instanceof Load) { updateClass = SP.LOAD_CLASS; } else if (updateExpr instanceof Clear) { updateClass = SP.CLEAR_CLASS; } else if (updateExpr instanceof Create) { updateClass = SP.CREATE_CLASS; } else { throw new RDFHandlerException("Unrecognised UpdateExpr: " + updateExpr.getClass()); } handler.handleStatement(valueFactory.createStatement(updateSubj, RDF.TYPE, updateClass)); if (output.text) { handler.handleStatement(valueFactory.createStatement(updateSubj, SP.TEXT_PROPERTY, valueFactory.createLiteral(sourceStrings[i]))); } if (output.rdf) { SpinVisitor visitor = new SpinVisitor(handler, null, updateSubj, dataset); updateExpr.visit(visitor); visitor.end(); } } handler.endRDF(); }