From 0d245492f7c903efaeb78fef5c20e2d5b95db898 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Thu, 20 Jun 2024 18:12:49 +0300 Subject: [PATCH] migration fixes --- .../DescriptionTemplateXmlMigrationService.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 1568873aa..de94e8d66 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 @@ -660,15 +660,18 @@ public class DescriptionTemplateXmlMigrationService { ExternalFetcherApiSourceConfigurationEntity apiEntity = new ExternalFetcherApiSourceConfigurationEntity(); + + String source = persist.getAutoCompleteOptions() != null ? persist.getAutoCompleteOptions().getSource() : null; + + if ( source == null || source.isEmpty()) { URI uri; if (persist.getUrl().contains("?")) { uri = new URI(persist.getUrl().substring(0, persist.getUrl().trim().lastIndexOf("?"))); } else { uri = new URI(persist.getUrl().trim()); } - String source = persist.getAutoCompleteOptions().getSource(); - source = source != null && !source.isEmpty() ? source : uri.getHost(); - + source = uri.getHost(); + } String parsedUrl = persist.getUrl().trim(); parsedUrl = parsedUrl.replace("%20", " "); parsedUrl = parsedUrl.replace("%22", "\""); @@ -705,14 +708,14 @@ public class DescriptionTemplateXmlMigrationService { data.setResultsArrayPath(persist.getOptionsRoot()); - if (persist.getAutoCompleteOptions() == null && this.conventionService.isNullOrEmpty(persist.getAutoCompleteOptions().getLabel())) { + if (persist.getAutoCompleteOptions() != null && !this.conventionService.isNullOrEmpty(persist.getAutoCompleteOptions().getLabel())) { data.setFieldsMapping(new ArrayList<>()); ResultFieldsMappingConfigurationEntity labelField = new ResultFieldsMappingConfigurationEntity(); labelField.setCode(ReferenceEntity.KnownFields.Label); labelField.setResponsePath(persist.getAutoCompleteOptions().getLabel()); data.getFieldsMapping().add(labelField); } - if (persist.getAutoCompleteOptions() == null && this.conventionService.isNullOrEmpty(persist.getAutoCompleteOptions().getValue())) { + if (persist.getAutoCompleteOptions() != null && !this.conventionService.isNullOrEmpty(persist.getAutoCompleteOptions().getValue())) { ResultFieldsMappingConfigurationEntity idField = new ResultFieldsMappingConfigurationEntity(); idField.setCode(ReferenceEntity.KnownFields.ReferenceId); idField.setResponsePath(persist.getAutoCompleteOptions().getValue());