home.templates.oai_dc.vm Maven / Gradle / Ivy
#macro(dc1 $tag)
#set ($value = $util.get($item, "dc:${tag}"))
#if ("$!value" != "")
$util.encodeXml($value)
#end
#end
#macro(dc2 $tag $field)
#set ($value = $util.get($item, $field))
#if ("$!value" != "")
$util.encodeXml($value)
#end
#end
#macro(dc3 $data $tag $field)
#set ($value = $data.get($field))
#if ("$!value" != "")
$util.encodeXml($value)
#end
#end
#macro(dcData $tag $data)
$util.encodeXml($data)
#end
#macro(relations $baseKey)
#set($valueMap = $util.getList($item, $baseKey))
#foreach($key in $valueMap.keySet())
#set($value = $valueMap.get($key).get("dc:identifier"))
#if ("$!value" != "")
$util.encodeXml($value)
#end
#end
#end
#macro(dcList $tag $baseKey $label)
#set($valueMap = $util.getList($item, $baseKey))
#foreach($key in $valueMap.keySet())
#set($values = $valueMap.get($key))
#if("$!label" == "")
#set($value = $values.get($key))
#else
#set($value = $values.get($label))
#end
$util.encodeXml($value)
#end
#end
#macro(dcAnzsrc $tag $baseKey $data $label)
#set($valueMap = $util.getList($item, $baseKey))
#foreach($key in $valueMap.keySet())
#set($values = $valueMap.get($key))
#if("$!label" != "")
#set($value = $values.get($label))
#else
#set($value = $values.get($data))
#end
#set($lastIndex = $value.lastIndexOf('-') + 1 )
#set($text = $value.substring($lastIndex).trim() )
$util.encodeXml($text)
#end
#end
### Resolve the identifier
#set ($formId = $util.get($item, 'dc:identifier.rdf:PlainLiteral'))
#set ($formOrigin = $util.get($item, 'dc:identifier.redbox:origin'))
#set($pidProperty = $systemConfig.getString($defaultOnError, "curation", "pidProperty"))
#set ($pid = $util.getMetadata($object, $pidProperty))
#if ("$!pid" == "")
#set ($pid = $util.get($item, "metadata", "rdf:resource"))
#if ("$!pid" == "")
#set ($pid = $util.get($item, "metadata", "dc.identifier"))
#end
#end
#set ($identifier = "")
#if ($formOrigin == "internal")
#if ($pid != "")
#set ($identifier = $pid)
#else
#set ($identifier = "$urlBase/detail/$oid")
#end
#else
#set ($identifier = $formId)
#end
$util.encodeXml($identifier)
#dc1("title")
## Type
#set ($type = $util.get($item, "dc:type.rdf:PlainLiteral"))
#if ("$!type" != "")
$util.encodeXml($type)
#end
### Date
#set ($dateFull = $util.get($item, "dc:created"))
#if ("$!dateFull" != "")
#set($index = $dateFull.indexOf('-'))
#set($date = $dateFull.substring(0, $index))
$util.encodeXml($date)
#end
### Language
#set ($langUri = $util.get($item, "dc:language.dc:identifier"))
#if ("$!langUri" != "")
#set($lastIndex = $langUri.lastIndexOf('/') + 1)
#set($lang = $langUri.substring($lastIndex))
$util.encodeXml($lang)
#end
#dc2("subject", "dc:coverage.redbox:timePeriod")
## Description tab
#dc1("description")
#relations("dc:relation.swrc:Publication")
#relations("dc:relation.bibo:Website")
## People
#set($valueMap = $util.getList($item, "dc:creator.foaf:Person"))
#foreach($key in $valueMap.keySet())
#set($value = $valueMap.get($key).get("foaf:name"))
#if ("$!value" != "")
$util.encodeXml($value)
#else
#set($value = $valueMap.get($key).get("foaf:givenName"))
#if ("$!value" != "")
#set($surname = $valueMap.get($key).get("foaf:familyName"))
#if ("$!surname" != "")
$util.encodeXml($surname), $util.encodeXml($value)
#else
$util.encodeXml($value)
#end
#end
#end
#end
#dcAnzsrc("subject" "dc:subject.anzsrc:for" "rdf:resource" "skos:prefLabel")
#dcAnzsrc("subject" "dc:subject.anzsrc:seo" "rdf:resource" "skos:prefLabel")
#dcList("subject" "dc:subject.vivo:keyword" "rdf:PlainLiteral")
#dc2("rights", "dc:accessRights.rdf:PlainLiteral")
#dc2("rights", "dc:accessRights.dc:RightsStatement")
#dc2("rights", "redbox:creativeCommonsLicense.dc:identifier")
#dc2("rights", "dc:license.dc:identifier")
## Management
#set($defaultOnError = "&Invalid XML placeholder... prevents ANDS Harvesting records in error&")
#set ($institution = $systemConfig.getString($defaultOnError, "identity", "RIF_CSGroup"))
#set ($affiliation = $util.get($item, "foaf:Organization.skos:prefLabel"))
#if ("$!affiliation" != "")
#set ($contributor = "${institution}. ${affiliation}")
#else
#set ($contributor = "${institution}.")
#end
$util.encodeXml($contributor)