prefilling source changes

This commit is contained in:
amentis 2024-03-01 18:45:32 +02:00
parent a5c194ac95
commit f0c076fe4f
11 changed files with 103 additions and 44 deletions

View File

@ -134,10 +134,6 @@ public class AuditableAction {
public static final EventId ContactSupport_Sent = new EventId(210000, "ContactSupport_Sent"); public static final EventId ContactSupport_Sent = new EventId(210000, "ContactSupport_Sent");
public static final EventId ContactSupport_PublicSent = new EventId(210001, "ContactSupport_PublicSent"); public static final EventId ContactSupport_PublicSent = new EventId(210001, "ContactSupport_PublicSent");
public static final EventId Prefilling_Query = new EventId(220000, "Prefilling_Query");
public static final EventId Prefilling_Generate = new EventId(210001, "Prefilling_Generate");
public static final EventId Prefilling_GenerateWithData = new EventId(210002, "Prefilling_GenerateWithData");
public static final EventId Maintenance_GenerateElastic = new EventId(220000, "Maintenance_GenerateElastic"); public static final EventId Maintenance_GenerateElastic = new EventId(220000, "Maintenance_GenerateElastic");
public static final EventId Maintenance_ClearElastic = new EventId(230000, "Maintenance_ClearElastic"); public static final EventId Maintenance_ClearElastic = new EventId(230000, "Maintenance_ClearElastic");
@ -149,6 +145,8 @@ public class AuditableAction {
public static final EventId PrefillingSource_Lookup = new EventId(260001, "PrefillingSource_Lookup"); public static final EventId PrefillingSource_Lookup = new EventId(260001, "PrefillingSource_Lookup");
public static final EventId PrefillingSource_Persist = new EventId(260002, "PrefillingSource_Persist"); public static final EventId PrefillingSource_Persist = new EventId(260002, "PrefillingSource_Persist");
public static final EventId PrefillingSource_Delete = new EventId(260003, "PrefillingSource_Delete"); public static final EventId PrefillingSource_Delete = new EventId(260003, "PrefillingSource_Delete");
public static final EventId PrefillingSource_Generate = new EventId(260005, "PrefillingSource_Generate");
public static final EventId PrefillingSource_GenerateWithData = new EventId(260006, "PrefillingSource_GenerateWithData");
} }

View File

@ -80,10 +80,10 @@ public class DescriptionProfilingRequest {
.failOn(DescriptionProfilingRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())), .failOn(DescriptionProfilingRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._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(DescriptionProfilingRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillingSourceId}, LocaleContextHolder.getLocale()))
this.spec() // this.spec() TODO
.must(() -> item.getProject() != null) // .must(() -> item.getProject() != null)
.failOn(DescriptionProfilingRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._project}, LocaleContextHolder.getLocale())) // .failOn(DescriptionProfilingRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._project}, LocaleContextHolder.getLocale()))
); );
} }
} }

View File

@ -91,13 +91,13 @@ public class DescriptionProfilingWithDataRequest {
.failOn(DescriptionProfilingWithDataRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())), .failOn(DescriptionProfilingWithDataRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> this.isValidGuid(item.getPrefillingSourceId())) .must(() -> this.isValidGuid(item.getPrefillingSourceId()))
.failOn(DescriptionProfilingWithDataRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._prefillingSourceId}, LocaleContextHolder.getLocale())), .failOn(DescriptionProfilingWithDataRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._prefillingSourceId}, LocaleContextHolder.getLocale()))
this.spec() // this.spec() TODO
.must(() -> item.getData() != null) // .must(() -> item.getData() != null)
.failOn(DescriptionProfilingWithDataRequest._data).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._data}, LocaleContextHolder.getLocale())), // .failOn(DescriptionProfilingWithDataRequest._data).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._data}, LocaleContextHolder.getLocale()))
this.spec() // this.spec()
.must(() -> item.getProject() != null) // .must(() -> item.getProject() != null)
.failOn(DescriptionProfilingWithDataRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._project}, LocaleContextHolder.getLocale())) // .failOn(DescriptionProfilingWithDataRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._project}, LocaleContextHolder.getLocale()))
); );
} }
} }

View File

@ -35,6 +35,7 @@ import eu.eudat.model.referencedefinition.Definition;
import eu.eudat.query.PrefillingSourceQuery; import eu.eudat.query.PrefillingSourceQuery;
import eu.eudat.query.lookup.ReferenceSearchLookup; import eu.eudat.query.lookup.ReferenceSearchLookup;
import eu.eudat.service.externalfetcher.ExternalFetcherService; import eu.eudat.service.externalfetcher.ExternalFetcherService;
import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
import eu.eudat.service.externalfetcher.models.ExternalDataResult; import eu.eudat.service.externalfetcher.models.ExternalDataResult;
import eu.eudat.service.reference.ReferenceService; import eu.eudat.service.reference.ReferenceService;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
@ -91,7 +92,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
private final JsonHandlingService jsonHandlingService; private final JsonHandlingService jsonHandlingService;
private final ReferenceService referenceService; private final ReferenceService referenceService;
private static final String Zenodo = "zenodo"; private static final String Zenodo = "Zenodo";
public PrefillingSourceServiceImpl( public PrefillingSourceServiceImpl(
EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory, EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory,
@ -328,7 +329,7 @@ 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()));
ExternalDataResult externalData = this.externalFetcherService.getExternalData(Stream.of(prefillingSourceDefinition.getGetConfiguration()).collect(Collectors.toList()), null, null); ExternalDataResult externalData = this.externalFetcherService.getExternalData(Stream.of(prefillingSourceDefinition.getGetConfiguration()).collect(Collectors.toList()), new ExternalReferenceCriteria(), null);
if (externalData == null || this.conventionService.isListNullOrEmpty(externalData.getResults())) { if (externalData == null || this.conventionService.isListNullOrEmpty(externalData.getResults())) {
return null; return null;
} }
@ -343,25 +344,33 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
} }
private Description mapPrefilledEntityToDescription(Description description, DefinitionEntity descriptionTemplateDefinition, PrefillingSourceDefinitionEntity prefillingSourceDefinition, String type, Map<String, String> externalData){ private Description mapPrefilledEntityToDescription(Description description, DefinitionEntity descriptionTemplateDefinition, PrefillingSourceDefinitionEntity prefillingSourceDefinition, String type, Map<String, String> externalData){
if (!this.conventionService.isListNullOrEmpty(prefillingSourceDefinition.getFields())) {
for (PrefillingSourceDefinitionFieldEntity field : prefillingSourceDefinition.getFields()) { for (PrefillingSourceDefinitionFieldEntity field : prefillingSourceDefinition.getFields()) {
String sourceValue = externalData.get(field.getCode()); String sourceValue = externalData.get(field.getCode());
this.prefillSystemValueToDescription(description, field.getSystemFieldTarget(), sourceValue); this.prefillSystemValueToDescription(description, field.getSystemFieldTarget(), sourceValue);
this.prefillSemanticValueToDescription(description, field.getSemanticTarget(), sourceValue, descriptionTemplateDefinition, type); this.prefillSemanticValueToDescription(description, field.getSemanticTarget(), sourceValue, descriptionTemplateDefinition, type);
} }
}
if (!this.conventionService.isListNullOrEmpty(prefillingSourceDefinition.getFixedValueFields())){
for (PrefillingSourceDefinitionFixedValueFieldEntity field: prefillingSourceDefinition.getFixedValueFields()) { for (PrefillingSourceDefinitionFixedValueFieldEntity field: prefillingSourceDefinition.getFixedValueFields()) {
this.prefillSystemValueToDescription(description, field.getSystemFieldTarget(), field.getFixedValue()); this.prefillSystemValueToDescription(description, field.getSystemFieldTarget(), field.getFixedValue());
this.prefillSemanticValueToDescription(description, field.getSemanticTarget(), field.getFixedValue(), descriptionTemplateDefinition, type); this.prefillSemanticValueToDescription(description, field.getSemanticTarget(), field.getFixedValue(), descriptionTemplateDefinition, type);
} }
}
if (!this.conventionService.isListNullOrEmpty(prefillingSourceDefinition.getFields())) {
for (PrefillingSourceDefinitionFieldEntity field : prefillingSourceDefinition.getFields()) { for (PrefillingSourceDefinitionFieldEntity field : prefillingSourceDefinition.getFields()) {
String sourceValue = externalData.get(field.getCode()); String sourceValue = externalData.get(field.getCode());
this.ensureZenodoFields(description, field.getSemanticTarget(), sourceValue, descriptionTemplateDefinition, type); this.ensureZenodoFields(description, field.getSemanticTarget(), sourceValue, descriptionTemplateDefinition, type);
} }
}
if (!this.conventionService.isListNullOrEmpty(prefillingSourceDefinition.getFixedValueFields())) {
for (PrefillingSourceDefinitionFixedValueFieldEntity field : prefillingSourceDefinition.getFixedValueFields()) { for (PrefillingSourceDefinitionFixedValueFieldEntity field : prefillingSourceDefinition.getFixedValueFields()) {
this.ensureZenodoFields(description, field.getSemanticTarget(), field.getFixedValue(), descriptionTemplateDefinition, type); this.ensureZenodoFields(description, field.getSemanticTarget(), field.getFixedValue(), descriptionTemplateDefinition, type);
} }
}
return description; return description;
} }
@ -371,7 +380,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
if (semanticTarget.equals("rda.dataset.distribution.data_access")) { if (semanticTarget.equals("rda.dataset.distribution.data_access")) {
if (value.equals("open")) { if (value.equals("open")) {
List<FieldEntity> issuedFieldEntities = definition.getAllField().stream().filter(x -> x.getSchematics() != null && x.getSchematics().contains("rda.dataset.issued")).toList(); List<FieldEntity> issuedFieldEntities = definition.getAllField().stream().filter(x -> x.getSchematics() != null && x.getSchematics().contains("rda.dataset.issued")).toList();
if (this.conventionService.isListNullOrEmpty(issuedFieldEntities)) { if (!this.conventionService.isListNullOrEmpty(issuedFieldEntities)) {
String issuedIdNode = issuedFieldEntities.getFirst().getId(); String issuedIdNode = issuedFieldEntities.getFirst().getId();
String issuedValue = this.conventionService.isNullOrEmpty(issuedIdNode) ? null : description.getProperties().getFieldSets().values().stream().map(PropertyDefinitionFieldSet::getItems).flatMap(List::stream) String issuedValue = this.conventionService.isNullOrEmpty(issuedIdNode) ? null : description.getProperties().getFieldSets().values().stream().map(PropertyDefinitionFieldSet::getItems).flatMap(List::stream)
.filter(x -> x.getFields() != null && x.getFields().containsKey(issuedIdNode)).map(x -> x.getFields().get(issuedIdNode).getTextValue()).findFirst().orElse(null); .filter(x -> x.getFields() != null && x.getFields().containsKey(issuedIdNode)).map(x -> x.getFields().get(issuedIdNode).getTextValue()).findFirst().orElse(null);

View File

@ -153,7 +153,7 @@ public class PrefillingSourceController {
Description item = this.prefillingSourceService.getPrefilledDescription(model); Description item = this.prefillingSourceService.getPrefilledDescription(model);
this.auditService.track(AuditableAction.Prefilling_Generate, Map.ofEntries( this.auditService.track(AuditableAction.PrefillingSource_Generate, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("model", model) new AbstractMap.SimpleEntry<String, Object>("model", model)
)); ));
@ -169,7 +169,7 @@ public class PrefillingSourceController {
Description item = this.prefillingSourceService.getPrefilledDescriptionUsingData(model); Description item = this.prefillingSourceService.getPrefilledDescriptionUsingData(model);
this.auditService.track(AuditableAction.Prefilling_GenerateWithData, Map.ofEntries( this.auditService.track(AuditableAction.PrefillingSource_GenerateWithData, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("model", model) new AbstractMap.SimpleEntry<String, Object>("model", model)
)); ));

View File

@ -0,0 +1,12 @@
import { Guid } from "@common/types/guid";
export interface DescriptionProfilingRequest {
prefillingSourceId: Guid;
descriptionTemplateId: Guid;
}
export interface DescriptionProfilingWithDataRequest {
prefillingSourceId: Guid;
descriptionTemplateId: Guid;
data: Map<String, Object>;
}

View File

@ -12,6 +12,8 @@ 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 { DescriptionProfilingRequest, DescriptionProfilingWithDataRequest } from '@app/core/model/description-profiling-request/description-profiling-request';
import { Description } from '@app/core/model/description/description';
@Injectable() @Injectable()
export class PrefillingSourceService { export class PrefillingSourceService {
@ -55,6 +57,22 @@ export class PrefillingSourceService {
catchError((error: any) => throwError(error))); catchError((error: any) => throwError(error)));
} }
generate(item: DescriptionProfilingRequest): Observable<Description> {
const url = `${this.apiBase}/generate`;
return this.http
.post<Description>(url, item).pipe(
catchError((error: any) => throwError(error)));
}
generateWithData(item: DescriptionProfilingWithDataRequest): Observable<Description> {
const url = `${this.apiBase}/generate-with-data`;
return this.http
.post<Description>(url, item).pipe(
catchError((error: any) => throwError(error)));
}
// //
// Autocomplete Commons // Autocomplete Commons
// //

View File

@ -13,6 +13,7 @@ import { TableOfContentsModule } from './table-of-contents/table-of-contents.mod
import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-editor.module'; import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-editor.module';
import { TagsFieldModule } from '@app/ui/tag/tags-field/tags-field.module'; import { TagsFieldModule } from '@app/ui/tag/tags-field/tags-field.module';
import { PrefillDescriptionDialogComponent } from './prefill-description/prefill-description.component'; import { PrefillDescriptionDialogComponent } from './prefill-description/prefill-description.component';
import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module';
@NgModule({ @NgModule({
imports: [ imports: [
@ -25,7 +26,8 @@ import { PrefillDescriptionDialogComponent } from './prefill-description/prefill
DescriptionFormModule, DescriptionFormModule,
DescriptionEditorRoutingModule, DescriptionEditorRoutingModule,
RichTextEditorModule, RichTextEditorModule,
TagsFieldModule TagsFieldModule,
AutoCompleteModule
], ],
declarations: [ declarations: [
DescriptionEditorComponent, DescriptionEditorComponent,

View File

@ -25,14 +25,24 @@
<h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.DESCRIPTION-TEMPLATE' | translate}}</h4> <h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.DESCRIPTION-TEMPLATE' | translate}}</h4>
</div> </div>
<mat-form-field class="col-md-12"> <mat-form-field class="col-md-12">
<mat-select placeholder="{{'PREFILL-DESCRIPTION-DIALOG.DESCRIPTION-TEMPLATE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="descriptionTempalte"> <mat-select placeholder="{{'PREFILL-DESCRIPTION-DIALOG.DESCRIPTION-TEMPLATE'| translate}}" [required]="true" [compareWith]="compareWith" [formControl]="prefillForm.get('descriptionTemplateId')">
<mat-option *ngFor="let descriptionTempalte of availableDescriptionTempaltes" [value]="descriptionTempalte.id"> <mat-option *ngFor="let descriptionTemplate of availableDescriptionTemplates" [value]="descriptionTemplate.id">
<div> <div>
{{descriptionTempalte.label}} {{descriptionTemplate.label}}
</div> </div>
</mat-option> </mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="prefillForm.get('descriptionTempalte').hasError('backendError')">{{prefillForm.get('descriptionTempalte').getError('backendError').message}}</mat-error> <mat-error *ngIf="prefillForm.get('descriptionTemplateId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row">
<h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.PREFILLING-SOURCE' | translate}}</h4>
</div>
<mat-form-field class="col-md-12">
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('prefillingSourceId')"
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.PREFILLING-SOURCE' | translate}}"
[configuration]="prefillingSourceService.singleAutocompleteConfiguration">
</app-single-auto-complete>
<mat-error *ngIf="prefillForm.get('prefillingSourceId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<!-- <div *ngIf="prefillSelected" class="row"> <!-- <div *ngIf="prefillSelected" class="row">

View File

@ -1,12 +1,14 @@
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 { DescriptionProfilingRequest } 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 { DmpBlueprintService } from "@app/core/services/dmp/dmp-blueprint.service"; import { DmpBlueprintService } from "@app/core/services/dmp/dmp-blueprint.service";
import { PrefillingService } from "@app/core/services/prefilling.service"; import { PrefillingSourceService } from "@app/core/services/prefilling-source/prefilling-source.service";
import { ProgressIndicationService } from "@app/core/services/progress-indication/progress-indication-service"; import { ProgressIndicationService } from "@app/core/services/progress-indication/progress-indication-service";
import { BaseComponent } from "@common/base/base.component"; import { BaseComponent } from "@common/base/base.component";
import { FormService } from "@common/forms/form-service";
import { Guid } from "@common/types/guid"; import { Guid } from "@common/types/guid";
import { TranslateService } from "@ngx-translate/core"; import { TranslateService } from "@ngx-translate/core";
import { UUID } from "crypto"; import { UUID } from "crypto";
@ -26,21 +28,22 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
dmp: Dmp; dmp: Dmp;
dmpSectionId: Guid; dmpSectionId: Guid;
availableDescriptionTempaltes: DescriptionTemplate[] = []; availableDescriptionTemplates: DescriptionTemplate[] = [];
constructor(public dialogRef: MatDialogRef<PrefillDescriptionDialogComponent>, constructor(public dialogRef: MatDialogRef<PrefillDescriptionDialogComponent>,
// private prefillingService: PrefillingService,
// private dmpBlueprintService: DmpBlueprintService, // private dmpBlueprintService: DmpBlueprintService,
// private dialog: MatDialog, // private dialog: MatDialog,
// private language: TranslateService, // private language: TranslateService,
private progressIndicationService: ProgressIndicationService, private progressIndicationService: ProgressIndicationService,
private fb: UntypedFormBuilder, private fb: UntypedFormBuilder,
public prefillingSourceService: PrefillingSourceService,
private formService: FormService,
@Inject(MAT_DIALOG_DATA) public data: any) { @Inject(MAT_DIALOG_DATA) public data: any) {
super(); super();
this.dmp = data.dmp; this.dmp = data.dmp;
this.dmpSectionId = data.dmpSectionId; this.dmpSectionId = data.dmpSectionId;
this.availableDescriptionTempaltes = this.dmp.dmpDescriptionTemplates.filter(x => x.sectionId == this.dmpSectionId).map(x => x.currentDescriptionTemplate); this.availableDescriptionTemplates = this.dmp.dmpDescriptionTemplates.filter(x => x.sectionId == this.dmpSectionId).map(x => x.currentDescriptionTemplate);
} }
ngOnInit() { ngOnInit() {
@ -49,8 +52,8 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
}); });
this.prefillForm = this.fb.group({ this.prefillForm = this.fb.group({
type: this.fb.control(false), type: this.fb.control(false),
descriptionTempalte: this.fb.control('', Validators.required), descriptionTemplateId: this.fb.control(null, Validators.required),
prefill: this.fb.control(null, Validators.required) prefillingSourceId: 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]);
@ -196,6 +199,12 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
// } else { // } else {
// this.closeDialog(); // this.closeDialog();
// } // }
const formData = this.formService.getValue(this.prefillForm.value) as DescriptionProfilingRequest;
this.prefillingSourceService.generate(formData)
.pipe(takeUntil(this._destroyed)).subscribe(
);
this.closeDialog();
} }
closeDialog(result = null): void { closeDialog(result = null): void {

View File

@ -1066,6 +1066,7 @@
"OR": "OR", "OR": "OR",
"HINT": "Select the dataset from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.", "HINT": "Select the dataset from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.",
"DESCRIPTION-TEMPLATE": "Description Template", "DESCRIPTION-TEMPLATE": "Description Template",
"PREFILLING-SOURCE": "Prefilling Source",
"SEARCH-HEADER": "Prefilled object", "SEARCH-HEADER": "Prefilled object",
"SEARCH": "Start typing to search for an entity to use for prefilling", "SEARCH": "Start typing to search for an entity to use for prefilling",
"ACTIONS": { "ACTIONS": {