uk.ac.ic.doc.automed.wrappers
Class XMLSchemaWrapper

java.lang.Object
  extended by uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
      extended by uk.ac.ic.doc.automed.wrappers.XMLSchemaWrapper

public class XMLSchemaWrapper
extends AutoMedWrapper

Author:
Andrew Charles Smith - acs203 This class provides methods to wrap an XML Schema document or an XML file constrained by an XML Schema in Automed.

Field Summary
static java.lang.String driverString
           
 
Fields inherited from class uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
am, awf, debug, driver, emptyKeyProtection, emptyKeys, optionKeyProtection, optionKeys, password, protocol, s, url, username
 
Constructor Summary
XMLSchemaWrapper()
          Creates a new, empty instance of XMLSchemaWrapper
XMLSchemaWrapper(AccessMethod am, java.lang.String password)
          This constructor is used when querying the schema
 
Method Summary
protected  void connect()
          Check that the XML file exists
 void createXSDOMRepresentation(java.lang.String uri)
          Create an internal representation of the XML Schema.
 boolean deleteIQL(ASG asg)
           
 ASG executeIQL(ASG q)
          Execute an IQL query on the datasource.
 AutoMedResult executeLocalQuery(AutoMedQuery amq)
          Execute a query in the datasource's native query language, and obtain a result in an AutoMedResult class
 ASG executeXMLSchemaQuery(ASG ASGquery)
          Given an IQL query, this method queries the XML file using DOM, then returns the answer in ASG format.
 AutoMedWrapperFactory getAutoMedWrapperFactory()
          Return the AutoMedWrapperFactory currently associated with this wrapper.
protected  AutoMedWrapperFactory getDefaultWrapperFactory()
          Return the default AutoMedWrapperFactory that is used to generate Schema instances from information in a data sources
 Document getDoc()
          Return the XSDOM document
static java.lang.String getDriver()
          The name of the driver string that identifies this wrapper
 java.lang.String getProtocolName()
          The name of the Protocol that this wrapper uses
 java.lang.String getUri()
           
 uk.ac.ic.doc.automed.wrappers.XMLInfo getXMLInfo()
          Return the xmlInfo object for this schema instance
 boolean insertIQL(ASG aSG)
          Execute an IQL insert on the datasource.
 boolean isXMLDoc()
          Was the original document read in an XML document or just a Schema document
static AutoMedWrapper newAutoMedWrapper(java.lang.String username, java.lang.String password, java.lang.String driver, java.lang.String url, java.lang.String schemaName, AutoMedWrapperFactory awf)
          This should be called once per schema file, to configure the repository.
 
Methods inherited from class uk.ac.ic.doc.automed.wrappers.AutoMedWrapper
atDebugLevel, cacheWrapper, getAccessMethod, getAutoMedWrapper, getAutoMedWrapper, getDrivers, getOption, getOptionKeyProtection, getOptionKeys, getProtocol, getQueryParser, getSchema, getSchema, newAutoMedSchema, newAutoMedWrapper, newAutoMedWrapper, registerWrapper, selectNewAutoMedWrapper, selectNewAutoMedWrapper, setDebugLevel, setOption
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

driverString

public static final java.lang.String driverString
See Also:
Constant Field Values
Constructor Detail

XMLSchemaWrapper

public XMLSchemaWrapper()
Creates a new, empty instance of XMLSchemaWrapper


XMLSchemaWrapper

public XMLSchemaWrapper(AccessMethod am,
                        java.lang.String password)
                 throws DataSourceException
This constructor is used when querying the schema

Throws:
DataSourceException
Method Detail

getUri

public java.lang.String getUri()

newAutoMedWrapper

public static AutoMedWrapper newAutoMedWrapper(java.lang.String username,
                                               java.lang.String password,
                                               java.lang.String driver,
                                               java.lang.String url,
                                               java.lang.String schemaName,
                                               AutoMedWrapperFactory awf)
                                        throws IntegrityException,
                                               DataSourceException
This should be called once per schema file, to configure the repository. Subsequent uses of the database should call the constructor for XMLSchemaWrapper with the AccessMethod of the XMLSchemaWrapper returned here.

Parameters:
schemaName - is the name of the Schema to create in the repository to represent the data source.
awf - is an XMLSchemaWrapperFactory instance configured to model the source schema in the desired manner. This may be left null, in which case an XMLSchemaWrapperFactory with default settings will be created.
Throws:
IntegrityException
DataSourceException

connect

protected void connect()
                throws DataSourceException
Check that the XML file exists

Specified by:
connect in class AutoMedWrapper
Throws:
DataSourceException - if unable to connect to the data source

createXSDOMRepresentation

public void createXSDOMRepresentation(java.lang.String uri)
                               throws java.lang.Exception
Create an internal representation of the XML Schema. If we've loaded an XML document the schema will come from the PSVI of the XML document. If we've loaded the schema document directly then we read that

Throws:
java.lang.Exception

deleteIQL

public boolean deleteIQL(ASG asg)
Overrides:
deleteIQL in class AutoMedWrapper

executeIQL

public ASG executeIQL(ASG q)
               throws DataSourceException
Description copied from class: AutoMedWrapper
Execute an IQL query on the datasource.

Specified by:
executeIQL in class AutoMedWrapper
Parameters:
q - An IQL query held in an ASG which complies with the limitations of what this wrapper is able to process
Returns:
An ASG containing the results of the query
Throws:
DataSourceException

executeLocalQuery

public AutoMedResult executeLocalQuery(AutoMedQuery amq)
Description copied from class: AutoMedWrapper
Execute a query in the datasource's native query language, and obtain a result in an AutoMedResult class

Overrides:
executeLocalQuery in class AutoMedWrapper

executeXMLSchemaQuery

public ASG executeXMLSchemaQuery(ASG ASGquery)
Given an IQL query, this method queries the XML file using DOM, then returns the answer in ASG format. Currently supports only schemes.

Parameters:
ASGquery - the IQL query in ASG format
Returns:
the answer to the IQL query in ASG format

isXMLDoc

public boolean isXMLDoc()
Was the original document read in an XML document or just a Schema document


getDoc

public Document getDoc()
Return the XSDOM document


getXMLInfo

public uk.ac.ic.doc.automed.wrappers.XMLInfo getXMLInfo()
Return the xmlInfo object for this schema instance


getDriver

public static java.lang.String getDriver()
The name of the driver string that identifies this wrapper


getAutoMedWrapperFactory

public AutoMedWrapperFactory getAutoMedWrapperFactory()
Description copied from class: AutoMedWrapper
Return the AutoMedWrapperFactory currently associated with this wrapper.

Overrides:
getAutoMedWrapperFactory in class AutoMedWrapper

getDefaultWrapperFactory

protected AutoMedWrapperFactory getDefaultWrapperFactory()
Description copied from class: AutoMedWrapper
Return the default AutoMedWrapperFactory that is used to generate Schema instances from information in a data sources

Specified by:
getDefaultWrapperFactory in class AutoMedWrapper

getProtocolName

public java.lang.String getProtocolName()
Description copied from class: AutoMedWrapper
The name of the Protocol that this wrapper uses

Specified by:
getProtocolName in class AutoMedWrapper

insertIQL

public boolean insertIQL(ASG aSG)
Description copied from class: AutoMedWrapper
Execute an IQL insert on the datasource. Note that in later releases this method will become abstract, but at present no Wrapper implements this method.

Overrides:
insertIQL in class AutoMedWrapper
Parameters:
aSG - is the ASG representation of an IQL query of the form

sub [t1, ..., tn] s

where:
  • 'sub' is the sub-bag builtin function (this has the same semantics as sub-set if operating on sets, which is what the extents of schemes are)
  • [t1, ..., tn] are the tuples to be inserted/deleted
  • s is the scheme that they will be inserted into/deleted from

The semantics and execution of the insert request will depend on the data source e.g. for a relational database it could be translated into a series of INSERT requests within a single transaction, which may fail or succeeed as a whole (and thus return False or True respectively from the insertIQL method). For a non-transactional repository like the HDM or XML flat files, we may choose to allow partial updates e.g. some of a set of tuples are inserted, while some already exist or violate some constraint or another.