All Downloads are FREE. Search and download functionalities are using the official Maven repository.

home.templates.rif.vm Maven / Gradle / Ivy

There is a newer version: 1.10.2
Show newest version
#macro(showElementRifCS $tag $field $attr $label $anzsrc)
    #set($valueMap = $util.getList($item, $field))
    #foreach($key in $valueMap.keySet())
        #set($value = $valueMap.get($key))     
            #if ($label != "" && $value.get($label)!= "")				
                #set($labelVal = $value.get($label))				
                #if ($anzsrc == "anzsrc")
                    #set($lastIndex = $labelVal.lastIndexOf('/') + 1 )
                    #set($labelVal = $labelVal.substring($lastIndex) )
                #end
    			<$tag$attr>$util.encodeXml($labelVal) 
        	#end
    #end
#end

#macro(showRelatedInfo $field $relatedInfoType $identifierType)
    
    #set($valueMap = $util.getList($item, $field))
    #foreach($key in $valueMap.keySet())
        #set ($row = $valueMap.get($key))
        #set ($value = $row.get("dc:identifier"))
        #if ("$!value" != "")
        
            $util.encodeXml($value)
            #set ($title = $row.get("dc:title"))
            #if ("$!title" != "")
            $util.encodeXml($title)
            #end
## Uncomment to map Notes as well
##            #set ($notes = $row.get("skos:note"))
##            #if ("$!notes" != "")
##            $util.encodeXml($notes)
##            #end
        
        #end
    #end
#end

#macro(geoSpatialMacro $field)
    #set($valueMap = $util.getList($item, $field))
    #foreach($key in $valueMap.keySet())
        #set($geoMap = $valueMap.get($key))
        #set($wkt = $geoMap.get("redbox:wktRaw"))
        #set($literal = $geoMap.get("rdf:PlainLiteral"))
        #set($type = $geoMap.get("dc:type"))

        #if($literal != "")
            #### Non - OpenLayers data
            #if($wkt == "")
                
                    $util.encodeXml($literal)
                    #if($type == "text")
                        #set($east = $geoMap.get("geo:long"))
                        #set($north = $geoMap.get("geo:lat"))
                        #if ("$!east" != "" &&"$!north" != "")
                        name=$util.encodeXml($literal); east=$east; north=$north; projection=WGS84
                        #end
                    #end
                
            #else
                #### Non - OpenLayers data
                #if($type != "")
                    #if ($literal.startsWith("POLYGON"))
                        #set($sanitisedLiteral = $literal.replaceFirst("POLYGON\(\((.*)\)\)", "$1"))
                        ###the placement of commas is counter to what's required
                        #set($literalArray = $sanitisedLiteral.split(","))
                        #foreach($pair in $literalArray)
                            #set($kmlResult = "$!kmlResult " + $pair.replace(" ", ","))
                        #end
                        #set($kml = $kmlResult.trim())
                        
                            $util.encodeXml($kml)
                        
                    #else
                        
                            $util.encodeXml($literal)
                        
                    #end
                #end
            #end
        #end
    #end
#end

#set($quote='"')

#set($defaultOnError = "&Invalid XML placeholder... prevents ANDS Harvesting records in error&")
#set($group = $systemConfig.getString($defaultOnError, "identity", "RIF_CSGroup"))

### Resolve the identifier
#set ($formId = $util.get($item, 'dc:identifier.rdf:PlainLiteral'))
#set ($formOrigin = $util.get($item, 'dc:identifier.redbox:origin'))
#set ($formType = $util.get($item, 'dc:identifier.dc:type.rdf:PlainLiteral'))

#set($pidType = $systemConfig.getString($defaultOnError, "curation", "pidType"))
#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 = "")
#set ($identifierType = "")
#if ($formOrigin == "internal")
    #if ($pid != "")
        #set ($identifier = $util.encodeXml($pid))
        #if ("$pidType" == "$defaultOnError")
            #set ($identifierType = $pidType)
        #else
            #set ($identifierType = $util.encodeXml($pidType))
        #end
    #else
        #set ($identifier = $util.encodeXml("$urlBase/detail/$oid"))
        #set ($identifierType = "uri")
    #end
#else
    #set ($identifier = $util.encodeXml($formId))
    #set ($identifierType = $util.encodeXml($formType))
#end
#if ("$!identifier" == "")
    ## We want invalid XML here so the record is never harvested without the correct ID
    #set($identifier = "&Invalid ID: Not curated yet&")
    #set ($identifierType = "invalid")
#end

####set($lang = "xml:lang=${quote}$util.get($item, 'dc:language.dc:identifier')${quote}")
#set($lang = "xml:lang=${quote}en${quote}")

            #if ("$group" == "$defaultOnError")
                
            #else
                
            #end

        $identifier
        $urlBase

        #set($dateModified = "")
        #if ($util.get($item, 'dc:modified') != "")
            #set($rawModified = "$util.getW3CDateTime($util.get($item, 'dc:modified'))")
            #set($dateModified = "dateModified=${quote}${rawModified}${quote}")
        #end

        #set($dateAccessioned = "")
        #if ($util.get($item, "dc:created") != "")
            #set($rawAccessioned = "$util.getW3CDateTime($util.get($item, 'dc:created'))")
            #set($dateAccessioned = "dateAccessioned=${quote}${rawAccessioned}${quote}")
        #end

        #################
        ## The order of child codes under  is important, don't
        ## change the order or the XML will not validate:
        ##  1)  
        ##  2)  
        ##  3)  
        ##  4)  
        ##  5)  
        ##  6)  
        ##  7)  
        ##  8)  
        ##  9)  
        ##  10) 
        ##
        ##  http://services.ands.org.au/documentation/rifcs/1.6/schemadocs/registryObjects.html
        #################
        
            $identifier

             ## Additional identifiers
             #set($valueMap = $util.getList($item, "dc:additionalidentifier"))
             #foreach($key in $valueMap.keySet())
                 #set ($row = $valueMap.get($key))
                 #set ($additionalIdentifier = $row.get("rdf:PlainLiteral"))
                 #set ($additionalIdentifierType = $row.get("type.rdf:PlainLiteral"))
                 #if ("$!additionalIdentifier" != "" && "$!additionalIdentifierType" != "")
                    $util.encodeXml($additionalIdentifier)
                 #end
             #end

            
                $util.encodeXml($util.get($item, "dc:title"))
            

        ## Dates
        ## Just date created for now to reach ANDS Quality Level 3
        #set($dateCreated = "")
        #if ($util.get($item, "dc:created") != "")
            #set($dateCreated = "$util.getW3CDateTime($util.get($item, 'dc:created'))")
            
                $dateCreated
            
        #end


        ## Location
        #set($valueMap = $util.getList($item, "bibo:Website"))
        #set($firstValue = "")
        #if ($valueMap.size() > 0)
            #set($firstValue = $valueMap.get("1").get("dc:identifier"))
        #end
        #set ($physicalLocation = $util.get($item, "vivo:Location.vivo:GeographicLocation.gn:name"))
        #if ("$!physicalLocation" != "" || "$!firstValue" != "")
            
            #foreach($key in $valueMap.keySet())
                #set ($value = $valueMap.get($key).get("dc:identifier"))
                #if ("$!value" != "")
                
                    
                        $util.encodeXml($value)
                    
                
                #end
            #end

            #### Physical location
            #if ("$!physicalLocation" != "")
                
                    
                        $util.encodeXml($physicalLocation)
                    
                
            #end
            #set ($value = $util.get($item, "locrel:prc.foaf:Person.foaf:email"))
            #if ("$!value" != "")
                 
                    
                        $util.encodeXml($value)
                    
                
            #end

            
        #end
        #set ($recordAsLocation = $util.get($item, "recordAsLocationDefault"))
        #if ("$!$recordAsLocation" != "")
            
                
                    
                        $util.encodeXml($recordAsLocation)
                    
                
            
        #end
        #set ($covFrom = $util.get($item, "dc:coverage.vivo:DateTimeInterval.vivo:start"))
        #set ($covTo = $util.get($item, "dc:coverage.vivo:DateTimeInterval.vivo:end"))
        #set ($covPeriod = $util.get($item, "dc:coverage.redbox:timePeriod"))
        #if ("$!covFrom" != "" || "$!covTo" != "" || "$!covPeriod" != "")
            
                
                    #if ("$!covFrom" != "")
                        $util.getW3CDateTime($covFrom)
                    #end
                    #if ("$!covTo" != "")
                        $util.getW3CDateTime($covTo)
                    #end
                    #if ("$!covPeriod" != "")
                        $util.encodeXml($covPeriod)
                    #end
                
            
        #end

            #geoSpatialMacro("dc:coverage.vivo:GeographicLocation")

            ### Relations
            #set($valueList = $item.getJsonSimpleList("relationships"))
            #set($relationshipKeys = [])
            #if($valueList)
                #foreach($value in $valueList)
                    #if ($value.getBoolean(false, "isCurated"))
                        #set($key = $value.getString("empty", "curatedPid"))
                        #set($rel = $value.getString("hasAssociationWith", "relationship"))
                        #set($desc = $value.getString("empty", "description"))
                        #if ($key != "empty")
                            #set($dummy = $relationshipKeys.add($key))
                            
                                $key
                                #if ($desc != "empty")
                                    
                                        $util.encodeXml($desc)
                                    
                                #else
                                    
                                #end
                            
                        #end
                    #end
                #end
            #end

            ### National Library Creators - Non-curated
            #set($valueMap = $util.getList($item, "dc:creator.foaf:Person"))
            #foreach($key in $valueMap.keySet())
                #set ($value = $valueMap.get($key).get("dc:identifier"))
                #if ("$!value" != "" && ( $value.startsWith("http://nla.gov.au/nla.party-") || $value.startsWith("http://orcid.org/")))
            
                $util.encodeXml($value)
                
            
                #end
            #end
			
			
			
           	#showElementRifCS ("rif:subject"  "dc:subject.vivo:keyword"  " type=${quote}local${quote} $lang"  "rdf:PlainLiteral"  "")
            #showElementRifCS ("rif:subject"  "dc:subject.anzsrc:for"  " type=${quote}anzsrc-for${quote} $lang"  "rdf:resource"  "anzsrc")
            #showElementRifCS ("rif:subject"  "dc:subject.anzsrc:seo"  " type=${quote}anzsrc-seo${quote} $lang"  "rdf:resource"  "anzsrc")
            

			
            
        #set ($value = $util.get($item, "dc:subject.anzsrc:toa.skos:prefLabel"))
        #if ("$!value" != "")
            $util.encodeXml($value)
        #end

        ################
        ## Description

        #set($valueMap = $util.getList($item, "dc:description"))
        #foreach($key in $valueMap.keySet())
            #set($description =  $valueMap.get($key))
            #set($descText = $description.get("shadow"))
            #set($descType = $description.get("type"))
            #if("$!descText" != "")
                $util.encodeXml($descText)
            #end
        #end


        #################
        ## Rights
        #set ($accessRights = $util.get($item, "dc:accessRights.skos:prefLabel"))
        #set ($accessRightsUri = $util.get($item, "dc:accessRights.dc:identifier"))
        #set ($accessRightsUriStr = "")
        #if ("$!accessRightsUri" != "")
            #set ($accessRightsUriStr = " rightsUri=${quote}${accessRightsUri}${quote}")
        #end
        #set ($accessRightsType = $util.get($item, "dc:accessRightsType"))
        #set ($accessRightsTypeStr = "")
        #if ("$!accessRightsType" != "")
            #set ($accessRightsTypeStr = " type=${quote}${accessRightsType}${quote}")
        #end
        #set ($rights = $util.get($item, "dc:accessRights.dc:RightsStatement.skos:prefLabel"))
        #set ($rightsUri = $util.get($item, "dc:accessRights.dc:RightsStatement.dc:identifier"))
        #set ($rightsUriStr = "")
        #if ("$!rightsUri" != "")
            #set ($rightsUriStr = " rightsUri=${quote}${rightsUri}${quote}")
        #end
        #set ($licence = $util.get($item, "dc:license.skos:prefLabel"))
        #set ($licenceUri = $util.get($item, "dc:license.dc:identifier"))
        #set ($licenceUriStr = "")
        #if ("$!licenceUri" != "")
            #set ($licenceUriStr = " rightsUri=${quote}${licenceUri}${quote}")
        #else
            #set ($licence = $util.get($item, "dc:license.rdf:Alt.skos:prefLabel"))
            #set ($licenceUri = $util.get($item, "dc:license.rdf:Alt.dc:identifier"))
            #if ("$!licenceUri" != "")
                #set ($licenceUriStr = " rightsUri=${quote}${licenceUri}${quote}")
            #end
        #end
        #set($licenceTypes = {"CC BY: Attribution 3.0 AU": "CC-BY",
        "CC BY-SA: Attribution-Share Alike 3.0 AU": "CC-BY-SA",
        "CC BY-ND: Attribution-No Derivative Works 3.0 AU": "CC-BY-ND",
        "CC BY-NC: Attribution-Noncommercial 3.0 AU": "CC-BY-NC",
        "CC BY-NC-SA: Attribution-Noncommercial-Share Alike 3.0 AU": "CC-BY-NC-SA",
        "CC BY-NC-ND: Attribution-Noncommercial-No Derivatives 3.0 AU": "CC-BY-NC-ND",
        "CC BY 4.0: Attribution 4.0 International": "CC-BY",
        "CC BY-SA 4.0: Attribution-Share Alike 4.0 International": "CC-BY-SA",
        "CC BY-ND 4.0: Attribution-No Derivative Works 4.0 International": "CC-BY-ND",
        "CC BY-NC 4.0: Attribution-Noncommercial 4.0 International": "CC-BY-NC",
        "CC BY-NC-SA 4.0: Attribution-Noncommercial-Share Alike 4.0 International": "CC-BY-NC-SA",
        "CC BY-NC-ND 4.0: Attribution-Noncommercial-No Derivatives 4.0 International": "CC-BY-NC-ND",
        "PDDL - Public Domain Dedication and License 1.0": "Unknown/Other",
        "ODC-By - Attribution License 1.0": "Unknown/Other",
        "ODC-ODbL - Attribution Share-Alike for data/databases 1.0": "Unknown/Other"
        })
        #set ($licenceType = "")
        #if ("$!licence" != "")
            #set ($licenceType = $licenceTypes.get($licence))
             #if ("$!licenceType" == "")
                #set($licenceType = "Unknown/Other")
             #end
        #end
        #set ($licenceTypeStr = "")
        #if ("$!licenceType" != "")
            #set ($licenceTypeStr = " type=${quote}${licenceType}${quote}")
        #end

        #if ("$!accessRights" != "" || "$!rights" != "" || "$!licence" != "")
            
            #if ("$!rights" != "")
                $util.encodeXml($rights)
            #end
            #if ("$!accessRights" != "")
                $util.encodeXml($accessRights)
            #end
            #if ("$!licence" != "")
                $util.encodeXml($licence)
            #end
            
        #end
        #################
		
        #showRelatedInfo("dc:relation.swrc:Publication", "publication", "uri")
        #showRelatedInfo("dc:relation.bibo:Website", "website", "uri")
        #showRelatedInfo("dc:relation.vivo:Service", "service", "uri")

        #set($valueMap = $util.getList($item, "dc:relation.vivo:Service"))
        #foreach($key in $valueMap.keySet())
            #set ($row = $valueMap.get($key))
            #set ($value = $row.get("dc:identifier"))
            ### Do not add related object if already listed in objects from curated relationships
            #if ("$!relationshipKeys" == "")
                #set ($relationshipKeys = [])
            #end
            #if ("$!value" != "" && !$relationshipKeys.contains($value))
                
                    $util.encodeXml($value)
                    #set ($relationship = $row.get("vivo:Relationship.rdf:PlainLiteral"))
                    #if ("$relationship" != "")
                    
                    #end
                
            #end
        #end


        #set($showCitation = $util.get($item, "dc:biblioGraphicCitation.redbox:sendCitation"))
        #if ("$!showCitation" != "" && $showCitation == "on")
            #set($doiProperty = $systemConfig.getString($defaultOnError, "andsDoi", "doiProperty"))
            #set ($doi = $util.getMetadata($object, $doiProperty))
            ## Use the DOI by preference for a citation
            #if ("$!doi" == "")
                #set ($citeId = $identifier)
                #set ($citeIdType = $identifierType)
            #else
                #set ($citeId = "http://dx.doi.org/${doi}")
                #set ($citeIdType = "doi")
            #end
            
            #set($citationString = $util.get($item, "dc:biblioGraphicCitation.skos:prefLabel"))
            #if ("$!citationString" != "")
                $util.encodeXml($citationString.replaceAll("\{ID_WILL_BE_HERE\}", $citeId))
            #end
            ##  has now been removed.
            ## See http://code.google.com/p/redbox-mint/issues/detail?id=77
            
        #end
        
    




© 2015 - 2024 Weber Informatics LLC | Privacy Policy