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 5a7459b8c..6001dc168 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 @@ -1435,29 +1435,41 @@ public class DataManagementPlanManager { runContact.setColor("116a78"); break; case FUNDER: - XWPFRun runFunder = systemFieldInput.createRun(); - runFunder.setText(dmpEntity.getGrant().getFunder().getLabel()); - runFunder.setColor("116a78"); + if (dmpEntity.getGrant() != null && dmpEntity.getGrant().getFunder() != null) { + XWPFRun runFunder = systemFieldInput.createRun(); + runFunder.setText(dmpEntity.getGrant().getFunder().getLabel()); + runFunder.setColor("116a78"); + } break; case GRANT: - XWPFRun runGrant = systemFieldInput.createRun(); - runGrant.setText(dmpEntity.getGrant().getLabel()); - runGrant.setColor("116a78"); + if (dmpEntity.getGrant() != null) { + XWPFRun runGrant = systemFieldInput.createRun(); + runGrant.setText(dmpEntity.getGrant().getLabel()); + runGrant.setColor("116a78"); + } break; case PROJECT: - XWPFRun runProject = systemFieldInput.createRun(); - runProject.setText(dmpEntity.getProject().getLabel()); - runProject.setColor("116a78"); + if (dmpEntity.getProject() != null ) { + XWPFRun runProject = systemFieldInput.createRun(); + runProject.setText(dmpEntity.getProject().getLabel()); + runProject.setColor("116a78"); + } break; case LICENSE: - XWPFRun runLicense = systemFieldInput.createRun(); - runLicense.setText(objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class).get("license").toString()); - runLicense.setColor("116a78"); + Map extraProperties = objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class); + if (extraProperties.containsKey("license")) { + XWPFRun runLicense = systemFieldInput.createRun(); + runLicense.setText(extraProperties.get("license").toString()); + runLicense.setColor("116a78"); + } break; case ACCESS_RIGHTS: - XWPFRun runAccessRights = systemFieldInput.createRun(); - runAccessRights.setText(objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class).get("visible").toString()); - runAccessRights.setColor("116a78"); + Map extraPropertiesMap = objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class); + if (extraPropertiesMap.containsKey("visible")) { + XWPFRun runAccessRights = systemFieldInput.createRun(); + runAccessRights.setText(extraPropertiesMap.get("visible").toString()); + runAccessRights.setColor("116a78"); + } break; } document.createParagraph(); @@ -1475,7 +1487,10 @@ public class DataManagementPlanManager { runExtraFieldDescription.setColor("116a78"); } 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"); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java index ddf1a0841..cf9905ffd 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java @@ -381,10 +381,12 @@ public class DataManagementPlan implements DataModel { if (this.properties != null) { this.extraFields = new ArrayList<>(); this.properties.forEach((id, value) -> { - ExtraFieldModel extraField = new ExtraFieldModel(); - extraField.setId(id); - extraField.setValue(value.toString()); - this.extraFields.add(extraField); + if (value != null) { + ExtraFieldModel extraField = new ExtraFieldModel(); + extraField.setId(id); + extraField.setValue(value.toString()); + this.extraFields.add(extraField); + } }); } if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue()))) diff --git a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.html b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.html index b3a196742..f8eb58905 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.html @@ -206,7 +206,7 @@
- + Description Templates
diff --git a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts index b1c623a11..3ad205bb3 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts @@ -175,6 +175,13 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie } } + checkForProfiles(event, sectionIndex: number) { + if (event.checked === false) { + this.descriptionTemplatesPerSection[sectionIndex] = new Array(); + this.descriptionTemplatesArray(sectionIndex).clear(); + } + } + filterProfiles(value: string): Observable { const request = new DataTableRequest(null, null, { fields: ['+label'] }); const criteria = new DatasetProfileCriteria();