diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetMigrationService.java index 0c4d46f34..976532add 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DatasetMigrationService.java @@ -408,25 +408,6 @@ public class DatasetMigrationService { fieldEntity.setTextValue(UUID.fromString(id).toString()); } } - case CURRENCY -> { - if(!this.conventionService.isNullOrEmpty(textValue)) { - Currency currency = migrationTools.tryParseJsonAsObjectString(Currency.class, textValue); - if (currency == null && textValue.toUpperCase(Locale.ROOT).contains("EUR")) { - currency = new Currency(); - currency.setName("Euro"); - currency.setValue("EUR"); - } - if (currency == null && textValue.toUpperCase(Locale.ROOT).contains("US DOLLAR")) { - currency = new Currency(); - currency.setName("US DOLLAR"); - currency.setValue("USD"); - } - if (currency == null) throw new MyApplicationException("Could not parse Currency : " + textValue); - //TODO: {"name":"Euro","value":"EUR"} what we want to keep ? - - fieldEntity.setTextValue(currency.getName()); - } - } case TAGS -> { if(!this.conventionService.isNullOrEmpty(textValue)) { Tag[] tags = migrationTools.tryParseJsonAsObjectString(Tag[].class, textValue); @@ -444,11 +425,32 @@ public class DatasetMigrationService { case INTERNAL_ENTRIES_DESCRIPTIONS -> throw new MyApplicationException("Found INTERNAL_ENTRIES_DMPS into description"); case REFERENCE_TYPES -> { if(!this.conventionService.isNullOrEmpty(textValue)) { //TODO - Map[] references = migrationTools.tryParseJsonAsObjectString(Map[].class, textValue); - ReferenceTypeDataEntity referenceTypeDataEntity = (ReferenceTypeDataEntity)currentField.getData(); if (referenceTypeDataEntity == null) throw new MyApplicationException("Could not parse description template reference : " + textValue); + Map[] references = migrationTools.tryParseJsonAsObjectString(Map[].class, textValue); + + if (referenceTypeDataEntity.getReferenceTypeId().equals(ReferenceTypeIds.Currency)){ + Currency currency = migrationTools.tryParseJsonAsObjectString(Currency.class, textValue); + if (currency == null && textValue.toUpperCase(Locale.ROOT).contains("EUR")) { + currency = new Currency(); + currency.setName("Euro"); + currency.setValue("EUR"); + } + if (currency == null && textValue.toUpperCase(Locale.ROOT).contains("US DOLLAR")) { + currency = new Currency(); + currency.setName("US DOLLAR"); + currency.setValue("USD"); + } + if (currency == null) throw new MyApplicationException("Could not parse Currency : " + textValue); + //TODO: {"name":"Euro","value":"EUR"} what we want to keep ? + + Map reference = new HashMap<>(); + reference.put(ReferenceEntity.KnownFields.ReferenceId, currency.getValue()); + reference.put(ReferenceEntity.KnownFields.Label, currency.getName()); + references = List.of(reference).toArray(Map[]::new); + } + if (references == null) { Map reference = migrationTools.tryParseJsonAsObjectString(Map.class, textValue); if (reference != null) references = List.of(reference).toArray(Map[]::new); diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlCleanInvalidReferenceTypesService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlCleanInvalidReferenceTypesService.java index 1e0ebcabb..34c6fe174 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlCleanInvalidReferenceTypesService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlCleanInvalidReferenceTypesService.java @@ -109,7 +109,6 @@ public class DescriptionTemplateXmlCleanInvalidReferenceTypesService { data.setNumbering(persist.getNumbering()); data.setOrdinal(persist.getOrdinal()); data.setDefaultVisibility(persist.isDefaultVisibility()); - data.setMultiplicity(persist.getMultiplicity()); data.setTitle(persist.getTitle()); if (!this.conventionService.isListNullOrEmpty(persist.getSections())) { diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlMigrationService.java index ed5350214..937b0db60 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlMigrationService.java @@ -140,7 +140,6 @@ public class DescriptionTemplateXmlMigrationService { data.setNumbering(persist.getNumbering()); data.setOrdinal(persist.getOrdinal()); data.setDefaultVisibility(persist.isDefaultVisibility()); - data.setMultiplicity(persist.getMultiplicity()); data.setTitle(persist.getTitle()); if (!this.conventionService.isListNullOrEmpty(persist.getSections())) { @@ -263,7 +262,7 @@ public class DescriptionTemplateXmlMigrationService { return this.buildLabelDataEntity(persist.getLabel(), FieldType.DATASET_IDENTIFIER); } if (renderStyle.equals("currency")){ - return this.buildLabelDataEntity(persist.getLabel(), FieldType.CURRENCY); + return this.buildReferenceTypeDataEntity(persist.getLabel(), false, ReferenceTypeIds.Currency); } if (renderStyle.equals("taxonomies")){ return this.buildReferenceTypeDataEntity(persist.getLabel(), ((TaxonomiesData)persist).getMultiAutoComplete(), ReferenceTypeIds.Taxonomy); diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ReferenceTypeIds.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ReferenceTypeIds.java index 43758cd12..2aed29b45 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ReferenceTypeIds.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/ReferenceTypeIds.java @@ -18,8 +18,9 @@ public class ReferenceTypeIds { public static UUID Publication = UUID.fromString("51225b6a-86a6-48ac-9192-f15096dbcb8a"); public static UUID Journal = UUID.fromString("8ec7556b-749d-4c4a-a4b9-43d064693795"); public static UUID PubRepositories = UUID.fromString("1e927daa-b856-443f-96da-22f325f7322f"); + public static UUID Currency = UUID.fromString("f39dbc8c-1e31-48cd-a0b1-0bf2921d87c4"); public static List KnownReferenceTypeIds = List.of(DataRepositories, Datasets, Funder, Grants, Organizations, - Project, Registries, Researcher, Services, License, Taxonomy, Publication, Journal, PubRepositories); + Project, Registries, Researcher, Services, License, Taxonomy, Publication, Journal, PubRepositories, Currency); }