Skip to content

Commit

Permalink
Associated record / Store all relations in index.
Browse files Browse the repository at this point in the history
  • Loading branch information
fxprunayre committed Aug 7, 2020
1 parent 71509da commit cf7c688
Showing 1 changed file with 89 additions and 24 deletions.
113 changes: 89 additions & 24 deletions src/main/plugin/iso19115-3.2018/index-fields/index.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:util="java:org.fao.geonet.util.XslUtil"
xmlns:related="java:org.fao.geonet.api.records.MetadataUtils"
xmlns:index="java:org.fao.geonet.kernel.search.EsSearchManager"
xmlns:gn-fn-index="http://geonetwork-opensource.org/xsl/functions/index"
xmlns:xlink="http://www.w3.org/1999/xlink"
Expand Down Expand Up @@ -608,7 +609,7 @@
<!-- TODOES: Index translations -->
{"value": "<xsl:value-of select="gn-fn-index:json-escape(.)"/>"
<xsl:if test="@xlink:href">,
"link": "<xsl:value-of select="gn-fn-index:json-escape(@xlink:href)"/>"
"link": "<xsl:value-of select="gn-fn-index:json-escape(@xlink:href)"/>"
</xsl:if>
}
<xsl:if test="position() != last()">,</xsl:if>
Expand Down Expand Up @@ -905,6 +906,14 @@
</xsl:if>
</xsl:for-each-group>


<xsl:for-each select="mdb:contentInfo/*/mrc:featureCatalogueCitation[@uuidref != '']">
<xsl:variable name="xlink"
select="@xlink:href"/>
<xsl:copy-of select="gn-fn-index:build-record-link(@uuidref, $xlink, @xlink:title, 'fcats')"/>
</xsl:for-each>


<xsl:for-each select="mdb:resourceLineage/*">
<xsl:for-each select="mrl:lineage/mrl:LI_Lineage/
mrl:statement/gco:CharacterString[. != '']">
Expand All @@ -914,6 +923,7 @@
</xsl:for-each>
<xsl:for-each select="mrl:lineage//mrl:source[@uuidref]">
<hassource><xsl:value-of select="@uuidref"/></hassource>
<xsl:copy-of select="gn-fn-index:build-record-link(@uuidref, $xlink, @xlink:title, 'sources')"/>
</xsl:for-each>
</xsl:for-each>

Expand Down Expand Up @@ -983,16 +993,13 @@
<xsl:apply-templates mode="index-extra-fields" select="."/>

<xsl:variable name="recordLinks"
select="mdb:parentMetadata/@uuidref[. != '']"/>
select="mdb:parentMetadata[@uuidref != '']"/>
<xsl:choose>
<xsl:when test="count($recordLinks) > 0">
<xsl:for-each select="$recordLinks">
<parentUuid><xsl:value-of select="."/></parentUuid>
<recordGroup><xsl:value-of select="."/></recordGroup>
<recordLink type="object">{
"type": "parent",
"to": "<xsl:value-of select="."/>"
}</recordLink>
<parentUuid><xsl:value-of select="@uuidref"/></parentUuid>
<recordGroup><xsl:value-of select="@uuidref"/></recordGroup>
<xsl:copy-of select="gn-fn-index:build-record-link(@uuidref, @xlink:href, @xlink:title, 'parent')"/>
<!--
TODOES - Need more work with routing
<recordJoin type="object">{"name": "children", "parent": "<xsl:value-of select="gn-fn-index:json-escape(.)"/>"}</recordLink>-->
Expand All @@ -1003,6 +1010,7 @@
</xsl:otherwise>
</xsl:choose>


<xsl:for-each select=".//mri:associatedResource/*">
<xsl:variable name="code"
select="if (mri:metadataReference/@uuidref != '')
Expand All @@ -1013,22 +1021,32 @@
select="mri:associationType/*/@codeListValue"/>
<xsl:if test="$associationType = $parentAssociatedResourceType">
<parentUuid><xsl:value-of select="$code"/></parentUuid>
<recordLink type="object">{
"type": "parent",
"to": "<xsl:value-of select="$code"/>"
}</recordLink>
<xsl:copy-of select="gn-fn-index:build-record-link($code, $xlink, @xlink:title, 'parent')"/>
</xsl:if>

<xsl:variable name="initiativeType"
select="mri:initiativeType/*/@codeListValue"/>
<recordLink type="object">{
"type": "<xsl:value-of select="$associationType"/>",
"subtype": "<xsl:value-of select="$initiativeType"/>",
"to": "<xsl:value-of select="$code"/>"
}</recordLink>
<xsl:variable name="properties">
<properties>
<p name="associationType" value="{$associationType}"/>
<p name="initiativeType" value="{$initiativeType}"/>
</properties>
</xsl:variable>
<xsl:copy-of select="gn-fn-index:build-record-link($code, $xlink, @xlink:title, 'siblings', $properties)"/>
</xsl:if>
</xsl:for-each>

<xsl:variable name="indexingTimeRecordLink"
select="util:getSettingValue('system/index/indexingTimeRecordLink')" />
<xsl:if test="$indexingTimeRecordLink = 'true'">
<xsl:variable name="parentUuid"
select=".//mri:associatedResource/*[mri:associationType/*/@codeListValue = parentAssociatedResourceType]/mri:metadataReference/@uuidref[. != '']"/>
<xsl:variable name="recordsLinks"
select="related:getTargetAssociatedResourcesAsNode(
$identifier,
if ($parentUuid) then $parentUuid else mdb:parentMetadata[@uuidref != '']/@uuidref)"/>
<xsl:copy-of select="$recordsLinks//recordLink"/>
</xsl:if>
</doc>

<!-- Index more documents for this element -->
Expand Down Expand Up @@ -1131,14 +1149,61 @@

<xsl:if test="$datasetId != ''">
<recordOperateOn><xsl:value-of select="$datasetId"/></recordOperateOn>
<recordLink type="object">{
"type": "dataset",
"origin": "local",
"to": "<xsl:value-of select="$datasetId"/>"
<xsl:if test="@xlink:href">,
"link": "<xsl:value-of select="@xlink:href"/>"
<xsl:variable name="xlink"
select="@xlink:href"/>

<xsl:variable name="resolvedDoc">
<xsl:if test="$processRemoteDocs
and $xlink != ''
and not(@xlink:title)
and not(starts-with($xlink, $siteUrl))">
<!-- Process remote docs only if it was not encoded with a title and is not a local one.
- uses @xlink:href to retrieve the remote metadata and index the relevant information for related service.
- if the metadata is found in the catalogue, it's used that information.
The xlink: href attribute can contain a URI to the MD_DataIdentification part of the metadata record of the dataset.
Example:
<srv:operatesOn uuidref="c9c62f4f-a8da-438e-a514-5963fb1b047b"
xlink:href="https://server/geonetwork/srv/dut/csw?service=CSW&amp;request=GetRecordById&amp;version=2.0.2&amp;outputSchema=http://www.isotc211.org/2005/gmd&amp;elementSetName=full&amp;
id=c9c62f4f-a8da-438e-a514-5963fb1b047b#MD_DataIdentification"/>
Ignore it for indexing.
-->
<xsl:variable name="xlinkHref" select="tokenize(@xlink:href, '#')[1]" />

<!-- remote url: request the document to index data -->
<xsl:variable name="remoteDoc" select="util:getUrlContent(@xlink:href)" />

<!-- Remote url that uuid is stored also locally: Use local.
Remote is supposed to be ISO19139 or 115-3. -->
<xsl:variable name="datasetUuid"
select="$remoteDoc//(*[local-name(.) = 'fileIdentifier']/*/text()|
*[local-name(.) = 'metadataIdentifier']/*/*[local-name(.) = 'code']/*/text())" />

<xsl:if test="count($datasetUuid) = 1
and string($datasetUuid)">
<xsl:variable name="existsLocally"
select="not(normalize-space(util:getRecord($datasetUuid)) = '')" />

<xsl:if test="not($existsLocally)">
<xsl:variable name="datasetTitle"
select="$remoteDoc//*[local-name(.) = 'identificationInfo']/*
/*[local-name(.) = 'citation']/*
/*[local-name(.) = 'title']/*/text()" />

<xsl:copy-of select="gn-fn-index:build-record-link($datasetUuid, $xlinkHref, $datasetTitle, 'datasets')"/>
</xsl:if>
</xsl:if>
</xsl:if>
}</recordLink>
</xsl:variable>

<xsl:choose>
<xsl:when test="$resolvedDoc != ''">
<xsl:copy-of select="$resolvedDoc"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="gn-fn-index:build-record-link($datasetId, $xlink, @xlink:title, 'datasets')"/>
</xsl:otherwise>
</xsl:choose>
<!--
TODOES - Need more work with routing -->
<!-- <recordLink type="object">{"name": "dataset", "parent": "<xsl:value-of select="gn-fn-index:json-escape(.)"/>"}</recordLink>-->
Expand Down

0 comments on commit cf7c688

Please sign in to comment.