migration currency changes
This commit is contained in:
parent
c27ba6ee6a
commit
a84332001e
|
@ -408,25 +408,6 @@ public class DatasetMigrationService {
|
||||||
fieldEntity.setTextValue(UUID.fromString(id).toString());
|
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 -> {
|
case TAGS -> {
|
||||||
if(!this.conventionService.isNullOrEmpty(textValue)) {
|
if(!this.conventionService.isNullOrEmpty(textValue)) {
|
||||||
Tag[] tags = migrationTools.tryParseJsonAsObjectString(Tag[].class, 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 INTERNAL_ENTRIES_DESCRIPTIONS -> throw new MyApplicationException("Found INTERNAL_ENTRIES_DMPS into description");
|
||||||
case REFERENCE_TYPES -> {
|
case REFERENCE_TYPES -> {
|
||||||
if(!this.conventionService.isNullOrEmpty(textValue)) { //TODO
|
if(!this.conventionService.isNullOrEmpty(textValue)) { //TODO
|
||||||
Map<String, Object>[] references = migrationTools.tryParseJsonAsObjectString(Map[].class, textValue);
|
|
||||||
|
|
||||||
ReferenceTypeDataEntity referenceTypeDataEntity = (ReferenceTypeDataEntity)currentField.getData();
|
ReferenceTypeDataEntity referenceTypeDataEntity = (ReferenceTypeDataEntity)currentField.getData();
|
||||||
if (referenceTypeDataEntity == null) throw new MyApplicationException("Could not parse description template reference : " + textValue);
|
if (referenceTypeDataEntity == null) throw new MyApplicationException("Could not parse description template reference : " + textValue);
|
||||||
|
|
||||||
|
Map<String, Object>[] 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<String, Object> 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) {
|
if (references == null) {
|
||||||
Map<String, Object> reference = migrationTools.tryParseJsonAsObjectString(Map.class, textValue);
|
Map<String, Object> reference = migrationTools.tryParseJsonAsObjectString(Map.class, textValue);
|
||||||
if (reference != null) references = List.of(reference).toArray(Map[]::new);
|
if (reference != null) references = List.of(reference).toArray(Map[]::new);
|
||||||
|
|
|
@ -109,7 +109,6 @@ public class DescriptionTemplateXmlCleanInvalidReferenceTypesService {
|
||||||
data.setNumbering(persist.getNumbering());
|
data.setNumbering(persist.getNumbering());
|
||||||
data.setOrdinal(persist.getOrdinal());
|
data.setOrdinal(persist.getOrdinal());
|
||||||
data.setDefaultVisibility(persist.isDefaultVisibility());
|
data.setDefaultVisibility(persist.isDefaultVisibility());
|
||||||
data.setMultiplicity(persist.getMultiplicity());
|
|
||||||
data.setTitle(persist.getTitle());
|
data.setTitle(persist.getTitle());
|
||||||
|
|
||||||
if (!this.conventionService.isListNullOrEmpty(persist.getSections())) {
|
if (!this.conventionService.isListNullOrEmpty(persist.getSections())) {
|
||||||
|
|
|
@ -140,7 +140,6 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
data.setNumbering(persist.getNumbering());
|
data.setNumbering(persist.getNumbering());
|
||||||
data.setOrdinal(persist.getOrdinal());
|
data.setOrdinal(persist.getOrdinal());
|
||||||
data.setDefaultVisibility(persist.isDefaultVisibility());
|
data.setDefaultVisibility(persist.isDefaultVisibility());
|
||||||
data.setMultiplicity(persist.getMultiplicity());
|
|
||||||
data.setTitle(persist.getTitle());
|
data.setTitle(persist.getTitle());
|
||||||
|
|
||||||
if (!this.conventionService.isListNullOrEmpty(persist.getSections())) {
|
if (!this.conventionService.isListNullOrEmpty(persist.getSections())) {
|
||||||
|
@ -263,7 +262,7 @@ public class DescriptionTemplateXmlMigrationService {
|
||||||
return this.buildLabelDataEntity(persist.getLabel(), FieldType.DATASET_IDENTIFIER);
|
return this.buildLabelDataEntity(persist.getLabel(), FieldType.DATASET_IDENTIFIER);
|
||||||
}
|
}
|
||||||
if (renderStyle.equals("currency")){
|
if (renderStyle.equals("currency")){
|
||||||
return this.buildLabelDataEntity(persist.getLabel(), FieldType.CURRENCY);
|
return this.buildReferenceTypeDataEntity(persist.getLabel(), false, ReferenceTypeIds.Currency);
|
||||||
}
|
}
|
||||||
if (renderStyle.equals("taxonomies")){
|
if (renderStyle.equals("taxonomies")){
|
||||||
return this.buildReferenceTypeDataEntity(persist.getLabel(), ((TaxonomiesData)persist).getMultiAutoComplete(), ReferenceTypeIds.Taxonomy);
|
return this.buildReferenceTypeDataEntity(persist.getLabel(), ((TaxonomiesData)persist).getMultiAutoComplete(), ReferenceTypeIds.Taxonomy);
|
||||||
|
|
|
@ -18,8 +18,9 @@ public class ReferenceTypeIds {
|
||||||
public static UUID Publication = UUID.fromString("51225b6a-86a6-48ac-9192-f15096dbcb8a");
|
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 Journal = UUID.fromString("8ec7556b-749d-4c4a-a4b9-43d064693795");
|
||||||
public static UUID PubRepositories = UUID.fromString("1e927daa-b856-443f-96da-22f325f7322f");
|
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<UUID> KnownReferenceTypeIds = List.of(DataRepositories, Datasets, Funder, Grants, Organizations,
|
public static List<UUID> 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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue