From b343b76c9ec7cd74013305ea1ebed87a9adf8f35 Mon Sep 17 00:00:00 2001 From: amentis Date: Fri, 16 Feb 2024 17:42:01 +0200 Subject: [PATCH] reference type small changes --- .../service/reference/ReferenceServiceImpl.java | 12 +++++++++--- .../remotefetcher/RemoteFetcherServiceImpl.java | 12 ++++++++++-- .../dmp-editor-blueprint/dmp-editor.component.html | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/reference/ReferenceServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/reference/ReferenceServiceImpl.java index d49b8ba3c..ba1531a90 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/reference/ReferenceServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/reference/ReferenceServiceImpl.java @@ -168,8 +168,14 @@ public class ReferenceServiceImpl implements ReferenceService { ReferenceTypeEntity data = this.entityManager.find(ReferenceTypeEntity.class, lookup.getTypeId()); if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{lookup.getTypeId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale())); - - ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(lookup.getLike().replaceAll("%", "")); + + String like; + if (lookup.getLike() != null){ + like = lookup.getLike().replaceAll("%", ""); + } else { + like = null; + } + ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(like); ExternalDataResult remoteRepos = this.getReferenceData(data, externalReferenceCriteria, lookup.getKey()); @@ -190,7 +196,7 @@ public class ReferenceServiceImpl implements ReferenceService { if (models.stream().noneMatch(x-> x.getReference() != null && x.getSource() != null && x.getReference().equals(externalReference.getReference()) && x.getSource().equals(externalReference.getSource()))) models.add(externalReference); } - if (!this.conventionService.isNullOrEmpty(lookup.getLike())) { models = models.stream().filter(x -> x.getLabel().toLowerCase().contains(lookup.getLike().replaceAll("%", "").toLowerCase())).collect(Collectors.toList()); } + if (!this.conventionService.isNullOrEmpty(like)) { models = models.stream().filter(x -> x.getLabel().toLowerCase().contains(like.toLowerCase())).collect(Collectors.toList()); } models = models.stream().sorted(Comparator.comparing(Reference::getLabel, Comparator.nullsFirst(Comparator.naturalOrder()))).collect(Collectors.toList()); if (lookup.getPage() != null && !lookup.getPage().isEmpty()){ diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/RemoteFetcherServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/RemoteFetcherServiceImpl.java index 0b37f860f..9a75fbfc3 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/RemoteFetcherServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/RemoteFetcherServiceImpl.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.JsonPath; +import com.jayway.jsonpath.PathNotFoundException; import eu.eudat.commons.enums.ReferenceTypeSourceType; import eu.eudat.commons.exceptions.HugeResultSetException; import eu.eudat.commons.types.dashborad.RecentActivityItemEntity; @@ -299,8 +300,15 @@ public class RemoteFetcherServiceImpl implements RemoteFetcherService { Map map = new HashMap<>(); for(ResultFieldsMappingConfiguration field : resultsConfigurationEntity.getFieldsMapping()) { if (this.conventionService.isNullOrEmpty(field.getResponsePath()) || this.conventionService.isNullOrEmpty(field.getCode())) continue; - Object value = JsonPath.parse(resultItem).read(field.getResponsePath()); - map.put(field.getCode(), normalizeJsonValue(value)); + try { + Object value = JsonPath.parse(resultItem).read(field.getResponsePath()); + map.put(field.getCode(), normalizeJsonValue(value)); + }catch (PathNotFoundException e){ + List nextLevelResults = jsonContext.read(resultsConfigurationEntity.getResultsArrayPath() + field.getResponsePath()); + for(Object nextLevelResultValue : nextLevelResults) { + map.put(field.getCode(), normalizeJsonValue(nextLevelResultValue)); + } + } } parsedData.add(map); } diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html index 508c48e5b..bb0ba452f 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html @@ -133,6 +133,7 @@
{{i + 1}}.{{j + 1}} {{enumUtils.toDmpBlueprintSystemFieldTypeString(field.systemFieldType)}}*
+
{{i + 1}}.{{j + 1}} {{field.referenceType.name}}*
{{i + 1}}.{{j + 1}} {{field.label}}*
{{field.description}}