reference type small changes

This commit is contained in:
amentis 2024-02-16 17:42:01 +02:00
parent 4f5b3cf647
commit b343b76c9e
3 changed files with 20 additions and 5 deletions

View File

@ -168,8 +168,14 @@ public class ReferenceServiceImpl implements ReferenceService {
ReferenceTypeEntity data = this.entityManager.find(ReferenceTypeEntity.class, lookup.getTypeId()); 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())); 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()); 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 (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()); models = models.stream().sorted(Comparator.comparing(Reference::getLabel, Comparator.nullsFirst(Comparator.naturalOrder()))).collect(Collectors.toList());
if (lookup.getPage() != null && !lookup.getPage().isEmpty()){ if (lookup.getPage() != null && !lookup.getPage().isEmpty()){

View File

@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;
import eu.eudat.commons.enums.ReferenceTypeSourceType; import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.exceptions.HugeResultSetException; import eu.eudat.commons.exceptions.HugeResultSetException;
import eu.eudat.commons.types.dashborad.RecentActivityItemEntity; import eu.eudat.commons.types.dashborad.RecentActivityItemEntity;
@ -299,8 +300,15 @@ public class RemoteFetcherServiceImpl implements RemoteFetcherService {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
for(ResultFieldsMappingConfiguration field : resultsConfigurationEntity.getFieldsMapping()) { for(ResultFieldsMappingConfiguration field : resultsConfigurationEntity.getFieldsMapping()) {
if (this.conventionService.isNullOrEmpty(field.getResponsePath()) || this.conventionService.isNullOrEmpty(field.getCode())) continue; if (this.conventionService.isNullOrEmpty(field.getResponsePath()) || this.conventionService.isNullOrEmpty(field.getCode())) continue;
Object value = JsonPath.parse(resultItem).read(field.getResponsePath()); try {
map.put(field.getCode(), normalizeJsonValue(value)); Object value = JsonPath.parse(resultItem).read(field.getResponsePath());
map.put(field.getCode(), normalizeJsonValue(value));
}catch (PathNotFoundException e){
List<Object> nextLevelResults = jsonContext.read(resultsConfigurationEntity.getResultsArrayPath() + field.getResponsePath());
for(Object nextLevelResultValue : nextLevelResults) {
map.put(field.getCode(), normalizeJsonValue(nextLevelResultValue));
}
}
} }
parsedData.add(map); parsedData.add(map);
} }

View File

@ -133,6 +133,7 @@
<div class="col-12"> <div class="col-12">
<div *ngFor="let field of section.fields; let j=index"> <div *ngFor="let field of section.fields; let j=index">
<div class="heading" *ngIf="!field.label && field.category === dmpBlueprintSectionFieldCategoryEnum.System">{{i + 1}}.{{j + 1}} {{enumUtils.toDmpBlueprintSystemFieldTypeString(field.systemFieldType)}}<span *ngIf="field.required">*</span></div> <div class="heading" *ngIf="!field.label && field.category === dmpBlueprintSectionFieldCategoryEnum.System">{{i + 1}}.{{j + 1}} {{enumUtils.toDmpBlueprintSystemFieldTypeString(field.systemFieldType)}}<span *ngIf="field.required">*</span></div>
<div class="heading" *ngIf="!field.label && field.category === dmpBlueprintSectionFieldCategoryEnum.ReferenceType">{{i + 1}}.{{j + 1}} {{field.referenceType.name}}<span *ngIf="field.required">*</span></div>
<div class="heading" *ngIf="field.label">{{i + 1}}.{{j + 1}} {{field.label}}<span *ngIf="field.required">*</span></div> <div class="heading" *ngIf="field.label">{{i + 1}}.{{j + 1}} {{field.label}}<span *ngIf="field.required">*</span></div>
<div *ngIf="field.description != null && field.description.length > 0" class="hint">{{field.description}}</div> <div *ngIf="field.description != null && field.description.length > 0" class="hint">{{field.description}}</div>
<div class="input-form"> <div class="input-form">