edu.ucsb.nceas.morpho.datapackage
Class AbstractDataPackage

java.lang.Object
  extended byedu.ucsb.nceas.morpho.datapackage.MetadataObject
      extended byedu.ucsb.nceas.morpho.datapackage.AbstractDataPackage
All Implemented Interfaces:
XMLFactoryInterface
Direct Known Subclasses:
EML200DataPackage, EML2Beta6DataPackage

public abstract class AbstractDataPackage
extends MetadataObject
implements XMLFactoryInterface

class that represents a data package. This class is abstract. Specific datapackages e.g. eml2, beta6., etc extend this abstact class

actually, only the load and serialize methods are abstract. A number of other concrete utlity methods are included in this class. Note that this class extends the MetadataObject class. The essense of this class is thus the DOM metadataNode (which contains references to all the Nodes in the DOM and the metadataPathNode. The metadataPathNode references an XML structure which maps generic DataPackage information to specific paths for the grammar being considered. Thus, handling changes in the grammar of eml2, for example, should just require one to create a new map from generic nodes to the new specific ones.

----- A description of how this class is to be used-----

New DataPackage class for Morpho for handling EML2 and other metadata content standards

It is desired to create a new class for representing 'generic' dataPackage objects, with EML2 being the immediate goal. It is desired, however, to avoid being too specific so that changes in standards can easily be configured without major code re-writes. This memo attempts to describe the current design.

A simplified class diagram is shown below for discussion purposes.

  MetadataObject  <----------------  AbstractDataPackage  <---------- EML200DataPackage
  <---------- NBIIBioDataPackage       <----DataPackageFactory
  <---------- EML2Beta6DataPackage
 

The base class is 'MetadataObject'. Basically, this class just a DOM structure containing the metadata for a defined schema (the 'schemaGrammer'(i.e. doctype) is also a member variable for the class) . There is also a member called the 'xpathKeyMap'. This is supposed to be a reference to a set of mappings between generic concepts (e.g. the package name) and the specific DOM xpath to the node in the specific DOM that contains the actual concept. This map is stored in a properties file of some type (e.g. an XML file) that is read at run time. Thus, minor changes in a schema can be handled by just updating this properties file rather than changing the code.

Now, the 'AbstractDataPackage' class extends the very general purpose 'MetadataObject' class and is meant to be used specifically for representing dataPackages of different types. The class is call 'Abstract...' because there are certain actions (like 'load' and 'serialize' that a specific to the schemaGrammar. Thus the 'AbstractDataPackage' class is extended by various schema specific classes such as the three shown above (i.e. EML200DataPackage, NBIIBioDataPackage, and EML2Beta6DataPackage). Note that the xpathKeyMap used is different for each of these specific package classes.

Finally, the DataPackageFactory class is used to create a new datapackage object f rom a supplied DOM or from a docID of a document on metacat or stored locally. A factory method is needed so that it can determine just what schema is desired and which of the specific package classes should be used to create the object. Once created, however, methods in the AbstractDataPackage that are generic can be used to get information stored in the package.

xpathKeyMap

Consider now how the xpathKeyMap works. An example in XML format for eml200 is reproduced below. It should be noted that this example is organized as a set of 'contextNode' elements. The 'package' contextNode corresponds to the root of datapackage DOM while other contextNodes, like 'entity' refer to some node in the dom other than the root. The contextNode serves as the point of departure for XPath searches. The concept allows for relative searche - e.g. one can give paths relative to the entity context node.

An example of xpathKeyMap use is the problem of finding the "accessionNumber" for a generic metadata schema. The document below has an 'accessionNumber' element under the 'package' contextNode. It's value for eml2 is seen to be '/eml:eml/@packageId'. ONe first looks up this value in the xpathKeyMap and then applies the xpath to the eml2 dataPackage dom. We have thus added a level of indirection where specific paths are looked up in the xpathKeyMap using generic path names.

As another example, one would look at the 'name' element under the 'entity' contextNode to get an entity name. In this case the relative path is simply 'entityName'. But how does one get the actual entity contextNode where the relative path starts? In this example, the higher level 'entities' element under the package contextNode is an xpath that will return a NodeSet of entity nodes in the eml2 dom. Each of these nodes is a starting point for the entity information (i.e. the root of the entity subtree).

  
  <?xml version="1.0"?>
  <xpathKeyMap schemaGrammar="eml2.0.0">
  <!-- element name is key, element value is Xpath for this grammar -->
  <contextNode name="package">
    <entities>/eml:eml/dataset/dataTable</entities>
    <title>/eml:eml/dataset/title</title>
    <author>/eml:eml/dataset/creator/individualName/surName</author>
    <accessionNumber>/eml:eml/@packageId</accessionNumber>
    <keywords>/eml:eml/dataset/keywordSet/keyword</keywords>
  </contextNode>
  <!-- Xpaths for entity values are defined as relative to top node of entity -->
  <contextNode name="entity">
    <name>entityName</name>
    <numRecords>numberOfRecords</numRecords>
    <entityDescription>entityDescription</entityDescription >
    <physical>physical</physical>
    <attributes>attributeList/attribute</attributes>
  </contextNode>
  <contextNode name="attribute">
    <name>attributeName</name>
    <dataType>storageType</dataType>
    <isText>count(measurementScale/nominal|measurementScale/ordinal)!=0</isText>
    <isDate>count(measurementScale/datetime)!=0</isDate>
  </contextNode>
  <contextNode name="physical">
    <name>objectName</name>
    <fieldDelimiter>dataFormat/textFormat/simpleDelimited/fieldDelimiter</fieldDelimiter>
    <numberHeaderLines>dataFormat/textFormat/numHeaderLines</numberHeaderLines>
    <size>size</size>
    <format>dataFormat/externallyDefinedFormat/formatName</format>
    <isText>count(dataFormat/textFormat)!=0</isText>
    <distribution>distribution</distribution>
  </contextNode>
  <contextNode name="distribution">
    <isOnline>count(online/url)!=0</isOnline>
    <url>online/url</url>
    <isInline>count(inline)!=0</isInline>
    <inline>inline</inline>
  </contextNode>
  </xpathKeyMap>
  


Field Summary
static java.lang.String BOTH
          used to signify that this package is stored on metacat and locally.
protected  ConfigXML config
           
protected  java.io.File dataPkgFile
           
protected  Entity[] entityArray
           
protected  FileSystemDataStore fileSysDataStore
           
protected  java.lang.String id
           
protected  java.lang.String initialId
           
static java.lang.String LOCAL
          used to signify that this package is located locally
protected  java.lang.String location
           
static java.lang.String METACAT
          used to signify that this package is located on a metacat server
protected  MetacatDataStore metacatDataStore
           
 
Fields inherited from class edu.ucsb.nceas.morpho.datapackage.MetadataObject
doc, grammar, grammarType, metadataNode, metadataPathNode, root
 
Constructor Summary
AbstractDataPackage()
           
 
Method Summary
 void addAttributeForImport(java.lang.String entityName, java.lang.String attributeName, java.lang.String scale, OrderedMap omap, java.lang.String xPath, boolean newTable)
           
 void addEntity(Entity entity)
          This method automatically adds an entity in the DOM at the next available position
 void addNewUnit(java.lang.String unitType, java.lang.String unit)
           
 org.w3c.dom.Node appendAdditionalMetadata(org.w3c.dom.Node addtMetadata)
           
 void clearAllAttributeImports()
           
 void delete(java.lang.String location)
          Deletes the package from the specified location
 void deleteAllEntities()
          This method deletes the indexed entity from the DOM
 java.util.List deleteAllSubtrees(java.lang.String genericName)
          DELETES ALL subtrees identified by genericName String; returns null if none found - USE WITH CARE!!
 void deleteAttribute(int entityIndex, int attributeIndex)
          This method deletes the indexed attribute from the indexed entity
 void deleteEntity(int entNum)
          This method deletes the indexed entity from the DOM
 org.w3c.dom.Node deleteSubtree(java.lang.String genericName, int index)
          deletes subtree at location identified by genericName and index; returns root Node of deleted subtree, or null if not found, so caller can determine whether call was successful
abstract  AbstractDataPackage download(java.lang.String id)
          Copies the AbstractDataPackage with the indicated id from metacat to the local file store
 void export(java.lang.String path)
          exports a package to a given path
 void exportDataFiles(java.lang.String path)
          copies all the data files in a package to a directory indicated by 'path'.
 void exportToZip(java.lang.String path)
          Exports a package to a zip file at the given path
 java.lang.String getAccessionNumber()
          convenience method to retrieve accession number from DOM
 org.w3c.dom.Node[] getAttributeArray(int entityIndex)
          This method creates an array of attribute Nodes for the indexed entity in the entityNode array.
 int getAttributeCountForAnEntity(int entityIndex)
          This method gets the count of the attributes present in a particular entity
 java.lang.String getAttributeDataType(int entityIndex, int attributeIndex)
           
 java.lang.String getAttributeID(int entityIndex, int attributeIndex)
           
 int getAttributeImportCount()
           
 int getAttributeIndex(int entityIndex, java.lang.String attributeName)
          This method retreives the attribute index given an Attribute Name and the index of the entity that the attribute is present in.
 java.lang.String getAttributeName(int entityIndex, int attributeIndex)
           
 java.lang.String getAttributeUnit(int entityIndex, int attributeIndex)
           
 java.lang.String getAuthor()
          convenience method to get the DataPackage author May be overridden for specific package types to give better response (e.g.
 java.lang.String getCompressionMethod(int entityIndex, int physicalIndex)
          This method returns the compression method for the indexed entity and physical object.
 org.w3c.dom.Node getCoverageNode()
          checks to see if the package has a coverage element at the package level returns a Node if it finds one; otherwise, null
 java.lang.String getCurrentImportAttributeName()
           
 java.lang.String getCurrentImportEntityName()
           
 OrderedMap getCurrentImportMap()
           
 java.lang.String getCurrentImportScale()
           
 java.lang.String getCurrentImportXPath()
           
 org.w3c.dom.Node[] getDistributionArray(int entityIndex, int physicalIndex)
          This method creates an array of 'distribution' nodes, following the eml2 model of a subtree with information about the distribution of the actual data being characterized by the metadata.
 java.lang.String getDistributionInlineData(int entityIndex, int physicalIndex, int distIndex)
          This method returns 'inline' data as a String for the indexed entity, physical object, and distribution object.
 java.lang.String getDistributionUrl(int entityIndex, int physicalIndex, int distIndex)
          This method returns the url for data as a String for the indexed entity, physical object, and distribution object.
 java.lang.String getEncodingMethod(int entityIndex, int physicalIndex)
          This method returns the encoding method for the indexed entity and physical object.
 Entity[] getEntityArray()
           
 int getEntityCount()
          This method gets the count of the entities present in the package
 java.lang.String getEntityDescription(int entNum)
          This method retrieves the entity Description, given the index of the entity in the entityNode array
 java.lang.String getEntityID(int entNum)
          This method retrieves the entity ID, given the index of the entity in the entityNode array
 int getEntityIndex(java.lang.String entName)
          This method retrieves entity index information, given the name of the entity in the entityNode array
 java.lang.String getEntityName(int entNum)
          This method retrieves entityName information, given the index of the entity in the entityNode array
 java.lang.String getEntityNumRecords(int entNum)
          This method retrieves the number of records in thr entity, given the index of the entity in the entityNode array
protected  java.io.File getFileWithID(java.lang.String ID, Morpho morpho)
           
 org.w3c.dom.NodeList getGeographicNodeList()
          gets a list of geographic nodes
 java.util.List getIDsForNodesWithName(java.lang.String genericName)
          returns a java.util.List containing IDs of all the rootnodes of all the subtrees identified by the passed unique String.
 java.lang.String getInitialId()
          gets the initialId variable
 java.lang.String getKeywords()
          convenience method for getting package keywords
 java.util.List getLastImportedAttributes()
           
 java.util.Vector getLastImportedDataSet()
           
 java.lang.String getLastImportedEntity()
           
 java.lang.String getLocation()
          Method to return the location
 java.lang.String getNewUniqueReferenceID()
          returns a new refID that is guaranteed to be unique within this datapackage
 Entity[] getOriginalEntityArray()
           
 java.lang.String getPackageId()
          convenience method to retrieve packageID from DOM synonym for getAccessionNumber
 org.w3c.dom.Node[] getPhysicalArray(int entityIndex)
           
 java.lang.String getPhysicalFieldDelimiter(int entityIndex, int physicalIndex)
          This method returns the FieldDelimiter for the indexed entity and physical object.
 java.lang.String getPhysicalFormat(int entityIndex, int physicalIndex)
          This method returns the physocal format.
 java.lang.String getPhysicalName(int entityIndex, int physicalIndex)
          This method returns the name of indexed physical object for the indicated entity index.
 java.lang.String getPhysicalNumberHeaderLines(int entityIndex, int physicalIndex)
          This method returns the number of header lines for the indexed entity and physical object.
 java.lang.String getPhysicalSize(int entityIndex, int physicalIndex)
          This method returns the size for the indexed entity and physical object.
 OrderedMap getSecondImportMap()
           
 org.w3c.dom.Node getSubtree(java.lang.String genericName, int index)
          returns cloned root Node of subtree identified by genericName String and int index; returns null if not found NOTE: the cloned subtree is a new node.
abstract  org.w3c.dom.Node getSubtreeAtReference(java.lang.String refID)
          returns cloned root Node of subtree identified by the passed unique String refID; returns null if not found
abstract  org.w3c.dom.Node getSubtreeAtReferenceNoClone(java.lang.String refID)
          returns pointer to root Node of subtree identified by the passed unique String refID; returns null if not found
 org.w3c.dom.Node getSubtreeNoClone(java.lang.String genericName, int index)
          returns root Node of subtree identified by genericName String and int index; returns null if not found
 java.util.List getSubtrees(java.lang.String genericName)
          returns a List of cloned root Nodes of subtrees identified by genericName String; returns null if not found NOTE: the cloned subtrees are new nodes.
abstract  java.util.List getSubtreesThatReference(java.lang.String refID)
          returns a List of pointers to subtrees that reference (the subtree identified by) the passed refID.
 org.w3c.dom.NodeList getTaxonomicNodeList()
          gets a list of taxonomic nodes
 org.w3c.dom.NodeList getTemporalNodeList()
          gets a list of temporal nodes
 java.lang.String getTitle()
          convenience method to get the DataPackage title
 java.lang.String[] getUnitDictionaryCustomUnitTypes()
           
 java.lang.String[] getUnitDictionaryUnitsOfType(java.lang.String type)
           
abstract  boolean ignoreConsecutiveDelimiters(int entityIndex, int physicalIndex)
          returns boolean indicating whether repeated delimiters should be ignored
 void insertAttribute(int entityIndex, Attribute newAttr, int attrIndex)
          This method inserts an attribute at the indexed position in the indexed entity
 void insertCoverage(org.w3c.dom.Node covSubtree)
          insert a coverage subtree (geographic, temporal, or taxonomic) under the package level coverage node 'covSubtree' is assumed to be a DOM subtree of the proper type to be added under a coverage node
 void insertEntity(Entity entity, int pos)
          This method inserts an entity in the DOM at the indexed position
static void insertObjectIntoArray(java.lang.Object[] arr, java.lang.Object value, java.lang.Object[] newArr)
           
 org.w3c.dom.Node insertSubtree(java.lang.String genericName, org.w3c.dom.Node subtreeRootNode, int index)
          inserts subtree rooted at Node, at location identified by genericName String and int index.
 boolean isCurrentImportNewTable()
           
 boolean isNewCustomUnit(java.lang.String type, java.lang.String unit)
           
abstract  void load(java.lang.String location, java.lang.String identifier, Morpho morpho)
          This abstract method loads a datapackage from metacat or the local file system based on an identifier.
 void loadCustomUnits()
           
 org.w3c.dom.Document openAsDom(java.lang.String id)
          method to return a DOM Document rather than a Reader Since the real purppose is to provide the source for an XSLT transform a DOM can passed instead of a Reader.
 java.io.Reader openAsReader(java.lang.String id)
          method to return a Reader object, which will provide access to a character-based resource.
 void removeAttributeForImport()
           
 void removeGeographicNodes()
          remove all the geographicNodes
 void removeTaxonomicNodes()
          remove all the taxonomicNodes
 void removeTemporalNodes()
          remove all the temporalNodes
 org.w3c.dom.Node replaceSubtree(java.lang.String genericName, org.w3c.dom.Node newSubtreeRootNode, int index)
          replaces subtree at location identified by genericName and index; returns root Node of replaced subtree, or null if not found, so caller can determine whether replace was successful
abstract  org.w3c.dom.Node replaceSubtreeAtReference(java.lang.String refID, org.w3c.dom.Node newSubtreeRoot)
          replaces subtree identified by the passed unique String refID; returns null if not found.
abstract  void serialize(java.lang.String location)
          This abstract method turns the datapackage into a form (e.g.
 void serializeData()
           
 void setAccessionNumber(java.lang.String id)
          convenience method to set accession number from DOM
 void setDistributionUrl(int entityIndex, int physicalIndex, int distIndex, java.lang.String urlS)
          This method sets the url for data as a String for the indexed entity, physical object, and distribution object.
 void setEntityID(int entNum, java.lang.String ID)
          This method sets the entity ID, given the index of the entity in the entityNode array and the ID.
 void setEntityNumRecords(int entNum, java.lang.String numRecS)
          This method sets the number of records in the entity, given the index of the entity in the entityNode array
 void setInitialId(java.lang.String initId)
          sets the initialId variable
 void setLastImportedAttributes(java.util.List attr)
           
 void setLastImportedDataSet(java.util.Vector data)
           
 void setLastImportedEntity(java.lang.String name)
           
 void setLocation(java.lang.String location)
          Method to set the location
 void setOriginalEntityArray(Entity[] arr)
           
 void setPhysicalFieldDelimiter(int entityIndex, int physicalIndex, java.lang.String delim)
          This method sets the FieldDelimiter for the indexed entity and physical object.
 void setPhysicalSize(int entityIndex, int physicalIndex, java.lang.String sizeS)
          This method sets the size for the indexed entity and physical object.
 void showPackageSummary()
          This method displays a summary of Package information by calling the various utility methods defined in this class.
 boolean subtreeExists(java.lang.String genericName, int index)
          convenience method to check if requested subtree exists (as identified by genericName String and int index).
abstract  AbstractDataPackage upload(java.lang.String id, boolean updatePackageId)
          Copies the AbstractDataPackage with the indicated id from the local file store to Metacat
 
Methods inherited from class edu.ucsb.nceas.morpho.datapackage.MetadataObject
getGenericValue, getMetadataNode, getMetadataPath, getXPathValue, main, setGenericValue, setMetadataNode, setMetadataPath, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

location

protected java.lang.String location

id

protected java.lang.String id

config

protected ConfigXML config

dataPkgFile

protected java.io.File dataPkgFile

fileSysDataStore

protected FileSystemDataStore fileSysDataStore

metacatDataStore

protected MetacatDataStore metacatDataStore

initialId

protected java.lang.String initialId

entityArray

protected Entity[] entityArray

METACAT

public static final java.lang.String METACAT
used to signify that this package is located on a metacat server

See Also:
Constant Field Values

LOCAL

public static final java.lang.String LOCAL
used to signify that this package is located locally

See Also:
Constant Field Values

BOTH

public static final java.lang.String BOTH
used to signify that this package is stored on metacat and locally.

See Also:
Constant Field Values
Constructor Detail

AbstractDataPackage

public AbstractDataPackage()
Method Detail

serialize

public abstract void serialize(java.lang.String location)
                        throws MetacatUploadException
This abstract method turns the datapackage into a form (e.g. string) that can be saved in the file system or metacat. Actual implementation is done in classes specific to grammar

Parameters:
location - String
Returns:
true if there is no indicated problem; false, otherwise
Throws:
MetacatUploadException

load

public abstract void load(java.lang.String location,
                          java.lang.String identifier,
                          Morpho morpho)
This abstract method loads a datapackage from metacat or the local file system based on an identifier. Basic action is to create a DOM and assign it to the underlying MetadataObject. Actual implementation is done in classes specific to grammar

Parameters:
location - String
identifier - String
morpho - Morpho

upload

public abstract AbstractDataPackage upload(java.lang.String id,
                                           boolean updatePackageId)
                                    throws MetacatUploadException
Copies the AbstractDataPackage with the indicated id from the local file store to Metacat

Parameters:
id - String
Returns:
AbstractDataPackage
Throws:
MetacatUploadException

download

public abstract AbstractDataPackage download(java.lang.String id)
Copies the AbstractDataPackage with the indicated id from metacat to the local file store

Parameters:
id - String
Returns:
AbstractDataPackage

getFileWithID

protected java.io.File getFileWithID(java.lang.String ID,
                                     Morpho morpho)
                              throws java.lang.Throwable
Throws:
java.lang.Throwable

setInitialId

public void setInitialId(java.lang.String initId)
sets the initialId variable


getInitialId

public java.lang.String getInitialId()
gets the initialId variable


getLocation

public java.lang.String getLocation()
Method to return the location

Returns:
String

setLocation

public void setLocation(java.lang.String location)
Method to set the location

Parameters:
location - String

getTitle

public java.lang.String getTitle()
convenience method to get the DataPackage title

Returns:
String

getAuthor

public java.lang.String getAuthor()
convenience method to get the DataPackage author May be overridden for specific package types to give better response (e.g. in eml2, folds together several elements and authors)

Returns:
String

getAccessionNumber

public java.lang.String getAccessionNumber()
convenience method to retrieve accession number from DOM

Returns:
String

getPackageId

public java.lang.String getPackageId()
convenience method to retrieve packageID from DOM synonym for getAccessionNumber

Returns:
String

setAccessionNumber

public void setAccessionNumber(java.lang.String id)
convenience method to set accession number from DOM

Parameters:
id - String

getKeywords

public java.lang.String getKeywords()
convenience method for getting package keywords

Returns:
String

subtreeExists

public boolean subtreeExists(java.lang.String genericName,
                             int index)
convenience method to check if requested subtree exists (as identified by genericName String and int index).

Parameters:
genericName - String
index - int
Returns:
returns true if requested subtree exists (as identified by genericName String and int index). Returns false otherwise

getSubtree

public org.w3c.dom.Node getSubtree(java.lang.String genericName,
                                   int index)
returns cloned root Node of subtree identified by genericName String and int index; returns null if not found NOTE: the cloned subtree is a new node. That new node is copied to a new Document object and made the root of the new document

Parameters:
genericName - String
index - int
Returns:
cloned root Node of subtree, or null if not found

getSubtrees

public java.util.List getSubtrees(java.lang.String genericName)
returns a List of cloned root Nodes of subtrees identified by genericName String; returns null if not found NOTE: the cloned subtrees are new nodes. Each new node is copied to a new Document object and made the root of the new document

Parameters:
genericName - String
Returns:
List containing the cloned root Nodes of subtrees, or an empty list if none found. Never returns null

getSubtreeAtReference

public abstract org.w3c.dom.Node getSubtreeAtReference(java.lang.String refID)
returns cloned root Node of subtree identified by the passed unique String refID; returns null if not found

Parameters:
refID - unique String refID
Returns:
cloned root Node of subtree, or null if refID not found

getSubtreeAtReferenceNoClone

public abstract org.w3c.dom.Node getSubtreeAtReferenceNoClone(java.lang.String refID)
returns pointer to root Node of subtree identified by the passed unique String refID; returns null if not found

Parameters:
refID - unique String refID
Returns:
pointer to root Node of subtree, or null if refID not found

replaceSubtreeAtReference

public abstract org.w3c.dom.Node replaceSubtreeAtReference(java.lang.String refID,
                                                           org.w3c.dom.Node newSubtreeRoot)
replaces subtree identified by the passed unique String refID; returns null if not found. Note that the new subtree will be given the same refID as the subtree it replaces, even if the newSubtreeRoot node has a different id set

Parameters:
refID - unique String refID. Note that the new subtree will be given the same refID as the subtree it replaces, even if the newSubtreeRoot node has a different id set
newSubtreeRoot - Node
Returns:
root Node of new subtree, or null if refID not found

getSubtreesThatReference

public abstract java.util.List getSubtreesThatReference(java.lang.String refID)
returns a List of pointers to subtrees that reference (the subtree identified by) the passed refID. More formally, returns a List of pointers to subtree root Nodes, where each subtree root Node contains a "references" child-node, and the content String of the references child-node matches the unique String refID passed to this method; returns an empty List if none found. Should never return null;

Parameters:
refID - unique String refID
Returns:
List of pointers to subtrees that reference the subtree identified by the passed refID. Returns an empty List if none found. Should never return null;

deleteAllSubtrees

public java.util.List deleteAllSubtrees(java.lang.String genericName)
DELETES ALL subtrees identified by genericName String; returns null if none found - USE WITH CARE!!

Parameters:
genericName - String
Returns:
List of deleted subtrees; empty List if not found. SHOULD NEVER RETURN null

getSubtreeNoClone

public org.w3c.dom.Node getSubtreeNoClone(java.lang.String genericName,
                                          int index)
returns root Node of subtree identified by genericName String and int index; returns null if not found

Parameters:
genericName - String
index - int
Returns:
uncloned root Node of subtree, or null if not found

getIDsForNodesWithName

public java.util.List getIDsForNodesWithName(java.lang.String genericName)
returns a java.util.List containing IDs of all the rootnodes of all the subtrees identified by the passed unique String. Returns an empty string if none found. NOTE - should never return null

Parameters:
genericName - string identifying nodes - e.g. "parties"
Returns:
a java.util.List containing IDs of all the rootnodes of all the subtrees identified by the passed unique String. Returns an empty List if none found. NOTE - should never return null

getNewUniqueReferenceID

public java.lang.String getNewUniqueReferenceID()
returns a new refID that is guaranteed to be unique within this datapackage

Returns:
String a new refID that is guaranteed to be unique within this datapackage

insertSubtree

public org.w3c.dom.Node insertSubtree(java.lang.String genericName,
                                      org.w3c.dom.Node subtreeRootNode,
                                      int index)
inserts subtree rooted at Node, at location identified by genericName String and int index. Returns root Node of inserted subtree, or null if target location not found, so caller can determine whether insertion was successful

Parameters:
genericName - String
index - int (zero relative). NOTE that subtree will be inserted before this index if a subtree already exists there
Returns:
root Node of inserted subtree, or null if target location not found, so caller can determine whether insertion was successful

deleteSubtree

public org.w3c.dom.Node deleteSubtree(java.lang.String genericName,
                                      int index)
deletes subtree at location identified by genericName and index; returns root Node of deleted subtree, or null if not found, so caller can determine whether call was successful

Parameters:
genericName - String
index - int (zero relative)
Returns:
root Node of deleted subtree, or null if subtree not found, so caller can determine whether insertion was successful

replaceSubtree

public org.w3c.dom.Node replaceSubtree(java.lang.String genericName,
                                       org.w3c.dom.Node newSubtreeRootNode,
                                       int index)
replaces subtree at location identified by genericName and index; returns root Node of replaced subtree, or null if not found, so caller can determine whether replace was successful

Parameters:
genericName - String
newSubtreeRootNode - the new subtree root Node
index - int (zero relative)
Returns:
root Node of replaced subtree, or null if subtree not found, so caller can determine whether replace was successful

getCoverageNode

public org.w3c.dom.Node getCoverageNode()
checks to see if the package has a coverage element at the package level returns a Node if it finds one; otherwise, null


getGeographicNodeList

public org.w3c.dom.NodeList getGeographicNodeList()
gets a list of geographic nodes


removeGeographicNodes

public void removeGeographicNodes()
remove all the geographicNodes


getTemporalNodeList

public org.w3c.dom.NodeList getTemporalNodeList()
gets a list of temporal nodes


removeTemporalNodes

public void removeTemporalNodes()
remove all the temporalNodes


getTaxonomicNodeList

public org.w3c.dom.NodeList getTaxonomicNodeList()
gets a list of taxonomic nodes


removeTaxonomicNodes

public void removeTaxonomicNodes()
remove all the taxonomicNodes


insertCoverage

public void insertCoverage(org.w3c.dom.Node covSubtree)
insert a coverage subtree (geographic, temporal, or taxonomic) under the package level coverage node 'covSubtree' is assumed to be a DOM subtree of the proper type to be added under a coverage node


getEntityArray

public Entity[] getEntityArray()

getEntityName

public java.lang.String getEntityName(int entNum)
This method retrieves entityName information, given the index of the entity in the entityNode array

Parameters:
entNum - int
Returns:
String

getEntityIndex

public int getEntityIndex(java.lang.String entName)
This method retrieves entity index information, given the name of the entity in the entityNode array

Parameters:
entName - String - name of the Entity whose index in the entity array is required
Returns:
int the index of the entity in the entity array. If that entity is not found, -1 is returned

getEntityNumRecords

public java.lang.String getEntityNumRecords(int entNum)
This method retrieves the number of records in thr entity, given the index of the entity in the entityNode array

Parameters:
entNum - int
Returns:
String

getEntityCount

public int getEntityCount()
This method gets the count of the entities present in the package

Returns:
int the number of entities in the package

getAttributeCountForAnEntity

public int getAttributeCountForAnEntity(int entityIndex)
This method gets the count of the attributes present in a particular entity

Parameters:
entityIndex - the index of the entity whose attribute count is desired
Returns:
int the number of attributes in that entity

setEntityNumRecords

public void setEntityNumRecords(int entNum,
                                java.lang.String numRecS)
This method sets the number of records in the entity, given the index of the entity in the entityNode array

Parameters:
entNum - int
numRecS - String

getEntityDescription

public java.lang.String getEntityDescription(int entNum)
This method retrieves the entity Description, given the index of the entity in the entityNode array

Parameters:
entNum - int
Returns:
String

getEntityID

public java.lang.String getEntityID(int entNum)
This method retrieves the entity ID, given the index of the entity in the entityNode array

Parameters:
entNum - the entity Index of the entity whose ID is required
Returns:
String the entity ID

setEntityID

public void setEntityID(int entNum,
                        java.lang.String ID)
This method sets the entity ID, given the index of the entity in the entityNode array and the ID. Caller must ensure that the ID is unique. No check for uniqueness is made here. Though the DataPackage Wizard automatically assigns an ID to all entities, it is possible that some old data sets may not have the ID assigned to them. For such cases, this method provides a way to set an ID

Parameters:
entNum - the entity Index of the entity whose ID is required
ID - the unique ID for this entity

deleteEntity

public void deleteEntity(int entNum)
This method deletes the indexed entity from the DOM

Parameters:
entNum - int

deleteAllEntities

public void deleteAllEntities()
This method deletes the indexed entity from the DOM


addEntity

public void addEntity(Entity entity)
This method automatically adds an entity in the DOM at the next available position

Parameters:
entity - Entity

insertEntity

public void insertEntity(Entity entity,
                         int pos)
This method inserts an entity in the DOM at the indexed position

Parameters:
entity - Entity
pos - int

getAttributeArray

public org.w3c.dom.Node[] getAttributeArray(int entityIndex)
This method creates an array of attribute Nodes for the indexed entity in the entityNode array. Note that the attribute array is created as needed rather than stored as a class member.


deleteAttribute

public void deleteAttribute(int entityIndex,
                            int attributeIndex)
This method deletes the indexed attribute from the indexed entity


appendAdditionalMetadata

public org.w3c.dom.Node appendAdditionalMetadata(org.w3c.dom.Node addtMetadata)

loadCustomUnits

public void loadCustomUnits()

getUnitDictionaryCustomUnitTypes

public java.lang.String[] getUnitDictionaryCustomUnitTypes()

getUnitDictionaryUnitsOfType

public java.lang.String[] getUnitDictionaryUnitsOfType(java.lang.String type)

insertObjectIntoArray

public static void insertObjectIntoArray(java.lang.Object[] arr,
                                         java.lang.Object value,
                                         java.lang.Object[] newArr)

isNewCustomUnit

public boolean isNewCustomUnit(java.lang.String type,
                               java.lang.String unit)

addNewUnit

public void addNewUnit(java.lang.String unitType,
                       java.lang.String unit)

insertAttribute

public void insertAttribute(int entityIndex,
                            Attribute newAttr,
                            int attrIndex)
This method inserts an attribute at the indexed position in the indexed entity


getAttributeName

public java.lang.String getAttributeName(int entityIndex,
                                         int attributeIndex)

getAttributeIndex

public int getAttributeIndex(int entityIndex,
                             java.lang.String attributeName)
This method retreives the attribute index given an Attribute Name and the index of the entity that the attribute is present in.

Parameters:
entityIndex - the index of the entity thats contains the given attribute
attributeName - the name of the attribute whose index is required
Returns:
int the index of the attribute in the given array. Returns -1 if the attribute is not found in the entity.

getAttributeID

public java.lang.String getAttributeID(int entityIndex,
                                       int attributeIndex)

getAttributeDataType

public java.lang.String getAttributeDataType(int entityIndex,
                                             int attributeIndex)

getAttributeUnit

public java.lang.String getAttributeUnit(int entityIndex,
                                         int attributeIndex)

getPhysicalArray

public org.w3c.dom.Node[] getPhysicalArray(int entityIndex)

getPhysicalName

public java.lang.String getPhysicalName(int entityIndex,
                                        int physicalIndex)
This method returns the name of indexed physical object for the indicated entity index.


getPhysicalFormat

public java.lang.String getPhysicalFormat(int entityIndex,
                                          int physicalIndex)
This method returns the physocal format. Note that only text formats are displayed by Morpho. The format is for the physical object identified by 'physicalIndex' of the entity with the indicated 'entityIndex'


getPhysicalSize

public java.lang.String getPhysicalSize(int entityIndex,
                                        int physicalIndex)
This method returns the size for the indexed entity and physical object.


setPhysicalSize

public void setPhysicalSize(int entityIndex,
                            int physicalIndex,
                            java.lang.String sizeS)
This method sets the size for the indexed entity and physical object.


getPhysicalFieldDelimiter

public java.lang.String getPhysicalFieldDelimiter(int entityIndex,
                                                  int physicalIndex)
This method returns the FieldDelimiter for the indexed entity and physical object. An empty string is returned when there is no meaningful fieldDelimiter (e.g. not a text format)


ignoreConsecutiveDelimiters

public abstract boolean ignoreConsecutiveDelimiters(int entityIndex,
                                                    int physicalIndex)
returns boolean indicating whether repeated delimiters should be ignored


setPhysicalFieldDelimiter

public void setPhysicalFieldDelimiter(int entityIndex,
                                      int physicalIndex,
                                      java.lang.String delim)
This method sets the FieldDelimiter for the indexed entity and physical object.


getPhysicalNumberHeaderLines

public java.lang.String getPhysicalNumberHeaderLines(int entityIndex,
                                                     int physicalIndex)
This method returns the number of header lines for the indexed entity and physical object. An empty string is returned when there is no meaningful numHeaderLines (e.g. not a text format)


getEncodingMethod

public java.lang.String getEncodingMethod(int entityIndex,
                                          int physicalIndex)
This method returns the encoding method for the indexed entity and physical object. An empty string is returned when there is no encoding information It is assumed that the encoding given here describes the inline data when data is stored inline (DFH)


getCompressionMethod

public java.lang.String getCompressionMethod(int entityIndex,
                                             int physicalIndex)
This method returns the compression method for the indexed entity and physical object. An empty string is returned when there is no encoding information It is assumed that the compression given here describes the inline data when data is stored inline (DFH)


getDistributionArray

public org.w3c.dom.Node[] getDistributionArray(int entityIndex,
                                               int physicalIndex)
This method creates an array of 'distribution' nodes, following the eml2 model of a subtree with information about the distribution of the actual data being characterized by the metadata. Multiple distribution subtrees are allowed in eml2; thus a Node array is returned (although usually only one distribution node is expected). Characterized by the entity and physical indicesS


getDistributionInlineData

public java.lang.String getDistributionInlineData(int entityIndex,
                                                  int physicalIndex,
                                                  int distIndex)
This method returns 'inline' data as a String for the indexed entity, physical object, and distribution object. Usually one would try to avoid large inline data collections because it will make DOMs hard to handle


getDistributionUrl

public java.lang.String getDistributionUrl(int entityIndex,
                                           int physicalIndex,
                                           int distIndex)
This method returns the url for data as a String for the indexed entity, physical object, and distribution object. Returns an empty string if there is no url pointing to the data, or data is not referenced.


setDistributionUrl

public void setDistributionUrl(int entityIndex,
                               int physicalIndex,
                               int distIndex,
                               java.lang.String urlS)
This method sets the url for data as a String for the indexed entity, physical object, and distribution object.


serializeData

public void serializeData()
                   throws MetacatUploadException
Throws:
MetacatUploadException

export

public void export(java.lang.String path)
exports a package to a given path

Parameters:
path - the path to which this package should be exported.

exportToZip

public void exportToZip(java.lang.String path)
Exports a package to a zip file at the given path

Parameters:
path - the path to export the zip file to

exportDataFiles

public void exportDataFiles(java.lang.String path)
copies all the data files in a package to a directory indicated by 'path'. Files are given the original file name, if available


delete

public void delete(java.lang.String location)
            throws java.lang.Exception
Deletes the package from the specified location

Throws:
java.lang.Exception

showPackageSummary

public void showPackageSummary()
This method displays a summary of Package information by calling the various utility methods defined in this class. Primary use is for debugging.


openAsReader

public java.io.Reader openAsReader(java.lang.String id)
                            throws DocumentNotFoundException
Description copied from interface: XMLFactoryInterface
method to return a Reader object, which will provide access to a character-based resource. The resource to be returned is determined based on the unique String identifier passed to this method

Specified by:
openAsReader in interface XMLFactoryInterface
Parameters:
id - a unique identifier used to determine what resource to return
Returns:
a Reader for the character-based resource
Throws:
DocumentNotFoundException - if id does not point to a document, or if requested document exists but cannot be accessed.

openAsDom

public org.w3c.dom.Document openAsDom(java.lang.String id)
Description copied from interface: XMLFactoryInterface
method to return a DOM Document rather than a Reader Since the real purppose is to provide the source for an XSLT transform a DOM can passed instead of a Reader. This avoids the need to convert a Reader to the DOM. Return of a 'null' Document is allowed as an indication that one should use the 'openAsReader' method.

Specified by:
openAsDom in interface XMLFactoryInterface
Parameters:
id - a unique identifier used to determine what resource to return

addAttributeForImport

public void addAttributeForImport(java.lang.String entityName,
                                  java.lang.String attributeName,
                                  java.lang.String scale,
                                  OrderedMap omap,
                                  java.lang.String xPath,
                                  boolean newTable)

getCurrentImportEntityName

public java.lang.String getCurrentImportEntityName()

getCurrentImportAttributeName

public java.lang.String getCurrentImportAttributeName()

getCurrentImportScale

public java.lang.String getCurrentImportScale()

getCurrentImportMap

public OrderedMap getCurrentImportMap()

getSecondImportMap

public OrderedMap getSecondImportMap()

getCurrentImportXPath

public java.lang.String getCurrentImportXPath()

isCurrentImportNewTable

public boolean isCurrentImportNewTable()

getAttributeImportCount

public int getAttributeImportCount()

removeAttributeForImport

public void removeAttributeForImport()

setLastImportedEntity

public void setLastImportedEntity(java.lang.String name)

setLastImportedDataSet

public void setLastImportedDataSet(java.util.Vector data)

setLastImportedAttributes

public void setLastImportedAttributes(java.util.List attr)

getLastImportedEntity

public java.lang.String getLastImportedEntity()

getLastImportedAttributes

public java.util.List getLastImportedAttributes()

getLastImportedDataSet

public java.util.Vector getLastImportedDataSet()

getOriginalEntityArray

public Entity[] getOriginalEntityArray()

setOriginalEntityArray

public void setOriginalEntityArray(Entity[] arr)

clearAllAttributeImports

public void clearAllAttributeImports()


Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.