-
-
Notifications
You must be signed in to change notification settings - Fork 495
Metadata Massive Replace
Date | Apr 22 2014 | Contacts | Jose García |
Status | In Progress | Release | 2.12 |
Resources | coming soon | Ticket # | |
Source code | coming soon | ||
Funding | Ontario Ministry of Natural Resources (OMNR), Environment Canada |
This proposal adds a new feature to apply a massive replacement process in the content of metadata records selection. The feature is focussed in iso19139 metadata, but can be extended in the future to other non iso19139 profiles.
The user can select a set of metadata records and define the replacements to apply from a predefined list of fields classified in sections:
The feature allows to test the replacements before applying them, getting a report with all the metadata records updated and the individual change(s) applied to each metadata.
Other approach for massive update can be to use XLinks to reference contacts and other sections in the metadata that can require massive updates for example if a phone number changes or the responsible of the metadata leaves the organisation, but not always is an option for users to use XLinks.
The list of fields to replace is defined in a translations file using this format (field key, field label):
<section id="Metadata">
<field key="id.contact.individualName">Contact > Individual Name</field>
<field key="id.contact.organisationName">Contact > Organization Name</field>
... more fields
</section>
<section id="Identification">
<field key="id.dataid.abstract">Data Identification > Abstract</field>
<field key="id.dataid.purpose">Data Identification > Purpose</field>
... more fields
</section>
In the iso19139 schema has been added a xslt massive-content-update.xsl
in the process
folder. This xslt receives an xml content with the list of replacements and applies it to the selected metadata:
List of replacements received by the process, for each replacement are defined these values:
- Field identifier
- Search value
- Replace value
<replacements>
<replacement>
<field>id.contact.individualName</field>
<searchValue>John</searchValue>
<replaceValue>Jennifer</replaceValue>
</replacement>
<replacement>
<field>id.contact.voicePhone</field>
<searchValue>44455454</searchValue>
<replaceValue>35445524</replaceValue>
</replacement>
</replacements>
The process applies the replacements and annotates the xml fields updated so can be displayed in the results report:
<!-- METADATA CONTACT updates: gmd:MD_Metadata/gmd:contact -->
<!-- individualName -->
<xsl:template match="gmd:MD_Metadata/gmd:contact/gmd:CI_ResponsibleParty/gmd:individualName">
<xsl:call-template name="replaceField">
<xsl:with-param name="fieldId">id.contact.individualName</xsl:with-param>
</xsl:call-template>
</xsl:template>
Here is a simplified snippet of the replacement template to highlight the checks done to apply a replacement and the annotation of a change in the field content:
<xsl:template name="replaceField">
<xsl:param name="fieldId" />
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:choose>
<!-- If there's a replacement for this field applied -->
<xsl:when test="$replacements/replacements/replacement[field = $fieldId] and string($replacements/replacements/replacement[field = $fieldId]/searchValue)">
<xsl:variable name="currentVal" select="gco:CharacterString" />
<xsl:variable name="newVal" select="replace(gco:CharacterString, $replacements/replacements/replacement[field = $fieldId]/searchValue, $replacements/replacements/replacement[field = $fieldId]/replaceValue, $case_insensitive)" />
<!-- If the field content has change --> annotate the change --->
<xsl:if test="$currentVal != $newVal">
<xsl:attribute name="geonet:change" select="$fieldId" />
<xsl:attribute name="geonet:original" select="$currentVal" />
<xsl:attribute name="geonet:new" select="$newVal" />
</xsl:if>
<xsl:value-of select="$newVal" />
</xsl:when>
<!-- No replacement for the field, just copy it -->
<xsl:otherwise>
<xsl:apply-templates select="@*|node()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
- Type: Search-UI
- Module: services, web-client, web
- Vote Proposed: TBA
- Jose García
If you have some comments, start a discussion, raise an issue or use one of our other communication channels to talk to us.