bug fixes: 1) when creating description template type check only for non deleted types, 2) dmp docx/pdf export: check if system fields exist 3) when creating/updating dmp check if value for extra fields is set, 4) when unchecking the 'Description Templates' checkbox in the blueprint editor, clear any templates selected

This commit is contained in:
Bernaldo Mihasi 2023-10-02 13:57:00 +03:00 committed by Diamantis Tziotzios
parent 09dcf5328d
commit 4373bf4b00
4 changed files with 45 additions and 21 deletions

View File

@ -1435,29 +1435,41 @@ public class DataManagementPlanManager {
runContact.setColor("116a78"); runContact.setColor("116a78");
break; break;
case FUNDER: case FUNDER:
XWPFRun runFunder = systemFieldInput.createRun(); if (dmpEntity.getGrant() != null && dmpEntity.getGrant().getFunder() != null) {
runFunder.setText(dmpEntity.getGrant().getFunder().getLabel()); XWPFRun runFunder = systemFieldInput.createRun();
runFunder.setColor("116a78"); runFunder.setText(dmpEntity.getGrant().getFunder().getLabel());
runFunder.setColor("116a78");
}
break; break;
case GRANT: case GRANT:
XWPFRun runGrant = systemFieldInput.createRun(); if (dmpEntity.getGrant() != null) {
runGrant.setText(dmpEntity.getGrant().getLabel()); XWPFRun runGrant = systemFieldInput.createRun();
runGrant.setColor("116a78"); runGrant.setText(dmpEntity.getGrant().getLabel());
runGrant.setColor("116a78");
}
break; break;
case PROJECT: case PROJECT:
XWPFRun runProject = systemFieldInput.createRun(); if (dmpEntity.getProject() != null ) {
runProject.setText(dmpEntity.getProject().getLabel()); XWPFRun runProject = systemFieldInput.createRun();
runProject.setColor("116a78"); runProject.setText(dmpEntity.getProject().getLabel());
runProject.setColor("116a78");
}
break; break;
case LICENSE: case LICENSE:
XWPFRun runLicense = systemFieldInput.createRun(); Map extraProperties = objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class);
runLicense.setText(objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class).get("license").toString()); if (extraProperties.containsKey("license")) {
runLicense.setColor("116a78"); XWPFRun runLicense = systemFieldInput.createRun();
runLicense.setText(extraProperties.get("license").toString());
runLicense.setColor("116a78");
}
break; break;
case ACCESS_RIGHTS: case ACCESS_RIGHTS:
XWPFRun runAccessRights = systemFieldInput.createRun(); Map extraPropertiesMap = objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class);
runAccessRights.setText(objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class).get("visible").toString()); if (extraPropertiesMap.containsKey("visible")) {
runAccessRights.setColor("116a78"); XWPFRun runAccessRights = systemFieldInput.createRun();
runAccessRights.setText(extraPropertiesMap.get("visible").toString());
runAccessRights.setColor("116a78");
}
break; break;
} }
document.createParagraph(); document.createParagraph();
@ -1475,7 +1487,10 @@ public class DataManagementPlanManager {
runExtraFieldDescription.setColor("116a78"); runExtraFieldDescription.setColor("116a78");
} }
XWPFRun runExtraFieldInput = extraFieldParagraph.createRun(); XWPFRun runExtraFieldInput = extraFieldParagraph.createRun();
runExtraFieldInput.setText(extraField.getLabel()); Map dmpProperties = objectMapper.readValue(dmpEntity.getProperties(), HashMap.class);
if (dmpProperties.containsKey(field.getId()) && dmpProperties.get(field.getId()) != null) {
runExtraFieldInput.setText((String) dmpProperties.get(field.getId()));
}
runExtraFieldInput.setColor("116a78"); runExtraFieldInput.setColor("116a78");
} }
} }

View File

@ -381,10 +381,12 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
if (this.properties != null) { if (this.properties != null) {
this.extraFields = new ArrayList<>(); this.extraFields = new ArrayList<>();
this.properties.forEach((id, value) -> { this.properties.forEach((id, value) -> {
ExtraFieldModel extraField = new ExtraFieldModel(); if (value != null) {
extraField.setId(id); ExtraFieldModel extraField = new ExtraFieldModel();
extraField.setValue(value.toString()); extraField.setId(id);
this.extraFields.add(extraField); extraField.setValue(value.toString());
this.extraFields.add(extraField);
}
}); });
} }
if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue()))) if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))

View File

@ -206,7 +206,7 @@
<div class="col-12"> <div class="col-12">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<mat-checkbox formControlName="hasTemplates"> <mat-checkbox formControlName="hasTemplates" (change)="checkForProfiles($event, sectionIndex)">
Description Templates Description Templates
</mat-checkbox> </mat-checkbox>
</div> </div>

View File

@ -175,6 +175,13 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
} }
} }
checkForProfiles(event, sectionIndex: number) {
if (event.checked === false) {
this.descriptionTemplatesPerSection[sectionIndex] = new Array<DatasetProfileModel>();
this.descriptionTemplatesArray(sectionIndex).clear();
}
}
filterProfiles(value: string): Observable<DatasetProfileModel[]> { filterProfiles(value: string): Observable<DatasetProfileModel[]> {
const request = new DataTableRequest<DatasetProfileCriteria>(null, null, { fields: ['+label'] }); const request = new DataTableRequest<DatasetProfileCriteria>(null, null, { fields: ['+label'] });
const criteria = new DatasetProfileCriteria(); const criteria = new DatasetProfileCriteria();