This commit is contained in:
Diamantis Tziotzios 2023-10-19 17:27:37 +03:00
parent d60cc144d5
commit 8a41a7dcd9
11 changed files with 125 additions and 151 deletions

View File

@ -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<UUID, String> 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<String, Object> dmpPropertiesMap = new HashMap<>();

View File

@ -23,7 +23,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
private UUID id;
private String label;
private UUID groupId;
private Tuple<UUID, String> profile;
private UUID profile;
private int version;
private int status;
private boolean lockable;
@ -53,10 +53,10 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
this.id = id;
}
public Tuple<UUID, String> getProfile() {
public UUID getProfile() {
return profile;
}
public void setProfile(Tuple<UUID, String> profile) {
public void setProfile(UUID profile) {
this.profile = profile;
}
@ -226,7 +226,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
@Override
public DataManagementPlanEditorModel fromDataModel(DMP entity) {
this.id = entity.getId();
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(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<DMP, DataManagem
DMP dataManagementPlanEntity = new DMP();
if (this.profile != null) {
DMPProfile dmpProfile = new DMPProfile();
dmpProfile.setId(this.profile.getId());
dmpProfile.setId(this.profile);
dataManagementPlanEntity.setProfile(dmpProfile);
}
dataManagementPlanEntity.setId(this.id);

View File

@ -1,15 +1,15 @@
dmp.domain = http://localhost:4200
####################PERSISTENCE OVERRIDES CONFIGURATIONS##########
database.url=
database.username=
database.password=
database.url= jdbc:postgresql://dbserver02.local.cite.gr:5432/dmptool
database.username= dmtadm
database.password= t00L4DM@18!
spring.datasource.maxIdle=10
spring.datasource.minIdle=5
spring.datasource.maxActive=10
####################ELASTIIC SEARCH TAGS OVERRIDES CONFIGURATIONS##########
elasticsearch.host = localhost
elasticsearch.host = dmp-elastic-heal.lib.auth.gr
elasticsearch.port = 9200
elasticsearch.username=elastic
elasticsearch.password=
@ -42,7 +42,7 @@ facebook.login.clientSecret=
facebook.login.namespace=
#############GOOGLE LOGIN CONFIGURATIONS#########
google.login.clientId=
google.login.clientId=524432312250-sc9qsmtmbvlv05r44onl6l93ia3k9deo.apps.googleusercontent.com
#############LINKEDIN LOGIN CONFIGURATIONS#########
linkedin.login.clientId=

View File

@ -141,6 +141,7 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
data => {
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();

View File

@ -64,7 +64,7 @@
<mat-form-field>
<mat-select placeholder="{{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="profile">
<mat-option *ngFor="let profile of availableProfiles" [value]="profile">
<div (click)="checkMinMax($event, profile)">
<div>
{{profile.label}}
</div>
</mat-option>

View File

@ -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);
}
});
}

View File

@ -27,7 +27,7 @@
<mat-form-field class="col-md-12">
<mat-select placeholder="{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PROFILE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="profile">
<mat-option *ngFor="let profile of data.availableProfiles" [value]="profile">
<div (click)="checkMinMax($event, profile)">
<div>
{{profile.label}}
</div>
</mat-option>

View File

@ -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);
}
});
}

View File

@ -267,7 +267,7 @@
</div>
</div> -->
</div>
<div *ngIf="field.category === 'EXTRA'">
<div *ngIf="field.category === 'EXTRA' && formGroup.get('extraFields')?.controls?.length > 0">
<div *ngIf="field.type === extraFieldTypesEnum.TEXT">
<mat-form-field>
<input matInput placeholder="{{field.placeholder}}" type="text" name="value" [formControl]="formGroup.get('extraFields').get(getExtraFieldIndex(field.id)).get('value')" [required]="field.required">

View File

@ -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() {

View File

@ -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",