edu.ucsb.nceas.morpho.datapackage
Class DataPackage

java.lang.Object
  extended byedu.ucsb.nceas.morpho.datapackage.DataPackage
All Implemented Interfaces:
XMLFactoryInterface

public class DataPackage
extends java.lang.Object
implements XMLFactoryInterface

class that represents a data package.


Constructor Summary
DataPackage(java.lang.String location, java.lang.String identifier, java.util.Vector relations, Morpho morpho, boolean accessCheckFlag)
          Create a new data package object with an id, location and associated relations.
 
Method Summary
 void checkTriplesForAccess()
           
 void delete(java.lang.String location)
          Deletes the package from the specified location
 void download()
          Downloads a metacat package to the local disk
 void export(java.lang.String path)
          exports a package to a given path
 void exportToEml2(java.lang.String path)
          transforms a package to eml2; first exports the metadata
 void exportToZip(java.lang.String path)
          Exports a package to a zip file at the given path
 java.lang.String getAccessFileId(java.lang.String id)
          get the id of the access doc for the indicated id
 java.lang.String getAccessFileIdForDataPackage()
           
 java.lang.String getAccessId()
          returns the access file's id from the package
 java.util.Vector getAllIdentifiers()
          returns a vector containing a distinct set of all of the file ids that make up this package
 java.io.File getAttributeFile(java.lang.String entityID)
           
 java.lang.String getAttributeFileId(java.lang.String entityID)
           
 java.util.Hashtable getAttributes()
          returns a hashtable of vectors with the basic values in it.
 java.io.File getDataFile(java.lang.String entityID)
           
 java.lang.String getDataFileID(java.lang.String entityID)
          returns the ID (i.e.
 java.lang.String getDataFileName(java.lang.String entityID)
          returns the original text name of the datafile, which for EML beta6 is contained in the triples relationship string, inside parentheses)
 java.io.File getFileFromId(java.lang.String id)
           
 java.lang.String getID()
          returns the id of the head of this package (i.e.
 java.lang.String getLocation()
          returns the location of the data package.
 java.io.File getPhysicalFile(java.lang.String entityID)
           
 java.lang.String getPhysicalFileId(java.lang.String entityID)
           
 java.util.Hashtable getRelatedFiles()
          returns a hashtable of the related files taken from the triples.
 org.w3c.dom.Document getTripleFileDom()
          returns the dom representation of the triple file.
 TripleCollection getTriples()
          gets the triplesCollection created by this object
 java.io.File getTriplesFile()
          gets the file that contains the package information.
 boolean hasDataFile(java.lang.String entityID)
           
 boolean hasMutipleVersions()
          Method to determine if the this pakcage has mutiple versions
 boolean isDataFile(java.lang.String id)
           
 boolean isDataFileText(java.lang.String entityID)
           
 org.w3c.dom.Document openAsDom(java.lang.String id)
          This method is needed by the XMLFactoryInterface In this case, null is always returned.
 java.io.InputStream openAsInputStream(java.lang.String identifier)
          Open a sub-element of this datapackage (for example, a Module, or a sub-tree), given its String identifier.
 java.io.Reader openAsReader(java.lang.String identifier)
          method to return a Reader object, which will provide access to a character-based resource.
 DataPackage upload()
          uploads the package with the default of automatically updating the ids when a conflict occurs.
 DataPackage upload(boolean updateIds)
          Uploads a local package to metacat
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataPackage

public DataPackage(java.lang.String location,
                   java.lang.String identifier,
                   java.util.Vector relations,
                   Morpho morpho,
                   boolean accessCheckFlag)
Create a new data package object with an id, location and associated relations.

Method Detail

openAsReader

public java.io.Reader openAsReader(java.lang.String identifier)
                            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:
identifier - 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)
This method is needed by the XMLFactoryInterface In this case, null is always returned.

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

openAsInputStream

public java.io.InputStream openAsInputStream(java.lang.String identifier)
                                      throws DocumentNotFoundException,
                                             java.io.FileNotFoundException
Open a sub-element of this datapackage (for example, a Module, or a sub-tree), given its String identifier.

Parameters:
identifier - the unique identifier needed to locate the desired sub-element.
Returns:
a java.io.InputStream to allow direct read access to the source
Throws:
DocumentNotFoundException - if document cannot be found
java.io.FileNotFoundException - if document cannot succesfully be opened and an InputStream returned

getTripleFileDom

public org.w3c.dom.Document getTripleFileDom()
returns the dom representation of the triple file.


getRelatedFiles

public java.util.Hashtable getRelatedFiles()
returns a hashtable of the related files taken from the triples. These are organized so that the key of the hashtable is the type of metadata (e.g. 'Entity') and the value of the hashtable is a vector of docids


getLocation

public java.lang.String getLocation()
returns the location of the data package. Either this.METACAT or this.LOCAL.


getAttributes

public java.util.Hashtable getAttributes()
returns a hashtable of vectors with the basic values in it. Currently, the basic values for the package editor are title, altTitle and originators


getTriples

public TripleCollection getTriples()
gets the triplesCollection created by this object


getTriplesFile

public java.io.File getTriplesFile()
gets the file that contains the package information.


getID

public java.lang.String getID()
returns the id of the head of this package (i.e. the resource file)


hasMutipleVersions

public boolean hasMutipleVersions()
Method to determine if the this pakcage has mutiple versions


getAccessId

public java.lang.String getAccessId()
                             throws java.io.FileNotFoundException,
                                    java.lang.Exception,
                                    CacheAccessException
returns the access file's id from the package

Returns:
returns the accession number of the access file or null if there is no access file.
Throws:
java.io.FileNotFoundException
java.lang.Exception
CacheAccessException

getAllIdentifiers

public java.util.Vector getAllIdentifiers()
returns a vector containing a distinct set of all of the file ids that make up this package


upload

public DataPackage upload()
                   throws MetacatUploadException
uploads the package with the default of automatically updating the ids when a conflict occurs.

Throws:
MetacatUploadException

upload

public DataPackage upload(boolean updateIds)
                   throws MetacatUploadException
Uploads a local package to metacat

Parameters:
updateIds - if this is true, the upload will automatically update the ids of all of the package documents if an id conflict is found. if it is false, a MetacatUploadException will be raised when an id conflict occurs
Returns:
the package that was uploaded. Note that this may have a different id from the one that was told to upload.
Throws:
MetacatUploadException

download

public void download()
Downloads a metacat package to the local disk


delete

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


exportToZip

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

Parameters:
path - the path to export the zip file to
Throws:
java.lang.Exception

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.

exportToEml2

public void exportToEml2(java.lang.String path)
transforms a package to eml2; first exports the metadata

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

isDataFile

public boolean isDataFile(java.lang.String id)

hasDataFile

public boolean hasDataFile(java.lang.String entityID)

isDataFileText

public boolean isDataFileText(java.lang.String entityID)

getDataFileName

public java.lang.String getDataFileName(java.lang.String entityID)
returns the original text name of the datafile, which for EML beta6 is contained in the triples relationship string, inside parentheses)

Parameters:
entityID - the ID of the entity for which the datafile text name is sought
Returns:
the original text name of the datafile (as a String)

getPhysicalFile

public java.io.File getPhysicalFile(java.lang.String entityID)

getPhysicalFileId

public java.lang.String getPhysicalFileId(java.lang.String entityID)

getAttributeFile

public java.io.File getAttributeFile(java.lang.String entityID)

getAttributeFileId

public java.lang.String getAttributeFileId(java.lang.String entityID)

getAccessFileId

public java.lang.String getAccessFileId(java.lang.String id)
get the id of the access doc for the indicated id


getAccessFileIdForDataPackage

public java.lang.String getAccessFileIdForDataPackage()

getDataFile

public java.io.File getDataFile(java.lang.String entityID)

getDataFileID

public java.lang.String getDataFileID(java.lang.String entityID)
returns the ID (i.e. the dentifier/version number from the subject/object of the triples) for the data file

Parameters:
entityID - the ID of the entity for which the datafile ID is sought
Returns:
the ID (as a String)

getFileFromId

public java.io.File getFileFromId(java.lang.String id)

checkTriplesForAccess

public void checkTriplesForAccess()


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