uk.co.lakesidetech.springxmldb.spring
Class SimpleXMLDBFacade

java.lang.Object
  extended byuk.co.lakesidetech.springxmldb.spring.SimpleXMLDBFacade
All Implemented Interfaces:
IXMLDBFacade
Direct Known Subclasses:
CachingXMLDBFacade

public class SimpleXMLDBFacade
extends java.lang.Object
implements IXMLDBFacade

A simple implementation of IXMLDBFacade which just delegates to the appropiate dao.

Author:
Stuart Eccles

Constructor Summary
SimpleXMLDBFacade()
           
 
Method Summary
protected  void addXMLDocsToNode(org.jdom.Element node, java.util.Map xmlDocs)
          add a collection of xml documents to a root node
protected  org.w3c.dom.Node convertResultMapToXML(java.util.Map results)
           
 java.lang.String insertUpdateXMLDocument(java.lang.String xmlDocument, java.lang.String docID, java.lang.String collectionPath)
          insert or update a String xml document
protected  java.util.Map produceLimitedMap(java.util.Map results, int limit)
           
 org.w3c.dom.Node queryResourceWithXPathCollectionAsString(java.lang.String resourceId, java.lang.String xPathQuery, java.lang.String collectionPath)
          query a specific resource with xpath
 org.w3c.dom.Node queryWithXPathCollectionAsString(java.lang.String xPathQuery, java.lang.String collectionPath)
          query a collection with xpath
 org.w3c.dom.Node queryWithXPathCollectionAsString(java.lang.String xPathQuery, java.lang.String collectionPath, int noResults)
          query a collection with xpath and limit the number of results obtained
 org.w3c.dom.Node queryWithXQueryCollectionAsString(java.lang.String xQuery, java.lang.String collectionPath)
          query a collection with an XQuery
 org.w3c.dom.Node queryWithXQueryCollectionAsString(java.lang.String xQuery, java.lang.String collectionPath, int noResults)
          query a collection with XQuery and limit to a number of results to return
 org.w3c.dom.Node queryWithXQueryCollectionAsString(java.lang.String xQuery, java.lang.String collectionPath, java.util.Map variables)
          query a collection with XQuery using a map of subsitiution parameters in the xquery
 org.w3c.dom.Node queryWithXQueryCollectionAsString(java.lang.String xQuery, java.lang.String collectionPath, java.util.Map variables, int noResults)
          query a collection with XQuery using a map of subsitiution parameters in the xquery.
 boolean removeDocument(java.lang.String docID, java.lang.String collectionPath)
          remove a document from the xml database
 org.xmldb.api.base.Resource retrieveDocumentAsResource(java.lang.String docID, java.lang.String collectionPath)
          Retrieve a XML:DB Resource object which could a XML or binary document
 java.lang.String retrieveDocumentAsString(java.lang.String docID, java.lang.String collectionPath)
          Retrieve a XML document as a String given the document id and collection path
 void setManageDao(IResourceManageXMLDBDao manageDao)
           
 void setXpathDao(IXPathXMLDBDao xpathDao)
           
 void setXqueryDao(IXQueryXMLDBDao xqueryDao)
           
 void setXupdateDao(IXUpdateXMLDBDao xupdateDao)
           
 void xupdateCollection(java.lang.String xupdate, java.lang.String collectionPath)
          run an xupdate command on an collection in the xml database
 void xupdateXMLDocument(java.lang.String xupdate, java.lang.String docID, java.lang.String collectionPath)
          run an xupdate command on an XML document
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleXMLDBFacade

public SimpleXMLDBFacade()
Method Detail

setXupdateDao

public void setXupdateDao(IXUpdateXMLDBDao xupdateDao)
Parameters:
xupdateDao - The xupdateDao to set.

setManageDao

public void setManageDao(IResourceManageXMLDBDao manageDao)
Parameters:
manageDao - The manageDao to set.

setXpathDao

public void setXpathDao(IXPathXMLDBDao xpathDao)
Parameters:
xpathDao - The xpathDao to set.

setXqueryDao

public void setXqueryDao(IXQueryXMLDBDao xqueryDao)
Parameters:
xqueryDao - The xqueryDao to set.

insertUpdateXMLDocument

public java.lang.String insertUpdateXMLDocument(java.lang.String xmlDocument,
                                                java.lang.String docID,
                                                java.lang.String collectionPath)
Description copied from interface: IXMLDBFacade
insert or update a String xml document

Specified by:
insertUpdateXMLDocument in interface IXMLDBFacade
Parameters:
xmlDocument - the String representation of xml document
docID - the document id to insert or update under
collectionPath - the collection path to insert or update the document in
Returns:
the id of the document

removeDocument

public boolean removeDocument(java.lang.String docID,
                              java.lang.String collectionPath)
Description copied from interface: IXMLDBFacade
remove a document from the xml database

Specified by:
removeDocument in interface IXMLDBFacade
Parameters:
docID - the id of the document to remove
collectionPath - the collection path the document is in
Returns:
true if deleted

retrieveDocumentAsString

public java.lang.String retrieveDocumentAsString(java.lang.String docID,
                                                 java.lang.String collectionPath)
Description copied from interface: IXMLDBFacade
Retrieve a XML document as a String given the document id and collection path

Specified by:
retrieveDocumentAsString in interface IXMLDBFacade
Parameters:
docID - the id of the document to retrieve
collectionPath - the collection the document is under
Returns:
A String XML document

queryWithXPathCollectionAsString

public org.w3c.dom.Node queryWithXPathCollectionAsString(java.lang.String xPathQuery,
                                                         java.lang.String collectionPath)
                                                  throws XMLDBDataAccessException,
                                                         XMLParsingException
Description copied from interface: IXMLDBFacade
query a collection with xpath

Specified by:
queryWithXPathCollectionAsString in interface IXMLDBFacade
Parameters:
xPathQuery - the xpath query
collectionPath - the collection path to query
Returns:
a map of resource ids and results
Throws:
XMLDBDataAccessException
XMLParsingException

queryResourceWithXPathCollectionAsString

public org.w3c.dom.Node queryResourceWithXPathCollectionAsString(java.lang.String resourceId,
                                                                 java.lang.String xPathQuery,
                                                                 java.lang.String collectionPath)
                                                          throws XMLDBDataAccessException,
                                                                 XMLParsingException
Description copied from interface: IXMLDBFacade
query a specific resource with xpath

Specified by:
queryResourceWithXPathCollectionAsString in interface IXMLDBFacade
Parameters:
resourceId - the resource id to query
xPathQuery - the xpath query
collectionPath - the collection path the resource is in
Returns:
a map of resource ids and results
Throws:
XMLDBDataAccessException
XMLParsingException

queryWithXQueryCollectionAsString

public org.w3c.dom.Node queryWithXQueryCollectionAsString(java.lang.String xQuery,
                                                          java.lang.String collectionPath)
                                                   throws XMLDBDataAccessException,
                                                          XMLParsingException
Description copied from interface: IXMLDBFacade
query a collection with an XQuery

Specified by:
queryWithXQueryCollectionAsString in interface IXMLDBFacade
Parameters:
xQuery - the xquery to use
collectionPath - the collection to query
Returns:
a map of resource ids and results
Throws:
XMLDBDataAccessException
XMLParsingException

queryWithXQueryCollectionAsString

public org.w3c.dom.Node queryWithXQueryCollectionAsString(java.lang.String xQuery,
                                                          java.lang.String collectionPath,
                                                          java.util.Map variables)
                                                   throws XMLDBDataAccessException,
                                                          XMLParsingException
Description copied from interface: IXMLDBFacade
query a collection with XQuery using a map of subsitiution parameters in the xquery

Specified by:
queryWithXQueryCollectionAsString in interface IXMLDBFacade
Parameters:
xQuery - teh xquery to use
collectionPath - the collection to query
variables - map of variables which can be used for substitution in the query
Returns:
a map of resource ids and results
Throws:
XMLDBDataAccessException
XMLParsingException

retrieveDocumentAsResource

public org.xmldb.api.base.Resource retrieveDocumentAsResource(java.lang.String docID,
                                                              java.lang.String collectionPath)
Description copied from interface: IXMLDBFacade
Retrieve a XML:DB Resource object which could a XML or binary document

Specified by:
retrieveDocumentAsResource in interface IXMLDBFacade
Parameters:
docID - the resource id to retrieve
collectionPath - the collection the resource is under
Returns:
the XML:DB resource

queryWithXPathCollectionAsString

public org.w3c.dom.Node queryWithXPathCollectionAsString(java.lang.String xPathQuery,
                                                         java.lang.String collectionPath,
                                                         int noResults)
                                                  throws XMLParsingException
Description copied from interface: IXMLDBFacade
query a collection with xpath and limit the number of results obtained

Specified by:
queryWithXPathCollectionAsString in interface IXMLDBFacade
Parameters:
xPathQuery - the xpath query
collectionPath - the colleciton path to query
noResults - the max number of results to return. 0 will return all
Returns:
a map of resource ids and results
Throws:
XMLParsingException

queryWithXQueryCollectionAsString

public org.w3c.dom.Node queryWithXQueryCollectionAsString(java.lang.String xQuery,
                                                          java.lang.String collectionPath,
                                                          int noResults)
                                                   throws XMLParsingException
Description copied from interface: IXMLDBFacade
query a collection with XQuery and limit to a number of results to return

Specified by:
queryWithXQueryCollectionAsString in interface IXMLDBFacade
Parameters:
xQuery - the xquery to use
collectionPath - the collection to query
noResults - the max number of results to return. 0 will return all
Returns:
Throws:
XMLParsingException

queryWithXQueryCollectionAsString

public org.w3c.dom.Node queryWithXQueryCollectionAsString(java.lang.String xQuery,
                                                          java.lang.String collectionPath,
                                                          java.util.Map variables,
                                                          int noResults)
                                                   throws XMLParsingException
Description copied from interface: IXMLDBFacade
query a collection with XQuery using a map of subsitiution parameters in the xquery. limited to a max number of resuls

Specified by:
queryWithXQueryCollectionAsString in interface IXMLDBFacade
Parameters:
xQuery - teh xquery to use
collectionPath - the collection to query
variables - map of variables which can be used for substitution in the query
noResults - max results to return. 0 will return all.
Returns:
a map of resource ids and results
Throws:
XMLParsingException

produceLimitedMap

protected java.util.Map produceLimitedMap(java.util.Map results,
                                          int limit)

convertResultMapToXML

protected org.w3c.dom.Node convertResultMapToXML(java.util.Map results)
                                          throws XMLParsingException
Throws:
XMLParsingException

addXMLDocsToNode

protected void addXMLDocsToNode(org.jdom.Element node,
                                java.util.Map xmlDocs)
                         throws org.jdom.JDOMException,
                                java.io.IOException
add a collection of xml documents to a root node

Parameters:
node - the JDOM node to add to
xmlDocs - a Map of String XML documents
Throws:
org.jdom.JDOMException - parsing the documents
java.io.IOException - input issue

xupdateXMLDocument

public void xupdateXMLDocument(java.lang.String xupdate,
                               java.lang.String docID,
                               java.lang.String collectionPath)
Description copied from interface: IXMLDBFacade
run an xupdate command on an XML document

Specified by:
xupdateXMLDocument in interface IXMLDBFacade
Parameters:
xupdate -
docID -
collectionPath -
Returns:
the id of the document
See Also:
IXMLDBFacade.xupdateXMLDocument(java.lang.String, java.lang.String, java.lang.String)

xupdateCollection

public void xupdateCollection(java.lang.String xupdate,
                              java.lang.String collectionPath)
Description copied from interface: IXMLDBFacade
run an xupdate command on an collection in the xml database

Specified by:
xupdateCollection in interface IXMLDBFacade
Parameters:
xupdate -
collectionPath -
Returns:
the id of the document
See Also:
IXMLDBFacade.xupdateCollection(java.lang.String, java.lang.String)