migration fixes

This commit is contained in:
Efstratios Giannopoulos 2024-06-20 18:12:49 +03:00
parent 7f2abaedd5
commit 0d245492f7
1 changed files with 8 additions and 5 deletions

View File

@ -660,15 +660,18 @@ public class DescriptionTemplateXmlMigrationService {
ExternalFetcherApiSourceConfigurationEntity apiEntity = new ExternalFetcherApiSourceConfigurationEntity(); ExternalFetcherApiSourceConfigurationEntity apiEntity = new ExternalFetcherApiSourceConfigurationEntity();
String source = persist.getAutoCompleteOptions() != null ? persist.getAutoCompleteOptions().getSource() : null;
if ( source == null || source.isEmpty()) {
URI uri; URI uri;
if (persist.getUrl().contains("?")) { if (persist.getUrl().contains("?")) {
uri = new URI(persist.getUrl().substring(0, persist.getUrl().trim().lastIndexOf("?"))); uri = new URI(persist.getUrl().substring(0, persist.getUrl().trim().lastIndexOf("?")));
} else { } else {
uri = new URI(persist.getUrl().trim()); uri = new URI(persist.getUrl().trim());
} }
String source = persist.getAutoCompleteOptions().getSource(); source = uri.getHost();
source = source != null && !source.isEmpty() ? source : uri.getHost(); }
String parsedUrl = persist.getUrl().trim(); String parsedUrl = persist.getUrl().trim();
parsedUrl = parsedUrl.replace("%20", " "); parsedUrl = parsedUrl.replace("%20", " ");
parsedUrl = parsedUrl.replace("%22", "\""); parsedUrl = parsedUrl.replace("%22", "\"");
@ -705,14 +708,14 @@ public class DescriptionTemplateXmlMigrationService {
data.setResultsArrayPath(persist.getOptionsRoot()); 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<>()); data.setFieldsMapping(new ArrayList<>());
ResultFieldsMappingConfigurationEntity labelField = new ResultFieldsMappingConfigurationEntity(); ResultFieldsMappingConfigurationEntity labelField = new ResultFieldsMappingConfigurationEntity();
labelField.setCode(ReferenceEntity.KnownFields.Label); labelField.setCode(ReferenceEntity.KnownFields.Label);
labelField.setResponsePath(persist.getAutoCompleteOptions().getLabel()); labelField.setResponsePath(persist.getAutoCompleteOptions().getLabel());
data.getFieldsMapping().add(labelField); 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(); ResultFieldsMappingConfigurationEntity idField = new ResultFieldsMappingConfigurationEntity();
idField.setCode(ReferenceEntity.KnownFields.ReferenceId); idField.setCode(ReferenceEntity.KnownFields.ReferenceId);
idField.setResponsePath(persist.getAutoCompleteOptions().getValue()); idField.setResponsePath(persist.getAutoCompleteOptions().getValue());