public class CollectionLevelScanner
extends java.lang.Object
Three different levels of the dataset collection must be provided to to properly map from CrawlableDataset to InvCatalog/InvDataset:
Besides the three CrawlableDatasets that define the collection to be
cataloged, there are a variety of ways to modify or enhance the resulting
catalog. For more details, see the documentation for the various setters
(setCollectionId()
,
setIdentifier()
,
setNamer()
,
setDoAddDataSize()
,
setSorter()
,
setProxyDsHandlers()
,
addChildEnhancer()
.
Here we'll look at the parameters used to construct a CollectionLevelScanner and to generate a catalog for the following request:
http://my.server:8080/thredds/ncep/nam/80km/catalog.xml
In the constuctor, we have:
The two datasets we'll use in the example are:
Following are the details on how the resulting InvDataset and InvCatalogRef objects are created.
<dataset name="20060208_1200_nam80km.grib"/> <catalogRef xlink:title="2000archive"/>
<dataset name="20060208_1200_nam80km.grib" ID="NCEP/nam/80km/20060208_1200_nam80km.grib"/> <catalogRef xlink:title="2000archive" ID="NCEP/nam/80km/2000archive" />where the values were determined as follows:
<dataset name="20060208_1200_nam80km.grib" ID="NCEP/nam/80km/20060208_1200_nam80km.grib" urlPath="ncep/nam/80km/20060208_1200_nam80km.grib" />where the values were determined as follows:
<catalogRef xlink:title="2000archive" xlink:href="2000archive/catalog.xml"/>where the values were determined as follows:
See DatasetScanCatalogBuilder
for more details on how a
THREDDS server config file (catalog.xml) and the contained datasetScan
elements map into CollectionLevelScanner.
Resulting single level catalogs can be used to construct multi-level catalogs by replacing InvCatalogRef objects with the catalogs generated for the corresponding CrawlableDataset objects. Construction of multi-level catalogs is supported in several ways:
NOTE: The StandardCatalogBuilder
class is an example of using
ColletionLevelScanner to construct multi-level catalogs.
Constructor and Description |
---|
CollectionLevelScanner(CollectionLevelScanner cs)
Copy constructor
|
CollectionLevelScanner(java.lang.String collectionPath,
CrawlableDataset collectionLevel,
CrawlableDataset catalogLevel,
CrawlableDataset currentLevel,
CrawlableDatasetFilter filter,
InvService service)
Construct a CollectionLevelScanner.
|
Modifier and Type | Method and Description |
---|---|
void |
addChildEnhancer(DatasetEnhancer childEnhancer)
Add the given DatasetEnhancer to the list that will be applied to each of
the child datasets.
|
InvCatalogImpl |
generateCatalog() |
InvCatalogImpl |
generateProxyDsResolverCatalog(ProxyDatasetHandler pdh)
Generate the catalog for a resolver request of the given ProxyDatasetHandler.
|
protected java.lang.String |
getCollectionId() |
protected java.lang.String |
getCollectionName() |
protected boolean |
getDoAddDataSize() |
protected CrawlableDatasetLabeler |
getIdentifier() |
protected CrawlableDatasetLabeler |
getNamer() |
java.util.Map |
getProxyDsHandlers() |
CrawlableDatasetSorter |
getSorter() |
void |
scan()
Scan the collection and gather information on contained datasets.
|
void |
setCollectionId(java.lang.String collectionId)
Set the value of the base dataset ID.
|
void |
setCollectionName(java.lang.String collectionName)
Set the value of the collection Name.
|
void |
setDoAddDataSize(boolean doAddDataSize)
Determines if datasetSize metadata will be added to each InvDataset built
during catalog generation.
|
void |
setIdentifier(CrawlableDatasetLabeler identifier)
Set the CrawlableDatasetLabeler used to determine the ID of the InvDataset
built during catalog generation.
|
void |
setNamer(CrawlableDatasetLabeler namer)
Set the CrawlableDatasetLabeler used to determine the name of each
InvDataset built during catalog generation.
|
void |
setProxyDsHandlers(java.util.Map proxyDsHandlers) |
void |
setSorter(CrawlableDatasetSorter sorter)
Set the sorter with which to sort the list of child CrawlableDatasets.
|
void |
setTopLevelMetadataContainer(InvDatasetImpl topLevelMetadataContainer)
Set the InvDatasetImpl that contains the metadata for the top level dataset.
|
public CollectionLevelScanner(java.lang.String collectionPath, CrawlableDataset collectionLevel, CrawlableDataset catalogLevel, CrawlableDataset currentLevel, CrawlableDatasetFilter filter, InvService service)
The collectionLevel and catalogLevel parameters are used to properly determine the dataset urlPath. The catalogLevel must either be the collectionLevel or be a decendent of the collectionLevel. The currentLevel, if not null, must either be the catalogLevel or be a decendent of the catalogLevel.
The currentLevel parameter indicates what level is to be scanned. It is the same as the catalogLevel except for the case when catalogRefs are not used for all collection levels. (The urlPath is still determined as described above. Only the location of the datasets is changed.)
collectionPath
- the path of the collection, used as the base of all resulting dataset@urlPath values (may be "", if null, "" is used).collectionLevel
- the root of the collection to be cataloged (must not be a CrawlableDatasetAlias).catalogLevel
- the location, within the collection, for which a catalog is being generated.currentLevel
- the location, at or below the catalog level, which is to be scanned for datasets. Only necessary when multiple catalogs are to be aggregated. May be null. If null, assumed to be same as catalog level.filter
- determines which CrawlableDatasets are accepted as part of the collection.service
- the default service of all InvDatasets in the generated catalog.java.lang.IllegalArgumentException
public CollectionLevelScanner(CollectionLevelScanner cs)
public CrawlableDatasetSorter getSorter()
public void setSorter(CrawlableDatasetSorter sorter)
sorter
- the CrawlableDatasetSorter that will be used to sort the list of child CrawlableDatasets.public java.util.Map getProxyDsHandlers()
public void setProxyDsHandlers(java.util.Map proxyDsHandlers)
public void setCollectionId(java.lang.String collectionId)
collectionId
- protected java.lang.String getCollectionId()
public void setCollectionName(java.lang.String collectionName)
collectionName
- protected java.lang.String getCollectionName()
public void setIdentifier(CrawlableDatasetLabeler identifier)
identifier
- protected CrawlableDatasetLabeler getIdentifier()
public void setNamer(CrawlableDatasetLabeler namer)
namer
- protected CrawlableDatasetLabeler getNamer()
public void setDoAddDataSize(boolean doAddDataSize)
doAddDataSize
- protected boolean getDoAddDataSize()
public void addChildEnhancer(DatasetEnhancer childEnhancer)
childEnhancer
- public void setTopLevelMetadataContainer(InvDatasetImpl topLevelMetadataContainer)
topLevelMetadataContainer
- public void scan() throws java.io.IOException
java.io.IOException
- if an I/O error occurs while locating the contained datasets.public InvCatalogImpl generateCatalog() throws java.io.IOException
java.io.IOException
public InvCatalogImpl generateProxyDsResolverCatalog(ProxyDatasetHandler pdh)
pdh
- the ProxyDatasetHandler corresponding to the resolver request.java.lang.IllegalStateException
- if this collection has not yet been scanned.java.lang.IllegalArgumentException
- if the given ProxyDatasetHandler is not known by this CollectionLevelScanner.