show prefilling pop up if only at least one dataset profile has enabled prefilling property

This commit is contained in:
Bernaldo Mihasi 2023-10-06 11:22:23 +03:00
parent c238615b50
commit ecd86f413a
7 changed files with 115 additions and 24 deletions

View File

@ -6,6 +6,7 @@ import eu.eudat.logic.managers.DatasetProfileManager;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem; import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel; import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
import eu.eudat.models.data.datasetprofile.DatasetProfileWithPrefillingPropertyModel;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -42,5 +43,12 @@ public class DatasetProfiles extends BaseController {
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(tableRequestItem); List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(tableRequestItem);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
} }
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofiles/getAllWithPrefilling"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<DatasetProfileWithPrefillingPropertyModel>>> getAllWithPrefilling(@RequestBody DatasetProfileTableRequestItem tableRequestItem) {
List<DatasetProfileWithPrefillingPropertyModel> datasetProfileTableData = this.datasetProfileManager.getAllWithPrefilling(tableRequestItem);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileWithPrefillingPropertyModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
}
} }

View File

@ -18,9 +18,11 @@ import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile; import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile;
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ImportXmlBuilderDatasetProfile; import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ImportXmlBuilderDatasetProfile;
import eu.eudat.models.data.admin.composite.DatasetProfile;
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData; import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem; import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel; import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
import eu.eudat.models.data.datasetprofile.DatasetProfileWithPrefillingPropertyModel;
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field; import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field;
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel; import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.common.DataTableData;
@ -129,6 +131,21 @@ public class DatasetProfileManager {
return datasetProfiles; return datasetProfiles;
} }
public List<DatasetProfileWithPrefillingPropertyModel> getAllWithPrefilling(DatasetProfileTableRequestItem tableRequestItem) {
List<DatasetProfileWithPrefillingPropertyModel> datasetProfiles = new ArrayList<>();
if (!tableRequestItem.getCriteria().getIds().isEmpty()) {
tableRequestItem.getCriteria().getIds().forEach(id -> {
DatasetProfile datasetProfile = this.getDatasetProfile(id.toString());
DatasetProfileWithPrefillingPropertyModel profileModel = new DatasetProfileWithPrefillingPropertyModel();
profileModel.setId(id);
profileModel.setLabel(datasetProfile.getLabel());
profileModel.setEnablePrefilling(datasetProfile.isEnablePrefilling());
datasetProfiles.add(profileModel);
});
}
return datasetProfiles;
}
public eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field queryForField(String xml, String fieldId) throws XPathExpressionException { public eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field queryForField(String xml, String fieldId) throws XPathExpressionException {
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field field = new Field(); eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field field = new Field();
Document document = XmlBuilder.fromXml(xml); Document document = XmlBuilder.fromXml(xml);

View File

@ -0,0 +1,30 @@
package eu.eudat.models.data.datasetprofile;
import java.util.UUID;
public class DatasetProfileWithPrefillingPropertyModel {
private UUID id;
private String label;
private boolean enablePrefilling;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public boolean isEnablePrefilling() {
return enablePrefilling;
}
public void setEnablePrefilling(boolean enablePrefilling) {
this.enablePrefilling = enablePrefilling;
}
}

View File

@ -5,6 +5,12 @@ export interface DatasetProfileModel {
description: string; description: string;
} }
export interface DatasetProfileWithPrefillingModel {
id: string;
label: string;
enablePrefilling: boolean;
}
// export class DatasetProfileModel implements Serializable<DatasetProfileModel> { // export class DatasetProfileModel implements Serializable<DatasetProfileModel> {
// public id: String; // public id: String;
// public label: String; // public label: String;

View File

@ -3,6 +3,7 @@ import { BaseCriteria } from "../base-criteria";
export class DatasetProfileCriteria extends BaseCriteria { export class DatasetProfileCriteria extends BaseCriteria {
public id: String; public id: String;
public groupIds: string[]; public groupIds: string[];
public ids: string[];
public allVersions: boolean; public allVersions: boolean;
public finalized: boolean = true; public finalized: boolean = true;
public status: number; public status: number;

View File

@ -1,10 +1,9 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { environment } from '../../../../environments/environment';
import { DataTableData } from '../../model/data-table/data-table-data'; import { DataTableData } from '../../model/data-table/data-table-data';
import { DataTableRequest } from '../../model/data-table/data-table-request'; import { DataTableRequest } from '../../model/data-table/data-table-request';
import { DatasetListingModel } from '../../model/dataset/dataset-listing'; import { DatasetListingModel } from '../../model/dataset/dataset-listing';
import { DatasetProfileModel } from '../../model/dataset/dataset-profile'; import { DatasetProfileModel, DatasetProfileWithPrefillingModel } from '../../model/dataset/dataset-profile';
import { DatasetCriteria } from '../../query/dataset/dataset-criteria'; import { DatasetCriteria } from '../../query/dataset/dataset-criteria';
import { ExploreDatasetCriteriaModel } from '../../query/explore-dataset/explore-dataset-criteria'; import { ExploreDatasetCriteriaModel } from '../../query/explore-dataset/explore-dataset-criteria';
import { BaseHttpService } from '../http/base-http.service'; import { BaseHttpService } from '../http/base-http.service';
@ -43,6 +42,10 @@ export class DatasetService {
return this.http.post<DatasetProfileModel[]>(this.configurationSevice.server + 'datasetprofiles/getAll', dataTableRequest); return this.http.post<DatasetProfileModel[]>(this.configurationSevice.server + 'datasetprofiles/getAll', dataTableRequest);
} }
getDatasetProfilesWithPrefilling(dataTableRequest: DataTableRequest<DatasetProfileCriteria>): Observable<DatasetProfileWithPrefillingModel[]> {
return this.http.post<DatasetProfileWithPrefillingModel[]>(this.configurationSevice.server + 'datasetprofiles/getAllWithPrefilling', dataTableRequest);
}
getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest<DatasetProfileCriteria>) { getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest<DatasetProfileCriteria>) {
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'datasetProfilesUsedByDatasets/paged', dataTableRequest); return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'datasetProfilesUsedByDatasets/paged', dataTableRequest);
} }

View File

@ -63,6 +63,9 @@ import {PrefillDatasetComponent} from "@app/ui/dataset/dataset-wizard/prefill-da
import {ToCEntry, ToCEntryType} from "@app/ui/misc/dataset-description-form/dataset-description.component"; import {ToCEntry, ToCEntryType} from "@app/ui/misc/dataset-description-form/dataset-description.component";
import {dispatchFakeEvent} from "@angular/cdk/testing/testbed/fake-events"; import {dispatchFakeEvent} from "@angular/cdk/testing/testbed/fake-events";
import { DmpDatasetProfile } from '@app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile'; import { DmpDatasetProfile } from '@app/core/model/dmp/dmp-dataset-profile/dmp-dataset-profile';
import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service';
import { DatasetService } from '@app/core/services/dataset/dataset.service';
import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria';
@Component({ @Component({
selector: 'app-dataset-wizard-component', selector: 'app-dataset-wizard-component',
@ -98,6 +101,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
dmpId: string; dmpId: string;
dmpSectionIndex: number; dmpSectionIndex: number;
availableDescriptionTemplates: DatasetProfileModel[] = []; availableDescriptionTemplates: DatasetProfileModel[] = [];
availableDescriptionTemplatesForPrefilling: DatasetProfileModel[] = [];
newDmpId: string; newDmpId: string;
publicId: string; publicId: string;
profileUpdateId: string; profileUpdateId: string;
@ -127,12 +131,14 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
constructor( constructor(
private datasetWizardService: DatasetWizardService, private datasetWizardService: DatasetWizardService,
private datasetService: DatasetService,
private route: ActivatedRoute, private route: ActivatedRoute,
public snackBar: MatSnackBar, public snackBar: MatSnackBar,
public router: Router, public router: Router,
public language: TranslateService, public language: TranslateService,
public externalSourcesService: ExternalSourcesService, public externalSourcesService: ExternalSourcesService,
public dmpService: DmpService, public dmpService: DmpService,
private dmpProfileService: DmpProfileService,
public dialog: MatDialog, public dialog: MatDialog,
public externalSourcesConfigurationService: ExternalSourcesConfigurationService, public externalSourcesConfigurationService: ExternalSourcesConfigurationService,
private uiNotificationService: UiNotificationService, private uiNotificationService: UiNotificationService,
@ -284,28 +290,48 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft; this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
this.formGroup.get('dmp').disable(); this.formGroup.get('dmp').disable();
const dialogRef = this.dialog.open(PrefillDatasetComponent, { this.dmpProfileService.getSingleBlueprint(data.profile.id)
width: '590px', .pipe(takeUntil(this._destroyed))
minHeight: '200px', .subscribe(result => {
restoreFocus: false, const request: DataTableRequest<DatasetProfileCriteria> = new DataTableRequest<DatasetProfileCriteria>(null, null, null);
data: { request.criteria = new DatasetProfileCriteria();
availableProfiles: this.availableDescriptionTemplates, request.criteria.ids = [];
datasetFormGroup: this.formGroup result.definition.sections[this.dmpSectionIndex].descriptionTemplates.forEach(template => request.criteria.ids.push(template.descriptionTemplateId));
}, this.availableDescriptionTemplates.forEach(template => request.criteria.ids.push(template.id));
panelClass: 'custom-modalbox' this.datasetService.getDatasetProfilesWithPrefilling(request)
}); .pipe(takeUntil(this._destroyed))
dialogRef.afterClosed().subscribe(result => { .subscribe(items => {
if(result) { items.forEach(template => {
this.datasetWizardModel = this.datasetWizardModel.fromModel(result); if(template.enablePrefilling){
this.datasetWizardModel.dmp = data; this.availableDescriptionTemplatesForPrefilling.push({id: template.id, label: template.label, description: ''});
this.datasetWizardModel.dmpSectionIndex = this.dmpSectionIndex; }
this.formGroup = this.datasetWizardModel.buildForm(); })
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); if (this.availableDescriptionTemplatesForPrefilling.length > 0) {
this.formGroup.get('dmp').disable(); const dialogRef = this.dialog.open(PrefillDatasetComponent, {
this.loadDatasetProfiles(); width: '590px',
this.registerFormListeners(); minHeight: '200px',
} restoreFocus: false,
}) data: {
availableProfiles: this.availableDescriptionTemplatesForPrefilling,
datasetFormGroup: this.formGroup
},
panelClass: 'custom-modalbox'
});
dialogRef.afterClosed().subscribe(result => {
if(result) {
this.datasetWizardModel = this.datasetWizardModel.fromModel(result);
this.datasetWizardModel.dmp = data;
this.datasetWizardModel.dmpSectionIndex = this.dmpSectionIndex;
this.formGroup = this.datasetWizardModel.buildForm();
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
this.formGroup.get('dmp').disable();
this.loadDatasetProfiles();
this.registerFormListeners();
}
})
}
});
});
this.loadDatasetProfiles(); this.loadDatasetProfiles();
this.registerFormListeners(); this.registerFormListeners();
// this.availableProfiles = data.profiles; // this.availableProfiles = data.profiles;