From 3ada0d5acc02f76570bbe71449a6214eed3d12ec Mon Sep 17 00:00:00 2001 From: Joyce Quach Date: Mon, 18 Nov 2024 16:31:56 -0500 Subject: [PATCH] Produce empty array of CCI tags in JSONIX->CKL mapper if the input JSONIX is an empty string representing the serialized CCI tags Signed-off-by: Joyce Quach --- .../src/ckl-mapper/checklist-jsonix-converter.ts | 1 + .../src/ckl-mapper/checklist-mapper.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libs/hdf-converters/src/ckl-mapper/checklist-jsonix-converter.ts b/libs/hdf-converters/src/ckl-mapper/checklist-jsonix-converter.ts index 1078a9a695..cd89316347 100644 --- a/libs/hdf-converters/src/ckl-mapper/checklist-jsonix-converter.ts +++ b/libs/hdf-converters/src/ckl-mapper/checklist-jsonix-converter.ts @@ -264,6 +264,7 @@ export class ChecklistJsonixConverter extends JsonixIntermediateConverter< const results = data.filter((attribute: T) => { return _.get(attribute, keyName) == tag; }); + // This produces a string that looks like '' or /(w+); (w+)/. return results.map((result: T) => _.get(result, dataName)).join('; '); } diff --git a/libs/hdf-converters/src/ckl-mapper/checklist-mapper.ts b/libs/hdf-converters/src/ckl-mapper/checklist-mapper.ts index 590639feb2..e81f67edf6 100644 --- a/libs/hdf-converters/src/ckl-mapper/checklist-mapper.ts +++ b/libs/hdf-converters/src/ckl-mapper/checklist-mapper.ts @@ -29,12 +29,21 @@ enum ImpactMapping { } /** - * Tranformer function that splits a string and return array + * Transformer function that splits a string and return array * @param input - string of CCI references * @returns ref - array of CCI references */ function cciRef(input: string): string[] { - return input.split('; '); + /* Input string from CKL->jsonix could look like '' or 'CCI-001234; CCI-005678'. + The former comes from this tag in the originating CKL: + + CCI_REF + + + */ + const CCI_REGEX = /CCI-(\d*)/g; + const foundCcis = input.match(CCI_REGEX); + return foundCcis || []; } /**