diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/ExternalFetcherServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/ExternalFetcherServiceImpl.java index a11793f8f..4e91f8648 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/ExternalFetcherServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/ExternalFetcherServiceImpl.java @@ -117,23 +117,25 @@ public class ExternalFetcherServiceImpl implements ExternalFetcherService { if (this.conventionService.isListNullOrEmpty(item.getOptions())) continue; Map result = new HashMap<>(); Map rawData = new HashMap<>(); + for (Object object: item.getOptions()) { StaticOptionEntity staticOption = (StaticOptionEntity) object; - if (this.conventionService.isNullOrEmpty(externalReferenceCriteria.getLike())){ rawData.put(staticOption.getCode(), staticOption.getValue()); result.put(staticOption.getCode(), staticOption.getValue()); result.put(ReferenceEntity.KnownFields.SourceLabel, staticSource.getLabel()); result.put(ReferenceEntity.KnownFields.Key, staticSource.getKey()); - }else if (!this.conventionService.isNullOrEmpty(externalReferenceCriteria.getLike()) && externalReferenceCriteria.getLike().toUpperCase().contains(staticOption.getValue().toUpperCase())){ - rawData.put(staticOption.getCode(), staticOption.getValue()); - result.put(staticOption.getCode(), staticOption.getValue()); - result.put(ReferenceEntity.KnownFields.SourceLabel, staticSource.getLabel()); - result.put(ReferenceEntity.KnownFields.Key, staticSource.getKey()); - } - } - if (!rawData.isEmpty()) externalDataResult.getRawData().add(rawData); - if (!result.isEmpty()) externalDataResult.getResults().add(result); + if (!this.conventionService.isNullOrEmpty(externalReferenceCriteria.getLike())) { + if ( (result.get(ReferenceEntity.KnownFields.ReferenceId) != null && result.get(ReferenceEntity.KnownFields.ReferenceId).toUpperCase().contains(externalReferenceCriteria.getLike().toUpperCase())) + || (result.get(ReferenceEntity.KnownFields.Label) != null && result.get(ReferenceEntity.KnownFields.Label).toUpperCase().contains(externalReferenceCriteria.getLike().toUpperCase())) + || (result.get(ReferenceEntity.KnownFields.Description) != null && result.get(ReferenceEntity.KnownFields.Description).toUpperCase().contains(externalReferenceCriteria.getLike().toUpperCase()))) { + if (!rawData.isEmpty()) externalDataResult.getRawData().add(rawData); + if (!result.isEmpty()) externalDataResult.getResults().add(result); + } + } else{ + if (!rawData.isEmpty()) externalDataResult.getRawData().add(rawData); + if (!result.isEmpty()) externalDataResult.getResults().add(result); + } } return externalDataResult;