incremental development
This commit is contained in:
parent
26c7e020e2
commit
726872b443
3 changed files with 110 additions and 6 deletions
|
@ -5,8 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.rdfservice;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.ModelChange.Operation;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Input parameter to changeSetUpdate() method in RDFService.
|
* Input parameter to changeSetUpdate() method in RDFService.
|
||||||
* Represents a precondition query and an ordered list of model changes.
|
* Represents a precondition query and an ordered list of model changes.
|
||||||
|
@ -14,28 +12,78 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.ModelChange.Operation;
|
||||||
|
|
||||||
public interface ChangeSet {
|
public interface ChangeSet {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for the precondition query
|
||||||
|
*
|
||||||
|
* @return String - a SPARQL query
|
||||||
|
*/
|
||||||
public String getPreconditionQuery();
|
public String getPreconditionQuery();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for the precondition query
|
||||||
|
*
|
||||||
|
* @param String - a SPARQL query
|
||||||
|
*/
|
||||||
public void setPreconditionQuery(String preconditionQuery);
|
public void setPreconditionQuery(String preconditionQuery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for the precondition query type
|
||||||
|
*
|
||||||
|
* @return RDFService.SPARQLQueryType - the precondition query type
|
||||||
|
*/
|
||||||
public RDFService.SPARQLQueryType getPreconditionQueryType();
|
public RDFService.SPARQLQueryType getPreconditionQueryType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for the precondition query type
|
||||||
|
*
|
||||||
|
* @param RDFService.SPARQLQueryType - the precondition query type
|
||||||
|
*/
|
||||||
public void setPreconditionQueryType(RDFService.SPARQLQueryType queryType);
|
public void setPreconditionQueryType(RDFService.SPARQLQueryType queryType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for the list of model changes
|
||||||
|
*
|
||||||
|
* @return List<ModelChange> - list of model changes
|
||||||
|
*/
|
||||||
public List<ModelChange> getModelChanges();
|
public List<ModelChange> getModelChanges();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds one model change representing an addition to the list of model changes
|
||||||
|
*
|
||||||
|
* @param InputStream - a serialized RDF model (collection of triples)
|
||||||
|
* @param RDFService.ModelSerializationFormat - format of the serialized RDF model
|
||||||
|
* @param String - URI of the graph to which the RDF model should be added
|
||||||
|
*/
|
||||||
public void addAddition(InputStream model,
|
public void addAddition(InputStream model,
|
||||||
RDFService.ModelSerializationFormat format,
|
RDFService.ModelSerializationFormat format,
|
||||||
String graphURI);
|
String graphURI);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds one model change representing a deletion to the list of model changes
|
||||||
|
*
|
||||||
|
* @param InputStream - a serialized RDF model (collection of triples)
|
||||||
|
* @param RDFService.ModelSerializationFormat - format of the serialized RDF model
|
||||||
|
* @param String - URI of the graph from which the RDF model should be removed
|
||||||
|
*/
|
||||||
public void addRemoval(InputStream model,
|
public void addRemoval(InputStream model,
|
||||||
RDFService.ModelSerializationFormat format,
|
RDFService.ModelSerializationFormat format,
|
||||||
String graphURI);
|
String graphURI);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of the ModelChange class
|
||||||
|
*/
|
||||||
public ModelChange manufactureModelChange();
|
public ModelChange manufactureModelChange();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of the ModelChange class
|
||||||
|
*
|
||||||
|
* @param InputStream - a serialized RDF model (collection of triples)
|
||||||
|
* @param RDFService.ModelSerializationFormat - format of the serialized RDF model
|
||||||
|
* @param ModelChange.Operation - the type of operation to be performed with the serialized RDF model
|
||||||
|
* @param String - URI of the graph on which to apply the model change operation
|
||||||
|
*/
|
||||||
public ModelChange manufactureModelChange(InputStream serializedModel,
|
public ModelChange manufactureModelChange(InputStream serializedModel,
|
||||||
RDFService.ModelSerializationFormat serializationFormat,
|
RDFService.ModelSerializationFormat serializationFormat,
|
||||||
Operation operation,
|
ModelChange.Operation operation,
|
||||||
String graphURI);
|
String graphURI);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,46 +25,96 @@ public class ChangeSetImpl implements ChangeSet {
|
||||||
private RDFService.SPARQLQueryType queryType;
|
private RDFService.SPARQLQueryType queryType;
|
||||||
private ArrayList<ModelChange> modelChanges;
|
private ArrayList<ModelChange> modelChanges;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for the precondition query
|
||||||
|
*
|
||||||
|
* @return String - a SPARQL query
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getPreconditionQuery() {
|
public String getPreconditionQuery() {
|
||||||
return preconditionQuery;
|
return preconditionQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for the precondition query
|
||||||
|
*
|
||||||
|
* @param String - a SPARQL query
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setPreconditionQuery(String preconditionQuery) {
|
public void setPreconditionQuery(String preconditionQuery) {
|
||||||
this.preconditionQuery = preconditionQuery;
|
this.preconditionQuery = preconditionQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for the precondition query type
|
||||||
|
*
|
||||||
|
* @return RDFService.SPARQLQueryType - the precondition query type
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public RDFService.SPARQLQueryType getPreconditionQueryType() {
|
public RDFService.SPARQLQueryType getPreconditionQueryType() {
|
||||||
return queryType;
|
return queryType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for the precondition query type
|
||||||
|
*
|
||||||
|
* @param RDFService.SPARQLQueryType - the precondition query type
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setPreconditionQueryType(RDFService.SPARQLQueryType queryType) {
|
public void setPreconditionQueryType(RDFService.SPARQLQueryType queryType) {
|
||||||
this.queryType = queryType;
|
this.queryType = queryType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for the list of model changes
|
||||||
|
*
|
||||||
|
* @return List<ModelChange> - list of model changes
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<ModelChange> getModelChanges() {
|
public List<ModelChange> getModelChanges() {
|
||||||
return modelChanges;
|
return modelChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds one model change representing an addition to the list of model changes
|
||||||
|
*
|
||||||
|
* @param InputStream - a serialized RDF model (collection of triples)
|
||||||
|
* @param RDFService.ModelSerializationFormat - format of the serialized RDF model
|
||||||
|
* @param String - URI of the graph to which the RDF model should be added
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addAddition(InputStream model, RDFService.ModelSerializationFormat format, String graphURI) {
|
public void addAddition(InputStream model, RDFService.ModelSerializationFormat format, String graphURI) {
|
||||||
modelChanges.add(manufactureModelChange(model,format, ModelChange.Operation.ADD, graphURI));
|
modelChanges.add(manufactureModelChange(model,format, ModelChange.Operation.ADD, graphURI));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds one model change representing a deletion to the list of model changes
|
||||||
|
*
|
||||||
|
* @param InputStream - a serialized RDF model (collection of triples)
|
||||||
|
* @param RDFService.ModelSerializationFormat - format of the serialized RDF model
|
||||||
|
* @param String - URI of the graph from which the RDF model should be removed
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addRemoval(InputStream model, RDFService.ModelSerializationFormat format, String graphURI) {
|
public void addRemoval(InputStream model, RDFService.ModelSerializationFormat format, String graphURI) {
|
||||||
modelChanges.add(manufactureModelChange(model, format, ModelChange.Operation.REMOVE, graphURI));
|
modelChanges.add(manufactureModelChange(model, format, ModelChange.Operation.REMOVE, graphURI));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of the ModelChange class
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ModelChange manufactureModelChange() {
|
public ModelChange manufactureModelChange() {
|
||||||
return new ModelChangeImpl();
|
return new ModelChangeImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of the ModelChange class
|
||||||
|
*
|
||||||
|
* @param InputStream - a serialized RDF model (collection of triples)
|
||||||
|
* @param RDFService.ModelSerializationFormat - format of the serialized RDF model
|
||||||
|
* @param ModelChange.Operation - the type of operation to be performed with the serialized RDF model
|
||||||
|
* @param String - URI of the graph on which to apply the model change operation
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ModelChange manufactureModelChange(InputStream serializedModel,
|
public ModelChange manufactureModelChange(InputStream serializedModel,
|
||||||
RDFService.ModelSerializationFormat serializationFormat,
|
RDFService.ModelSerializationFormat serializationFormat,
|
||||||
|
|
|
@ -57,7 +57,13 @@ public class RDFServiceImpl implements RDFService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an RDFService for a remote repository
|
* Returns an RDFService for a remote repository
|
||||||
* @param endpointURI
|
* @param String - URI of the SPARQL endpoint for the knowledge base
|
||||||
|
* @param String - URI of the default write graph within the knowledge base.
|
||||||
|
* this is the graph that will be written to when a graph
|
||||||
|
* is not explicitly specified.
|
||||||
|
*
|
||||||
|
* The default read graph is the union of all graphs in the
|
||||||
|
* knowledge base
|
||||||
*/
|
*/
|
||||||
public RDFServiceImpl(String endpointURI, String defaultWriteGraphURI) {
|
public RDFServiceImpl(String endpointURI, String defaultWriteGraphURI) {
|
||||||
this.endpointURI = endpointURI;
|
this.endpointURI = endpointURI;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue