diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SectionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SectionEntity.java index 39767a2cb..400fa58f7 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SectionEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SectionEntity.java @@ -37,6 +37,10 @@ public class SectionEntity { @XmlElement(name = "descriptionTemplate") private List descriptionTemplates; + @XmlElementWrapper(name = "prefillingSourcesIds") + @XmlElement(name = "id") + private List prefillingSourcesIds; + public UUID getId() { return id; } @@ -86,6 +90,14 @@ public class SectionEntity { this.descriptionTemplates = descriptionTemplates; } + public List getPrefillingSourcesIds() { + return prefillingSourcesIds; + } + + public void setPrefillingSourcesIds(List prefillingSourcesIds) { + this.prefillingSourcesIds = prefillingSourcesIds; + } + public List getAllField(){ return this.getFields() != null ? this.getFields() : new ArrayList<>(); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/SectionBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/SectionBuilder.java index 0c3e20314..a47cbe12d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/SectionBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/SectionBuilder.java @@ -4,9 +4,13 @@ import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.commons.enums.DmpBlueprintFieldCategory; import eu.eudat.commons.types.dmpblueprint.*; import eu.eudat.convention.ConventionService; +import eu.eudat.data.PrefillingSourceEntity; import eu.eudat.model.builder.BaseBuilder; +import eu.eudat.model.builder.PrefillingSourceBuilder; import eu.eudat.model.dmpblueprintdefinition.Section; +import eu.eudat.query.PrefillingSourceQuery; import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; @@ -24,13 +28,15 @@ import java.util.*; public class SectionBuilder extends BaseBuilder { private final BuilderFactory builderFactory; + private final QueryFactory queryFactory; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired public SectionBuilder( - ConventionService conventionService, BuilderFactory builderFactory) { + ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory) { super(conventionService, new LoggerService(LoggerFactory.getLogger(SectionBuilder.class))); this.builderFactory = builderFactory; + this.queryFactory = queryFactory; } public SectionBuilder authorize(EnumSet values) { @@ -48,6 +54,7 @@ public class SectionBuilder extends BaseBuilder { //Not Bulk Build because is XML no interaction with db FieldSet descriptionTemplatesFields = fields.extractPrefixed(this.asPrefix(Section._descriptionTemplates)); FieldSet fieldsFields = fields.extractPrefixed(this.asPrefix(Section._fields)); + FieldSet prefillingSourcesFields = fields.extractPrefixed(this.asPrefix(Section._prefillingSources)); List
models = new ArrayList<>(); for (SectionEntity d : data) { @@ -67,6 +74,10 @@ public class SectionBuilder extends BaseBuilder { List referenceFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.ReferenceType.equals(x.getCategory())).map(x-> (ReferenceTypeFieldEntity)x).toList(); m.getFields().addAll(this.builderFactory.builder(ReferenceFieldBuilder.class).authorize(this.authorize).build(fieldsFields, referenceFieldEntities)); } + if (!prefillingSourcesFields.isEmpty() && d.getPrefillingSourcesIds() != null) { + List prefillingSourceEntities = this.queryFactory.query(PrefillingSourceQuery.class).authorize(this.authorize).ids(d.getPrefillingSourcesIds()).collectAs(prefillingSourcesFields); + m.setPrefillingSources(this.builderFactory.builder(PrefillingSourceBuilder.class).authorize(this.authorize).build(prefillingSourcesFields, prefillingSourceEntities)); + } models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/Section.java b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/Section.java index 844f2912c..65b64acdf 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/Section.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/Section.java @@ -1,6 +1,8 @@ package eu.eudat.model.dmpblueprintdefinition; +import eu.eudat.model.PrefillingSource; + import java.util.List; import java.util.UUID; @@ -27,6 +29,9 @@ public class Section { public final static String _descriptionTemplates = "descriptionTemplates"; private List descriptionTemplates; + public final static String _prefillingSources = "prefillingSources"; + private List prefillingSources; + public UUID getId() { return id; } @@ -82,6 +87,14 @@ public class Section { public void setDescriptionTemplates(List descriptionTemplates) { this.descriptionTemplates = descriptionTemplates; } + + public List getPrefillingSources() { + return prefillingSources; + } + + public void setPrefillingSources(List prefillingSources) { + this.prefillingSources = prefillingSources; + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/SectionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/SectionPersist.java index 4a6eee0bc..46ae7a356 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/SectionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/SectionPersist.java @@ -45,6 +45,10 @@ public class SectionPersist { public static final String _descriptionTemplates = "descriptionTemplates"; + private List prefillingSourcesIds= null; + + public static final String _prefillingSourcesIds = "prefillingSourcesIds"; + public UUID getId() { return id; } @@ -101,6 +105,14 @@ public class SectionPersist { this.descriptionTemplates = descriptionTemplates; } + public List getPrefillingSourcesIds() { + return prefillingSourcesIds; + } + + public void setPrefillingSourcesIds(List prefillingSourcesIds) { + this.prefillingSourcesIds = prefillingSourcesIds; + } + @Component(SectionPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public static class SectionPersistValidator extends BaseValidator { diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionFieldPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionFieldPersist.java index 4a525a625..1288ea9dc 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionFieldPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionFieldPersist.java @@ -91,7 +91,11 @@ public class PrefillingSourceDefinitionFieldPersist { @Override protected List specifications(PrefillingSourceDefinitionFieldPersist item) { - return Arrays.asList(); + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getCode())) + .failOn(PrefillingSourceDefinitionFieldPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourceDefinitionFieldPersist._code}, LocaleContextHolder.getLocale())) + ); } } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionPersist.java index ec8e8e503..ed6f4c5ee 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionPersist.java @@ -23,6 +23,9 @@ public class PrefillingSourceDefinitionPersist { private ExternalFetcherApiSourceConfigurationPersist getConfiguration; public static final String _getConfiguration = "getConfiguration"; + private Boolean getEnabled; + public static final String _getEnabled = "getEnabled"; + private List fields; public static final String _fields = "fields"; @@ -42,6 +45,14 @@ public class PrefillingSourceDefinitionPersist { this.getConfiguration = getConfiguration; } + public Boolean getGetEnabled() { + return getEnabled; + } + + public void setGetEnabled(Boolean getEnabled) { + this.getEnabled = getEnabled; + } + public List getFields() { return fields; } @@ -82,11 +93,11 @@ public class PrefillingSourceDefinitionPersist { .on(PrefillingSourceDefinitionPersist._searchConfiguration) .over(item.getSearchConfiguration()) .using(() -> this.validatorFactory.validator(ExternalFetcherApiSourceConfigurationPersist.ExternalFetcherApiSourceConfigurationPersistValidator.class)), -// this.refSpec() TODO -// .iff(() -> !this.isNull(item.getGetConfiguration())) -// .on(PrefillingSourceDefinitionPersist._getConfiguration) -// .over(item.getGetConfiguration()) -// .using(() -> this.validatorFactory.validator(ExternalFetcherApiSourceConfigurationPersist.ExternalFetcherApiSourceConfigurationPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getGetConfiguration()) && item.getGetEnabled()) + .on(PrefillingSourceDefinitionPersist._getConfiguration) + .over(item.getGetConfiguration()) + .using(() -> this.validatorFactory.validator(ExternalFetcherApiSourceConfigurationPersist.ExternalFetcherApiSourceConfigurationPersistValidator.class)), this.navSpec() .iff(() -> !this.isListNullOrEmpty(item.getFields())) .on(PrefillingSourceDefinitionPersist._fields) diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java index 33fc249db..79cb450e1 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java @@ -216,6 +216,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { data.setLabel(persist.getLabel()); data.setOrdinal(persist.getOrdinal()); data.setHasTemplates(persist.getHasTemplates()); + data.setPrefillingSourcesIds(persist.getPrefillingSourcesIds()); if (!this.conventionService.isListNullOrEmpty(persist.getFields())) { data.setFields(new ArrayList<>()); for (FieldPersist fieldPersist : persist.getFields()) { diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceServiceImpl.java index 4d6fc29ab..a8c36a34e 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceServiceImpl.java @@ -117,7 +117,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService { if (persist.getSearchConfiguration() != null ) { data.setSearchConfiguration(this.buildExternalFetcherApiConfigEntity(persist.getSearchConfiguration())); } - if (persist.getGetConfiguration() != null ) { + if (persist.getGetConfiguration() != null && persist.getGetEnabled()) { data.setGetConfiguration(this.buildExternalFetcherApiConfigEntity(persist.getGetConfiguration())); } diff --git a/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts b/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts index 7398dcbff..abe85a36b 100644 --- a/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts +++ b/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts @@ -5,6 +5,7 @@ import { DmpBlueprintSystemFieldType } from "@app/core/common/enum/dmp-blueprint import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model"; import { Guid } from "@common/types/guid"; import { ReferenceType } from "../reference-type/reference-type"; +import { PrefillingSource } from "../prefilling-source/prefilling-source"; export interface DmpBlueprint extends BaseEntity { @@ -28,6 +29,7 @@ export interface DmpBlueprintDefinitionSection { fields: FieldInSection[]; hasTemplates: boolean; descriptionTemplates?: DescriptionTemplatesInSection[]; + prefillingSources: PrefillingSource[]; } export interface DescriptionTemplatesInSection { @@ -87,6 +89,7 @@ export interface DmpBlueprintDefinitionSectionPersist { fields: FieldInSectionPersist[]; hasTemplates: boolean; descriptionTemplates?: DescriptionTemplatesInSectionPersist[]; + prefillingSourcesIds: Guid[]; } export interface DescriptionTemplatesInSectionPersist { diff --git a/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts b/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts index 19d7510b5..018897aad 100644 --- a/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts +++ b/dmp-frontend/src/app/core/services/utilities/enum-utils.service.ts @@ -176,8 +176,8 @@ export class EnumUtils { toExternalFetcherSourceTypeString(status: ExternalFetcherSourceType): string { switch (status) { - case ExternalFetcherSourceType.API: return this.language.instant('TYPES.REFERENCE-TYPE-SOURCE-TYPE.API'); - case ExternalFetcherSourceType.STATIC: return this.language.instant('TYPES.REFERENCE-TYPE-SOURCE-TYPE.STATIC'); + case ExternalFetcherSourceType.API: return this.language.instant('TYPES.EXTERNAL-FETCHER-SOURCE-TYPE.API'); + case ExternalFetcherSourceType.STATIC: return this.language.instant('TYPES.EXTERNAL-FETCHER-SOURCE-TYPE.STATIC'); } } @@ -191,8 +191,8 @@ export class EnumUtils { toExternalFetcherApiHTTPMethodTypeString(status: ExternalFetcherApiHTTPMethodType): string { switch (status) { - case ExternalFetcherApiHTTPMethodType.GET: return this.language.instant('TYPES.REFERENCE-TYPE-EXTERNAL-API-HTTP-METHOD-TYPE.GET'); - case ExternalFetcherApiHTTPMethodType.POST: return this.language.instant('TYPES.REFERENCE-TYPE-EXTERNAL-API-HTTP-METHOD-TYPE.POST'); + case ExternalFetcherApiHTTPMethodType.GET: return this.language.instant('TYPES.EXTERNAL-FETCHER-API-HTTP-METHOD-TYPE.GET'); + case ExternalFetcherApiHTTPMethodType.POST: return this.language.instant('TYPES.EXTERNAL-FETCHER-API-HTTP-METHOD-TYPE.POST'); } } diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html index 47c1cbcce..e68cf2a99 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html @@ -247,6 +247,13 @@ {{section.get('descriptionTemplates').getError('backendError').message}} +
+ + {{'DMP-BLUEPRINT-EDITOR.FIELDS.PREFILLING-SOURCES' | translate}} + + {{section.get('prefillingSourcesIds').getError('backendError').message}} + +
diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts index 8a46c19a2..d0b3ee603 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts @@ -42,6 +42,7 @@ import { DmpBlueprintEditorResolver } from './dmp-blueprint-editor.resolver'; import { DmpBlueprintEditorService } from './dmp-blueprint-editor.service'; import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service'; import { SemanticsService } from '@app/core/services/semantic/semantics.service'; +import { PrefillingSourceService } from '@app/core/services/prefilling-source/prefilling-source.service'; @Component({ @@ -124,7 +125,8 @@ export class DmpBlueprintEditorComponent extends BaseEditor this.fields.push(new FieldInSectionEditorModel(this.validationErrorModel).fromModel(x))); } if (item.descriptionTemplates) { item.descriptionTemplates.map(x => this.descriptionTemplates.push(new DescriptionTemplatesInSectionEditorModel(this.validationErrorModel).fromModel(x))); } + if (item.prefillingSources) this.prefillingSourcesIds = item.prefillingSources.map(x => x.id); } return this; } @@ -227,7 +229,8 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef disabled: disabled }) ), context.getValidation('descriptionTemplates').validators - ) + ), + prefillingSourcesIds: [{ value: this.prefillingSourcesIds, disabled: disabled }, context.getValidation('prefillingSourcesIds').validators], }); } @@ -246,6 +249,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef baseValidationArray.push({ key: 'hasTemplates', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}hasTemplates`)] }); baseValidationArray.push({ key: 'fields', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] }); baseValidationArray.push({ key: 'descriptionTemplates', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}descriptionTemplates`)] }); + baseValidationArray.push({ key: 'prefillingSourcesIds', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}prefillingSourcesIds`)] }); baseValidationArray.push({ key: 'hash', validators: [] }); baseContext.validation = baseValidationArray; @@ -263,7 +267,7 @@ export class DmpBlueprintDefinitionSectionEditorModel implements DmpBlueprintDef validationErrorModel }); - ['id', 'label', 'ordinal', 'description', 'hasTemplates', 'hash'].forEach(keyField => { + ['id', 'label', 'ordinal', 'description', 'hasTemplates', 'prefillingSourcesIds', 'hash'].forEach(keyField => { const control = formGroup?.get(keyField); control?.clearValidators(); control?.addValidators(context.getValidation(keyField).validators); diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts index f80098b14..d778d6235 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, ExtraFieldInSection, FieldInSection, ReferenceTypeFieldInSection, SystemFieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; +import { PrefillingSource } from '@app/core/model/prefilling-source/prefilling-source'; import { ReferenceType } from '@app/core/model/reference-type/reference-type'; import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; @@ -46,6 +47,10 @@ export class DmpBlueprintEditorResolver extends BaseEditorResolver { [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), + + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.prefillingSources), nameof(x => x.id)].join('.'), + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.prefillingSources), nameof(x => x.label)].join('.'), + nameof(x => x.createdAt), nameof(x => x.hash), nameof(x => x.isActive) diff --git a/dmp-frontend/src/app/ui/admin/prefilling-source/editor/prefilling-source-editor.component.html b/dmp-frontend/src/app/ui/admin/prefilling-source/editor/prefilling-source-editor.component.html index 369a7f40a..0621f41eb 100644 --- a/dmp-frontend/src/app/ui/admin/prefilling-source/editor/prefilling-source-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/prefilling-source/editor/prefilling-source-editor.component.html @@ -113,7 +113,7 @@
- + {{'PREFILLING-SOURCE-EDITOR.FIELDS.GET-SOURCE-CONFIGURATION' | translate}} {{formGroup.get('definition').get('getEnabled').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} diff --git a/dmp-frontend/src/app/ui/admin/prefilling-source/editor/prefilling-source-editor.component.ts b/dmp-frontend/src/app/ui/admin/prefilling-source/editor/prefilling-source-editor.component.ts index 7687535f4..3ce89ed69 100644 --- a/dmp-frontend/src/app/ui/admin/prefilling-source/editor/prefilling-source-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/prefilling-source/editor/prefilling-source-editor.component.ts @@ -25,9 +25,10 @@ import { TranslateService } from '@ngx-translate/core'; import { map, takeUntil } from 'rxjs/operators'; import { PrefillingSourceEditorResolver } from './prefilling-source-editor.resolver'; import { PrefillingSourceEditorService } from './prefilling-source-editor.service'; -import { PrefillingSourceEditorModel } from './prefilling-source-editor.model'; +import { PrefillingSourceDefinitionEditorModel, PrefillingSourceEditorModel } from './prefilling-source-editor.model'; import { ResultFieldsMappingConfigurationEditorModel } from '@app/ui/external-fetcher/external-fetcher-source-editor.model'; import { SemanticsService } from '@app/core/services/semantic/semantics.service'; +import { MatCheckboxChange } from '@angular/material/checkbox'; @Component({ selector: 'app-prefilling-source-editor-component', @@ -110,9 +111,6 @@ export class PrefillingSourceEditorComponent extends BaseEditor PrefillingSourceDefinitionFieldEditorModel.reapplyValidators({ formGroup: control as UntypedFormGroup, rootPath: `${rootPath}fields[${index}].`, validationErrorModel: validationErrorModel }) ); + + ExternalFetcherBaseSourceConfigurationEditorModel.reapplyValidators({ + formGroup: formGroup.get('searchConfiguration') as UntypedFormGroup, + rootPath: `${rootPath}searchConfiguration.`, + validationErrorModel: validationErrorModel + }); + + if(formGroup.get('getEnabled').value == true){ + ExternalFetcherBaseSourceConfigurationEditorModel.reapplyValidators({ + formGroup: formGroup.get('getConfiguration') as UntypedFormGroup, + rootPath: `${rootPath}getConfiguration.`, + validationErrorModel: validationErrorModel + }); + } } } diff --git a/dmp-frontend/src/app/ui/external-fetcher/external-fetcher-source.component.ts b/dmp-frontend/src/app/ui/external-fetcher/external-fetcher-source.component.ts index 6f3174d06..54eed58e1 100644 --- a/dmp-frontend/src/app/ui/external-fetcher/external-fetcher-source.component.ts +++ b/dmp-frontend/src/app/ui/external-fetcher/external-fetcher-source.component.ts @@ -6,7 +6,7 @@ import { ReferenceType } from '@app/core/model/reference-type/reference-type'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { BaseComponent } from '@common/base/base.component'; import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { QueryCaseConfigEditorModel, QueryConfigEditorModel, StaticOptionEditorModel } from './external-fetcher-source-editor.model'; +import { ExternalFetcherBaseSourceConfigurationEditorModel, QueryCaseConfigEditorModel, QueryConfigEditorModel, StaticOptionEditorModel } from './external-fetcher-source-editor.model'; import { Guid } from '@common/types/guid'; @Component({ @@ -34,7 +34,16 @@ export class ExternalFetcherSourceComponent extends BaseComponent implements OnI ) { super(); } ngOnInit() { - console.log(this.referenceTypeSourceIndex); + } + + private reApplyValidators(){ + ExternalFetcherBaseSourceConfigurationEditorModel.reapplyValidators( + { + formGroup: this.formGroup, + validationErrorModel: this.validationErrorModel, + rootPath: this.validationRootPath + } + ) } // @@ -50,7 +59,9 @@ export class ExternalFetcherSourceComponent extends BaseComponent implements OnI removeQuery(queryIndex: number): void { const formArray = (this.formGroup.get('queries') as FormArray); - formArray.removeAt(queryIndex); + formArray.removeAt(queryIndex); + this.reApplyValidators(); + formArray.markAsDirty(); } // cases @@ -65,6 +76,8 @@ export class ExternalFetcherSourceComponent extends BaseComponent implements OnI removeCase(queryIndex: number, index: number): void { const formArray = (this.formGroup.get('queries') as FormArray).at(queryIndex).get('cases') as FormArray; formArray.removeAt(index); + this.reApplyValidators(); + formArray.markAsDirty(); } // Options @@ -88,6 +101,8 @@ export class ExternalFetcherSourceComponent extends BaseComponent implements OnI removeOption(optionIndex: number): void { const formArray = (this.formGroup.get('options') as FormArray); formArray.removeAt(optionIndex); + this.reApplyValidators(); + formArray.markAsDirty(); } setReferenceTypeDependenciesMap(ids: Guid[], index: number){ diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index b0c119da6..2e831445e 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -1681,7 +1681,8 @@ "OPTIONS-ROOT": "Options Root", "LABEL": "Label", "VALUE": "Value" - } + }, + "PREFILLING-SOURCES":"Prefilling Sources" }, "ACTIONS": { "ADD-FIELD": "Add Field", @@ -2364,11 +2365,11 @@ "TEXT": "Text", "DATE": "Date" }, - "REFERENCE-TYPE-SOURCE-TYPE": { + "EXTERNAL-FETCHER-SOURCE-TYPE": { "API": "API", "STATIC": "Static" }, - "REFERENCE-TYPE-EXTERNAL-API-HTTP-METHOD-TYPE": { + "EXTERNAL-FETCHER-API-HTTP-METHOD-TYPE": { "GET": "GET", "POST": "POST" },