This page describes the concept implemented on:
https://git.magnolia-cms.com/gitweb/?p=modules/dam.git;a=shortlog;h=refs/heads/MGNLDAM-411
Problems with metadata
Rationale:
MGNLDAM-418
-
Getting issue details...
STATUS
MGNLDAM-411
-
Getting issue details...
STATUS
- Metadata are only really used in
DamTemplatingFunctions- the ui, for example, treats the metadata
as JCR properties of underyling Node of an Asset.
We need to be able to use custom metadata from templates & apps (fields, columns, ...)
- In
DamTemplatingFunctionswe assume thatAssetalways supportMagnoliaAssetMetadataandDublinCore
and we construct maps from them (bean to map).
Proposed solution:
Add method
Asset#supports(Class<? extends AssetMetadata> metaData);Create multibinding
AssetMetadataDefinitioninterface which will bind namespace withAssetMetadataextending class.
- Create
AssetMetadataRegistrywhich wraps all registered AssetMetadataDefinition classes.
- Create
DamTemplatingFunctions could then check the asset for support of every registered metadata class and
construct a map from it:
public Map<String, Object> getAssetMap(Asset asset) {
for (AssetMetadataDefinition metadataDefinition : metadataRegistry.getAll()) {
if (asset.supports(metadataDefinition.getMetadataClass())) {
...
Then in template:
[#assign assetMap = damfn.getAssetMap(asset)]
${assetMap.metadata.dc.contributor!}
Sorting: MGNLDAM-546
assetQuery.withKeyword("foo").orderBy(asset.getMetadata(DublinCore.class), "contributor", Order.ASCENDING)