Version: 1.1.1

ca.ucalgary.seahawk.util
Class DataUtils

java.lang.Object
  extended by ca.ucalgary.seahawk.util.DataUtils

public class DataUtils
extends Object

Contains methods for the storage and retrieval of Seahawk-specific information from Moby XML payloads, specifically in the context of data provenance for programming-by-example.


Field Summary
static String ARTICLE_PEERS_MODE
           
static String DATATYPE_PEERS_MODE
           
static DocumentBuilder docBuilder
           
static String INPUTSRC_ATTR
           
static String PI_TARGET
           
static String REGISTRY_ATTR
           
static String SERVICEID_ATTR
           
static String SERVICEINPUT_ATTR
           
static String TEMP_FILE_PREFIX
           
static XPathFactory xPathFactory
           
 
Constructor Summary
DataUtils()
           
 
Method Summary
static Boolean addHASXPtrs(List<String> filterList, Element object)
          If any moby object member is in a HAS relationship, add it to the list of filterable items
static void addUserData(MobyDataInstance mdi, URL conditionalOutputURL, FilterSearch filter)
          Record a condition for data acceptability, another service call with an output filter criteria. i.e. records if(f1(x) matches f1's output filter){...}
static void addUserDataToPayload(MobyContentInstance contentInstance, Document sourceDoc)
          Tacks the data provenance info saved as processing instructions during saveInputData() back into the MobyContentInstance loaded from file using the usual, customization-oblivious MobyDataUtils.fromXMLDocument().
static URL createServiceInputFileForPeers(MobyContentInstance peerJobs, MobyDataJob sampleJob)
          Create a temp file that populates the MobyContentInstance from the sample data for all missing fields in peerJobs.
static String elementInContextToNameBasedXPath(Element targetElement)
          Generalizes the element instance into an XPath retrieving it and all similarly nested elements (based on traversing the parent nodes and prepending their names)
static void filterNodes(Node rootNode, Map<String,String> filteredXPtrs)
          Loads targetURL, minus the nodes specified by the xpath keys in filteredXPtrs (map values are not currently used).
static List<String> findFilteredNodes(Document targetDoc, FilterSearch filter, List<String> filterableXPtrs, Map<String,String> xPtrsToFilter, Map<String,Boolean> jobXPtrs, MutableNodeList currentSelectedData, StringBuffer currentSelectionXPath, boolean apply)
          Returns a list of xptrs to filterable nodes in the targetDoc, an populates the list of xptrs that should be filtered according to the provided filter.
static Document findFilteredNodes(URL targetURL, FilterSearch filter, Map<String,String> xPtrsToFilter)
          For one-off filtering of a doc.
static String findMobyJobName(Node n)
           
static Document getInputDoc(Document responseDom)
           
static MobyDataJob getInputSample(Document responseDom, Registry registry)
          Backtrack from a service result to the input doc sent to the service
static MobyDataJob getInputSample(Document responseDom, String jobName, Registry registry)
          Same as two-arg, but retrieves a specific job's input (or null if not a job name found in the doc).
static URL getInputURL(Document responseDom)
           
static List<String> getInputXPtrs(URL serviceResultURL, URL targetInputURL)
          Gets a list of XPointers of the style /1/1/1/4/3/1 from targetInputURL that were used as input to the service call that resulted in serviceResultURL.
static NodeList getPeerElements(Document doc, MobyDataInstance mobyData, Map<String,String> xPtrsToFilter, String peerMode)
          We need to enumerate the possible peer-sets for the selected data item.
static Registry getRegistry(Document responseDoc)
          Find out which registry the service that created the reponse is registered in.
static String getSeahawkAttrFromDoc(Document mobyXmlDoc, String attrName)
           
static String getSeahawkAttrFromDoc(URL docURL, String attrName)
          Retrieves processing instructions embedded in Moby XML docs if they have the for
static MobyService getService(Document responseDoc)
           
static MobyService getService(URL responseURL)
          Find out what the service was that created the given URL.
static String getXPtr(Node n)
           
static MobyDataInstance loadMobyDataFromXPointer(URL docURL, Document domDoc, String targetXptr, Map<String,String> filteredXPtrs, FilterSearch docFilter)
           
static MobyDataInstance loadMobyDataFromXPointer(URL targetURL, Map<String,String> filteredXPtrs, FilterSearch docFilter)
          Get the data instance object associated with a given XPointer in a Moby XML doc.
static void replaceUserData(MobyDataInstance mdi, String selectionXPath)
          Replace the selection xpath info in the data instance
static URL saveOutputData(MobyContentInstance outputData, MobyService payloadSource, MobyContentInstance inputData, String registryEndpoint)
           
static URL saveOutputData(MobyRequestEvent mre)
           
static URL saveOutputData(String output, MobyService payloadSource, URL inputURL, String registryEndpoint)
           
static void setUserData(MobyDataInstance mobyData, URL srcURL, String selectionXPath, String dataSrcXPtr, FilterSearch fs)
          Record the PbE pertinent info about the data to the Moby data object so it can be tracked through the rest of the app.
static void updateInputFilter(URL serviceResultURL, URL sourceServiceResultURL, FilterSearch newFilter)
          Edit a service input document's backtracking references to have a new filter criteria.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PI_TARGET

public static final String PI_TARGET
See Also:
Constant Field Values

REGISTRY_ATTR

public static final String REGISTRY_ATTR
See Also:
Constant Field Values

SERVICEID_ATTR

public static final String SERVICEID_ATTR
See Also:
Constant Field Values

SERVICEINPUT_ATTR

public static final String SERVICEINPUT_ATTR
See Also:
Constant Field Values

INPUTSRC_ATTR

public static final String INPUTSRC_ATTR
See Also:
Constant Field Values

TEMP_FILE_PREFIX

public static final String TEMP_FILE_PREFIX
See Also:
Constant Field Values

docBuilder

public static DocumentBuilder docBuilder

xPathFactory

public static XPathFactory xPathFactory

ARTICLE_PEERS_MODE

public static final String ARTICLE_PEERS_MODE
See Also:
Constant Field Values

DATATYPE_PEERS_MODE

public static final String DATATYPE_PEERS_MODE
See Also:
Constant Field Values
Constructor Detail

DataUtils

public DataUtils()
Method Detail

updateInputFilter

public static void updateInputFilter(URL serviceResultURL,
                                     URL sourceServiceResultURL,
                                     FilterSearch newFilter)
Edit a service input document's backtracking references to have a new filter criteria. This is useful when a user changes filter criteria in the midst of a PbE session.

Parameters:
serviceResultURL - the service result from which the input will be backtracked
sourceServiceResultURL - input sources coming from this service result will be the target for editing
newFilter - the new filter criteria for passing data to the next service

getInputXPtrs

public static List<String> getInputXPtrs(URL serviceResultURL,
                                         URL targetInputURL)
                                  throws Exception
Gets a list of XPointers of the style /1/1/1/4/3/1 from targetInputURL that were used as input to the service call that resulted in serviceResultURL.

Parameters:
serviceResultURL - the service response from which to backtrack the input data
targetInputURL - the service response chain that we're interested in (remember that input can come from multiple docs)
Throws:
Exception

saveOutputData

public static URL saveOutputData(MobyRequestEvent mre)
                          throws Exception
Throws:
Exception

saveOutputData

public static URL saveOutputData(MobyContentInstance outputData,
                                 MobyService payloadSource,
                                 MobyContentInstance inputData,
                                 String registryEndpoint)
                          throws Exception
Throws:
Exception

saveOutputData

public static URL saveOutputData(String output,
                                 MobyService payloadSource,
                                 URL inputURL,
                                 String registryEndpoint)
                          throws Exception
Throws:
Exception

getInputURL

public static URL getInputURL(Document responseDom)
                       throws Exception
Throws:
Exception

getInputDoc

public static Document getInputDoc(Document responseDom)
                            throws Exception
Throws:
Exception

getInputSample

public static MobyDataJob getInputSample(Document responseDom,
                                         Registry registry)
                                  throws Exception
Backtrack from a service result to the input doc sent to the service

Parameters:
responseDom - the XML DOM for the answer from a Moby Web service called in Seahawk
Throws:
Exception

getInputSample

public static MobyDataJob getInputSample(Document responseDom,
                                         String jobName,
                                         Registry registry)
                                  throws Exception
Same as two-arg, but retrieves a specific job's input (or null if not a job name found in the doc).

Throws:
Exception

addUserDataToPayload

public static void addUserDataToPayload(MobyContentInstance contentInstance,
                                        Document sourceDoc)
                                 throws Exception
Tacks the data provenance info saved as processing instructions during saveInputData() back into the MobyContentInstance loaded from file using the usual, customization-oblivious MobyDataUtils.fromXMLDocument().

Throws:
Exception

filterNodes

public static void filterNodes(Node rootNode,
                               Map<String,String> filteredXPtrs)
Loads targetURL, minus the nodes specified by the xpath keys in filteredXPtrs (map values are not currently used).


loadMobyDataFromXPointer

public static MobyDataInstance loadMobyDataFromXPointer(URL targetURL,
                                                        Map<String,String> filteredXPtrs,
                                                        FilterSearch docFilter)
Get the data instance object associated with a given XPointer in a Moby XML doc.

Parameters:
targetURL - of the form URLpath#/1/1/2/1 where /1/1/2/1 is an XPointer, or an standard xpath, to the part of the Moby XML doc to deserialize
filteredXPtrs - a map of the xpointers to data that should NOT be deserialized if children of the targetURL XPointer
docFilter - the current filter applied to the document in targetURL

loadMobyDataFromXPointer

public static MobyDataInstance loadMobyDataFromXPointer(URL docURL,
                                                        Document domDoc,
                                                        String targetXptr,
                                                        Map<String,String> filteredXPtrs,
                                                        FilterSearch docFilter)

elementInContextToNameBasedXPath

public static String elementInContextToNameBasedXPath(Element targetElement)
Generalizes the element instance into an XPath retrieving it and all similarly nested elements (based on traversing the parent nodes and prepending their names)


setUserData

public static void setUserData(MobyDataInstance mobyData,
                               URL srcURL,
                               String selectionXPath,
                               String dataSrcXPtr,
                               FilterSearch fs)
Record the PbE pertinent info about the data to the Moby data object so it can be tracked through the rest of the app.


addUserData

public static void addUserData(MobyDataInstance mdi,
                               URL conditionalOutputURL,
                               FilterSearch filter)
Record a condition for data acceptability, another service call with an output filter criteria. i.e. records if(f1(x) matches f1's output filter){...}


replaceUserData

public static void replaceUserData(MobyDataInstance mdi,
                                   String selectionXPath)
Replace the selection xpath info in the data instance


getSeahawkAttrFromDoc

public static String getSeahawkAttrFromDoc(URL docURL,
                                           String attrName)
                                    throws Exception
Retrieves processing instructions embedded in Moby XML docs if they have the for

Throws:
Exception

getSeahawkAttrFromDoc

public static String getSeahawkAttrFromDoc(Document mobyXmlDoc,
                                           String attrName)
                                    throws Exception
Throws:
Exception

getService

public static MobyService getService(URL responseURL)
                              throws Exception
Find out what the service was that created the given URL.

Parameters:
responseURL - the service response whose origin we should trace
Throws:
Exception

getService

public static MobyService getService(Document responseDoc)
                              throws Exception
Throws:
Exception

getRegistry

public static Registry getRegistry(Document responseDoc)
                            throws Exception
Find out which registry the service that created the reponse is registered in.

Parameters:
responseDoc - the service response whose origin we should trace
Throws:
Exception

getXPtr

public static String getXPtr(Node n)

addHASXPtrs

public static Boolean addHASXPtrs(List<String> filterList,
                                  Element object)
If any moby object member is in a HAS relationship, add it to the list of filterable items


findFilteredNodes

public static Document findFilteredNodes(URL targetURL,
                                         FilterSearch filter,
                                         Map<String,String> xPtrsToFilter)
For one-off filtering of a doc. Populates xPtrsToFilter, and returns the whole doc which you can manipulate yourself (e.g. removing the nodes identified).


findFilteredNodes

public static List<String> findFilteredNodes(Document targetDoc,
                                             FilterSearch filter,
                                             List<String> filterableXPtrs,
                                             Map<String,String> xPtrsToFilter,
                                             Map<String,Boolean> jobXPtrs,
                                             MutableNodeList currentSelectedData,
                                             StringBuffer currentSelectionXPath,
                                             boolean apply)
Returns a list of xptrs to filterable nodes in the targetDoc, an populates the list of xptrs that should be filtered according to the provided filter. In-place edited fields are xPtrsToFilter, jobXPtrs, currentSelectedData, and currentSelectionXPath (for caching efficiency on multiple consecutive calls to this method, such as a live typed search in the UI). The latter three can be null if no caching is desired.


createServiceInputFileForPeers

public static URL createServiceInputFileForPeers(MobyContentInstance peerJobs,
                                                 MobyDataJob sampleJob)
                                          throws Exception
Create a temp file that populates the MobyContentInstance from the sample data for all missing fields in peerJobs. This is used to populate a bunch of jobs at once, iterating over some list of values popped into the peerJobs payload. Used after service wrapping demo to call new service fopr all demo input peers.

Throws:
Exception

getPeerElements

public static NodeList getPeerElements(Document doc,
                                       MobyDataInstance mobyData,
                                       Map<String,String> xPtrsToFilter,
                                       String peerMode)
We need to enumerate the possible peer-sets for the selected data item. Is the user interested in items in the same namespace/data type, or same article name?


findMobyJobName

public static String findMobyJobName(Node n)

Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010