64961: UUID filtering on compare + formToBitstream refactoring

This commit is contained in:
Kristof De Langhe
2019-09-17 11:10:07 +02:00
parent 4157844178
commit 3c3cff4398
3 changed files with 45 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
import { isEmpty, isNotUndefined, isUndefined } from '../../shared/empty.util';
import { isEmpty, isNotEmpty, isNotUndefined, isUndefined } from '../../shared/empty.util';
import {
MetadataMapInterface,
MetadataValue,
@@ -215,4 +215,19 @@ export class Metadata {
});
return metadataMap;
}
/**
* Set the first value of a metadata by field key
* Creates a new MetadataValue if the field doesn't exist yet
* @param mdMap The map to add/change values in
* @param key The metadata field
* @param value The value to add
*/
public static setFirstValue(mdMap: MetadataMapInterface, key: string, value: string) {
if (isNotEmpty(mdMap[key])) {
mdMap[key][0].value = value;
} else {
mdMap[key] = [Object.assign(new MetadataValue(), { value: value })]
}
}
}