incremental development

This commit is contained in:
stellamit 2012-05-23 13:31:11 +00:00
parent 26c7e020e2
commit 726872b443
3 changed files with 110 additions and 6 deletions

View file

@ -5,8 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.rdfservice;
import java.io.InputStream;
import java.util.List;
import edu.cornell.mannlib.vitro.webapp.rdfservice.ModelChange.Operation;
/*
* Input parameter to changeSetUpdate() method in RDFService.
* 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 {
/**
* Getter for the precondition query
*
* @return String - a SPARQL query
*/
public String getPreconditionQuery();
/**
* Setter for the precondition query
*
* @param String - a SPARQL query
*/
public void setPreconditionQuery(String preconditionQuery);
/**
* Getter for the precondition query type
*
* @return RDFService.SPARQLQueryType - the precondition query type
*/
public RDFService.SPARQLQueryType getPreconditionQueryType();
/**
* Setter for the precondition query type
*
* @param RDFService.SPARQLQueryType - the precondition query type
*/
public void setPreconditionQueryType(RDFService.SPARQLQueryType queryType);
/**
* Getter for the list of model changes
*
* @return List<ModelChange> - list of model changes
*/
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,
RDFService.ModelSerializationFormat format,
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,
RDFService.ModelSerializationFormat format,
String graphURI);
/**
* Creates an instance of the ModelChange class
*/
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,
RDFService.ModelSerializationFormat serializationFormat,
Operation operation,
ModelChange.Operation operation,
String graphURI);
}

View file

@ -25,46 +25,96 @@ public class ChangeSetImpl implements ChangeSet {
private RDFService.SPARQLQueryType queryType;
private ArrayList<ModelChange> modelChanges;
/**
* Getter for the precondition query
*
* @return String - a SPARQL query
*/
@Override
public String getPreconditionQuery() {
return preconditionQuery;
}
/**
* Setter for the precondition query
*
* @param String - a SPARQL query
*/
@Override
public void setPreconditionQuery(String preconditionQuery) {
this.preconditionQuery = preconditionQuery;
}
/**
* Getter for the precondition query type
*
* @return RDFService.SPARQLQueryType - the precondition query type
*/
@Override
public RDFService.SPARQLQueryType getPreconditionQueryType() {
return queryType;
}
/**
* Setter for the precondition query type
*
* @param RDFService.SPARQLQueryType - the precondition query type
*/
@Override
public void setPreconditionQueryType(RDFService.SPARQLQueryType queryType) {
this.queryType = queryType;
}
/**
* Getter for the list of model changes
*
* @return List<ModelChange> - list of model changes
*/
@Override
public List<ModelChange> getModelChanges() {
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
public void addAddition(InputStream model, RDFService.ModelSerializationFormat format, String 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
public void addRemoval(InputStream model, RDFService.ModelSerializationFormat format, String graphURI) {
modelChanges.add(manufactureModelChange(model, format, ModelChange.Operation.REMOVE, graphURI));
}
/**
* Creates an instance of the ModelChange class
*/
@Override
public ModelChange manufactureModelChange() {
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
public ModelChange manufactureModelChange(InputStream serializedModel,
RDFService.ModelSerializationFormat serializationFormat,

View file

@ -57,7 +57,13 @@ public class RDFServiceImpl implements RDFService {
/**
* 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) {
this.endpointURI = endpointURI;