NIHVIVO-3841 some javadoc updates for RDFService
This commit is contained in:
parent
f997b7073c
commit
2d72b1aa42
11 changed files with 82 additions and 231 deletions
|
@ -2,15 +2,12 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.rdfservice;
|
package edu.cornell.mannlib.vitro.webapp.rdfservice;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
*
|
* An interface for listening to triples that are added to or removed
|
||||||
* A listener that filters all its listening down to the single-statement level. Users of
|
* from the triple store, and other miscellaneous events.
|
||||||
* this class override addedStatement(statement) and removedStatement(statement).
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface ChangeListener {
|
public interface ChangeListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override this to listen to all statements added to the RDF store.
|
* Override this to listen to all statements added to the RDF store.
|
||||||
*
|
*
|
||||||
|
|
|
@ -5,7 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.rdfservice;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
|
@ -13,36 +13,26 @@ import java.util.List;
|
||||||
public interface ChangeSet {
|
public interface ChangeSet {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for the precondition query
|
|
||||||
*
|
|
||||||
* @return String - a SPARQL query
|
* @return String - a SPARQL query
|
||||||
*/
|
*/
|
||||||
public String getPreconditionQuery();
|
public String getPreconditionQuery();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for the precondition query
|
|
||||||
*
|
|
||||||
* @param preconditionQuery - a SPARQL query
|
* @param preconditionQuery - 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
|
* @return RDFService.SPARQLQueryType - the precondition query type
|
||||||
*/
|
*/
|
||||||
public RDFService.SPARQLQueryType getPreconditionQueryType();
|
public RDFService.SPARQLQueryType getPreconditionQueryType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for the precondition query type
|
|
||||||
*
|
|
||||||
* @param queryType - the precondition query type
|
* @param queryType - 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
|
* @return List<ModelChange> - list of model changes
|
||||||
*/
|
*/
|
||||||
public List<ModelChange> getModelChanges();
|
public List<ModelChange> getModelChanges();
|
||||||
|
@ -71,6 +61,8 @@ public interface ChangeSet {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance of the ModelChange class
|
* Creates an instance of the ModelChange class
|
||||||
|
*
|
||||||
|
* @return ModelChange - an empty instance of the ModelChange class
|
||||||
*/
|
*/
|
||||||
public ModelChange manufactureModelChange();
|
public ModelChange manufactureModelChange();
|
||||||
|
|
||||||
|
@ -81,6 +73,9 @@ public interface ChangeSet {
|
||||||
* @param serializationFormat - format of the serialized RDF model
|
* @param serializationFormat - format of the serialized RDF model
|
||||||
* @param operation - the type of operation to be performed with the serialized RDF model
|
* @param operation - the type of operation to be performed with the serialized RDF model
|
||||||
* @param graphURI - URI of the graph on which to apply the model change operation
|
* @param graphURI - URI of the graph on which to apply the model change operation
|
||||||
|
*
|
||||||
|
* @return ModelChange - a ModelChange instance initialized with the input
|
||||||
|
* model, model format, operation and graphURI
|
||||||
*/
|
*/
|
||||||
public ModelChange manufactureModelChange(InputStream serializedModel,
|
public ModelChange manufactureModelChange(InputStream serializedModel,
|
||||||
RDFService.ModelSerializationFormat serializationFormat,
|
RDFService.ModelSerializationFormat serializationFormat,
|
||||||
|
@ -88,31 +83,37 @@ public interface ChangeSet {
|
||||||
String graphURI);
|
String graphURI);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an event that will be be passed to any change listeners in advance of
|
* Adds an event that will be be passed to any change listeners in advance of
|
||||||
* the change set additions and retractions being performed. The event
|
* the change set additions and retractions being performed. The event
|
||||||
* will only be fired if the precondition (if any) is met.
|
* will only be fired if the precondition (if any) is met.
|
||||||
* @param event
|
*
|
||||||
|
* @param event - event to notify listeners of in advance of making
|
||||||
|
* changes to the triple store.
|
||||||
*/
|
*/
|
||||||
public void addPreChangeEvent(Object event);
|
public void addPreChangeEvent(Object event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an event that will be be passed to any change listeners after all of
|
* Adds an event that will be be passed to any change listeners after all of
|
||||||
* the change set additions and retractions are performed.
|
* the change set additions and retractions are performed.
|
||||||
* @param event
|
*
|
||||||
|
* @param event - the event to notify listeners of after the changes are
|
||||||
|
* performed.
|
||||||
*/
|
*/
|
||||||
public void addPostChangeEvent(Object event);
|
public void addPostChangeEvent(Object event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of events to pass to any change listeners in
|
* Returns a list of events to pass to any change listeners in
|
||||||
* advance of the change set additions and retractions being performed.
|
* advance of the change set additions and retractions being performed.
|
||||||
* @return
|
*
|
||||||
|
* @return List<Object>
|
||||||
*/
|
*/
|
||||||
public List<Object> getPreChangeEvents();
|
public List<Object> getPreChangeEvents();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of events to pass to any change listeners after
|
* Returns a list of events to pass to any change listeners after
|
||||||
* the change set additions and retractions are performed.
|
* the change set additions and retractions are performed.
|
||||||
* @return
|
*
|
||||||
|
* @return List<Object>
|
||||||
*/
|
*/
|
||||||
public List<Object> getPostChangeEvents();
|
public List<Object> getPostChangeEvents();
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.rdfservice;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* A ModelChange is one component of a ChangeSet.
|
* A ModelChange is one component of a ChangeSet.
|
||||||
* Represents a model (collection of RDF triples), the URI
|
* Represents a model (collection of RDF triples), the URI
|
||||||
* of a graph, and an indication of whether to add or
|
* of a graph, and an indication of whether to add or
|
||||||
|
@ -18,58 +18,45 @@ public interface ModelChange {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for the serialized model
|
* @return InputStream - the serialized model (collection of RDF triples) representing a change to make
|
||||||
*
|
|
||||||
* @return InputStream - a serialized model (collection of RDF triples) representing a change to make
|
|
||||||
*/
|
*/
|
||||||
public InputStream getSerializedModel();
|
public InputStream getSerializedModel();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for the serialized model
|
* @param serializedModel - the serialized model (collection of RDF triples) representing a change to make
|
||||||
*
|
|
||||||
* @param serializedModel - a serialized model (collection of RDF triples) representing a change to make
|
|
||||||
*/
|
*/
|
||||||
public void setSerializedModel(InputStream serializedModel);
|
public void setSerializedModel(InputStream serializedModel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for the serialization format of the model
|
|
||||||
*
|
|
||||||
* @return RDFService.ModelSerializationFormat - the serialization format of the model
|
* @return RDFService.ModelSerializationFormat - the serialization format of the model
|
||||||
*/
|
*/
|
||||||
public RDFService.ModelSerializationFormat getSerializationFormat();
|
public RDFService.ModelSerializationFormat getSerializationFormat();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for the serialization format of the model
|
|
||||||
*
|
|
||||||
* @param serializationFormat - the serialization format of the model
|
* @param serializationFormat - the serialization format of the model
|
||||||
*/
|
*/
|
||||||
public void setSerializationFormat(RDFService.ModelSerializationFormat serializationFormat);
|
public void setSerializationFormat(RDFService.ModelSerializationFormat serializationFormat);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for the operation type
|
|
||||||
*
|
|
||||||
* @return ModelChange.Operation - the operation to be performed
|
* @return ModelChange.Operation - the operation to be performed
|
||||||
*/
|
*/
|
||||||
public ModelChange.Operation getOperation();
|
public ModelChange.Operation getOperation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for the operation type
|
|
||||||
*
|
|
||||||
* @param operation - the operation to be performed
|
* @param operation - the operation to be performed
|
||||||
*/
|
*/
|
||||||
public void setOperation(ModelChange.Operation operation);
|
public void setOperation(ModelChange.Operation operation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for the URI of the graph to which to apply the change
|
|
||||||
*
|
|
||||||
* @return String - the URI of the graph to which to apply the change
|
* @return String - the URI of the graph to which to apply the change
|
||||||
*/
|
*/
|
||||||
public String getGraphURI();
|
public String getGraphURI();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for the URI of the graph to which to apply the change
|
|
||||||
*
|
|
||||||
* @param graphURI - the URI of the graph to which to apply the change
|
* @param graphURI - the URI of the graph to which to apply the change
|
||||||
|
* If the graphURI is null the change applies to the
|
||||||
|
* default write graph. If this method is not used to
|
||||||
|
* set the write graph the default write graph will be used.
|
||||||
*/
|
*/
|
||||||
public void setGraphURI(String graphURI);
|
public void setGraphURI(String graphURI);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.rdfservice;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Interface for API to write, read, and update Vitro's RDF store, with support
|
* Interface for API to write, read, and update Vitro's RDF store, with support
|
||||||
* to allow listening, logging and auditing.
|
* to allow listening, logging and auditing.
|
||||||
*/
|
*/
|
||||||
|
@ -25,11 +25,11 @@ public interface RDFService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a series of additions to and or removals from specified graphs
|
* Performs a series of additions to and or removals from specified graphs
|
||||||
* in the RDF store. preConditionSparql will be executed against the
|
* in the RDF store. preConditionSparql is executed against the
|
||||||
* union of all the graphs in the knowledge base before any updates are made.
|
* union of all the graphs in the knowledge base before any updates are made.
|
||||||
* If the precondition query returns a non-empty result, no updates
|
* If the precondition query returns a non-empty result, no updates
|
||||||
* will be made.
|
* are made made.
|
||||||
*
|
*
|
||||||
* @param changeSet - a set of changes to be performed on the RDF store.
|
* @param changeSet - a set of changes to be performed on the RDF store.
|
||||||
*
|
*
|
||||||
|
@ -38,8 +38,8 @@ public interface RDFService {
|
||||||
public boolean changeSetUpdate(ChangeSet changeSet) throws RDFServiceException;
|
public boolean changeSetUpdate(ChangeSet changeSet) throws RDFServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the given individual already exists in the default graph, throws an
|
* If the given individual already exists in the default write graph, throws an
|
||||||
* RDFServiceException, otherwise adds one type assertion to the default
|
* RDFServiceException, otherwise adds one type assertion to the default write
|
||||||
* graph.
|
* graph.
|
||||||
*
|
*
|
||||||
* @param individualURI - URI of the individual to be added
|
* @param individualURI - URI of the individual to be added
|
||||||
|
@ -60,7 +60,9 @@ public interface RDFService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a SPARQL construct query against the knowledge base. The query may have
|
* Performs a SPARQL construct query against the knowledge base. The query may have
|
||||||
* an embedded graph identifier.
|
* an embedded graph identifier. If the query does not contain a graph identifier
|
||||||
|
* the query is executed against the union of all named and unnamed graphs in the
|
||||||
|
* store.
|
||||||
*
|
*
|
||||||
* @param query - the SPARQL query to be executed against the RDF store
|
* @param query - the SPARQL query to be executed against the RDF store
|
||||||
* @param resultFormat - type of serialization for RDF result of the SPARQL query
|
* @param resultFormat - type of serialization for RDF result of the SPARQL query
|
||||||
|
@ -72,7 +74,9 @@ public interface RDFService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a SPARQL describe query against the knowledge base. The query may have
|
* Performs a SPARQL describe query against the knowledge base. The query may have
|
||||||
* an embedded graph identifier.
|
* an embedded graph identifier. If the query does not contain a graph identifier
|
||||||
|
* the query is executed against the union of all named and unnamed graphs in the
|
||||||
|
* store.
|
||||||
*
|
*
|
||||||
* @param query - the SPARQL query to be executed against the RDF store
|
* @param query - the SPARQL query to be executed against the RDF store
|
||||||
* @param resultFormat - type of serialization for RDF result of the SPARQL query
|
* @param resultFormat - type of serialization for RDF result of the SPARQL query
|
||||||
|
@ -84,7 +88,9 @@ public interface RDFService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a SPARQL select query against the knowledge base. The query may have
|
* Performs a SPARQL select query against the knowledge base. The query may have
|
||||||
* an embedded graph identifier.
|
* an embedded graph identifier. If the query does not contain a graph identifier
|
||||||
|
* the query is executed against the union of all named and unnamed graphs in the
|
||||||
|
* store.
|
||||||
*
|
*
|
||||||
* @param query - the SPARQL query to be executed against the RDF store
|
* @param query - the SPARQL query to be executed against the RDF store
|
||||||
* @param resultFormat - format for the result of the Select query
|
* @param resultFormat - format for the result of the Select query
|
||||||
|
@ -96,35 +102,41 @@ public interface RDFService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a SPARQL ASK query against the knowledge base. The query may have
|
* Performs a SPARQL ASK query against the knowledge base. The query may have
|
||||||
* an embedded graph identifier.
|
* an embedded graph identifier. If the query does not contain a graph identifier
|
||||||
|
* the query is executed against the union of all named and unnamed graphs in the
|
||||||
|
* store.
|
||||||
*
|
*
|
||||||
* @param query - the SPARQL query to be executed against the RDF store
|
* @param query - the SPARQL ASK query to be executed against the RDF store
|
||||||
*
|
*
|
||||||
* @return boolean - the result of the SPARQL query
|
* @return boolean - the result of the SPARQL ASK query
|
||||||
*/
|
*/
|
||||||
public boolean sparqlAskQuery(String query) throws RDFServiceException;
|
public boolean sparqlAskQuery(String query) throws RDFServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all the graph URIs in the RDF store.
|
* Returns a list of all the graph URIs in the RDF store.
|
||||||
*
|
*
|
||||||
* @return List<String> - list of all the graph URIs in the RDF store
|
* @return List<String> - list of all the named graph URIs in the RDF store.
|
||||||
|
* Return an empty list of there no named graphs in
|
||||||
|
* the store.
|
||||||
*/
|
*/
|
||||||
public List<String> getGraphURIs() throws RDFServiceException;
|
public List<String> getGraphURIs() throws RDFServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TBD - we need to define this method
|
* To be determined. This is a place holder and is not implemented
|
||||||
|
* in current implementations.
|
||||||
*/
|
*/
|
||||||
public void getGraphMetadata() throws RDFServiceException;
|
public void getGraphMetadata() throws RDFServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the URI of the default write graph
|
* Returns the URI of the default write graph
|
||||||
*
|
*
|
||||||
* @return String URI of default write graph
|
* @return String URI of default write graph. Returns null if no
|
||||||
|
* default write graph has been set.
|
||||||
*/
|
*/
|
||||||
public String getDefaultWriteGraphURI() throws RDFServiceException;
|
public String getDefaultWriteGraphURI() throws RDFServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a listener to listen to changes in any graph in
|
* Registers a listener to listen to changes in any graph in
|
||||||
* the RDF store.
|
* the RDF store.
|
||||||
*
|
*
|
||||||
* @param changeListener - the change listener
|
* @param changeListener - the change listener
|
||||||
|
@ -132,23 +144,25 @@ public interface RDFService {
|
||||||
public void registerListener(ChangeListener changeListener) throws RDFServiceException;
|
public void registerListener(ChangeListener changeListener) throws RDFServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregister a listener from listening to changes in
|
* Unregisters a listener from listening to changes in
|
||||||
* the RDF store in any graph.
|
* any graph in the RDF store
|
||||||
*
|
*
|
||||||
* @param changeListener - the change listener
|
* @param changeListener - the change listener
|
||||||
*/
|
*/
|
||||||
public void unregisterListener(ChangeListener changeListener) throws RDFServiceException;
|
public void unregisterListener(ChangeListener changeListener) throws RDFServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a ChangeSet object
|
* Creates a ChangeSet object
|
||||||
*
|
*
|
||||||
* @return ChangeSet an empty ChangeSet object
|
* @return ChangeSet an empty ChangeSet object
|
||||||
*/
|
*/
|
||||||
public ChangeSet manufactureChangeSet();
|
public ChangeSet manufactureChangeSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free any resources held by this RDFService object
|
* Frees any resources held by this RDFService object
|
||||||
|
*
|
||||||
|
* The implementation of this method should be idempotent so that
|
||||||
|
* multiple invocations do not cause an error.
|
||||||
*/
|
*/
|
||||||
public void close();
|
public void close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,20 +4,23 @@ package edu.cornell.mannlib.vitro.webapp.rdfservice;
|
||||||
|
|
||||||
public interface RDFServiceFactory {
|
public interface RDFServiceFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return RDFService - an RDFService instance
|
||||||
|
*/
|
||||||
public RDFService getRDFService();
|
public RDFService getRDFService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a listener to listen to changes in any graph in
|
* Registers a listener to listen to changes in any graph in
|
||||||
* the RDF store. Any RDFService objects returned by this factory should notify
|
* the RDF store. Any RDFService objects returned by this factory
|
||||||
* this listener of changes.
|
* should notify this listener of changes.
|
||||||
*
|
*
|
||||||
* @param changeListener - the change listener
|
* @param changeListener - the change listener
|
||||||
*/
|
*/
|
||||||
public void registerListener(ChangeListener changeListener) throws RDFServiceException;
|
public void registerListener(ChangeListener changeListener) throws RDFServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregister a listener from listening to changes in
|
* Unregisters a listener from listening to changes in the RDF store.
|
||||||
* the RDF store. Any RDFService objects returned by this factory should notify
|
* Any RDFService objects returned by this factory should notify
|
||||||
* this listener of changes.
|
* this listener of changes.
|
||||||
*
|
*
|
||||||
* @param changeListener - the change listener
|
* @param changeListener - the change listener
|
||||||
|
|
|
@ -11,10 +11,6 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.ModelChange;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.ModelChange.Operation;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.ModelChange.Operation;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
|
|
||||||
/*
|
|
||||||
* Input parameter to changeSetUpdate() method in RDFService.
|
|
||||||
* Represents a precondition query and an ordered list of model changes.
|
|
||||||
*/
|
|
||||||
public class ChangeSetImpl implements ChangeSet {
|
public class ChangeSetImpl implements ChangeSet {
|
||||||
|
|
||||||
public ChangeSetImpl() {
|
public ChangeSetImpl() {
|
||||||
|
@ -27,96 +23,46 @@ public class ChangeSetImpl implements ChangeSet {
|
||||||
private ArrayList<Object> preChangeEvents = new ArrayList<Object>();
|
private ArrayList<Object> preChangeEvents = new ArrayList<Object>();
|
||||||
private ArrayList<Object> postChangeEvents = new ArrayList<Object>();
|
private ArrayList<Object> postChangeEvents = new ArrayList<Object>();
|
||||||
|
|
||||||
/**
|
|
||||||
* 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,
|
||||||
|
@ -144,5 +90,4 @@ public class ChangeSetImpl implements ChangeSet {
|
||||||
public List<Object> getPostChangeEvents() {
|
public List<Object> getPostChangeEvents() {
|
||||||
return this.postChangeEvents;
|
return this.postChangeEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,6 @@ import java.io.InputStream;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.ModelChange;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.ModelChange;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
|
|
||||||
/*
|
|
||||||
* A ModelChange is one component of a ChangeSet.
|
|
||||||
* Represents a model (collection of RDF triples), the URI
|
|
||||||
* of a graph, and an indication of whether to add or
|
|
||||||
* remove the model from the graph.
|
|
||||||
*/
|
|
||||||
public class ModelChangeImpl implements ModelChange {
|
public class ModelChangeImpl implements ModelChange {
|
||||||
|
|
||||||
private InputStream serializedModel;
|
private InputStream serializedModel;
|
||||||
|
@ -33,81 +27,41 @@ public class ModelChangeImpl implements ModelChange {
|
||||||
this.graphURI = graphURI;
|
this.graphURI = graphURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for the serialized model
|
|
||||||
*
|
|
||||||
* @return InputStream - a model (collection of RDF triples), serialized
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getSerializedModel() {
|
public InputStream getSerializedModel() {
|
||||||
return serializedModel;
|
return serializedModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter for the serialized model
|
|
||||||
*
|
|
||||||
* @param InputStream - a model (collection of RDF triples), serialized
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setSerializedModel(InputStream serializedModel) {
|
public void setSerializedModel(InputStream serializedModel) {
|
||||||
this.serializedModel = serializedModel;
|
this.serializedModel = serializedModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for the serialization format of the model
|
|
||||||
*
|
|
||||||
* @return RDFService.ModelSerializationFormat - the serialization format of the model
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public RDFService.ModelSerializationFormat getSerializationFormat() {
|
public RDFService.ModelSerializationFormat getSerializationFormat() {
|
||||||
return serializationFormat;
|
return serializationFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter for the serialization format of the model
|
|
||||||
*
|
|
||||||
* @param RDFService.ModelSerializationFormat - the serialization format of the model
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setSerializationFormat(RDFService.ModelSerializationFormat serializationFormat) {
|
public void setSerializationFormat(RDFService.ModelSerializationFormat serializationFormat) {
|
||||||
this.serializationFormat = serializationFormat;
|
this.serializationFormat = serializationFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for the operation type
|
|
||||||
*
|
|
||||||
* @return ModelChange.Operation - the operation type
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Operation getOperation() {
|
public Operation getOperation() {
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter for the operation type
|
|
||||||
*
|
|
||||||
* @param ModelChange.Operation - the operation type
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setOperation(Operation operation) {
|
public void setOperation(Operation operation) {
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for the URI of the graph to which to apply the change
|
|
||||||
*
|
|
||||||
* @return String - the graph URI
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getGraphURI() {
|
public String getGraphURI() {
|
||||||
return graphURI;
|
return graphURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter for the URI of the graph to which to apply the change
|
|
||||||
*
|
|
||||||
* @param String - the graph URI
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setGraphURI(String graphURI) {
|
public void setGraphURI(String graphURI) {
|
||||||
this.graphURI = graphURI;
|
this.graphURI = graphURI;
|
||||||
|
|
|
@ -24,25 +24,12 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.ModelChange;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
|
|
||||||
/*
|
|
||||||
* API to write, read, and update Vitro's RDF store, with support
|
|
||||||
* to allow listening, logging and auditing.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public abstract class RDFServiceImpl implements RDFService {
|
public abstract class RDFServiceImpl implements RDFService {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(RDFServiceImpl.class);
|
private static final Log log = LogFactory.getLog(RDFServiceImpl.class);
|
||||||
protected String defaultWriteGraphURI;
|
protected String defaultWriteGraphURI;
|
||||||
protected List<ChangeListener> registeredListeners = new CopyOnWriteArrayList<ChangeListener>();
|
protected List<ChangeListener> registeredListeners = new CopyOnWriteArrayList<ChangeListener>();
|
||||||
|
|
||||||
/**
|
|
||||||
* If the given individual already exists in the default graph, throws an
|
|
||||||
* RDFServiceException, otherwise adds one type assertion to the default
|
|
||||||
* graph.
|
|
||||||
*
|
|
||||||
* @param String individualURI - URI of the individual to be added
|
|
||||||
* @param String individualTypeURI - URI of the type for the individual
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void newIndividual(String individualURI,
|
public void newIndividual(String individualURI,
|
||||||
String individualTypeURI) throws RDFServiceException {
|
String individualTypeURI) throws RDFServiceException {
|
||||||
|
@ -50,15 +37,6 @@ public abstract class RDFServiceImpl implements RDFService {
|
||||||
newIndividual(individualURI, individualTypeURI, defaultWriteGraphURI);
|
newIndividual(individualURI, individualTypeURI, defaultWriteGraphURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* If the given individual already exists in the given graph, throws an
|
|
||||||
* RDFServiceException, otherwise adds one type assertion to the given
|
|
||||||
* graph.
|
|
||||||
*
|
|
||||||
* @param String individualURI - URI of the individual to be added
|
|
||||||
* @param String individualTypeURI - URI of the type for the individual
|
|
||||||
* @param String graphURI - URI of the graph to which to add the individual
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void newIndividual(String individualURI,
|
public void newIndividual(String individualURI,
|
||||||
String individualTypeURI,
|
String individualTypeURI,
|
||||||
|
@ -89,21 +67,11 @@ public abstract class RDFServiceImpl implements RDFService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the URI of the default write graph
|
|
||||||
*
|
|
||||||
* @return String URI of default write graph
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getDefaultWriteGraphURI() throws RDFServiceException {
|
public String getDefaultWriteGraphURI() throws RDFServiceException {
|
||||||
return defaultWriteGraphURI;
|
return defaultWriteGraphURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a listener to listen to changes in any graph in
|
|
||||||
* the RDF store.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void registerListener(ChangeListener changeListener) throws RDFServiceException {
|
public synchronized void registerListener(ChangeListener changeListener) throws RDFServiceException {
|
||||||
|
|
||||||
|
@ -112,21 +80,11 @@ public abstract class RDFServiceImpl implements RDFService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister a listener from listening to changes in any graph
|
|
||||||
* in the RDF store.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void unregisterListener(ChangeListener changeListener) throws RDFServiceException {
|
public synchronized void unregisterListener(ChangeListener changeListener) throws RDFServiceException {
|
||||||
registeredListeners.remove(changeListener);
|
registeredListeners.remove(changeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a ChangeSet object
|
|
||||||
*
|
|
||||||
* @return a ChangeSet object
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ChangeSet manufactureChangeSet() {
|
public ChangeSet manufactureChangeSet() {
|
||||||
return new ChangeSetImpl();
|
return new ChangeSetImpl();
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class RDFServiceUtils {
|
||||||
case N3:
|
case N3:
|
||||||
return "N3";
|
return "N3";
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("unexpected format in getFormatString");
|
throw new RuntimeException("unexpected format in getSerializationFormatString");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,6 @@ public abstract class RDFServiceJena extends RDFServiceImpl implements RDFServic
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeUsingSparqlUpdate(Dataset dataset, Model model, String graphURI) {
|
private void removeUsingSparqlUpdate(Dataset dataset, Model model, String graphURI) {
|
||||||
|
|
||||||
StmtIterator stmtIt = model.listStatements();
|
StmtIterator stmtIt = model.listStatements();
|
||||||
|
|
||||||
if (!stmtIt.hasNext()) {
|
if (!stmtIt.hasNext()) {
|
||||||
|
@ -236,13 +235,6 @@ public abstract class RDFServiceJena extends RDFServiceImpl implements RDFServic
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void newIndividual(String individualURI, String individualTypeURI,
|
|
||||||
String graphURI) throws RDFServiceException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private InputStream getRDFResultStream(String query, boolean construct,
|
private InputStream getRDFResultStream(String query, boolean construct,
|
||||||
ModelSerializationFormat resultFormat) throws RDFServiceException {
|
ModelSerializationFormat resultFormat) throws RDFServiceException {
|
||||||
DatasetWrapper dw = getDatasetWrapper();
|
DatasetWrapper dw = getDatasetWrapper();
|
||||||
|
@ -353,7 +345,6 @@ public abstract class RDFServiceJena extends RDFServiceImpl implements RDFServic
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getGraphMetadata() throws RDFServiceException {
|
public void getGraphMetadata() throws RDFServiceException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class RDFServiceModel extends RDFServiceJena implements RDFService {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected DatasetWrapper getDatasetWrapper() {
|
protected DatasetWrapper getDatasetWrapper() {
|
||||||
DatasetWrapper datasetWrapper = new DatasetWrapper(new DatasetImpl(model));
|
DatasetWrapper datasetWrapper = new DatasetWrapper(new DatasetImpl(model));
|
||||||
return datasetWrapper;
|
return datasetWrapper;
|
||||||
|
|
Loading…
Add table
Reference in a new issue