reference type ui fixes
This commit is contained in:
parent
aabcdd8c65
commit
244c8f2afd
|
@ -6,7 +6,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
public class ReferenceTypeField extends Field {
|
public class ReferenceTypeField extends Field {
|
||||||
|
|
||||||
public final static String _referenceType = "referenceTypeId";
|
public final static String _referenceType = "referenceType";
|
||||||
private ReferenceType referenceType;
|
private ReferenceType referenceType;
|
||||||
|
|
||||||
public ReferenceType getReferenceType() {
|
public ReferenceType getReferenceType() {
|
||||||
|
|
|
@ -51,6 +51,7 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ReferenceServiceImpl implements ReferenceService {
|
public class ReferenceServiceImpl implements ReferenceService {
|
||||||
|
@ -173,7 +174,7 @@ public class ReferenceServiceImpl implements ReferenceService {
|
||||||
ExternalDataResult remoteRepos = this.getReferenceData(data, externalReferenceCriteria, lookup.getKey());
|
ExternalDataResult remoteRepos = this.getReferenceData(data, externalReferenceCriteria, lookup.getKey());
|
||||||
|
|
||||||
List<Reference> externalModels = new ArrayList<>();
|
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<>();
|
List<ReferenceEntity> referenceEntities = new ArrayList<>();
|
||||||
for (Map<String, String> result : remoteRepos.getResults()){
|
for (Map<String, String> result : remoteRepos.getResults()){
|
||||||
if (result == null || result.isEmpty()) continue;;
|
if (result == null || result.isEmpty()) continue;;
|
||||||
|
@ -186,11 +187,11 @@ public class ReferenceServiceImpl implements ReferenceService {
|
||||||
List<Reference> models = this.fetchReferenceFromDb(lookup);
|
List<Reference> models = this.fetchReferenceFromDb(lookup);
|
||||||
|
|
||||||
for (Reference externalReference : externalModels){
|
for (Reference externalReference : externalModels){
|
||||||
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().toLowerCase())).toList(); }
|
if (!this.conventionService.isNullOrEmpty(lookup.getLike())) { models = models.stream().filter(x -> x.getLabel().toLowerCase().contains(lookup.getLike().toLowerCase())).collect(Collectors.toList()); }
|
||||||
models.sort(Comparator.comparing(Reference::getLabel));
|
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()){
|
||||||
models = models.stream().skip(initialOffset).limit(lookup.getPage().getSize()).toList();
|
models = models.stream().skip(initialOffset).limit(lookup.getPage().getSize()).toList();
|
||||||
|
@ -204,7 +205,7 @@ public class ReferenceServiceImpl implements ReferenceService {
|
||||||
ReferenceEntity referenceEntity = new ReferenceEntity();
|
ReferenceEntity referenceEntity = new ReferenceEntity();
|
||||||
referenceEntity.setTypeId(data.getId());
|
referenceEntity.setTypeId(data.getId());
|
||||||
referenceEntity.setIsActive(IsActive.Active);
|
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.setSource(result.getOrDefault(ReferenceEntity.KnownFields.Key, null));
|
||||||
referenceEntity.setAbbreviation(result.getOrDefault(ReferenceEntity.KnownFields.Abbreviation, null));
|
referenceEntity.setAbbreviation(result.getOrDefault(ReferenceEntity.KnownFields.Abbreviation, null));
|
||||||
referenceEntity.setDescription(result.getOrDefault(ReferenceEntity.KnownFields.Description, null));
|
referenceEntity.setDescription(result.getOrDefault(ReferenceEntity.KnownFields.Description, null));
|
||||||
|
@ -225,15 +226,18 @@ public class ReferenceServiceImpl implements ReferenceService {
|
||||||
|
|
||||||
private List<Reference> fetchReferenceFromDb(ReferenceSearchLookup lookup){
|
private List<Reference> fetchReferenceFromDb(ReferenceSearchLookup lookup){
|
||||||
ReferenceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).sourceTypes(ReferenceSourceType.Internal).typeIds(lookup.getTypeId());
|
ReferenceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).sourceTypes(ReferenceSourceType.Internal).typeIds(lookup.getTypeId());
|
||||||
List<ReferenceEntity> data = query.collectAs(lookup.getProject());
|
//TODO: Stratis update db for references.
|
||||||
return this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
|
||||||
|
//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) {
|
private ExternalDataResult getReferenceData(ReferenceTypeEntity referenceType, ExternalReferenceCriteria externalReferenceCriteria, String key) {
|
||||||
ReferenceTypeDefinitionEntity referenceTypeDefinition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, referenceType.getDefinition());
|
ReferenceTypeDefinitionEntity referenceTypeDefinition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, referenceType.getDefinition());
|
||||||
if (referenceTypeDefinition == null || this.conventionService.isListNullOrEmpty(referenceTypeDefinition.getSources())) return new ExternalDataResult();
|
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()) {
|
for (Map<String, String> result: results.getResults()) {
|
||||||
result.put("referenceType", referenceType.getName());
|
result.put("referenceType", referenceType.getName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class RemoteFetcherServiceImpl implements RemoteFetcherService {
|
||||||
// this.applyFunderToQuery(apiSource, externalReferenceCriteria);
|
// this.applyFunderToQuery(apiSource, externalReferenceCriteria);
|
||||||
|
|
||||||
String auth = null;
|
String auth = null;
|
||||||
if (apiSource.getAuth() != null) {
|
if (apiSource.getAuth() != null && apiSource.getAuth().getEnabled() != null && apiSource.getAuth().getEnabled()) {
|
||||||
auth = this.buildAuthentication(apiSource.getAuth());
|
auth = this.buildAuthentication(apiSource.getAuth());
|
||||||
}
|
}
|
||||||
results.addAll(this.queryExternalData(fetchStrategy, apiSource, externalReferenceCriteria, auth));
|
results.addAll(this.queryExternalData(fetchStrategy, apiSource, externalReferenceCriteria, auth));
|
||||||
|
|
|
@ -13,7 +13,7 @@ BEGIN
|
||||||
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
|
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||||
"is_active" smallint NOT NULL DEFAULT 1,
|
"is_active" smallint NOT NULL DEFAULT 1,
|
||||||
CONSTRAINT "Ntf_User_pkey" PRIMARY KEY (id)
|
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.');
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.043', '2024-01-24 12:00:00.000000+02', now(), 'Add table ntf_User.');
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS public."ntf_UserContactInfo"
|
||||||
REFERENCES public."ntf_User" (id) MATCH SIMPLE
|
REFERENCES public."ntf_User" (id) MATCH SIMPLE
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
ON DELETE 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.');
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.044', '2024-01-24 12:00:00.000000+02', now(), 'Add table ntf_UserContactInfo.');
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS public."ntf_UserCredential"
|
||||||
REFERENCES public."ntf_User" (id) MATCH SIMPLE
|
REFERENCES public."ntf_User" (id) MATCH SIMPLE
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
ON DELETE 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.');
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.045', '2024-01-24 12:00:00.000000+02', now(), 'Add table ntf_UserCredential.');
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS public."ntf_TenantUser"
|
||||||
REFERENCES public."ntf_User" (id) MATCH SIMPLE
|
REFERENCES public."ntf_User" (id) MATCH SIMPLE
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
ON DELETE 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.');
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.046', '2024-01-25 12:00:00.000000+02', now(), 'Add table ntf_TenantUser.');
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ BEGIN
|
||||||
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
|
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||||
"is_active" smallint NOT NULL DEFAULT 1,
|
"is_active" smallint NOT NULL DEFAULT 1,
|
||||||
CONSTRAINT "ant_User_pkey" PRIMARY KEY (id)
|
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.');
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.051', '2024-02-13 12:00:00.000000+02', now(), 'Add table ant_User.');
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS public."ant_UserCredential"
|
||||||
REFERENCES public."ant_User" (id) MATCH SIMPLE
|
REFERENCES public."ant_User" (id) MATCH SIMPLE
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
ON DELETE 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.');
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.052', '2024-02-13 12:00:00.000000+02', now(), 'Add table ant_UserCredential.');
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS public."ant_TenantUser"
|
||||||
REFERENCES public."ant_User" (id) MATCH SIMPLE
|
REFERENCES public."ant_User" (id) MATCH SIMPLE
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
ON DELETE 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.');
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.053', '2024-02-13 12:00:00.000000+02', now(), 'Add table ant_TenantUser.');
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Guid } from "@common/types/guid";
|
||||||
|
|
||||||
export class ReferenceSearchLookup extends Lookup {
|
export class ReferenceSearchLookup extends Lookup {
|
||||||
like: string;
|
like: string;
|
||||||
referenceTypeId: Guid;
|
typeId: Guid;
|
||||||
key: string;
|
key: string;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -14,7 +14,7 @@ export class ReferenceSearchLookup extends Lookup {
|
||||||
|
|
||||||
export class ReferenceSearchDefinitionLookup extends Lookup {
|
export class ReferenceSearchDefinitionLookup extends Lookup {
|
||||||
like: string;
|
like: string;
|
||||||
referenceTypeId: Guid;
|
typeId: Guid;
|
||||||
key: string;
|
key: string;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
|
@ -160,7 +160,7 @@ export class ReferenceService {
|
||||||
nameof<Reference>(x => x.sourceType),
|
nameof<Reference>(x => x.sourceType),
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
lookup.referenceTypeId = typeId;
|
lookup.typeId = typeId;
|
||||||
lookup.order = { items: [nameof<Reference>(x => x.label)] };
|
lookup.order = { items: [nameof<Reference>(x => x.label)] };
|
||||||
if (like) { lookup.like = this.filterService.transformLike(like); }
|
if (like) { lookup.like = this.filterService.transformLike(like); }
|
||||||
return lookup;
|
return lookup;
|
||||||
|
|
|
@ -131,7 +131,7 @@
|
||||||
<div class="col-auto" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.ReferenceType">
|
<div class="col-auto" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.ReferenceType">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'DMP-BLUEPRINT-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}</mat-label>
|
<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('backendError')">{{field.get('referenceTypeId').getError('backendError').message}}</mat-error>
|
||||||
<mat-error *ngIf="field.get('referenceTypeId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="field.get('referenceTypeId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
|
@ -125,9 +125,7 @@ export class DmpBlueprintDefinitionEditorModel implements DmpBlueprintDefinition
|
||||||
return this.formBuilder.group({
|
return this.formBuilder.group({
|
||||||
sections: this.formBuilder.array(
|
sections: this.formBuilder.array(
|
||||||
(this.sections ?? []).map(
|
(this.sections ?? []).map(
|
||||||
(item, index) => new DmpBlueprintDefinitionSectionEditorModel(
|
(item, index) => item.buildForm({
|
||||||
this.validationErrorModel
|
|
||||||
).fromModel(item).buildForm({
|
|
||||||
rootPath: `${rootPath}sections[${index}].`,
|
rootPath: `${rootPath}sections[${index}].`,
|
||||||
disabled: disabled
|
disabled: disabled
|
||||||
})
|
})
|
||||||
|
@ -216,9 +214,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
|
||||||
hasTemplates: [{ value: this.hasTemplates, disabled: disabled }, context.getValidation('hasTemplates').validators],
|
hasTemplates: [{ value: this.hasTemplates, disabled: disabled }, context.getValidation('hasTemplates').validators],
|
||||||
fields: this.formBuilder.array(
|
fields: this.formBuilder.array(
|
||||||
(this.fields ?? []).map(
|
(this.fields ?? []).map(
|
||||||
(item, index) => new FieldInSectionEditorModel(
|
(item, index) => item.buildForm({
|
||||||
this.validationErrorModel
|
|
||||||
).fromModel(item).buildForm({
|
|
||||||
rootPath: `${rootPath}fields[${index}].`,
|
rootPath: `${rootPath}fields[${index}].`,
|
||||||
disabled: disabled
|
disabled: disabled
|
||||||
})
|
})
|
||||||
|
@ -226,9 +222,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef
|
||||||
),
|
),
|
||||||
descriptionTemplates: this.formBuilder.array(
|
descriptionTemplates: this.formBuilder.array(
|
||||||
(this.descriptionTemplates ?? []).map(
|
(this.descriptionTemplates ?? []).map(
|
||||||
(item, index) => new DescriptionTemplatesInSectionEditorModel(
|
(item, index) => item.buildForm({
|
||||||
this.validationErrorModel
|
|
||||||
).fromModel(item).buildForm({
|
|
||||||
rootPath: `${rootPath}descriptionTemplates[${index}].`,
|
rootPath: `${rootPath}descriptionTemplates[${index}].`,
|
||||||
disabled: disabled
|
disabled: disabled
|
||||||
})
|
})
|
||||||
|
|
|
@ -336,7 +336,7 @@ export class ReferenceTypeSourceBaseConfigurationEditorModel implements Referenc
|
||||||
if (item.paginationPath) this.paginationPath = item.paginationPath;
|
if (item.paginationPath) this.paginationPath = item.paginationPath;
|
||||||
if (item.contentType) this.contentType = item.contentType;
|
if (item.contentType) this.contentType = item.contentType;
|
||||||
if (item.firstPage) this.firstPage = item.firstPage;
|
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.requestBody) this.requestBody = item.requestBody;
|
||||||
if (item.filterType) this.filterType = item.filterType;
|
if (item.filterType) this.filterType = item.filterType;
|
||||||
if (item.auth) this.auth = new AuthenticationConfigurationEditorModel(this.validationErrorModel).fromModel(item.auth);
|
if (item.auth) this.auth = new AuthenticationConfigurationEditorModel(this.validationErrorModel).fromModel(item.auth);
|
||||||
|
|
Loading…
Reference in New Issue