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
parent 3d10e8ad28
commit 2bf0a857bc
5 changed files with 46 additions and 22 deletions

View File

@ -23,7 +23,7 @@ public class DescriptionTemplateTypeDaoImpl extends DatabaseAccess<DescriptionTe
@Override
public DescriptionTemplateType findFromName(String name){
try {
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.equal(root.get("name"), name)).getSingle();
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.and(builder.equal(root.get("name"), name), builder.notEqual(root.get("status"), DescriptionTemplateType.Status.DELETED.getValue()))).getSingle();
}
catch(Exception e){
return null;

View File

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

View File

@ -381,10 +381,12 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
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())))

View File

@ -206,7 +206,7 @@
<div class="col-12">
<div class="row">
<div class="col-12">
<mat-checkbox formControlName="hasTemplates">
<mat-checkbox formControlName="hasTemplates" (change)="checkForProfiles($event, sectionIndex)">
Description Templates
</mat-checkbox>
</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[]> {
const request = new DataTableRequest<DatasetProfileCriteria>(null, null, { fields: ['+label'] });
const criteria = new DatasetProfileCriteria();