prefilling fixes

This commit is contained in:
Efstratios Giannopoulos 2024-04-18 14:15:03 +03:00
parent 7cc067125a
commit 5e6b231a0f
13 changed files with 136 additions and 81 deletions

View File

@ -10,7 +10,7 @@ public class Prefilling {
private String label; private String label;
public static final String _label = "label"; public static final String _label = "label";
private Map<String, Object> data; private Map<String, String> data;
public static final String _data = "data"; public static final String _data = "data";
private String key; private String key;
public static final String _key = "key"; public static final String _key = "key";
@ -33,11 +33,11 @@ public class Prefilling {
this.label = label; this.label = label;
} }
public Map<String, Object> getData() { public Map<String, String> getData() {
return data; return data;
} }
public void setData(Map<String, Object> data) { public void setData(Map<String, String> data) {
this.data = data; this.data = data;
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.model.persist; package eu.eudat.model.persist;
import eu.eudat.commons.validation.BaseValidator; import eu.eudat.commons.validation.BaseValidator;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
@ -16,14 +17,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class DescriptionProfilingRequest { public class DescriptionPrefillingRequest {
private Map<String, String> data; private DescriptionPrefillingRequestData data;
public static final String _data = "data"; public static final String _data = "data";
private String prefillId;
public static final String _prefillId = "prefillId";
private UUID prefillingSourceId; private UUID prefillingSourceId;
public static final String _prefillingSourceId = "prefillingSourceId"; public static final String _prefillingSourceId = "prefillingSourceId";
@ -35,22 +33,14 @@ public class DescriptionProfilingRequest {
private BaseFieldSet project; private BaseFieldSet project;
public static final String _project = "project"; public static final String _project = "project";
public Map<String, String> getData() { public DescriptionPrefillingRequestData getData() {
return data; return data;
} }
public void setData(Map<String, String> data) { public void setData(DescriptionPrefillingRequestData data) {
this.data = data; this.data = data;
} }
public String getPrefillId() {
return prefillId;
}
public void setPrefillId(String prefillId) {
this.prefillId = prefillId;
}
public UUID getPrefillingSourceId() { public UUID getPrefillingSourceId() {
return prefillingSourceId; return prefillingSourceId;
} }
@ -77,44 +67,46 @@ public class DescriptionProfilingRequest {
@Component(DescriptionProfilingRequestValidator.ValidatorName) @Component(DescriptionProfilingRequestValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DescriptionProfilingRequestValidator extends BaseValidator<DescriptionProfilingRequest> { public static class DescriptionProfilingRequestValidator extends BaseValidator<DescriptionPrefillingRequest> {
public static final String ValidatorName = "DescriptionProfilingRequestValidator"; public static final String ValidatorName = "DescriptionProfilingRequestValidator";
private final MessageSource messageSource; private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
protected DescriptionProfilingRequestValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { protected DescriptionProfilingRequestValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors); super(conventionService, errors);
this.messageSource = messageSource; this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
} }
@Override @Override
protected Class<DescriptionProfilingRequest> modelClass() { protected Class<DescriptionPrefillingRequest> modelClass() {
return DescriptionProfilingRequest.class; return DescriptionPrefillingRequest.class;
} }
@Override @Override
protected List<Specification> specifications(DescriptionProfilingRequest item) { protected List<Specification> specifications(DescriptionPrefillingRequest item) {
return Arrays.asList( return Arrays.asList(
this.spec() this.spec()
.must(() -> this.isValidGuid(item.getDescriptionTemplateId())) .must(() -> this.isValidGuid(item.getDescriptionTemplateId()))
.failOn(DescriptionProfilingRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())), .failOn(DescriptionPrefillingRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPrefillingRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> this.isValidGuid(item.getPrefillingSourceId())) .must(() -> this.isValidGuid(item.getPrefillingSourceId()))
.failOn(DescriptionProfilingRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillingSourceId}, LocaleContextHolder.getLocale())), .failOn(DescriptionPrefillingRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPrefillingRequest._prefillingSourceId}, LocaleContextHolder.getLocale())),
this.refSpec()
.iff(() -> !this.isNull(item.getData()))
.on(DescriptionReferencePersist._reference)
.over(item.getData())
.using(() -> this.validatorFactory.validator(DescriptionPrefillingRequestData.DescriptionPrefillingRequestDataValidator.class)),
this.spec() this.spec()
.must(() -> !this.isEmpty(item.getPrefillId())) .must(() -> !this.isNull(item.getData()))
.failOn(DescriptionProfilingRequest._prefillId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillId}, LocaleContextHolder.getLocale())) .failOn(DescriptionPrefillingRequest._data).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPrefillingRequest._data}, LocaleContextHolder.getLocale()))
// this.spec()
// .must(() -> item.getData() != null)
// .failOn(DescriptionProfilingWithDataRequest._data).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._data}, LocaleContextHolder.getLocale()))
// this.spec()
// .must(() -> item.getProject() != null)
// .failOn(DescriptionProfilingWithDataRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._project}, LocaleContextHolder.getLocale()))
); );
} }
} }
} }

View File

@ -0,0 +1,71 @@
package eu.eudat.model.persist;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import gr.cite.tools.validation.specification.Specification;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DescriptionPrefillingRequestData {
private HashMap<String, String> data;
public static final String _data = "data";
private String id;
public static final String _id = "id";
public HashMap<String, String> getData() {
return data;
}
public void setData(HashMap<String, String> data) {
this.data = data;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Component(DescriptionPrefillingRequestDataValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DescriptionPrefillingRequestDataValidator extends BaseValidator<DescriptionPrefillingRequestData> {
public static final String ValidatorName = "DescriptionPrefillingRequestDataValidator";
private final MessageSource messageSource;
protected DescriptionPrefillingRequestDataValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected Class<DescriptionPrefillingRequestData> modelClass() {
return DescriptionPrefillingRequestData.class;
}
@Override
protected List<Specification> specifications(DescriptionPrefillingRequestData item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isEmpty(item.getId()))
.failOn(DescriptionPrefillingRequestData._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPrefillingRequestData._id}, LocaleContextHolder.getLocale()))
);
}
}
}

View File

@ -1,24 +1,6 @@
package eu.eudat.service.maintenance; package eu.eudat.service.maintenance;
import eu.eudat.model.Description;
import eu.eudat.model.Prefilling;
import eu.eudat.model.PrefillingSource;
import eu.eudat.model.persist.DescriptionProfilingRequest;
import eu.eudat.model.persist.PrefillingSearchRequest;
import eu.eudat.model.persist.PrefillingSourcePersist;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.exception.MyValidationException;
import gr.cite.tools.fieldset.FieldSet;
import jakarta.xml.bind.JAXBException;
import org.xml.sax.SAXException;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
public interface MaintenanceService { public interface MaintenanceService {

View File

@ -4,7 +4,7 @@ import eu.eudat.model.Description;
import eu.eudat.model.Prefilling; import eu.eudat.model.Prefilling;
import eu.eudat.model.PrefillingSource; import eu.eudat.model.PrefillingSource;
import eu.eudat.model.persist.PrefillingSearchRequest; import eu.eudat.model.persist.PrefillingSearchRequest;
import eu.eudat.model.persist.DescriptionProfilingRequest; import eu.eudat.model.persist.DescriptionPrefillingRequest;
import eu.eudat.model.persist.PrefillingSourcePersist; import eu.eudat.model.persist.PrefillingSourcePersist;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException; import gr.cite.tools.exception.MyForbiddenException;
@ -28,6 +28,6 @@ public interface PrefillingSourceService {
List<Prefilling> searchPrefillings(PrefillingSearchRequest model); List<Prefilling> searchPrefillings(PrefillingSearchRequest model);
Description getPrefilledDescription(DescriptionProfilingRequest model, FieldSet fields) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException; Description getPrefilledDescription(DescriptionPrefillingRequest model, FieldSet fields) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException;
} }

View File

@ -25,7 +25,7 @@ import eu.eudat.model.builder.PrefillingSourceBuilder;
import eu.eudat.model.deleter.PrefillingSourceDeleter; import eu.eudat.model.deleter.PrefillingSourceDeleter;
import eu.eudat.model.descriptionproperties.*; import eu.eudat.model.descriptionproperties.*;
import eu.eudat.model.persist.PrefillingSearchRequest; import eu.eudat.model.persist.PrefillingSearchRequest;
import eu.eudat.model.persist.DescriptionProfilingRequest; import eu.eudat.model.persist.DescriptionPrefillingRequest;
import eu.eudat.model.persist.PrefillingSourcePersist; import eu.eudat.model.persist.PrefillingSourcePersist;
import eu.eudat.model.persist.externalfetcher.*; import eu.eudat.model.persist.externalfetcher.*;
import eu.eudat.model.persist.prefillingsourcedefinition.PrefillingSourceDefinitionFieldPersist; import eu.eudat.model.persist.prefillingsourcedefinition.PrefillingSourceDefinitionFieldPersist;
@ -330,6 +330,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
prefilling.setLabel(result.getOrDefault(Prefilling._label, null)); prefilling.setLabel(result.getOrDefault(Prefilling._label, null));
prefilling.setKey(result.getOrDefault(Prefilling._key, null)); prefilling.setKey(result.getOrDefault(Prefilling._key, null));
prefilling.setTag(result.getOrDefault(Prefilling._tag, null)); prefilling.setTag(result.getOrDefault(Prefilling._tag, null));
if (prefillingSourceDefinition.getGetConfiguration() == null) prefilling.setData(result);
prefillings.add(prefilling); prefillings.add(prefilling);
} }
@ -339,7 +340,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
return prefillings; return prefillings;
} }
public Description getPrefilledDescription(DescriptionProfilingRequest model, FieldSet fieldSet) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { public Description getPrefilledDescription(DescriptionPrefillingRequest model, FieldSet fieldSet) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(model.getPrefillingSourceId()).first(); PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(model.getPrefillingSourceId()).first();
if (prefillingSourceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (prefillingSourceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
@ -347,17 +348,16 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
PrefillingSourceDefinitionEntity prefillingSourceDefinition = this.xmlHandlingService.fromXmlSafe(PrefillingSourceDefinitionEntity.class, prefillingSourceEntity.getDefinition()); PrefillingSourceDefinitionEntity prefillingSourceDefinition = this.xmlHandlingService.fromXmlSafe(PrefillingSourceDefinitionEntity.class, prefillingSourceEntity.getDefinition());
if (prefillingSourceDefinition == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSourceDefinition.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (prefillingSourceDefinition == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSourceDefinition.class.getSimpleName()}, LocaleContextHolder.getLocale()));
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria();
externalReferenceCriteria.setLike(model.getPrefillId());
Map<String, String> data = new HashMap<>(); Map<String, String> data = new HashMap<>();
if (prefillingSourceDefinition.getGetConfiguration() != null){ if (prefillingSourceDefinition.getGetConfiguration() != null){
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria();
externalReferenceCriteria.setLike(model.getData().getId());
ExternalDataResult externalData = this.externalFetcherService.getExternalData(Stream.of(prefillingSourceDefinition.getGetConfiguration()).collect(Collectors.toList()), externalReferenceCriteria, null); ExternalDataResult externalData = this.externalFetcherService.getExternalData(Stream.of(prefillingSourceDefinition.getGetConfiguration()).collect(Collectors.toList()), externalReferenceCriteria, null);
if (externalData != null && !this.conventionService.isListNullOrEmpty(externalData.getResults())) { if (externalData != null && !this.conventionService.isListNullOrEmpty(externalData.getResults())) {
data = externalData.getResults().getFirst(); data = externalData.getResults().getFirst();
} }
} else { } else {
data = model.getData() == null ? new HashMap<>() : model.getData(); data = model.getData() == null ? new HashMap<>() : model.getData().getData();
} }
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId()); DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId());

View File

@ -12,13 +12,12 @@ import eu.eudat.model.censorship.DescriptionCensor;
import eu.eudat.model.censorship.PrefillingCensor; import eu.eudat.model.censorship.PrefillingCensor;
import eu.eudat.model.censorship.PrefillingSourceCensor; import eu.eudat.model.censorship.PrefillingSourceCensor;
import eu.eudat.model.persist.PrefillingSearchRequest; import eu.eudat.model.persist.PrefillingSearchRequest;
import eu.eudat.model.persist.DescriptionProfilingRequest; import eu.eudat.model.persist.DescriptionPrefillingRequest;
import eu.eudat.model.persist.PrefillingSourcePersist; import eu.eudat.model.persist.PrefillingSourcePersist;
import eu.eudat.model.result.QueryResult; import eu.eudat.model.result.QueryResult;
import eu.eudat.query.PrefillingSourceQuery; import eu.eudat.query.PrefillingSourceQuery;
import eu.eudat.query.lookup.PrefillingSourceLookup; import eu.eudat.query.lookup.PrefillingSourceLookup;
import eu.eudat.service.prefillingsource.PrefillingSourceService; import eu.eudat.service.prefillingsource.PrefillingSourceService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.auditing.AuditService; import gr.cite.tools.auditing.AuditService;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.data.censor.CensorFactory;
@ -63,7 +62,6 @@ public class PrefillingSourceController {
private final MessageSource messageSource; private final MessageSource messageSource;
private final AuthorizationService authorizationService;
private final PrefillingSourceService prefillingSourceService; private final PrefillingSourceService prefillingSourceService;
@ -73,13 +71,12 @@ public class PrefillingSourceController {
AuditService auditService, AuditService auditService,
CensorFactory censorFactory, CensorFactory censorFactory,
QueryFactory queryFactory, QueryFactory queryFactory,
MessageSource messageSource, AuthorizationService authorizationService, PrefillingSourceService prefillingSourceService) { MessageSource messageSource, PrefillingSourceService prefillingSourceService) {
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.auditService = auditService; this.auditService = auditService;
this.censorFactory = censorFactory; this.censorFactory = censorFactory;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.messageSource = messageSource; this.messageSource = messageSource;
this.authorizationService = authorizationService;
this.prefillingSourceService = prefillingSourceService; this.prefillingSourceService = prefillingSourceService;
} }
@ -162,8 +159,8 @@ public class PrefillingSourceController {
} }
@PostMapping("generate") @PostMapping("generate")
@ValidationFilterAnnotation(validator = DescriptionProfilingRequest.DescriptionProfilingRequestValidator.ValidatorName, argumentName = "model") @ValidationFilterAnnotation(validator = DescriptionPrefillingRequest.DescriptionProfilingRequestValidator.ValidatorName, argumentName = "model")
public Description generate(@RequestBody DescriptionProfilingRequest model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { public Description generate(@RequestBody DescriptionPrefillingRequest model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting" + Prefilling.class.getSimpleName()).And("model", model)); logger.debug(new MapLogEntry("persisting" + Prefilling.class.getSimpleName()).And("model", model));
this.censorFactory.censor(DescriptionCensor.class).censor(fieldSet, null); this.censorFactory.censor(DescriptionCensor.class).censor(fieldSet, null);

View File

@ -5,10 +5,14 @@ export interface PrefillingSearchRequest {
prefillingSourceId: Guid; prefillingSourceId: Guid;
} }
export interface DescriptionProfilingRequest { export interface DescriptionPrefillingRequest {
prefillingSourceId: Guid; prefillingSourceId: Guid;
descriptionTemplateId: Guid; descriptionTemplateId: Guid;
data: Map<String, Object>; data: DescriptionPrefillingRequestData;
prefillId: string;
project: string[]; project: string[];
} }
export interface DescriptionPrefillingRequestData {
data: Map<string, string>;
id: string;
}

View File

@ -32,6 +32,7 @@ export interface Prefilling {
label: string, label: string,
key: string, key: string,
tag: string tag: string
data: Map<string, string>
} }
// Persist // Persist

View File

@ -12,7 +12,7 @@ import { catchError, map } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof'; import { nameof } from 'ts-simple-nameof';
import { ConfigurationService } from '../configuration/configuration.service'; import { ConfigurationService } from '../configuration/configuration.service';
import { BaseHttpV2Service } from '../http/base-http-v2.service'; import { BaseHttpV2Service } from '../http/base-http-v2.service';
import { PrefillingSearchRequest, DescriptionProfilingRequest } from '@app/core/model/description-profiling-request/description-profiling-request'; import { DescriptionPrefillingRequest, PrefillingSearchRequest } from '@app/core/model/description-profiling-request/description-profiling-request';
import { Description } from '@app/core/model/description/description'; import { Description } from '@app/core/model/description/description';
@Injectable() @Injectable()
@ -65,7 +65,7 @@ export class PrefillingSourceService {
catchError((error: any) => throwError(error))); catchError((error: any) => throwError(error)));
} }
generate(item: DescriptionProfilingRequest, reqFields: string[] = []): Observable<Description> { generate(item: DescriptionPrefillingRequest, reqFields: string[] = []): Observable<Description> {
const url = `${this.apiBase}/generate`; const url = `${this.apiBase}/generate`;
const options = { params: { f: reqFields } }; const options = { params: { f: reqFields } };
@ -113,4 +113,4 @@ export class PrefillingSourceService {
return lookup; return lookup;
} }
} }

View File

@ -191,6 +191,7 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
}else{ }else{
const definition = this.formGroup.get('definition') as UntypedFormGroup; const definition = this.formGroup.get('definition') as UntypedFormGroup;
if (definition.get('getConfiguration')) definition.removeControl('getConfiguration'); if (definition.get('getConfiguration')) definition.removeControl('getConfiguration');
this.submitFields();
} }
} }
@ -253,7 +254,14 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
for (let i = 0; i < fieldsFormArray.length; i++) { for (let i = 0; i < fieldsFormArray.length; i++) {
const code = fieldsFormArray.at(i).get('code').value; const code = fieldsFormArray.at(i).get('code').value;
// this.addFieldMapping(code, "searchConfiguration"); // this.addFieldMapping(code, "searchConfiguration");
if(this.formGroup.get('definition').get('getEnabled').value == true) this.addFieldMapping(code, "getConfiguration"); if (this.formGroup.get('definition').get('getEnabled').value == true) {
this.addFieldMapping(code, "getConfiguration");
this.removeFieldMapping((this.formGroup.get('definition').get('searchConfiguration') as FormGroup), code);
}
else {
this.addFieldMapping(code, "searchConfiguration");
this.removeFieldMapping((this.formGroup.get('definition').get('getConfiguration') as FormGroup), code);
}
} }
} }
} }

View File

@ -51,7 +51,7 @@
<h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.SEARCH-HEADER' | translate}}</h4> <h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.SEARCH-HEADER' | translate}}</h4>
</div> </div>
<mat-form-field class="col-md-12"> <mat-form-field class="col-md-12">
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('prefillId')" <app-single-auto-complete [required]="true" [formControl]="prefillForm.get('data')"
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.SEARCH' | translate}}" placeholder="{{'PREFILL-DESCRIPTION-DIALOG.SEARCH' | translate}}"
[configuration]="prefillAutoCompleteConfiguration"> [configuration]="prefillAutoCompleteConfiguration">
</app-single-auto-complete> </app-single-auto-complete>

View File

@ -1,7 +1,7 @@
import { Component, Inject, OnInit } from "@angular/core"; import { Component, Inject, OnInit } from "@angular/core";
import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from "@angular/material/dialog"; import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from "@angular/material/dialog";
import { PrefillingSearchRequest, DescriptionProfilingRequest } from "@app/core/model/description-profiling-request/description-profiling-request"; import { DescriptionPrefillingRequest, PrefillingSearchRequest } from "@app/core/model/description-profiling-request/description-profiling-request";
import { DescriptionTemplate } from "@app/core/model/description-template/description-template"; import { DescriptionTemplate } from "@app/core/model/description-template/description-template";
import { Dmp } from "@app/core/model/dmp/dmp"; import { Dmp } from "@app/core/model/dmp/dmp";
import { Prefilling } from "@app/core/model/prefilling-source/prefilling-source"; import { Prefilling } from "@app/core/model/prefilling-source/prefilling-source";
@ -62,7 +62,7 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
type: this.fb.control(false), type: this.fb.control(false),
descriptionTemplateId: this.fb.control(null, Validators.required), descriptionTemplateId: this.fb.control(null, Validators.required),
prefillingSourceId: this.fb.control(null, Validators.required), prefillingSourceId: this.fb.control(null, Validators.required),
prefillId: this.fb.control(null, Validators.required), data: this.fb.control(null, Validators.required),
}) })
// if (this.data.availableProfiles && this.data.availableProfiles.length === 1) { // if (this.data.availableProfiles && this.data.availableProfiles.length === 1) {
// this.addProfileIfUsedLessThanMax(this.data.availableProfiles[0]); // this.addProfileIfUsedLessThanMax(this.data.availableProfiles[0]);
@ -73,12 +73,12 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
displayFn: (item) => (item['label'].length > 60) ? (item['label'].substr(0, 60) + "...") : item['label'], displayFn: (item) => (item['label'].length > 60) ? (item['label'].substr(0, 60) + "...") : item['label'],
titleFn: (item) => item['label'], titleFn: (item) => item['label'],
subtitleFn: (item) => item['id'], subtitleFn: (item) => item['id'],
valueAssign: (item) => item['id'], valueAssign: (item) => item,
}; };
} }
changePreffillingSource(){ changePreffillingSource(){
this.prefillForm.get('prefillId').setValue(null); this.prefillForm.get('data').setValue(null);
} }
// addProfileIfUsedLessThanMax(profile: DescriptionProfileModel) { // addProfileIfUsedLessThanMax(profile: DescriptionProfileModel) {
@ -210,7 +210,7 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
// } else { // } else {
// this.closeDialog(); // this.closeDialog();
// } // }
const formData = this.formService.getValue(this.prefillForm.value) as DescriptionProfilingRequest; const formData = this.formService.getValue(this.prefillForm.value) as DescriptionPrefillingRequest;
this.prefillingSourceService.generate(formData, DescriptionEditorResolver.descriptionTemplateLookupFields(nameof<Description>(x => x.descriptionTemplate))) this.prefillingSourceService.generate(formData, DescriptionEditorResolver.descriptionTemplateLookupFields(nameof<Description>(x => x.descriptionTemplate)))
.pipe(takeUntil(this._destroyed)).subscribe(description => { .pipe(takeUntil(this._destroyed)).subscribe(description => {
@ -226,4 +226,4 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
closeDialog(result = null): void { closeDialog(result = null): void {
this.dialogRef.close(result); this.dialogRef.close(result);
} }
} }