Package com.bc.ceres.metadata
Class MetadataResourceEngine
java.lang.Object
com.bc.ceres.metadata.MetadataResourceEngine
A engine for processing text resources using velocity. It supports:
- reading resources in XML or property format
- reading of resources belonging to source(s)
- allows to manipulate the used velocity context
- writing the context using given templates
- Since:
- Ceres 0.13.2
-
Constructor Summary
ConstructorsConstructorDescriptionMetadataResourceEngine
(SimpleFileSystem simpleFileSystem) Creates the metadata engine.MetadataResourceEngine
(SimpleFileSystem simpleFileSystem, MetadataResourceResolver metadataResourceResolver) Creates the metadata engine. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.velocity.VelocityContext
Return the used velocity context.void
readRelatedResource
(String sourceId, String sourcePath) Reads the all metadata file belonging to the given source item and places them into a map registered as 'sourceMetadata' the velocity context.readResource
(String name, String path) Reads the resource with the given path and stores its content in the velocity context using the given key.void
writeRelatedResource
(String templatePath, String targetPath) Writes metadata belonging to the given target item.
-
Constructor Details
-
MetadataResourceEngine
Creates the metadata engine.- Parameters:
simpleFileSystem
- A abstraction of the used filesystem.
-
MetadataResourceEngine
public MetadataResourceEngine(SimpleFileSystem simpleFileSystem, MetadataResourceResolver metadataResourceResolver) Creates the metadata engine.- Parameters:
simpleFileSystem
- A abstraction of the used filesystem.metadataResourceResolver
- A resolver for metadata resource names..
-
-
Method Details
-
getVelocityContext
public org.apache.velocity.VelocityContext getVelocityContext()Return the used velocity context.- Returns:
- the velocity context
-
readResource
Reads the resource with the given path and stores its content in the velocity context using the given key. If evaluate is set totrue
. The content will be evaluated using the current state of the velocity context.- Parameters:
name
- The name under which the metadata are placed into the velocity contextpath
- The path name of the metadata resource- Returns:
- The resource
- Throws:
IOException
- If an I/O error occurs
-
readRelatedResource
Reads the all metadata file belonging to the given source item and places them into a map registered as 'sourceMetadata' the velocity context. The 'sourceMetadata'-map contains the processed metadata files as another map. The map of metadata files can be retrieved using the key 'sourceId'.Metadata files belong to a source if they follow a naming pattern: For a given
sourcePath
"chl_a.nc", e.g. "chl_a-metadata.xml" and "chl_a-report.html" are considered.- Parameters:
sourceId
- The name under which the metadata are placed in the 'sourceMetadata'-mapsourcePath
- The path name of the source item- Throws:
IOException
- If an I/O error occurs
-
writeRelatedResource
Writes metadata belonging to the given target item. For this the velocity template is evaluated using the current context.The target metadata files follow a naming pattern: For a given
templatePath
"report.xml.vm" andtargetPath
"chl_a.nc" a target metadata file "chl_a-report.xml" gets written.- Parameters:
templatePath
- The path name of the velocity templatetargetPath
- The path name of the target item- Throws:
IOException
- If an I/O error occurs
-