Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thesaurus / Date improvements. #8392

Merged
merged 4 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions core/src/main/java/org/fao/geonet/kernel/Thesaurus.java
Original file line number Diff line number Diff line change
Expand Up @@ -1064,12 +1064,11 @@ private Date parseThesaurusDate(Element dateEl) {

StringBuffer errorMsg = new StringBuffer("Error parsing the thesaurus date value: ");
errorMsg.append(dateVal);
boolean success = false;

for (SimpleDateFormat df : dfList) {
try {
thesaurusDate = df.parse(dateVal);
success = true;
return thesaurusDate;
} catch (Exception ex) {
// Ignore the exception and try next format
errorMsg.append("\n * with format: ");
Expand All @@ -1079,11 +1078,9 @@ private Date parseThesaurusDate(Element dateEl) {
}
}
// Report error if no success
if (!success) {
errorMsg.append("\nCheck thesaurus date in ");
errorMsg.append(this.fname);
Log.error(Geonet.THESAURUS_MAN, errorMsg.toString());
}
errorMsg.append("\nCheck thesaurus date in ");
errorMsg.append(this.fname);
Log.error(Geonet.THESAURUS_MAN, errorMsg.toString());
return thesaurusDate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
<xsl:param name="withThesaurusAnchor"/>

<mri:descriptiveKeywords>
<xsl:namespace name="mri" select="'http://standards.iso.org/iso/19115/-3/mri/1.0'"/>
<xsl:namespace name="mcc" select="'http://standards.iso.org/iso/19115/-3/mcc/1.0'"/>
<xsl:namespace name="cit" select="'http://standards.iso.org/iso/19115/-3/cit/2.0'"/>
<xsl:namespace name="gco" select="'http://standards.iso.org/iso/19115/-3/gco/1.0'"/>
<xsl:namespace name="gcx" select="'http://standards.iso.org/iso/19115/-3/gcx/1.0'"/>
<xsl:namespace name="xlink" select="'http://www.w3.org/1999/xlink'"/>
<xsl:choose>
<xsl:when test="$withXlink">
<xsl:variable name="multiple"
Expand Down Expand Up @@ -257,20 +263,22 @@
codeListValue="{$thesauri/thesaurus[key = $currentThesaurus]/dname}" />
</mri:type>
<xsl:if test="$thesaurusInfo">
<xsl:variable name="thesaurus"
select="$thesauri/thesaurus[key = $currentThesaurus]"/>

<xsl:variable name="thesaurusInMainLanguage"
select="$thesauri/thesaurus[key = $currentThesaurus]
/multilingualTitles/multilingualTitle[
select="$thesaurus/multilingualTitles/multilingualTitle[
lang = util:twoCharLangCode($mainLanguage, '')]/title"/>
<xsl:variable name="thesaurusTitle"
select="if ($thesaurusInMainLanguage != '')
then $thesaurusInMainLanguage
else $thesauri/thesaurus[key = $currentThesaurus]/title"/>
else $thesaurus/title"/>
<mri:thesaurusName>
<cit:CI_Citation>
<cit:title>
<xsl:choose>
<xsl:when test="$withThesaurusAnchor = true()">
<gcx:Anchor xlink:href="{$thesauri/thesaurus[key = $currentThesaurus]/defaultNamespace}">
<gcx:Anchor xlink:href="{$thesaurus/defaultNamespace}">
<xsl:value-of select="$thesaurusTitle"/>
</gcx:Anchor>
</xsl:when>
Expand All @@ -282,121 +290,30 @@
</xsl:choose>
</cit:title>

<xsl:variable name="thesaurusDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/date)" />
<xsl:variable name="thesaurusCreatedDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/createdDate)"/>
<xsl:variable name="thesaurusIssuedDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/issuedDate)"/>
<xsl:variable name="thesaurusModifiedDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/modifiedDate)"/>
<xsl:variable name="thesaurusDates" as="node()*">
<publication date="{normalize-space($thesaurus/date)}"/>
<creation date="{normalize-space($thesaurus/createdDate)}"/>
<publication date="{normalize-space($thesaurus/issuedDate)}"/>
<publication date="{normalize-space($thesaurus/modifiedDate)}"/>
</xsl:variable>

<xsl:if test="$thesaurusDate != ''">
<xsl:for-each-group select="$thesaurusDates[@date != '']" group-by="@date">
<xsl:sort select="@date" order="descending"/>
<cit:date>
<cit:CI_Date>
<cit:date>
<xsl:choose>
<xsl:when test="contains($thesaurusDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusDate" />
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusDate" />
</gco:Date>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="{if (contains(current-grouping-key(), 'T')) then 'gco:DateTime' else 'gco:Date'}">
<xsl:value-of select="current-grouping-key()" />
</xsl:element>
</cit:date>
<cit:dateType>
<cit:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="publication" />
codeList="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#CI_DateTypeCode"
codeListValue="{name(current-group()[1])}"/>
</cit:dateType>
</cit:CI_Date>
</cit:date>
</xsl:if>

<!-- Publication Date-->
<xsl:choose>
<xsl:when test="$thesaurusIssuedDate != ''">
<cit:date>
<cit:CI_Date>
<cit:date>
<xsl:choose>
<xsl:when test="contains($thesaurusIssuedDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusIssuedDate" />
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusIssuedDate" />
</gco:Date>
</xsl:otherwise>
</xsl:choose>
</cit:date>
<cit:dateType>
<cit:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="publication" />
</cit:dateType>
</cit:CI_Date>
</cit:date>
</xsl:when>
<xsl:otherwise>
<cit:date>
<cit:CI_Date>
<cit:date>
<xsl:choose>
<xsl:when test="contains($thesaurusDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusDate" />
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusDate" />
</gco:Date>
</xsl:otherwise>
</xsl:choose>
</cit:date>
<cit:dateType>
<cit:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="publication" />
</cit:dateType>
</cit:CI_Date>
</cit:date>
</xsl:otherwise>
</xsl:choose>

<!--Creation Date-->
<xsl:if test="$thesaurusCreatedDate != ''">
<cit:date>
<cit:CI_Date>
<cit:date>
<xsl:choose>
<xsl:when test="contains($thesaurusCreatedDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusCreatedDate" />
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusCreatedDate" />
</gco:Date>
</xsl:otherwise>
</xsl:choose>
</cit:date>
<cit:dateType>
<cit:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="creation" />
</cit:dateType>
</cit:CI_Date>
</cit:date>
</xsl:if>
</xsl:for-each-group>

<xsl:if test="$withThesaurusAnchor">
<cit:identifier>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@
<xsl:param name="withThesaurusAnchor"/>

<gmd:descriptiveKeywords>
<xsl:namespace name="gmd" select="'http://www.isotc211.org/2005/gmd'"/>
<xsl:namespace name="gco" select="'http://www.isotc211.org/2005/gco'"/>
<xsl:namespace name="gmx" select="'http://www.isotc211.org/2005/gmx'"/>
<xsl:namespace name="xlink" select="'http://www.w3.org/1999/xlink'"/>
<xsl:choose>
<xsl:when test="$withXlink">
<xsl:variable name="isLocalXlink"
Expand Down Expand Up @@ -314,22 +318,24 @@
codeListValue="{$thesauri/thesaurus[key = $currentThesaurus]/dname}"/>
</gmd:type>
<xsl:if test="$thesaurusInfo">
<xsl:variable name="thesaurus"
select="$thesauri/thesaurus[key = $currentThesaurus]"/>

<xsl:variable name="thesaurusInMainLanguage"
select="$thesauri/thesaurus[key = $currentThesaurus]
select="$thesaurus
/multilingualTitles/multilingualTitle[
lang = util:twoCharLangCode($mainLanguage, '')]/title"/>
<xsl:variable name="thesaurusTitle"
select="if ($thesaurusInMainLanguage != '')
then $thesaurusInMainLanguage
else $thesauri/thesaurus[key = $currentThesaurus]/title"/>
else $thesaurus/title"/>

<gmd:thesaurusName>
<gmd:CI_Citation>
<gmd:title>
<xsl:choose>
<xsl:when test="$withTitleAnchor = true()">
<gmx:Anchor xlink:href="{$thesauri/thesaurus[key = $currentThesaurus]/defaultNamespace}">
<gmx:Anchor xlink:href="{$thesaurus/defaultNamespace}">
<xsl:value-of select="$thesaurusTitle"/>
</gmx:Anchor>
</xsl:when>
Expand All @@ -341,95 +347,31 @@
</xsl:choose>
</gmd:title>

<xsl:variable name="thesaurusDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/date)"/>
<xsl:variable name="thesaurusCreatedDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/createdDate)"/>
<xsl:variable name="thesaurusIssuedDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/issuedDate)"/>
<xsl:variable name="thesaurusModifiedDate"
select="normalize-space($thesauri/thesaurus[key = $currentThesaurus]/modifiedDate)"/>

<!-- Publication Date-->
<xsl:choose>
<xsl:when test="$thesaurusIssuedDate != ''">
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<xsl:choose>
<xsl:when test="contains($thesaurusIssuedDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusIssuedDate"/>
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusIssuedDate"/>
</gco:Date>
</xsl:otherwise>
</xsl:choose>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="publication"/>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</xsl:when>
<xsl:otherwise>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<xsl:choose>
<xsl:when test="contains($thesaurusDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusDate"/>
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusDate"/>
</gco:Date>
</xsl:otherwise>
</xsl:choose>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="publication"/>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="thesaurusDates" as="node()*">
<publication date="{normalize-space($thesaurus/date)}"/>
<creation date="{normalize-space($thesaurus/createdDate)}"/>
<publication date="{normalize-space($thesaurus/issuedDate)}"/>
<publication date="{normalize-space($thesaurus/modifiedDate)}"/>
</xsl:variable>

<!--Creation Date-->
<xsl:if test="$thesaurusCreatedDate != ''">
<xsl:for-each-group select="$thesaurusDates[@date != '']" group-by="@date">
<xsl:sort select="@date" order="descending"/>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<xsl:choose>
<xsl:when test="contains($thesaurusCreatedDate, 'T')">
<gco:DateTime>
<xsl:value-of select="$thesaurusCreatedDate"/>
</gco:DateTime>
</xsl:when>
<xsl:otherwise>
<gco:Date>
<xsl:value-of select="$thesaurusCreatedDate"/>
</gco:Date>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="{if (contains(current-grouping-key(), 'T')) then 'gco:DateTime' else 'gco:Date'}">
<xsl:value-of select="current-grouping-key()" />
</xsl:element>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode
codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="creation"/>
codeListValue="{name(current-group()[1])}"/>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</xsl:if>
</xsl:for-each-group>

<!--
You can pull in the publisher from the Thesaurus XML. See Metadata101/iso19139.ca.HNAP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@


<dcterms:issued><xsl:value-of select="if ($thesaurusDate != '') then $thesaurusDate else $now"/></dcterms:issued>
<dcterms:modified><xsl:value-of select="if ($thesaurusDate != '') then $thesaurusDate else $now"/></dcterms:modified>

<xsl:for-each select="distinct-values($concepts/*[skos:narrower and not(skos:broader)]/@rdf:about)">
<skos:hasTopConcept rdf:resource="{.}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@


<dcterms:issued><xsl:value-of select="if ($thesaurusDate != '') then $thesaurusDate else $now"/></dcterms:issued>
<dcterms:modified><xsl:value-of select="if ($thesaurusDate != '') then $thesaurusDate else $now"/></dcterms:modified>

<!-- Add top concepts for all items with no parent -->
<xsl:if test="$hasBroaderNarrowerLinks">
Expand Down