reference type ui fixes

This commit is contained in:
Diamantis Tziotzios 2024-02-15 18:36:46 +02:00
parent aabcdd8c65
commit 244c8f2afd
15 changed files with 30 additions and 32 deletions

View File

@ -6,7 +6,7 @@ import java.util.UUID;
public class ReferenceTypeField extends Field {
public final static String _referenceType = "referenceTypeId";
public final static String _referenceType = "referenceType";
private ReferenceType referenceType;
public ReferenceType getReferenceType() {

View File

@ -51,6 +51,7 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class ReferenceServiceImpl implements ReferenceService {
@ -173,7 +174,7 @@ public class ReferenceServiceImpl implements ReferenceService {
ExternalDataResult remoteRepos = this.getReferenceData(data, externalReferenceCriteria, lookup.getKey());
List<Reference> externalModels = new ArrayList<>();
if (remoteRepos != null && this.conventionService.isListNullOrEmpty(remoteRepos.getResults())){
if (remoteRepos != null && !this.conventionService.isListNullOrEmpty(remoteRepos.getResults())){
List<ReferenceEntity> referenceEntities = new ArrayList<>();
for (Map<String, String> result : remoteRepos.getResults()){
if (result == null || result.isEmpty()) continue;;
@ -189,8 +190,8 @@ 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().toLowerCase())).toList(); }
models.sort(Comparator.comparing(Reference::getLabel));
if (!this.conventionService.isNullOrEmpty(lookup.getLike())) { models = models.stream().filter(x -> x.getLabel().toLowerCase().contains(lookup.getLike().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()){
models = models.stream().skip(initialOffset).limit(lookup.getPage().getSize()).toList();
@ -204,7 +205,7 @@ public class ReferenceServiceImpl implements ReferenceService {
ReferenceEntity referenceEntity = new ReferenceEntity();
referenceEntity.setTypeId(data.getId());
referenceEntity.setIsActive(IsActive.Active);
referenceEntity.setReference(result.getOrDefault(ReferenceEntity.KnownFields.Key, null) + ":" + remoteRepos.getResults().getFirst().getOrDefault("reference_id", null));
referenceEntity.setReference(result.getOrDefault(ReferenceEntity.KnownFields.ReferenceId, null) + ":" + remoteRepos.getResults().getFirst().getOrDefault("reference_id", null));
referenceEntity.setSource(result.getOrDefault(ReferenceEntity.KnownFields.Key, null));
referenceEntity.setAbbreviation(result.getOrDefault(ReferenceEntity.KnownFields.Abbreviation, null));
referenceEntity.setDescription(result.getOrDefault(ReferenceEntity.KnownFields.Description, null));
@ -225,15 +226,18 @@ public class ReferenceServiceImpl implements ReferenceService {
private List<Reference> fetchReferenceFromDb(ReferenceSearchLookup lookup){
ReferenceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).sourceTypes(ReferenceSourceType.Internal).typeIds(lookup.getTypeId());
List<ReferenceEntity> data = query.collectAs(lookup.getProject());
return this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
//TODO: Stratis update db for references.
//List<ReferenceEntity> data = query.collectAs(lookup.getProject());
//return this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
return new ArrayList<>();
}
private ExternalDataResult getReferenceData(ReferenceTypeEntity referenceType, ExternalReferenceCriteria externalReferenceCriteria, String key) {
ReferenceTypeDefinitionEntity referenceTypeDefinition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, referenceType.getDefinition());
if (referenceTypeDefinition == null || this.conventionService.isListNullOrEmpty(referenceTypeDefinition.getSources())) return new ExternalDataResult();
ExternalDataResult results = this.remoteFetcherService.getExternalData(referenceTypeDefinition.getSources().stream().map(x -> (SourceBaseConfiguration)x).toList(), externalReferenceCriteria, key, null);
ExternalDataResult results = this.remoteFetcherService.getExternalData(referenceTypeDefinition.getSources().stream().map(x -> (SourceBaseConfiguration)x).collect(Collectors.toList()), externalReferenceCriteria, key, null);
for (Map<String, String> result: results.getResults()) {
result.put("referenceType", referenceType.getName());
}

View File

@ -88,7 +88,7 @@ public class RemoteFetcherServiceImpl implements RemoteFetcherService {
// this.applyFunderToQuery(apiSource, externalReferenceCriteria);
String auth = null;
if (apiSource.getAuth() != null) {
if (apiSource.getAuth() != null && apiSource.getAuth().getEnabled() != null && apiSource.getAuth().getEnabled()) {
auth = this.buildAuthentication(apiSource.getAuth());
}
results.addAll(this.queryExternalData(fetchStrategy, apiSource, externalReferenceCriteria, auth));

View File

@ -13,7 +13,7 @@ BEGIN
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
"is_active" smallint NOT NULL DEFAULT 1,
CONSTRAINT "Ntf_User_pkey" PRIMARY KEY (id)
)
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.043', '2024-01-24 12:00:00.000000+02', now(), 'Add table ntf_User.');

View File

@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS public."ntf_UserContactInfo"
REFERENCES public."ntf_User" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.044', '2024-01-24 12:00:00.000000+02', now(), 'Add table ntf_UserContactInfo.');

View File

@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS public."ntf_UserCredential"
REFERENCES public."ntf_User" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.045', '2024-01-24 12:00:00.000000+02', now(), 'Add table ntf_UserCredential.');

View File

@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS public."ntf_TenantUser"
REFERENCES public."ntf_User" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.046', '2024-01-25 12:00:00.000000+02', now(), 'Add table ntf_TenantUser.');

View File

@ -13,7 +13,7 @@ BEGIN
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
"is_active" smallint NOT NULL DEFAULT 1,
CONSTRAINT "ant_User_pkey" PRIMARY KEY (id)
)
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.051', '2024-02-13 12:00:00.000000+02', now(), 'Add table ant_User.');

View File

@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS public."ant_UserCredential"
REFERENCES public."ant_User" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.052', '2024-02-13 12:00:00.000000+02', now(), 'Add table ant_UserCredential.');

View File

@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS public."ant_TenantUser"
REFERENCES public."ant_User" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.053', '2024-02-13 12:00:00.000000+02', now(), 'Add table ant_TenantUser.');

View File

@ -3,7 +3,7 @@ import { Guid } from "@common/types/guid";
export class ReferenceSearchLookup extends Lookup {
like: string;
referenceTypeId: Guid;
typeId: Guid;
key: string;
constructor() {
@ -14,7 +14,7 @@ export class ReferenceSearchLookup extends Lookup {
export class ReferenceSearchDefinitionLookup extends Lookup {
like: string;
referenceTypeId: Guid;
typeId: Guid;
key: string;
constructor() {

View File

@ -160,7 +160,7 @@ export class ReferenceService {
nameof<Reference>(x => x.sourceType),
]
};
lookup.referenceTypeId = typeId;
lookup.typeId = typeId;
lookup.order = { items: [nameof<Reference>(x => x.label)] };
if (like) { lookup.like = this.filterService.transformLike(like); }
return lookup;

View File

@ -131,7 +131,7 @@
<div class="col-auto" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.ReferenceType">
<mat-form-field class="w-100">
<mat-label>{{'DMP-BLUEPRINT-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}</mat-label>
<app-single-auto-complete placeholder="{{'DMP-BLUEPRINT-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}" [required]="true" [form]="field.get('referenceTypeId')" [configuration]="referenceTypeService.singleAutocompleteConfiguration"></app-single-auto-complete>
<app-single-auto-complete placeholder="{{'DMP-BLUEPRINT-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}" [required]="true" [formControl]="field.get('referenceTypeId')" [configuration]="referenceTypeService.singleAutocompleteConfiguration"></app-single-auto-complete>
<mat-error *ngIf="field.get('referenceTypeId').hasError('backendError')">{{field.get('referenceTypeId').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('referenceTypeId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>

View File

@ -125,9 +125,7 @@ export class DmpBlueprintDefinitionEditorModel implements DmpBlueprintDefinition
return this.formBuilder.group({
sections: this.formBuilder.array(
(this.sections ?? []).map(
(item, index) => new DmpBlueprintDefinitionSectionEditorModel(
this.validationErrorModel
).fromModel(item).buildForm({
(item, index) => item.buildForm({
rootPath: `${rootPath}sections[${index}].`,
disabled: disabled
})
@ -216,9 +214,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
hasTemplates: [{ value: this.hasTemplates, disabled: disabled }, context.getValidation('hasTemplates').validators],
fields: this.formBuilder.array(
(this.fields ?? []).map(
(item, index) => new FieldInSectionEditorModel(
this.validationErrorModel
).fromModel(item).buildForm({
(item, index) => item.buildForm({
rootPath: `${rootPath}fields[${index}].`,
disabled: disabled
})
@ -226,9 +222,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
),
descriptionTemplates: this.formBuilder.array(
(this.descriptionTemplates ?? []).map(
(item, index) => new DescriptionTemplatesInSectionEditorModel(
this.validationErrorModel
).fromModel(item).buildForm({
(item, index) => item.buildForm({
rootPath: `${rootPath}descriptionTemplates[${index}].`,
disabled: disabled
})

View File

@ -336,7 +336,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
if (item.paginationPath) this.paginationPath = item.paginationPath;
if (item.contentType) this.contentType = item.contentType;
if (item.firstPage) this.firstPage = item.firstPage;
if (item.httpMethod) this.httpMethod = item.httpMethod;
if (item.httpMethod != null) this.httpMethod = item.httpMethod;
if (item.requestBody) this.requestBody = item.requestBody;
if (item.filterType) this.filterType = item.filterType;
if (item.auth) this.auth = new AuthenticationConfigurationEditorModel(this.validationErrorModel).fromModel(item.auth);