From d8c1c62cb83155ea1aca09caf87e38672757b6af Mon Sep 17 00:00:00 2001 From: Joshua Darnell Date: Mon, 25 Mar 2024 09:46:12 -0700 Subject: [PATCH] #48: Updated annotations handling (#49) Co-authored-by: darnjo --- lib/process-lookup-resource-metadata.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/process-lookup-resource-metadata.js b/lib/process-lookup-resource-metadata.js index aedb8f8..ae24856 100644 --- a/lib/process-lookup-resource-metadata.js +++ b/lib/process-lookup-resource-metadata.js @@ -128,23 +128,31 @@ const processLookupResourceMetadata = ({ const lookupMetadata = { lookupName, lookupValue: StandardLookupValue || LookupValue, - type: EDM_STRING_TYPE, - annotations: [ + type: EDM_STRING_TYPE + }; + + const annotations = []; + + if (LegacyODataValue && LegacyODataValue?.trim()?.length) { + annotations.push( { term: LEGACY_ODATA_VALUE_TERM, value: LegacyODataValue, - }, - ], - }; + }); + } - if (StandardLookupValue?.length) { - lookupMetadata.annotations.push({ + if (StandardLookupValue && StandardLookupValue?.trim()?.length) { + annotations.push({ term: LOOKUP_STANDARD_NAME_ANNOTATION_TERM, value: StandardLookupValue, }); } - return lookupMetadata; + if (annotations?.length) { + return { ...lookupMetadata, annotations }; + } else { + return lookupMetadata; + } } ) || []), ],