Compare commits
3 Commits
9cc42c57e9
...
5f3ab00009
Author | SHA1 | Date |
---|---|---|
Bernaldo Mihasi | 5f3ab00009 | |
Bernaldo Mihasi | beac6be706 | |
Bernaldo Mihasi | fbad63ee76 |
|
@ -1633,7 +1633,13 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
wordBuilder.fillFooter(dmpEntity, null, document, false);
|
wordBuilder.fillFooter(dmpEntity, null, document, false);
|
||||||
|
|
||||||
String fileName = "DMP_" + dmpEntity.getGrant().getLabel();
|
String fileName;
|
||||||
|
if (dmpEntity.getGrant() != null && dmpEntity.getGrant().getLabel() != null) {
|
||||||
|
fileName = "DMP_" + dmpEntity.getGrant().getLabel();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fileName = "DMP_" + dmpEntity.getLabel();
|
||||||
|
}
|
||||||
if (versioned) {
|
if (versioned) {
|
||||||
fileName += "_" + dmpEntity.getVersion();
|
fileName += "_" + dmpEntity.getVersion();
|
||||||
}
|
}
|
||||||
|
@ -1882,7 +1888,12 @@ public class DataManagementPlanManager {
|
||||||
writer.close();
|
writer.close();
|
||||||
FileEnvelope fileEnvelope = new FileEnvelope();
|
FileEnvelope fileEnvelope = new FileEnvelope();
|
||||||
fileEnvelope.setFile(xmlFile);
|
fileEnvelope.setFile(xmlFile);
|
||||||
|
if (dmp.getGrant() != null && dmp.getGrant().getLabel() != null) {
|
||||||
fileEnvelope.setFilename("DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion() + ".xml");
|
fileEnvelope.setFilename("DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion() + ".xml");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fileEnvelope.setFilename("DMP_" + dmp.getLabel() + "_" + dmp.getVersion() + ".xml");
|
||||||
|
}
|
||||||
|
|
||||||
return fileEnvelope;
|
return fileEnvelope;
|
||||||
}
|
}
|
||||||
|
@ -1900,7 +1911,13 @@ public class DataManagementPlanManager {
|
||||||
.collect(Collectors.toSet()));
|
.collect(Collectors.toSet()));
|
||||||
String result = rdaManager.convertToRDA(dmp);
|
String result = rdaManager.convertToRDA(dmp);
|
||||||
|
|
||||||
String fileName = "DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion();
|
String fileName;
|
||||||
|
if (dmp.getGrant() != null && dmp.getGrant().getLabel() != null) {
|
||||||
|
fileName = "DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fileName = "DMP_" + dmp.getLabel() + "_" + dmp.getVersion();
|
||||||
|
}
|
||||||
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "").replace(" ", "_").replace(",", "_");
|
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "").replace(" ", "_").replace(",", "_");
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
File file = new File(this.environment.getProperty("temp.temp") + uuid + ".json");
|
File file = new File(this.environment.getProperty("temp.temp") + uuid + ".json");
|
||||||
|
|
|
@ -39,7 +39,9 @@ public class RecentDatasetModel extends RecentActivityModel<Dataset, RecentDatas
|
||||||
this.setFinalizedAt(entity.getFinalizedAt());
|
this.setFinalizedAt(entity.getFinalizedAt());
|
||||||
this.setPublishedAt(entity.getDmp() != null ? entity.getDmp().getPublishedAt() : new Date());
|
this.setPublishedAt(entity.getDmp() != null ? entity.getDmp().getPublishedAt() : new Date());
|
||||||
this.setProfile(entity.getProfile() != null ? new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()): null);
|
this.setProfile(entity.getProfile() != null ? new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()): null);
|
||||||
this.setGrant(entity.getDmp() != null ? entity.getDmp().getGrant().getLabel() : "");
|
if (entity.getDmp() != null && entity.getDmp().getGrant() != null) {
|
||||||
|
this.setGrant(entity.getDmp().getGrant().getLabel());
|
||||||
|
}
|
||||||
this.setDmp( entity.getDmp() != null ? entity.getDmp().getLabel() : "");
|
this.setDmp( entity.getDmp() != null ? entity.getDmp().getLabel() : "");
|
||||||
this.setDmpId(entity.getDmp() != null ? entity.getDmp().getId().toString() : "");
|
this.setDmpId(entity.getDmp() != null ? entity.getDmp().getId().toString() : "");
|
||||||
this.setPublic(entity.getDmp().isPublic());
|
this.setPublic(entity.getDmp().isPublic());
|
||||||
|
@ -58,7 +60,9 @@ public class RecentDatasetModel extends RecentActivityModel<Dataset, RecentDatas
|
||||||
this.setFinalizedAt(entity.getFinalizedAt());
|
this.setFinalizedAt(entity.getFinalizedAt());
|
||||||
this.setPublishedAt(entity.getDmp() != null ? entity.getDmp().getPublishedAt() : new Date());
|
this.setPublishedAt(entity.getDmp() != null ? entity.getDmp().getPublishedAt() : new Date());
|
||||||
this.setProfile(entity.getProfile() != null ? new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()) : null);
|
this.setProfile(entity.getProfile() != null ? new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()) : null);
|
||||||
this.setGrant(entity.getDmp() != null ? entity.getDmp().getGrant().getLabel() : "");
|
if (entity.getDmp() != null && entity.getDmp().getGrant() != null) {
|
||||||
|
this.setGrant(entity.getDmp().getGrant().getLabel());
|
||||||
|
}
|
||||||
this.setDmp( entity.getDmp() != null ? entity.getDmp().getLabel() : "");
|
this.setDmp( entity.getDmp() != null ? entity.getDmp().getLabel() : "");
|
||||||
this.setDmpId(entity.getDmp() != null ? entity.getDmp().getId().toString() : "");
|
this.setDmpId(entity.getDmp() != null ? entity.getDmp().getId().toString() : "");
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -51,7 +51,9 @@ public class RecentDmpModel extends RecentActivityModel<DMP, RecentDmpModel> {
|
||||||
this.setVersion(entity.getVersion());
|
this.setVersion(entity.getVersion());
|
||||||
this.datasets = entity.getDataset().stream().map(dataset -> new DatasetUrlListing().fromDataModel(dataset)).collect(Collectors.toList());
|
this.datasets = entity.getDataset().stream().map(dataset -> new DatasetUrlListing().fromDataModel(dataset)).collect(Collectors.toList());
|
||||||
this.setFinalizedAt(entity.getFinalizedAt());
|
this.setFinalizedAt(entity.getFinalizedAt());
|
||||||
|
if (entity.getGrant() != null) {
|
||||||
this.setGrant(entity.getGrant().getLabel());
|
this.setGrant(entity.getGrant().getLabel());
|
||||||
|
}
|
||||||
this.groupId = entity.getGroupId();
|
this.groupId = entity.getGroupId();
|
||||||
this.setPublic(entity.isPublic());
|
this.setPublic(entity.isPublic());
|
||||||
this.setPublishedAt(entity.getPublishedAt());
|
this.setPublishedAt(entity.getPublishedAt());
|
||||||
|
|
|
@ -275,8 +275,10 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
||||||
this.project.getExistProject().fromDataModel(entity.getProject());
|
this.project.getExistProject().fromDataModel(entity.getProject());
|
||||||
this.associatedUsers = entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList());
|
this.associatedUsers = entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList());
|
||||||
this.users = entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList());
|
this.users = entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||||
|
if (entity.getGrant() != null) {
|
||||||
this.funder = new FunderDMPEditorModel();
|
this.funder = new FunderDMPEditorModel();
|
||||||
this.funder.getExistFunder().fromDataModel(entity.getGrant().getFunder());
|
this.funder.getExistFunder().fromDataModel(entity.getGrant().getFunder());
|
||||||
|
}
|
||||||
this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
|
this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -174,9 +174,11 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
entity.setVersion(this.getVersion());
|
entity.setVersion(this.getVersion());
|
||||||
|
|
||||||
entity.setDataset(this.getDatasets().stream().map(DatasetUrlListing::toDataModel).collect(Collectors.toCollection(LinkedHashSet::new)));
|
entity.setDataset(this.getDatasets().stream().map(DatasetUrlListing::toDataModel).collect(Collectors.toCollection(LinkedHashSet::new)));
|
||||||
|
if (this.getGrant() != null && !this.getGrant().isEmpty()) {
|
||||||
Grant grant = new Grant();
|
Grant grant = new Grant();
|
||||||
grant.setLabel(this.getGrant());
|
grant.setLabel(this.getGrant());
|
||||||
entity.setGrant(grant);
|
entity.setGrant(grant);
|
||||||
|
}
|
||||||
entity.setUsers(this.getUsers().stream().map(UserInfoListingModel::toDataModel).collect(Collectors.toSet()));
|
entity.setUsers(this.getUsers().stream().map(UserInfoListingModel::toDataModel).collect(Collectors.toSet()));
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,9 +173,11 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
|
||||||
entity.setFinalizedAt(this.getFinalizedAt());
|
entity.setFinalizedAt(this.getFinalizedAt());
|
||||||
entity.setStatus(Integer.valueOf(this.getStatus()).shortValue());
|
entity.setStatus(Integer.valueOf(this.getStatus()).shortValue());
|
||||||
DMP dmp = new DMP();
|
DMP dmp = new DMP();
|
||||||
|
if (this.getGrant() != null && !this.getGrant().isEmpty()) {
|
||||||
Grant grant = new Grant();
|
Grant grant = new Grant();
|
||||||
grant.setLabel(this.getGrant());
|
grant.setLabel(this.getGrant());
|
||||||
dmp.setGrant(grant);
|
dmp.setGrant(grant);
|
||||||
|
}
|
||||||
dmp.setLabel(this.getDmp());
|
dmp.setLabel(this.getDmp());
|
||||||
dmp.setId(UUID.fromString(this.getDmpId()));
|
dmp.setId(UUID.fromString(this.getDmpId()));
|
||||||
dmp.setPublishedAt(this.getDmpPublishedAt());
|
dmp.setPublishedAt(this.getDmpPublishedAt());
|
||||||
|
|
|
@ -162,7 +162,9 @@ public class DmpRDAExportModel {
|
||||||
dmpRda.ethical_issues_exist = "unknown";
|
dmpRda.ethical_issues_exist = "unknown";
|
||||||
dmpRda.language = "en";
|
dmpRda.language = "en";
|
||||||
dmpRda.modified = formatter.format(new Date());
|
dmpRda.modified = formatter.format(new Date());
|
||||||
|
if (entity.getGrant() != null) {
|
||||||
dmpRda.project = new ProjectRDAExportModel().fromDataModel(entity.getGrant());
|
dmpRda.project = new ProjectRDAExportModel().fromDataModel(entity.getGrant());
|
||||||
|
}
|
||||||
dmpRda.title = entity.getLabel();
|
dmpRda.title = entity.getLabel();
|
||||||
|
|
||||||
return dmpRda;
|
return dmpRda;
|
||||||
|
|
|
@ -157,9 +157,11 @@ public class DataManagementPlanPublicListingModel implements DataModel<DMP, Data
|
||||||
entity.setPublishedAt(this.getPublishedAt());
|
entity.setPublishedAt(this.getPublishedAt());
|
||||||
entity.setVersion(this.getVersion());
|
entity.setVersion(this.getVersion());
|
||||||
|
|
||||||
|
if (this.getGrant() != null) {
|
||||||
Grant grant = new Grant();
|
Grant grant = new Grant();
|
||||||
grant.setLabel(this.getGrant());
|
grant.setLabel(this.getGrant());
|
||||||
entity.setGrant(grant);
|
entity.setGrant(grant);
|
||||||
|
}
|
||||||
entity.setUsers(this.getUsers().stream().map(UserInfoPublicModel::toDataModel).collect(Collectors.toSet()));
|
entity.setUsers(this.getUsers().stream().map(UserInfoPublicModel::toDataModel).collect(Collectors.toSet()));
|
||||||
entity.setResearchers(this.getResearchers().stream().map(ResearcherPublicModel::toDataModel).collect(Collectors.toSet()));
|
entity.setResearchers(this.getResearchers().stream().map(ResearcherPublicModel::toDataModel).collect(Collectors.toSet()));
|
||||||
return entity;
|
return entity;
|
||||||
|
|
|
@ -126,7 +126,9 @@ public class DatasetPublicListingModel implements DataModel<Dataset, DatasetPubl
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.createdAt = entity.getCreated();
|
this.createdAt = entity.getCreated();
|
||||||
this.modifiedAt = entity.getModified();
|
this.modifiedAt = entity.getModified();
|
||||||
this.grant = entity.getDmp() != null ? entity.getDmp().getGrant().getLabel() : "";
|
if(entity.getDmp() != null && entity.getDmp().getGrant() != null) {
|
||||||
|
this.grant = entity.getDmp().getGrant().getLabel();
|
||||||
|
}
|
||||||
this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : "";
|
this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : "";
|
||||||
this.dmpId = entity.getDmp() != null ? entity.getDmp().getId().toString() : "";
|
this.dmpId = entity.getDmp() != null ? entity.getDmp().getId().toString() : "";
|
||||||
this.profile = entity.getProfile() != null ? new DatasetProfilePublicModel().fromDataModel(entity.getProfile()) : null;
|
this.profile = entity.getProfile() != null ? new DatasetProfilePublicModel().fromDataModel(entity.getProfile()) : null;
|
||||||
|
@ -153,9 +155,11 @@ public class DatasetPublicListingModel implements DataModel<Dataset, DatasetPubl
|
||||||
entity.setFinalizedAt(this.getFinalizedAt());
|
entity.setFinalizedAt(this.getFinalizedAt());
|
||||||
entity.setStatus(Dataset.Status.FINALISED.getValue());
|
entity.setStatus(Dataset.Status.FINALISED.getValue());
|
||||||
DMP dmp = new DMP();
|
DMP dmp = new DMP();
|
||||||
|
if (this.getGrant() != null && !this.getGrant().isEmpty()) {
|
||||||
Grant grant = new Grant();
|
Grant grant = new Grant();
|
||||||
grant.setLabel(this.getGrant());
|
grant.setLabel(this.getGrant());
|
||||||
dmp.setGrant(grant);
|
dmp.setGrant(grant);
|
||||||
|
}
|
||||||
dmp.setLabel(this.getDmp());
|
dmp.setLabel(this.getDmp());
|
||||||
dmp.setId(UUID.fromString(this.getDmpId()));
|
dmp.setId(UUID.fromString(this.getDmpId()));
|
||||||
dmp.setPublishedAt(this.getDmpPublishedAt());
|
dmp.setPublishedAt(this.getDmpPublishedAt());
|
||||||
|
|
|
@ -16,7 +16,7 @@ export interface DmpModel {
|
||||||
id: string;
|
id: string;
|
||||||
label: string;
|
label: string;
|
||||||
groupId: String;
|
groupId: String;
|
||||||
profile: String;
|
profile: DmpProfile;
|
||||||
version: number;
|
version: number;
|
||||||
status: DmpStatus;
|
status: DmpStatus;
|
||||||
lockable: boolean;
|
lockable: boolean;
|
||||||
|
@ -38,3 +38,9 @@ export interface DmpModel {
|
||||||
extraProperties: Map<String, any>;
|
extraProperties: Map<String, any>;
|
||||||
language: String;
|
language: String;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface DmpProfile {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
}
|
|
@ -178,7 +178,7 @@
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>Description</mat-label>
|
<mat-label>Description</mat-label>
|
||||||
<input matInput type="text" name="description" forehmControlName="description">
|
<input matInput type="text" name="description" formControlName="description">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="centered-row-item col-1">
|
<div class="centered-row-item col-1">
|
||||||
|
@ -247,7 +247,7 @@
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>Max Multiplicity</mat-label>
|
<mat-label>Max Multiplicity</mat-label>
|
||||||
<input matInput type="number" min="0" name="maxMultiplicity" formControlName="maxMultiplicity">
|
<input matInput type="number" min="1" name="maxMultiplicity" formControlName="maxMultiplicity">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -63,8 +63,10 @@
|
||||||
<div class="profile-form">
|
<div class="profile-form">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-select placeholder="{{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="profile">
|
<mat-select placeholder="{{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="profile">
|
||||||
<mat-option *ngFor="let profile of availableProfiles" [value]="profile" (click)="checkMinMax($event, profile)">
|
<mat-option *ngFor="let profile of availableProfiles" [value]="profile">
|
||||||
|
<div (click)="checkMinMax($event, profile)">
|
||||||
{{profile.label}}
|
{{profile.label}}
|
||||||
|
</div>
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="formGroup.get('profile').hasError('backendError')">{{formGroup.get('profile').getError('backendError').message}}</mat-error>
|
<mat-error *ngIf="formGroup.get('profile').hasError('backendError')">{{formGroup.get('profile').getError('backendError').message}}</mat-error>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { BaseComponent } from '@common/base/base.component';
|
import { BaseComponent } from '@common/base/base.component';
|
||||||
|
@ -8,9 +8,8 @@ import { TranslateService } from '@ngx-translate/core';
|
||||||
import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile';
|
import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service';
|
import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service';
|
||||||
import { DatasetWizardEditorModel } from '../dataset-wizard-editor.model';
|
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-editor-component',
|
selector: 'app-dataset-editor-component',
|
||||||
|
@ -51,6 +50,7 @@ export class DatasetEditorComponent extends BaseComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
checkMinMax(event, profile: DatasetProfileModel) {
|
checkMinMax(event, profile: DatasetProfileModel) {
|
||||||
|
event.stopPropagation();
|
||||||
const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value;
|
const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value;
|
||||||
const blueprintId = this.formGroup.get('dmp').value.profile.id;
|
const blueprintId = this.formGroup.get('dmp').value.profile.id;
|
||||||
this.dmpProfileService.getSingleBlueprint(blueprintId)
|
this.dmpProfileService.getSingleBlueprint(blueprintId)
|
||||||
|
@ -68,20 +68,24 @@ export class DatasetEditorComponent extends BaseComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(count === foundTemplate.maxMultiplicity){
|
if(count === foundTemplate.maxMultiplicity){
|
||||||
event.stopPropagation();
|
this.dialog.open(PopupNotificationDialogComponent, {
|
||||||
this.dialog.open(ConfirmationDialogComponent, {
|
|
||||||
data: {
|
data: {
|
||||||
message: 'MAX DATASETS USING TEMPLATE',
|
title: 'Max datasets using this template.',
|
||||||
confirmButton: 'RETURN',
|
message: 'Select another profile.'
|
||||||
cancelButton: 'CANCEL'
|
}, maxWidth: '30em'
|
||||||
},
|
});
|
||||||
maxWidth:'30em'
|
}
|
||||||
})
|
else{
|
||||||
.afterClosed()
|
this.formGroup.get('profile').setValue(profile);
|
||||||
.subscribe(confirm=>{})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
this.formGroup.get('profile').setValue(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.formGroup.get('profile').setValue(profile);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,6 +289,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
|
||||||
restoreFocus: false,
|
restoreFocus: false,
|
||||||
data: {
|
data: {
|
||||||
availableProfiles: this.availableDescriptionTemplates,
|
availableProfiles: this.availableDescriptionTemplates,
|
||||||
|
datasetFormGroup: this.formGroup
|
||||||
},
|
},
|
||||||
panelClass: 'custom-modalbox'
|
panelClass: 'custom-modalbox'
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,7 +27,9 @@
|
||||||
<mat-form-field class="col-md-12">
|
<mat-form-field class="col-md-12">
|
||||||
<mat-select placeholder="{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PROFILE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="profile">
|
<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">
|
<mat-option *ngFor="let profile of data.availableProfiles" [value]="profile">
|
||||||
|
<div (click)="checkMinMax($event, profile)">
|
||||||
{{profile.label}}
|
{{profile.label}}
|
||||||
|
</div>
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="prefillForm.get('profile').hasError('backendError')">{{prefillForm.get('profile').getError('backendError').message}}</mat-error>
|
<mat-error *ngIf="prefillForm.get('profile').hasError('backendError')">{{prefillForm.get('profile').getError('backendError').message}}</mat-error>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {Component, Inject, OnInit} from "@angular/core";
|
import {Component, Inject, OnInit} from "@angular/core";
|
||||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from "@angular/material/dialog";
|
||||||
import {map, takeUntil} from "rxjs/operators";
|
import {map, takeUntil} from "rxjs/operators";
|
||||||
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";
|
||||||
|
@ -8,6 +8,9 @@ import {Observable, of} from "rxjs";
|
||||||
import {Prefilling} from "@app/core/model/dataset/prefilling";
|
import {Prefilling} from "@app/core/model/dataset/prefilling";
|
||||||
import {PrefillingService} from "@app/core/services/prefilling.service";
|
import {PrefillingService} from "@app/core/services/prefilling.service";
|
||||||
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
|
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
|
||||||
|
import { DatasetProfileModel } from "@app/core/model/dataset/dataset-profile";
|
||||||
|
import { DmpProfileService } from "@app/core/services/dmp/dmp-profile.service";
|
||||||
|
import { PopupNotificationDialogComponent } from "@app/library/notification/popup/popup-notification.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'prefill-dataset-component',
|
selector: 'prefill-dataset-component',
|
||||||
|
@ -23,6 +26,8 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
constructor(public dialogRef: MatDialogRef<PrefillDatasetComponent>,
|
constructor(public dialogRef: MatDialogRef<PrefillDatasetComponent>,
|
||||||
private prefillingService: PrefillingService,
|
private prefillingService: PrefillingService,
|
||||||
|
private dmpProfileService: DmpProfileService,
|
||||||
|
private dialog: MatDialog,
|
||||||
private progressIndicationService: ProgressIndicationService,
|
private progressIndicationService: ProgressIndicationService,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any) {
|
@Inject(MAT_DIALOG_DATA) public data: any) {
|
||||||
|
@ -39,7 +44,7 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit {
|
||||||
prefill: this.fb.control(null, Validators.required)
|
prefill: 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.prefillForm.get('profile').patchValue(this.data.availableProfiles[0]);
|
this.addProfileIfUsedLessThanMax(this.data.availableProfiles[0]);
|
||||||
}
|
}
|
||||||
this.prefillAutoCompleteConfiguration = {
|
this.prefillAutoCompleteConfiguration = {
|
||||||
filterFn: this.searchDatasets.bind(this),
|
filterFn: this.searchDatasets.bind(this),
|
||||||
|
@ -50,6 +55,79 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addProfileIfUsedLessThanMax(profile: DatasetProfileModel) {
|
||||||
|
const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
|
||||||
|
const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
|
||||||
|
this.dmpProfileService.getSingleBlueprint(blueprintId)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(result => {
|
||||||
|
const section = result.definition.sections[dmpSectionIndex];
|
||||||
|
if(section.hasTemplates){
|
||||||
|
const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === profile.id);
|
||||||
|
if (foundTemplate !== undefined) {
|
||||||
|
let count = 0;
|
||||||
|
if(this.data.datasetFormGroup.get('dmp').value.datasets != null){
|
||||||
|
for(let dataset of this.data.datasetFormGroup.get('dmp').value.datasets){
|
||||||
|
if(dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId){
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(count < foundTemplate.maxMultiplicity){
|
||||||
|
this.prefillForm.get('profile').patchValue(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.prefillForm.get('profile').patchValue(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.prefillForm.get('profile').patchValue(profile);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
checkMinMax(event, profile: DatasetProfileModel) {
|
||||||
|
event.stopPropagation();
|
||||||
|
const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
|
||||||
|
const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
|
||||||
|
this.dmpProfileService.getSingleBlueprint(blueprintId)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(result => {
|
||||||
|
const section = result.definition.sections[dmpSectionIndex];
|
||||||
|
if(section.hasTemplates){
|
||||||
|
const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === profile.id);
|
||||||
|
if (foundTemplate !== undefined) {
|
||||||
|
let count = 0;
|
||||||
|
if(this.data.datasetFormGroup.get('dmp').value.datasets != null){
|
||||||
|
for(let dataset of this.data.datasetFormGroup.get('dmp').value.datasets){
|
||||||
|
if(dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId){
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(count === foundTemplate.maxMultiplicity){
|
||||||
|
this.dialog.open(PopupNotificationDialogComponent, {
|
||||||
|
data: {
|
||||||
|
title: 'Max datasets using this template.',
|
||||||
|
message: 'Select another profile.'
|
||||||
|
}, maxWidth: '30em'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.prefillForm.get('profile').setValue(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.prefillForm.get('profile').setValue(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.prefillForm.get('profile').setValue(profile);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public compareWith(object1: any, object2: any) {
|
public compareWith(object1: any, object2: any) {
|
||||||
return object1 && object2 && object1.id === object2.id;
|
return object1 && object2 && object1.id === object2.id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,10 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div *ngIf="dataset.grant">
|
||||||
<div class="row header">{{'DMP-OVERVIEW.GRANT' | translate}}</div>
|
<div class="row header">{{'DMP-OVERVIEW.GRANT' | translate}}</div>
|
||||||
<div class="row dataset-label">{{ dataset.grant.label }}</div>
|
<div class="row dataset-label">{{ dataset.grant.label }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row header">{{'DMP-OVERVIEW.RESEARCHERS' | translate}}</div>
|
<div class="row header">{{'DMP-OVERVIEW.RESEARCHERS' | translate}}</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
@ -53,7 +53,7 @@ export class DmpEditorModel {
|
||||||
|
|
||||||
fromModel(item: DmpModel): DmpEditorModel {
|
fromModel(item: DmpModel): DmpEditorModel {
|
||||||
this.id = item.id;
|
this.id = item.id;
|
||||||
this.profile = item.profile;
|
this.profile = item.profile.id;
|
||||||
this.label = item.label;
|
this.label = item.label;
|
||||||
this.groupId = item.groupId;
|
this.groupId = item.groupId;
|
||||||
this.version = item.version;
|
this.version = item.version;
|
||||||
|
|
|
@ -608,6 +608,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
});
|
});
|
||||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: DmpFinalizeDialogOutput) => {
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: DmpFinalizeDialogOutput) => {
|
||||||
if (result && !result.cancelled) {
|
if (result && !result.cancelled) {
|
||||||
|
if(!this.checkIfAnyProfileIsUsedLessThanMin(data)) {
|
||||||
|
|
||||||
var datasetsToBeFinalized: DatasetsToBeFinalized = {
|
var datasetsToBeFinalized: DatasetsToBeFinalized = {
|
||||||
uuids: result.datasetsToBeFinalized
|
uuids: result.datasetsToBeFinalized
|
||||||
};
|
};
|
||||||
|
@ -633,12 +635,44 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
error => this.onUpdateCallbackError(error)
|
error => this.onUpdateCallbackError(error)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private checkIfAnyProfileIsUsedLessThanMin(dmpModel: DmpModel): boolean {
|
||||||
|
const blueprintId = dmpModel.profile.id;
|
||||||
|
this.dmpProfileService.getSingleBlueprint(blueprintId)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(result => {
|
||||||
|
result.definition.sections.forEach(section => {
|
||||||
|
if(section.hasTemplates){
|
||||||
|
section.descriptionTemplates.forEach(template => {
|
||||||
|
if(template.minMultiplicity > 0) {
|
||||||
|
let count = 0;
|
||||||
|
dmpModel.datasets.filter(dataset => dataset.dmpSectionIndex === (section.ordinal - 1)).forEach(dataset => {
|
||||||
|
if(dataset.profile.id === template.descriptionTemplateId){
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(count < template.minMultiplicity){
|
||||||
|
this.dialog.open(PopupNotificationDialogComponent, {
|
||||||
|
data: {
|
||||||
|
title: 'Min(' + template.minMultiplicity + ') datasets needed using this template.',
|
||||||
|
message: 'Add dataset.'
|
||||||
|
}, maxWidth: '30em'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// newVersion(id: String, label: String) {
|
// newVersion(id: String, label: String) {
|
||||||
// let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }])
|
// let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }])
|
||||||
// window.open(url.toString(), '_blank')
|
// window.open(url.toString(), '_blank')
|
||||||
|
|
|
@ -43,7 +43,7 @@ export class DmpWizardEditorModel {
|
||||||
|
|
||||||
fromModel(item: DmpModel): DmpWizardEditorModel {
|
fromModel(item: DmpModel): DmpWizardEditorModel {
|
||||||
this.id = item.id;
|
this.id = item.id;
|
||||||
this.profile = item.profile;
|
this.profile = item.profile.id;
|
||||||
this.label = item.label;
|
this.label = item.label;
|
||||||
this.groupId = item.groupId;
|
this.groupId = item.groupId;
|
||||||
this.version = item.version;
|
this.version = item.version;
|
||||||
|
|
Loading…
Reference in New Issue