From 2517582c5d734d9905b626b1038e169d300dba2b Mon Sep 17 00:00:00 2001 From: Jim Cole Date: Fri, 9 Feb 2024 11:17:00 -0700 Subject: [PATCH] Refactor handling of SMAP instrument information Current SMAP instrument metadata is not compatible with the expected UMM-G mappings. This results in CMR flagging the UMM-G metadata as invalid. To work around this issue, instrument information is not carried over to UMM-G. This commit is a cleanup of the first pass on addressing this issue. Handling of instrument information is now conditional based on whether any useful data was extracted from the source metadata so that the functionality remains available should future SMAP metadata adhere to published UMM-G mappings. --- .../metadata/aggregator/MetadataFilesToEcho.java | 10 ++++++++++ .../cumulus/metadata/aggregator/UMMGranuleFile.java | 12 +++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/gov/nasa/cumulus/metadata/aggregator/MetadataFilesToEcho.java b/src/main/java/gov/nasa/cumulus/metadata/aggregator/MetadataFilesToEcho.java index 508fa5f..d241a1d 100644 --- a/src/main/java/gov/nasa/cumulus/metadata/aggregator/MetadataFilesToEcho.java +++ b/src/main/java/gov/nasa/cumulus/metadata/aggregator/MetadataFilesToEcho.java @@ -838,12 +838,22 @@ private void readIsoSmapMetadataFile(String s3Location, Document doc, XPath xpat Source source = new Source(); source.setSourceShortName(xpath.evaluate(IsoSmapXPath.PLATFORM, doc)); + Sensor sensor = new Sensor(); + sensor.setSensorShortName(xpath.evaluate(IsoSmapXPath.INSTRUMENT, doc)); DatasetSource datasetSource = new DatasetSource(); DatasetSource.DatasetSourcePK datasetSourcePK = new DatasetSource.DatasetSourcePK(); datasetSourcePK.setSource(source); datasetSource.setDatasetSourcePK(datasetSourcePK); + datasetSourcePK.setSource(source); + + if (!sensor.getSensorShortName().trim().isEmpty()) { + datasetSourcePK.setSensor(sensor); + } + + datasetSource.setDatasetSourcePK(datasetSourcePK); + dataset.add(datasetSource); NodeList inputGranules = (NodeList) xpath.evaluate(IsoSmapXPath.GRANULE_INPUT, doc, XPathConstants.NODESET); diff --git a/src/main/java/gov/nasa/cumulus/metadata/aggregator/UMMGranuleFile.java b/src/main/java/gov/nasa/cumulus/metadata/aggregator/UMMGranuleFile.java index d1ed2d4..6caa42f 100644 --- a/src/main/java/gov/nasa/cumulus/metadata/aggregator/UMMGranuleFile.java +++ b/src/main/java/gov/nasa/cumulus/metadata/aggregator/UMMGranuleFile.java @@ -883,11 +883,13 @@ private JSONArray exportPlatform() { JSONObject platform = new JSONObject(); platform.put("ShortName", datasetSource.getDatasetSourcePK().getSource().getSourceShortName()); - JSONArray instruments = new JSONArray(); - JSONObject instrument = new JSONObject(); - instrument.put("ShortName", datasetSource.getDatasetSourcePK().getSensor().getSensorShortName()); - instruments.add(instrument); - platform.put("Instruments", instruments); + if (!datasetSource.getDatasetSourcePK().getSensor().getSensorShortName().trim().isEmpty()) { + JSONArray instruments = new JSONArray(); + JSONObject instrument = new JSONObject(); + instrument.put("ShortName", datasetSource.getDatasetSourcePK().getSensor().getSensorShortName()); + instruments.add(instrument); + platform.put("Instruments", instruments); + } platforms.add(platform); }