|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface IPrecondition
To avoid race conditions during a transaction's commital on the Anzo server, the server allows a transaction author to specify zero or more preconditions that must be satisfied (in an atomic fashion) before the actual triple additions and deletions occur. A precondition is defined as a Sparql query and an expected result from said query. A dataset must be defined to which the query is run against.
Example:
...
final INamedGraph graph = datasetService.getRemoteGraph("http://testGraph", true);
final Statement stmt = Constants.valueFactory.createStatement(Constants.valueFactory.createURI("http://openanzo.org/subject"),Constants.valueFactory.createURI("http://openanzo.org/predicate1"), Constants.valueFactory.createURI("http://openanzo.org/object1"));
Command testCommand{
public Object execute() {
graph.add(stmt);
return null;
}
};
IPrecondition precondition = new Precondition();
Set<URI> defaults = new HashSet<URI>();
defaults.add(Constants.valueFactory.createURI("http://testGraph"));
precondition.setQuery("ASK { <http://testGraph> " + QueryEncoder.encodeForQuery(NamedGraph.revisionProperty)+" "+ QueryEncoder.encodeForQuery(Constants.valueFactory.createTypedLiteral(new Long(5)))+"}");
precondition.setResult(AskResult.createAskResult(true));
command.addPrecondition(precondition);
graph.executeInTransaction(command);
| Method Summary | |
|---|---|
java.util.Set<org.openrdf.model.URI> |
getDefaultGraphUris()
Get the set of NamedGraph URIs that make up the default graph for the dataset for this precondition. |
java.util.Set<org.openrdf.model.URI> |
getNamedGraphUris()
Get the set of NamedGraph URIs that make up the dataset for this precondition. |
java.lang.String |
getQuery()
Get the Sparql query string that defines the precondition |
IResult |
getResult()
Get the expected result from the sparql query. |
void |
setDefaultGraphUris(java.util.Set<org.openrdf.model.URI> namedGraphUris)
Set the set of NamedGraph URIs that make up the default graph for the dataset for this precondition. |
void |
setNamedGraphUris(java.util.Set<org.openrdf.model.URI> namedGraphUris)
Set the set of NamedGraph URIs that make up the dataset for this precondition. |
void |
setQuery(java.lang.String query)
Set the Sparql query string that defines the precondition. |
void |
setResult(IResult result)
Set the expected result from the sparql query. |
| Method Detail |
|---|
java.util.Set<org.openrdf.model.URI> getNamedGraphUris()
void setNamedGraphUris(java.util.Set<org.openrdf.model.URI> namedGraphUris)
namedGraphUris - Set of NamedGraph URIs that make up the dataset.java.util.Set<org.openrdf.model.URI> getDefaultGraphUris()
void setDefaultGraphUris(java.util.Set<org.openrdf.model.URI> namedGraphUris)
namedGraphUris - Set of NamedGraph URIs that make up the dataset.java.lang.String getQuery()
void setQuery(java.lang.String query)
query - IResult getResult()
void setResult(IResult result)
result - the expected results from the query
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||