diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index f2d4037ea..5b5b89a1a 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -481,7 +481,7 @@ public class DataManagementPlanManager { DMP newDmp = dataManagementPlan.toDataModel(); if(dataManagementPlan.getProfile() != null){ - DMPProfile dmpProfile = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().find(dataManagementPlan.getProfile().getId()); + DMPProfile dmpProfile = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().find(dataManagementPlan.getProfile()); newDmp.setProfile(dmpProfile); } if (newDmp.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue()) { @@ -2050,16 +2050,14 @@ public class DataManagementPlanManager { DataManagementPlanEditorModel dm = new DataManagementPlanEditorModel(); DmpProfileImportModel dmpProfileImportModel = dataManagementPlans.get(0).getDmpProfile(); - Tuple tupleProfile = new Tuple<>(); + UUID profileId = null; if (dmpProfileImportModel != null) { - tupleProfile.setId(dmpProfileImportModel.getDmpProfileId()); - tupleProfile.setLabel(dmpProfileImportModel.getDmpProfileName()); + profileId = dmpProfileImportModel.getDmpProfileId(); } else { - tupleProfile.setId(UUID.fromString("86635178-36a6-484f-9057-a934e4eeecd5")); - tupleProfile.setLabel("Dmp Default Blueprint"); + profileId = UUID.fromString("86635178-36a6-484f-9057-a934e4eeecd5"); } - dm.setProfile(tupleProfile); + dm.setProfile(profileId); Map dmpPropertiesMap = new HashMap<>(); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java index c23ad1f14..066aad9f8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java @@ -23,7 +23,7 @@ public class DataManagementPlanEditorModel implements DataModel profile; + private UUID profile; private int version; private int status; private boolean lockable; @@ -53,10 +53,10 @@ public class DataManagementPlanEditorModel implements DataModel getProfile() { + public UUID getProfile() { return profile; } - public void setProfile(Tuple profile) { + public void setProfile(UUID profile) { this.profile = profile; } @@ -226,7 +226,7 @@ public class DataManagementPlanEditorModel implements DataModel(entity.getProfile().getId(), entity.getProfile().getLabel()) : null; + this.profile = entity.getProfile() != null ? entity.getProfile().getId() : null; this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()); this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()); this.version = entity.getVersion(); @@ -289,7 +289,7 @@ public class DataManagementPlanEditorModel implements DataModel { this.dmpBlueprintModel = new DmpBlueprintEditor().fromModel(data); this.dmpBlueprintModel.id = null; + this.dmpBlueprintModel.created = null; this.dmpBlueprintModel.status = DmpProfileStatus.Draft; this.formGroup = this.dmpBlueprintModel.buildForm(); this.buildSystemFields(); diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html index c56c214e4..b5b27b9c1 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html @@ -64,7 +64,7 @@ -
+
{{profile.label}}
diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts index 5f5d2a023..371faa461 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts @@ -49,43 +49,40 @@ export class DatasetEditorComponent extends BaseComponent { ] }; - checkMinMax(event, profile: DatasetProfileModel) { - event.stopPropagation(); + ngOnInit() { + this.formGroup.get('profile').valueChanges.pipe(takeUntil(this._destroyed)).subscribe(x => { + this.checkMinMax(x); + }); + } + + checkMinMax(profile: DatasetProfileModel) { const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value; const blueprintId = this.formGroup.get('dmp').value.profile.id; this.dmpProfileService.getSingleBlueprint(blueprintId) .pipe(takeUntil(this._destroyed)) .subscribe(result => { const section = result.definition.sections[dmpSectionIndex]; - if(section.hasTemplates){ + if (section.hasTemplates) { const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === profile.id); if (foundTemplate !== undefined) { let count = 0; - if(this.formGroup.get('dmp').value.datasets != null){ - for(let dataset of this.formGroup.get('dmp').value.datasets){ - if(dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId){ + if (this.formGroup.get('dmp').value.datasets != null) { + for (let dataset of this.formGroup.get('dmp').value.datasets) { + if (dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId) { count++; } } - if(count === foundTemplate.maxMultiplicity){ + if (count === foundTemplate.maxMultiplicity) { this.dialog.open(PopupNotificationDialogComponent, { data: { title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'), message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE') }, maxWidth: '30em' }); - } - else{ - this.formGroup.get('profile').setValue(profile); + this.formGroup.get('profile').reset(); } } } - else { - this.formGroup.get('profile').setValue(profile); - } - } - else { - this.formGroup.get('profile').setValue(profile); } }); } diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.html index b6d159d7b..e0f150529 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.html +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.html @@ -27,7 +27,7 @@ -
+
{{profile.label}}
diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.ts index bc632ae2d..72f788ece 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component.ts @@ -55,6 +55,10 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit { titleFn: (item) => item['name'], subtitleFn: (item) => item['pid'] }; + + this.prefillForm.get('profile').valueChanges.pipe(takeUntil(this._destroyed)).subscribe(x => { + this.checkMinMax(x); + }); } addProfileIfUsedLessThanMax(profile: DatasetProfileModel) { @@ -89,8 +93,7 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit { }); } - checkMinMax(event, profile: DatasetProfileModel) { - event.stopPropagation(); + checkMinMax(profile: DatasetProfileModel) { const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value; const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id; this.dmpProfileService.getSingleBlueprint(blueprintId) @@ -114,18 +117,10 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit { message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE') }, maxWidth: '30em' }); - } - else{ - this.prefillForm.get('profile').setValue(profile); + this.prefillForm.get('profile').reset(); } } } - else { - this.prefillForm.get('profile').setValue(profile); - } - } - else { - this.prefillForm.get('profile').setValue(profile); } }); } diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html index bcbad4cfe..2cf8b6e82 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html @@ -267,7 +267,7 @@
--> -
+
diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts index 0da9ee5a8..34e5c1072 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts @@ -161,81 +161,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im if (itemId != null) { this.isNew = false; - this.dmpService.getSingle(itemId).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(async data => { - this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => { - this.lockStatus = lockStatus; - - this.dmp = new DmpEditorModel(); - this.dmp.grant = new GrantTabModel(); - this.dmp.project = new ProjectFormModel(); - this.dmp.funder = new FunderFormModel(); - this.dmp.extraProperties = new ExtraPropertiesFormModel(); - this.dmp.fromModel(data); - this.formGroup = this.dmp.buildForm(); - - this.datasets = this.formGroup.get('datasets') as FormArray; - - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - if (!isNullOrUndefined(this.formGroup.get('profile').value)) { - this.dmpProfileService.getSingleBlueprint(this.formGroup.get('profile').value) - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - this.selectedDmpBlueprintDefinition = result.definition; - this.checkForGrant(); - this.checkForFunder(); - this.checkForProject(); - this.buildExtraFields(); - this.formGroup.get('profile').setValue(result); - this.maxStep = this.selectedDmpBlueprintDefinition.sections.length; - this.step = 1; - this.addProfiles(this.dmp.profiles); - }); - } - this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep; - - this.setIsUserOwner(); - if (!this.isUserOwner) { - - if(this.isUserMember()){ - this.router.navigate(['plans', 'overview', itemId]); - return; - } - this.isFinalized = true; - this.formGroup.disable(); - } - - if (this.dmp.status === DmpStatus.Finalized || lockStatus) { - this.isFinalized = true; - this.formGroup.disable(); - } - - if (this.authService.current() != null) { - if (!lockStatus) { - this.lock = new LockModel(data.id, this.getUserFromDMP()); - - this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { - this.lock.id = Guid.parse(result); - interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); - }); - } - } - - this.associatedUsers = data.associatedUsers; - this.people = data.users; - this.formGroup.valueChanges.pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - }); - if(this.lockStatus){ - this.dialog.open(PopupNotificationDialogComponent,{data:{ - title:this.language.instant('DMP-EDITOR.LOCKED.TITLE'), - message:this.language.instant('DMP-EDITOR.LOCKED.MESSAGE') - }, maxWidth:'30em'}); - } - }); - }); + this.getItem(itemId); } else { this.dmp = new DmpEditorModel(); @@ -258,7 +184,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im this.checkForFunder(); this.checkForProject(); this.buildExtraFields(); - this.formGroup.get('profile').setValue(result); + this.formGroup.get('profile').setValue(result.id); this.maxStep = this.selectedDmpBlueprintDefinition.sections.length; this.step = 1; this.addProfiles(); @@ -308,6 +234,84 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im }; } + private getItem(itemId: String) { + this.dmpService.getSingle(itemId).pipe(map(data => data as DmpModel)) + .pipe(takeUntil(this._destroyed)) + .subscribe(async data => { + this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => { + this.lockStatus = lockStatus; + + this.dmp = new DmpEditorModel(); + this.dmp.grant = new GrantTabModel(); + this.dmp.project = new ProjectFormModel(); + this.dmp.funder = new FunderFormModel(); + this.dmp.extraProperties = new ExtraPropertiesFormModel(); + this.dmp.fromModel(data); + this.formGroup = this.dmp.buildForm(); + + this.datasets = this.formGroup.get('datasets') as FormArray; + + this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + if (!isNullOrUndefined(this.formGroup.get('profile').value)) { + this.dmpProfileService.getSingleBlueprint(this.formGroup.get('profile').value) + .pipe(takeUntil(this._destroyed)) + .subscribe(result => { + this.selectedDmpBlueprintDefinition = result.definition; + this.checkForGrant(); + this.checkForFunder(); + this.checkForProject(); + this.buildExtraFields(); + this.formGroup.get('profile').setValue(result.id); + this.maxStep = this.selectedDmpBlueprintDefinition.sections.length; + this.step = 1; + this.addProfiles(this.dmp.profiles); + }); + } + this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep; + + this.setIsUserOwner(); + if (!this.isUserOwner) { + + if(this.isUserMember()){ + this.router.navigate(['plans', 'overview', itemId]); + return; + } + this.isFinalized = true; + this.formGroup.disable(); + } + + if (this.dmp.status === DmpStatus.Finalized || lockStatus) { + this.isFinalized = true; + this.formGroup.disable(); + } + + if (this.authService.current() != null) { + if (!lockStatus) { + this.lock = new LockModel(data.id, this.getUserFromDMP()); + + this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { + this.lock.id = Guid.parse(result); + interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); + }); + } + } + + this.associatedUsers = data.associatedUsers; + this.people = data.users; + this.formGroup.valueChanges.pipe(takeUntil(this._destroyed)) + .subscribe(x => { + this.formChanged(); + }); + if(this.lockStatus){ + this.dialog.open(PopupNotificationDialogComponent,{data:{ + title:this.language.instant('DMP-EDITOR.LOCKED.TITLE'), + message:this.language.instant('DMP-EDITOR.LOCKED.MESSAGE') + }, maxWidth:'30em'}); + } + }); + }); + } + extraFieldsArray(): FormArray { return this.formGroup.get('extraFields') as FormArray; } @@ -437,7 +441,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im .pipe(takeUntil(this._destroyed)) .subscribe(result => { this.selectedDmpBlueprintDefinition = result.definition; - this.formGroup.get('profile').setValue(result); + this.formGroup.get('profile').setValue(result.id); this.maxStep = this.selectedDmpBlueprintDefinition.sections.length; this.nextStep(); }); @@ -511,7 +515,9 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im onSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void { this.scrollTop = document.getElementById('editor-form').scrollTop; // return; - this.dmpService.createDmp(this.formGroup.getRawValue()) + const rawvalue = this.formGroup.getRawValue(); + if (rawvalue.profile instanceof Object) rawvalue.profile = rawvalue.profile.id; + this.dmpService.createDmp(rawvalue) .pipe(takeUntil(this._destroyed)) .subscribe( complete => { @@ -578,24 +584,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im if(this.isNew){ this.router.navigate(['/plans', 'edit', dmp.id]); } - let dmpEditorModel: DmpEditorModel; - dmpEditorModel = new DmpEditorModel(); - dmpEditorModel.grant = new GrantTabModel(); - dmpEditorModel.project = new ProjectFormModel(); - dmpEditorModel.funder = new FunderFormModel(); - dmpEditorModel.extraProperties = new ExtraPropertiesFormModel(); - dmpEditorModel.fromModel(dmp); - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.associatedUsers = dmp.associatedUsers; - this.people = dmp.users; - - setTimeout(() => { this.formGroup = null; }); - setTimeout(() => { - this.formGroup = dmpEditorModel.buildForm(); - this.formGroup.valueChanges.pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.formChanged(); - });}); + this.getItem(dmp.id); setTimeout(() => { document.getElementById('editor-form').scrollTop = this.scrollTop; }); this.saving = false; this.isNew = false; @@ -870,13 +859,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im } getExtraFieldIndex(id: string): string { - let foundFieldIndex: number; - (this.formGroup.get('extraFields') as FormArray).controls.forEach((element, index) => { - if(element.value.id === id) { - foundFieldIndex = index; - } - }); - return foundFieldIndex.toString(); + return (this.formGroup.get('extraFields') as FormArray).controls.findIndex((element) => element.value.id == id).toString(); } private checkForGrant() { diff --git a/dmp-frontend/src/assets/config/config.json b/dmp-frontend/src/assets/config/config.json index 17b0c3fa1..a37c8ee10 100644 --- a/dmp-frontend/src/assets/config/config.json +++ b/dmp-frontend/src/assets/config/config.json @@ -57,7 +57,7 @@ "loginProviders": { "enabled": [1, 2, 3, 4, 5, 6, 7, 8], "facebookConfiguration": { "clientId": "" }, - "googleConfiguration": { "clientId": "" }, + "googleConfiguration": { "clientId": "524432312250-sc9qsmtmbvlv05r44onl6l93ia3k9deo.apps.googleusercontent.com" }, "linkedInConfiguration": { "clientId": "", "oauthUrl": "https://www.linkedin.com/oauth/v2/authorization",