Skip to content

Commit

Permalink
Feature catalogue / Add table of content of feature types
Browse files Browse the repository at this point in the history
A feature catalogue can contain one or more feature types description.
When describing a model with lots of feature types, then the editor can be quite large (and then can cause issue related to timeout or number of fields)

The problem is quite similar to #7998 (ie. timeout, number of form fields).

To better manage this case, make a list of existing feature types and user can click on it to edit only one feature type at a time.

This is enable by default for ISO19110 and ISO19115-3 feature catalogue
in all views. The first table is selected by default.

A selector can be manually configured using the following:

```xml
          <section name="gfc:featureType">
            <select name="Select a feature type"
                    xpath="/gfc:FC_FeatureCatalogue/gfc:featureType"
                    parameter="featureType"
                    value="*/gfc:typeName/gco:LocalName/text()"
                    layout="dropdown"/>
                    <!--tabs|pills|dropdown-->

            <section xpath="/gfc:FC_FeatureCatalogue/gfc:featureType[
                                    */gfc:typeName/gco:LocalName = $p2/featureType
                                    or (not($p2/featureType) and position() = 1)
                                    or ($p3 = 'md.format.html')]"
                     or="featureType"
                     in="/gfc:FC_FeatureCatalogue"/>
          </section>
```

`$p2` correspond to the variable `request` and `$p3` to the `service` in the XSL template (see `base-variables.xsl` and `evaluate.xsl`).
So if there is no `featureType` parameter, the first feature type will be displayed.
If the view mode is `md.format.html`, all feature types will be displayed.

It has only been tested for feature catalogue but can be probably reuse
in other places eg. conformity

* Dropdown (default)

* Tabs

* Pills

* Avoid JS error on large forms by using JQuery `empty()` instead of
find and remove:

```
RangeError: Maximum call stack size exceeded
    at Sizzle.select (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:2592:12)
    at Function.Sizzle [as find] (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:869:9)
    at jQuery.fn.init.find (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:2792:11)
    at refreshForm (EditorService.js:324:42)
```

* ISO19110 to ISO19115-3 conversion / Convert cardinality to
  CharacterString
  • Loading branch information
fxprunayre committed Sep 11, 2024
1 parent c2a3f5f commit 3af8717
Show file tree
Hide file tree
Showing 33 changed files with 383 additions and 15 deletions.
6 changes: 5 additions & 1 deletion core/src/main/java/org/fao/geonet/util/XslUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,11 @@ private static List<Element> buildRecordLink(List<Hit> hits, String type) {
public static String escapeForJson(String value) {
return StringEscapeUtils.escapeJson(value);
}


public static String escapeForEcmaScript(String value) {
return StringEscapeUtils.escapeEcmaScript(value);
}

public static String getWebAnalyticsService() {
ApplicationContext applicationContext = ApplicationContextHolder.get();
WebAnalyticsConfiguration webAnalyticsConfiguration = applicationContext.getBean(WebAnalyticsConfiguration.class);
Expand Down
63 changes: 63 additions & 0 deletions schemas/config-editor.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ the mandatory section with no name and then the inner elements.
</xs:element>
<xs:element ref="action"/>
<xs:element ref="directive"/>
<xs:element ref="select"/>
<xs:element ref="text"/>
<xs:element ref="xsl"/>
<xs:element ref="section"/>
Expand Down Expand Up @@ -2530,4 +2531,66 @@ added in the directive panel eg. `text` for guidelines or add `action` to easily
</xs:sequence>
</xs:complexType>
</xs:element>


<xs:element name="select">
<xs:annotation>
<xs:documentation><![CDATA[
Create a selector on an element to minimize form size when complex elements are repeated.
For example, a feature catalogue can describe many feature types. Instead of displaying
all feature types, add a dropdown (or tabs) to select one and edit it.
The selector will add the parameter with the selected value to the form.
Add a dynamic section with a reference to that parameter to build the editor form for the requested element.
.. code-block:: xml
<section name="gfc:featureType">
<select name="Select a feature type"
xpath="/gfc:FC_FeatureCatalogue/gfc:featureType"
parameter="featureType"
value="*/gfc:typeName/gco:LocalName/text()"
layout="dropdown"/>
<field xpath="/gfc:FC_FeatureCatalogue/gfc:featureType[
*/gfc:typeName/gco:LocalName = $p2/featureType
or (not($p2/featureType) and position() = 1)
or ($p3 = 'md.format.html')]"
or="featureType"
in="/gfc:FC_FeatureCatalogue"/>
</section>
`$p2` correspond to the variable `request` and `$p3` to the `service` in the XSL template (see `base-variables.xsl`).
So if there is no `featureType` parameter, the first feature type will be displayed.
If the view mode is `md.format.html`, all feature types will be displayed.
]]></xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="name" use="optional" type="xs:string"/>
<xs:attribute name="xpath" use="required" type="xs:string"/>
<xs:attribute name="parameter" use="required" type="xs:string"/>
<xs:attribute name="value" use="required" type="xs:string"/>
<xs:attribute name="icon" use="required" type="xs:string">
<xs:annotation>
<xs:documentation><![CDATA[Icon display on the dropdown selector.]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="layout" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="dropdown"/>
<xs:enumeration value="tabs"/>
<xs:enumeration value="pills"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:anyAttribute/>
</xs:complexType>
</xs:element>
</xs:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
<xsl:template name="evaluate-dublin-core">
<xsl:param name="base" as="node()"/>
<xsl:param name="in"/>
<xsl:copy-of select="saxon:evaluate(concat('$p1', $in), $base)"/>
<xsl:copy-of select="saxon:evaluate(concat('$p1', $in), $base, $request, $service)"/>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@

<!-- View configuration -->
<views>
<view name="default" default="true">
<view name="default" default="true"
class="gn-label-above-input gn-indent-bluescale">
<sidePanel>
<directive data-gn-need-help="creating-metadata"/>
<directive data-gn-associated-resources-panel="gnCurrentEdit.metadata" />
Expand All @@ -91,18 +92,22 @@
in="/gfc:FC_FeatureCatalogue"/>
<field xpath="/gfc:FC_FeatureCatalogue/gfc:functionalLanguage" or="functionalLanguage"
in="/gfc:FC_FeatureCatalogue"/>
<field xpath="/gfc:FC_FeatureCatalogue/gfc:featureType" or="featureType" in="/gfc:FC_FeatureCatalogue"/>
<field xpath="/gfc:FC_FeatureCatalogue/gfc:featureType" or="featureType"
in="/gfc:FC_FeatureCatalogue"/>

<action type="suggest"
process="add-columns-from-csv"/>
</section>
</tab>
<flatModeExceptions>
<for name="gfc:code"/>
<for name="gfc:featureType"/>
<for name="gfc:carrierOfCharacteristics"/>
<for name="gfc:listedValue"/>
</flatModeExceptions>
</view>
<view name="advanced">
<view name="advanced"
class="gn-label-above-input gn-indent-bluescale">
<sidePanel>
<directive data-gn-need-help="creating-metadata"/>
<directive data-gn-validation-report=""/>
Expand Down
18 changes: 17 additions & 1 deletion schemas/iso19110/src/main/plugin/iso19110/layout/evaluate.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@
<xsl:template name="evaluate-iso19110">
<xsl:param name="base" as="node()"/>
<xsl:param name="in"/>
<xsl:copy-of select="saxon:evaluate(concat('$p1', $in), $base)"/>

<xsl:variable name="nodeOrAttribute" select="saxon:evaluate(concat('$p1', $in), $base, $request, $service)"/>

<xsl:choose>
<xsl:when test="$nodeOrAttribute instance of text()+">
<xsl:value-of select="$nodeOrAttribute"/>
</xsl:when>
<xsl:when test="$nodeOrAttribute instance of element()+">
<xsl:copy-of select="$nodeOrAttribute"/>
</xsl:when>
<xsl:when test="$nodeOrAttribute instance of attribute()+">
<xsl:value-of select="$nodeOrAttribute"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$nodeOrAttribute"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
44 changes: 42 additions & 2 deletions schemas/iso19110/src/main/plugin/iso19110/layout/layout.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
~ Rome - Italy. email: [email protected]
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gmd="http://www.isotc211.org/2005/gmd"
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:gmx="http://www.isotc211.org/2005/gmx"
xmlns:gfc="http://www.isotc211.org/2005/gfc"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:gn="http://www.fao.org/geonetwork"
xmlns:gn-fn-metadata="http://geonetwork-opensource.org/xsl/functions/metadata"
xmlns:gn-fn-iso19110="http://geonetwork-opensource.org/xsl/functions/profiles/iso19110"
Expand All @@ -38,7 +40,7 @@
<xsl:include href="layout-custom-fields.xsl"/>

<!-- Ignore all gn element -->
<xsl:template mode="mode-iso19110" match="gn:*|@gn:*" priority="1000"/>
<xsl:template mode="mode-iso19110" match="gn:*|@gn:*|@id|@uuid" priority="1000"/>


<!-- Template to display non existing element ie. geonet:child element
Expand Down Expand Up @@ -70,6 +72,43 @@
</xsl:template>


<xsl:template mode="mode-iso19110"
match="gfc:featureType"
priority="2000">

<xsl:variable name="isFirstFeatureType"
select="preceding-sibling::*[1]/name() != 'gfc:featureType'"
as="xs:boolean"/>

<xsl:if test="$isFirstFeatureType">
<xsl:variable name="selector" as="node()*">
<select name="selectFeaturetype"
icon="fa gn-icon-featureCatalog"
xpath="/gfc:FC_FeatureCatalogue/gfc:featureType"
parameter="featureType"
value="*/gfc:typeName/gco:LocalName/text()"
layout="dropdown"/>
</xsl:variable>
<xsl:apply-templates mode="form-builder"
select="$selector">
<xsl:with-param name="base" select="ancestor::gfc:FC_FeatureCatalogue"/>
</xsl:apply-templates>
</xsl:if>

<xsl:variable name="isRequestedFeatureType"
select="*/gfc:typeName/gco:LocalName = $request/featureType"/>

<xsl:variable name="isRequestedFeatureTypeInCurrentRecord"
select="count(../gfc:featureType[*/gfc:typeName/gco:LocalName = $request/featureType]) > 0"/>

<xsl:if test="$isRequestedFeatureType
or (not($isRequestedFeatureTypeInCurrentRecord) and $isFirstFeatureType)
or ($service = 'md.format.html')">
<xsl:call-template name="mode-iso19110-fieldset"/>
</xsl:if>
</xsl:template>


<!-- Visit all XML tree recursively -->
<xsl:template mode="mode-iso19110" match="gfc:*">
<xsl:apply-templates mode="mode-iso19110" select="*|@*"/>
Expand All @@ -85,6 +124,7 @@

<!-- Boxed element -->
<xsl:template mode="mode-iso19110" priority="200"
name="mode-iso19110-fieldset"
match="gfc:*[gfc:FC_FeatureType]|
gfc:*[gfc:FC_AssociationRole]|
gfc:*[gfc:FC_AssociationOperation]|
Expand Down
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/ara/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
<advanced>Full</advanced>
<default>Simple</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/cat/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
<advanced>Complet</advanced>
<default>Senzill</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/chi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
<advanced>Full</advanced>
<default>Simple</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<xml_iso19110Tooai_dc>Save this metadata as an OAI Dublin Core XML file</xml_iso19110Tooai_dc>

<advanced>Volledig</advanced>
<default>Eenvoudig</default>
<default>Standaard</default>
<xml>XML</xml>
<selectFeaturetype>Selecteer een objecttype</selectFeaturetype>
<missingFeatureTypeName>Nieuw objecttype</missingFeatureTypeName>
</strings>
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/eng/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@
<advanced>Full</advanced>
<default>Simple</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/fin/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
<advanced>Full</advanced>
<default>Simple</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/fre/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
<advanced>Complète</advanced>
<default>Simple</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/ger/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
<advanced>Full</advanced>
<default>Simple</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/ita/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
<advanced>Full</advanced>
<default>Simple</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/nor/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
<advanced>Full</advanced>
<default>Simple</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/por/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@
<advanced>Full</advanced>
<default>Simple</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/rus/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
<advanced>Full</advanced>
<default>Simple</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/slo/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@
<advanced>Celý rozsah</advanced>
<default>Jednoduchý</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/spa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
<advanced>Completo</advanced>
<default>Simple</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
3 changes: 3 additions & 0 deletions schemas/iso19110/src/main/plugin/iso19110/loc/tur/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@
<advanced>Full</advanced>
<default>Simple</default>
<xml>XML</xml>
<selectFeaturetype>Select a feature type</selectFeaturetype>
<missingFeatureTypeName>New feature type</missingFeatureTypeName>

</strings>
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@
<xsl:value-of select="."/>
</xsl:template>

<!--
Feature Catalogue cardinality is changed from a gco:Multiplicity to a CharacterString
-->
<xsl:template match="gfcold:cardinality" priority="5" mode="from19139to19115-3.2018">
<gfc:cardinality>
<gco:CharacterString>
<xsl:value-of select="concat(*/gcoold:range/*/gcoold:lower/*/text(), '..', */gcoold:range/*/gcoold:upper/*/text())"/>
</gco:CharacterString>
</gfc:cardinality>
</xsl:template>

<xsl:template match="gmd:language|gmd:locale" priority="5" mode="from19139to19115-3.2018">
<xsl:variable name="nameSpacePrefix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<xsl:param name="in"/>
<!-- <xsl:message>in xml <xsl:copy-of select="$base"></xsl:copy-of></xsl:message>
<xsl:message>search for <xsl:copy-of select="$in"></xsl:copy-of></xsl:message>-->
<xsl:variable name="nodeOrAttribute" select="saxon:evaluate(concat('$p1', $in), $base)"/>
<xsl:variable name="nodeOrAttribute" select="saxon:evaluate(concat('$p1', $in), $base, $request, $service)"/>

<xsl:choose>
<xsl:when test="$nodeOrAttribute instance of text()+">
Expand All @@ -61,7 +61,7 @@
<xsl:param name="base" as="node()"/>
<xsl:param name="in"/>

<xsl:value-of select="saxon:evaluate(concat('$p1', $in), $base)"/>
<xsl:value-of select="saxon:evaluate(concat('$p1', $in), $base, $request, $service)"/>
</xsl:template>

</xsl:stylesheet>
Loading

0 comments on commit 3af8717

Please sign in to comment.