Package thredds.catalog
Class InvDatasetImpl
- java.lang.Object
-
- thredds.catalog.InvDataset
-
- 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.- See Also:
InvDataset
-
-
Field Summary
Fields Modifier and Type Field Description protected StringBuilder
log
protected boolean
mark
protected org.jdom2.Element
ncmlElement
protected ThreddsMetadata
tm
protected ThreddsMetadata
tmi
-
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, variableMapLink, variables
-
-
Constructor Summary
Constructors Constructor Description InvDatasetImpl(String urlPath, FeatureType dataType, ServiceType stype)
Construct an InvDatasetImpl which refers to a urlPath.InvDatasetImpl(InvDatasetImpl from)
copy constructorInvDatasetImpl(InvDatasetImpl parent, String name, FeatureType dataType, String serviceName, String urlPath)
Constructor from Catalog XML info.InvDatasetImpl(InvDataset parent, String name)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addAccess(List<InvAccess> a)
Add a list of InvAccess elements to this dataset.void
addAccess(InvAccess a)
Add InvAccess element 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 datasetvoid
addService(InvService service)
Deprecated.add services only to catalogprotected 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()
Filteringorg.jdom2.Element
getNcmlElement()
InvDataset
getParentReal()
Get real parent dataset, no proxiesString
getServiceName()
List<InvService>
getServicesLocal()
Get services attached specifically to this dataset.String
getUrlPath()
Get urlPath for this DatasetObject
getUserProperty(Object key)
Look up the User property having the given keyint
hashCode()
Override Object.hashCode() to implement equals.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 catalogboolean
replaceDataset(InvDatasetImpl remove, InvDatasetImpl add)
Replace the given dataset if it is a nesetd dataset.static String
resolve(InvDataset ds, String href)
resolve relative URLS against the catalog URL.void
setAlias(String alias)
Set alias for this Datasetvoid
setAuthority(String authorityName)
Set authorityName for this Datasetvoid
setCatalog(InvCatalog catalog)
Set the containing catalog; use only for top level dataset.void
setCollectionType(CollectionType collectionType)
Set collectionTypevoid
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 harvestvoid
setID(String id)
Set the ID for this Datasetvoid
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.jdom2.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(CalendarDateRange tc)
void
setTimeCoverage(DateRange tc)
void
setUrlPath(String urlPath)
Set the urlPath for this InvDatasetImplvoid
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)
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, getCalendarDateCoverage, 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, getVariableMapLink, getVariables, getVariables, hasAccess, hasNestedDatasets, isHarvest
-
-
-
-
Field Detail
-
tm
protected ThreddsMetadata tm
-
tmi
protected ThreddsMetadata tmi
-
ncmlElement
protected org.jdom2.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 datasetname
- : display name of datasetdataType
- : 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 pathdataType
- : data typestype
- : 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 single metadata element, pointed to by getLocalMetadata(). All inherited thredds metadata 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(CalendarDateRange tc)
-
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.jdom2.Element getNcmlElement()
- Returns:
- the ncml element if it exists, else return null.
-
setNcmlElement
public void setNcmlElement(org.jdom2.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 positionds
- 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 removedadd
- - 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.add services only to catalogAdd a service to this dataset.- Parameters:
service
- add this service to the dataset
-
removeService
public void removeService(InvService service)
Deprecated.put services in catalogRemove 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
-
writeHtmlDescription
public static void writeHtmlDescription(StringBuilder buff, InvDatasetImpl ds, boolean complete, boolean isServer, boolean datasetEvents, boolean catrefEvents)
Deprecated.- Parameters:
buff
- ads
- acomplete
- aisServer
- adatasetEvents
- acatrefEvents
- 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 URLScatrefEvents
- if true, prepend "catref:" to any catref URLS
-
resolve
public static String resolve(InvDataset ds, String href)
resolve relative URLS against the catalog URL.- Parameters:
ds
- use ds parent catalog, if it existshref
- 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.
-
-