thredds.catalog
Class InvDatasetImpl

java.lang.Object
  extended by thredds.catalog.InvDataset
      extended by thredds.catalog.InvDatasetImpl
Direct Known Subclasses:
InvCatalogRef, InvDatasetImplProxy

public class InvDatasetImpl
extends InvDataset

Concrete implementation of a thredds Dataset, for reading and writing from XML.

Author:
john caron
See Also:
InvDataset

Field Summary
protected  StringBuilder log
           
protected  boolean mark
           
protected  org.jdom.Element ncmlElement
           
protected  ThreddsMetadata tm
           
protected  ThreddsMetadata tmi
           
protected  ThreddsMetadata tmi6
           
 
Fields inherited from class thredds.catalog.InvDataset
access, authorityName, catalog, collectionType, contributors, creators, dataFormatType, datasets, dataType, dates, defaultService, docs, gc, harvest, id, keywords, metadata, name, parent, projects, properties, publishers, restrictAccess, services, tc, variables
 
Constructor Summary
InvDatasetImpl(InvDatasetImpl from)
          copy constructor
InvDatasetImpl(InvDatasetImpl parent, String name, FeatureType dataType, String serviceName, String urlPath)
          Constructor from Catalog XML info.
InvDatasetImpl(InvDataset parent, String name)
           
InvDatasetImpl(String urlPath, FeatureType dataType, ServiceType stype)
          Construct an InvDatasetImpl which refers to a urlPath.
 
Method Summary
 void addAccess(InvAccess a)
          Add InvAccess element to this dataset.
 void addAccess(List<InvAccess> a)
          Add a list of InvAccess elements to this dataset.
 void addDataset(int index, InvDatasetImpl ds)
          Add a nested dataset at the location indicated by index.
 void addDataset(InvDatasetImpl ds)
          Add a nested dataset.
 void addDocumentation(InvDocumentation doc)
          Add documentation element to this dataset.
 void addProperty(InvProperty p)
          Add a property to this dataset
 void addService(InvService service)
          Deprecated. put services in catalog
protected  void canonicalize()
          Put metadata into canonical form.
 String dump()
           
 boolean equals(Object o)
          InvDatasetImpl elements with same values are equal.
 boolean finish()
          Finish constructing after all elements have been added.
 List<InvAccess> getAccessLocal()
           
 String getAlias()
           
 double getDataSize()
           
 DateType getLastModifiedDate()
           
 ThreddsMetadata getLocalMetadata()
          Get the metadata stored in this dataset element.
 ThreddsMetadata getLocalMetadataInheritable()
          local metadata that should be inherited by this dataset's children.
protected  boolean getMark()
          Filtering
 org.jdom.Element getNcmlElement()
           
 InvDataset getParentReal()
          Get real parent dataset, no proxies
 String getServiceName()
           
 List<InvService> getServicesLocal()
          Get services attached specifically to this dataset.
 String getUrlPath()
          Get urlPath for this Dataset
 Object getUserProperty(Object key)
          Look up the User property having the given key
 int hashCode()
          Override Object.hashCode() to implement equals.
static void main(String[] args)
          test
 boolean removeDataset(InvDatasetImpl ds)
          Remove the given dataset element from this dataset if it is in the dataset.
 boolean removeLocalMetadata(InvMetadata metadata)
          Remove the given InvMetadata from the set of metadata local to this dataset.
 void removeService(InvService service)
          Deprecated. put services in catalog
 boolean replaceDataset(InvDatasetImpl remove, InvDatasetImpl add)
          Replace the given dataset if it is a nesetd dataset.
static String resolve(InvDataset ds, String href)
          resolve reletive URLS against the catalog URL.
 void setAlias(String alias)
          Set alias for this Dataset
 void setAuthority(String authorityName)
          Set authorityName for this Dataset
 void setCatalog(InvCatalog catalog)
          Set the containing catalog; use only for top level dataset.
 void setCollectionType(CollectionType collectionType)
          Set collectionType
 void setContributors(List<ThreddsMetadata.Contributor> a)
           
 void setDataFormatType(DataFormatType dataFormatType)
           
 void setDataSize(double dataSize)
           
 void setDataType(FeatureType dataType)
           
 void setGeospatialCoverage(ThreddsMetadata.GeospatialCoverage gc)
           
 void setHarvest(boolean harvest)
          Set harvest
 void setID(String id)
          Set the ID for this Dataset
 void setKeywords(List<ThreddsMetadata.Vocab> a)
           
 void setLastModifiedDate(Date lastModDate)
           
 void setLastModifiedDate(DateType lastModDate)
           
 void setLocalMetadata(ThreddsMetadata tm)
           
protected  void setMark(boolean mark)
           
 void setName(String name)
          Set name of this Dataset.
 void setNcmlElement(org.jdom.Element ncmlElement)
           
 void setParent(InvDatasetImpl parent)
          Set the parent dataset.
 void setProjects(List<ThreddsMetadata.Vocab> a)
           
 void setPublishers(List<ThreddsMetadata.Source> a)
           
 void setResourceControl(String restrictAccess)
           
 void setServiceName(String serviceName)
           
 void setServicesLocal(List<InvService> s)
          Set the list of services attached specifically to this dataset.
 void setTimeCoverage(DateRange tc)
           
 void setUrlPath(String urlPath)
          Set the urlPath for this InvDatasetImpl
 void setUserProperty(Object key, Object value)
           
 String toString()
           
 void transferMetadata(InvDatasetImpl fromDs, boolean copyInheritedMetadataFromParents)
          Transfer all inheritable metadata from fromDs to the local metadata of this dataset.
static void writeHtmlDescription(StringBuilder buff, InvDatasetImpl ds, boolean complete, boolean isServer, boolean datasetEvents, boolean catrefEvents)
          Deprecated. Instead use writeHtmlDescription(StringBuilder buff, InvDatasetImpl ds, boolean complete, boolean isServer, boolean datasetEvents, boolean catrefEvents, boolean resolveRelativeUrls)
static void writeHtmlDescription(StringBuilder buff, InvDatasetImpl ds, boolean complete, boolean isServer, boolean datasetEvents, boolean catrefEvents, boolean resolveRelativeUrls)
          Write an Html representation of the given dataset.
 
Methods inherited from class thredds.catalog.InvDataset
findAccess, findDatasetByName, findProperty, findService, getAccess, getAccess, getAuthority, getCatalogUrl, getCollectionType, getContributors, getCreators, getDataFormatType, getDatasets, getDataType, getDates, getDocumentation, getDocumentation, getFullName, getGeospatialCoverage, getHistory, getID, getKeywords, getMetadata, getMetadata, getName, getParent, getParentCatalog, getProcessing, getProjects, getProperties, getPublishers, getRestrictAccess, getRights, getServiceDefault, getSubsetUrl, getSummary, getTimeCoverage, getUniqueID, getVariables, getVariables, hasAccess, hasNestedDatasets, isHarvest
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

tm

protected ThreddsMetadata tm

tmi

protected ThreddsMetadata tmi

tmi6

protected ThreddsMetadata tmi6

ncmlElement

protected org.jdom.Element ncmlElement

log

protected StringBuilder log

mark

protected boolean mark
Constructor Detail

InvDatasetImpl

public InvDatasetImpl(InvDatasetImpl parent,
                      String name,
                      FeatureType dataType,
                      String serviceName,
                      String urlPath)
Constructor from Catalog XML info. You must call finish() before this object is ready to be used. We had to do it this way so that nested service elements could be added through addService(), before we define on the default service.

Parameters:
parent - : parent dataset
name - : display name of dataset
dataType - : DataType name (may be null)
serviceName - : default service (may be null)
urlPath - : URL = server.getURLbase() + urlPath

InvDatasetImpl

public InvDatasetImpl(String urlPath,
                      FeatureType dataType,
                      ServiceType stype)
Construct an InvDatasetImpl which refers to a urlPath. This is used to create a standalone InvDatasetImpl, outside of an InvCatalog. An "anonymous" InvServerImpl is created and attached to the InvDataset.

Parameters:
urlPath - : construct URL from this path
dataType - : data type
stype - : ServiceType

InvDatasetImpl

public InvDatasetImpl(InvDataset parent,
                      String name)

InvDatasetImpl

public InvDatasetImpl(InvDatasetImpl from)
copy constructor

Parameters:
from - copy from here
Method Detail

finish

public boolean finish()
Finish constructing after all elements have been added. This does the inheritence thing This can be called again if new elements are added.

Returns:
true if successful.

transferMetadata

public void transferMetadata(InvDatasetImpl fromDs,
                             boolean copyInheritedMetadataFromParents)
Transfer all inheritable metadata from fromDs to the local metadata of this dataset. Called by InvDatasetScan to transfer inheritable metaddata to the nested catalogRef

Parameters:
fromDs - transfer from here

canonicalize

protected void canonicalize()
Put metadata into canonical form. All non-inherited thredds metadata put into dataset. All inherited thredds metaddata put into single metadata element, pointed to by getLocalMetadataInherited. This is needed to do reliable editing.


getAlias

public String getAlias()
Returns:
alias for this Dataset, if there is one

setAlias

public void setAlias(String alias)
Set alias for this Dataset

Parameters:
alias - ID of another Dataset

setCatalog

public void setCatalog(InvCatalog catalog)
Set the containing catalog; use only for top level dataset.

Parameters:
catalog - the containing catalog for the top level dataset.

getParentReal

public InvDataset getParentReal()
Get real parent dataset, no proxies

Returns:
parent dataset. If top dataset, return null.

getUrlPath

public String getUrlPath()
Get urlPath for this Dataset

Returns:
urlPath for this Dataset

setUrlPath

public void setUrlPath(String urlPath)
Set the urlPath for this InvDatasetImpl

Parameters:
urlPath - the urlPath for this InvDatasetImpl

setAuthority

public void setAuthority(String authorityName)
Set authorityName for this Dataset

Parameters:
authorityName - for this Dataset

setCollectionType

public void setCollectionType(CollectionType collectionType)
Set collectionType

Parameters:
collectionType - the collection type

setHarvest

public void setHarvest(boolean harvest)
Set harvest

Parameters:
harvest - true if this dataset should be harvested for Digital Libraries

setID

public void setID(String id)
Set the ID for this Dataset

Parameters:
id - unique ID

setName

public void setName(String name)
Set name of this Dataset.

Parameters:
name - of the dataset

setParent

public void setParent(InvDatasetImpl parent)
Set the parent dataset.

Parameters:
parent - parent dataset

setGeospatialCoverage

public void setGeospatialCoverage(ThreddsMetadata.GeospatialCoverage gc)

setTimeCoverage

public void setTimeCoverage(DateRange tc)

setDataFormatType

public void setDataFormatType(DataFormatType dataFormatType)

setDataType

public void setDataType(FeatureType dataType)

getDataSize

public double getDataSize()

setDataSize

public void setDataSize(double dataSize)

getLastModifiedDate

public DateType getLastModifiedDate()

setLastModifiedDate

public void setLastModifiedDate(DateType lastModDate)

setLastModifiedDate

public void setLastModifiedDate(Date lastModDate)

setServiceName

public void setServiceName(String serviceName)

setContributors

public void setContributors(List<ThreddsMetadata.Contributor> a)

setKeywords

public void setKeywords(List<ThreddsMetadata.Vocab> a)

setProjects

public void setProjects(List<ThreddsMetadata.Vocab> a)

setPublishers

public void setPublishers(List<ThreddsMetadata.Source> a)

setResourceControl

public void setResourceControl(String restrictAccess)

addAccess

public void addAccess(InvAccess a)
Add InvAccess element to this dataset.

Parameters:
a - add dthis

addAccess

public void addAccess(List<InvAccess> a)
Add a list of InvAccess elements to this dataset.

Parameters:
a - add all of these

getAccessLocal

public List<InvAccess> getAccessLocal()
Returns:
the local access (non-expanded) elements.

getNcmlElement

public org.jdom.Element getNcmlElement()
Returns:
the ncml element if it exists, else return null.

setNcmlElement

public void setNcmlElement(org.jdom.Element ncmlElement)

addDataset

public void addDataset(InvDatasetImpl ds)
Add a nested dataset.

Parameters:
ds - add this

addDataset

public void addDataset(int index,
                       InvDatasetImpl ds)
Add a nested dataset at the location indicated by index.

Parameters:
index - add at this position
ds - add this

removeDataset

public boolean removeDataset(InvDatasetImpl ds)
Remove the given dataset element from this dataset if it is in the dataset.

Parameters:
ds - - the dataset element to be removed
Returns:
true if this dataset contained the given dataset element.

replaceDataset

public boolean replaceDataset(InvDatasetImpl remove,
                              InvDatasetImpl add)
Replace the given dataset if it is a nesetd dataset.

Parameters:
remove - - the dataset element to be removed
add - - the dataset element to be added
Returns:
true on success

addDocumentation

public void addDocumentation(InvDocumentation doc)
Add documentation element to this dataset.

Parameters:
doc - add this

addProperty

public void addProperty(InvProperty p)
Add a property to this dataset

Parameters:
p - add this

addService

public void addService(InvService service)
Deprecated. put services in catalog

Add a service to this dataset.

Parameters:
service - add this

removeService

public void removeService(InvService service)
Deprecated. put services in catalog

Remove a service from this dataset.

Parameters:
service - remove this

getServicesLocal

public List<InvService> getServicesLocal()
Get services attached specifically to this dataset.

Returns:
List of type InvService. May be empty, but not null.

setServicesLocal

public void setServicesLocal(List<InvService> s)
Set the list of services attached specifically to this dataset. Discard any previous servies.

Parameters:
s - list of services.

getLocalMetadata

public ThreddsMetadata getLocalMetadata()
Get the metadata stored in this dataset element. Inherited metadata only in an InvMetadata object.

Returns:
the metadata stored in this dataset element.

setLocalMetadata

public void setLocalMetadata(ThreddsMetadata tm)

getLocalMetadataInheritable

public ThreddsMetadata getLocalMetadataInheritable()
local metadata that should be inherited by this dataset's children.

Returns:
local metadata that should be inherited by this dataset's children.

removeLocalMetadata

public boolean removeLocalMetadata(InvMetadata metadata)
Remove the given InvMetadata from the set of metadata local to this dataset.

Parameters:
metadata - remove this
Returns:
true if an InvMetadata is removed, false otherwise.

getServiceName

public String getServiceName()

getMark

protected boolean getMark()
Filtering

Returns:
true if this is "marked"

setMark

protected void setMark(boolean mark)

getUserProperty

public Object getUserProperty(Object key)
Look up the User property having the given key

Parameters:
key - property key
Returns:
User property having the given key, or null

setUserProperty

public void setUserProperty(Object key,
                            Object value)

toString

public String toString()
Overrides:
toString in class Object

writeHtmlDescription

public static void writeHtmlDescription(StringBuilder buff,
                                        InvDatasetImpl ds,
                                        boolean complete,
                                        boolean isServer,
                                        boolean datasetEvents,
                                        boolean catrefEvents)
Deprecated. Instead use writeHtmlDescription(StringBuilder buff, InvDatasetImpl ds, boolean complete, boolean isServer, boolean datasetEvents, boolean catrefEvents, boolean resolveRelativeUrls)

Parameters:
buff - a
ds - a
complete - a
isServer - a
datasetEvents - a
catrefEvents - a

writeHtmlDescription

public static void writeHtmlDescription(StringBuilder buff,
                                        InvDatasetImpl ds,
                                        boolean complete,
                                        boolean isServer,
                                        boolean datasetEvents,
                                        boolean catrefEvents,
                                        boolean resolveRelativeUrls)
Write an Html representation of the given dataset.

With datasetEvents, catrefEvents = true, this is used to construct an HTML page on the client (eg using HtmlPage); the client then detects URL clicks and processes.

With datasetEvents, catrefEvents = false, this is used to construct an HTML page on the server. (eg using HtmlPage); the client then detects URL clicks and processes.

Parameters:
buff - put HTML here.
ds - the dataset.
complete - if true, add HTML header and ender so its a complete, valid HTML page.
isServer - if true, then we are in the thredds data server, so do the following:
  • append "html" to DODS Access URLs
datasetEvents - if true, prepend "dataset:" to any dataset access URLS
catrefEvents - if true, prepend "catref:" to any catref URLS

resolve

public static String resolve(InvDataset ds,
                             String href)
resolve reletive URLS against the catalog URL.

Parameters:
ds - use ds parent catalog, if it exists
href - URL to resolve
Returns:
resolved URL

dump

public String dump()
Returns:
debugging info

equals

public boolean equals(Object o)
InvDatasetImpl elements with same values are equal.

Overrides:
equals in class Object

hashCode

public int hashCode()
Override Object.hashCode() to implement equals.

Overrides:
hashCode in class Object

main

public static void main(String[] args)
test



Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.