geonetwork / core-geonetwork

GeoNetwork is a catalog application to manage spatially referenced resources. It provides powerful metadata editing and search functions as well as an interactive web map viewer. It is currently used in numerous Spatial Data Infrastructure initiatives across the world.
http://geonetwork-opensource.org/
GNU General Public License v2.0
420 stars 489 forks source link

how to associate a codelist with a field in config-editor.xml #7848

Open smrgeoinfo opened 7 months ago

smrgeoinfo commented 7 months ago

I have a number of vocabularies that need to be used for populating various text fields in the DDE metadata profile. We have labels and definitions, I can easily generate skos representations. I have gotten a field with templateModeOnly="true" to and a codelist from codelists.xml defined in the template/values/key/codelist element; this shows existing data, but I need to be able to create an add button in the editor that adds a value limited to the codelist.

I tried

         <action type="add" name=" " btnLabel="Add DDE acquisition type" 
            or="acquisitionInformation"
            in="/mdb:MD_Metadata">
            <template>
              <values>
                <key label="acquisitionCode" 
                  xpath="gco:CharacterString">
                  <codelist name="DDEAcqusitionTypeCode"/>
                </key>
              </values>
              <snippet>

                  <mac:MI_AcquisitionInformation>
                    <mac:operation>
                      <mac:MI_Operation>
                        <mac:description>
                          <gco:CharacterString>{{acquisitionCode}}</gco:CharacterString>
                        </mac:description>
                        <mac:status gco:nilReason="unknown"/>
                      </mac:MI_Operation>
                    </mac:operation>
                  </mac:MI_AcquisitionInformation>
              </snippet>
            </template>
          </action>

this displays teh button, but when you click on it, nothing happens.
in config-editor.xml, batchEdit section, I see:

 <field name="topicCats" xpath="mri:identificationInfo/*/
                      mri:topicCategory" use="data-gn-codelist-picker"
        codelist="mri:MD_TopicCategoryCode" indexField="topicCat" insertMode="gn_create">

and in https://github.com/geonetwork/core-geonetwork/pull/7227

<field xpath="/*/gmd:identificationInfo/*/gmd:resourceConstraints/*[gmd:accessConstraints]/gmd:otherConstraints"
                 del="../.."
                 use="data-gn-keyword-picker">
            <directiveAttributes 
                                 data-thesaurus-key="external.theme.httpinspireeceuropaeumetadatacodelistLimitationsOnPublicAccess-LimitationsOnPublicAccess"
                                 data-display-definition="true"
                                 data-show-hints-on-focus="true"
                                 data-thesaurus-concept-id-attribute="xlinkCOLONhref"/>
          </field>

After some sleuthing around, I found code for keywordPicker (and keywordSelector, but not codelistPicker) in geonetwork\core-geonetwork\web-ui\src\main\resources\catalog\components\thesaurus\ThesaurusDirective.js, but its not clear what the directive attributes in the example from 7227 do. I assume the key links to the skos file in some fashion? how does this work to bind a text box field element to a codelist? Questions

  1. does the codelist need to be SKOS (or ISO19135, but I'm not going there...)
  2. how is the codelist bound to a field using the keyword picker or selector
  3. can a template in an add action bind keys to a codelist. Why isn't my example with acquisitionInformation working?
  4. I'd like the values to show up as displayed in the topicCategory control-- is that a different directive? How is that configured?
fxprunayre commented 7 months ago

For add action, you can only have multiple snippet https://docs.geonetwork-opensource.org/4.2/customizing-application/editor-ui/creating-custom-editor/#creating-custom-editor-action but there is no support to suggest snippet from a codelist.

The other option is indeed to use the keywordPicker directive to configure an element to use a thesaurus. See examples https://github.com/geonetwork/core-geonetwork/blob/main/schemas/iso19139/src/main/plugin/iso19139/layout/config-editor.xml#L54-L79

smrgeoinfo commented 6 months ago

Keyword picker worked, sort of..., e.g.

<field name="DDEacquisitionType" xpath="mac:MI_Operation/mac:description"  
            or="description"  in="mac:MI_Operation"
            use="data-gn-keyword-picker"  del="../../../..">
            <directiveAttributes data-thesaurus-key="local.theme.acquisitioncodeskos" />
          </field>

the pick list that is displayed are all labeled "undefined'. If you pick one, it show the term from the vocabulary.