data.gov icon indicating copy to clipboard operation
data.gov copied to clipboard

Remove incorrect "required" element check in ISO19115-3 reader modules

Open rshewitt opened this issue 6 months ago • 1 comments

User Story

In order to ensure the ISO19115-3 reader works correctly, datagov wants to remove conditions checking for incorrect "required" elements in the mdtranslator ISO19115-3 reader.

Acceptance Criteria

[ACs should be clearly demoable/verifiable whenever possible. Try specifying them using BDD.]

  • [ ] GIVEN the ISO19115-3 reader and all its modules
    WHEN the incorrect required element check if removed
    THEN it should no longer be in the codebase
    AND there shouldn't be any errors/warnings caused by them.

Background

  • related to 4843
  • an incorrect pattern had been followed during the ISO19115-3 reader feature development. specifically, there's often a check at the beginning of each module for a "required" element that isn't actually required. Let's take module_browse_graphic.rb as an example. The condition at the start of self.unpack checks if mcc:MD_BrowseGraphic is within xLogo ( i.e. the parent element ) when in fact these elements represent the same thing. cit:logo is a mcc:MD_BrowseGraphic_PropertyType element type which can 0 or many times within a CI_Organisation_Type element ( i.e. cit:CI_Organisation ). A cit:CI_Organisation element may have a valid self-closing cit:logo element (e.g. <cit:logo/>) which won't have the mcc:MD_BrowseGraphic element within it. this condition indicating it's required is incorrect. the purpose of this ticket is to remove these incorrect checks from all ISO19115-3 reader modules.
#...
module BrowseGraphic
   # xpaths for finding xml elements
   @@nameXPath = 'mcc:fileName//gco:CharacterString'
   @@descXPath = 'mcc:fileDescription//gco:CharacterString'
   @@typeXPath = 'mcc:fileType//gco:CharacterString'
   @@browseGraphicXPath = 'mcc:MD_BrowseGraphic'
   @@imageConstraintsXPath = 'mcc:imageConstraints'
   @@linkageXPath = 'mcc:linkage'
   def self.unpack(xLogo, hResponseObj)
      intMetadataClass = InternalMetadata.new
      hGraphic = intMetadataClass.newGraphic

      xBrowseGraphic = xLogo.xpath(@@browseGraphicXPath)[0]

      if xBrowseGraphic.nil?
         msg = 'WARNING: ISO19115-3 reader: element \'mcc:MD_BrowseGraphic\' '\
            'is missing in logo'
         hResponseObj[:readerExecutionMessages] << msg
         hResponseObj[:readerExecutionPass] = false
         return nil
      end
#...
<!-- ... -->
<cit:party>
  <cit:CI_Organisation>
     <cit:name>
        <gco:CharacterString>U.S. Geological Survey, Alaska Science Center</gco:CharacterString>
     </cit:name>
     <cit:logo>
        <mcc:MD_BrowseGraphic/>
<!-- ... -->

Security Considerations (required)

[Any security concerns that might be implicated in the change. "None" is OK, just be explicit here!]

Sketch

[Notes or a checklist reflecting our understanding of the selected approach]

rshewitt avatar Aug 12 '24 15:08 rshewitt