Make DMP export to be more consistent with the DMP shown on the front end UI

This commit is contained in:
George Kalampokis 2022-03-29 15:12:56 +03:00
parent c41c89774b
commit afb0be5b18
1 changed files with 17 additions and 1 deletions

View File

@ -1220,9 +1220,12 @@ public class DataManagementPlanManager {
wordBuilder.addParagraphContent("Datasets", document, ParagraphStyle.HEADER1, BigInteger.ZERO);
// Space below Datasets.
XWPFParagraph parBreakDatasets = document.createParagraph();
final Boolean isFinalized = dmpEntity.getStatus() == DMP.DMPStatus.FINALISED.getValue();
final Boolean isPublic = dmpEntity.isPublic();
dmpEntity.getDataset().stream()
.filter(item -> item.getStatus() != Dataset.Status.CANCELED.getValue())
.filter(item -> item.getStatus() != Dataset.Status.DELETED.getValue())
.filter(item -> !isPublic && !isFinalized || item.getStatus() == Dataset.Status.FINALISED.getValue())
.forEach(datasetEntity -> {
Map<String, Object> properties = new HashMap<>();
if (datasetEntity.getProperties() != null) {
@ -1348,7 +1351,13 @@ public class DataManagementPlanManager {
eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id));
if (!dmp.isPublic() && dmp.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
throw new UnauthorisedException();
List<Dataset> datasets = dmp.getDataset().stream().filter(dataset -> dataset.getStatus() != Dmp.DMPStatus.DELETED.getValue()).collect(Collectors.toList());
final Boolean isFinalized = dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue();
final Boolean isPublic = dmp.isPublic();
List<Dataset> datasets = dmp.getDataset().stream()
.filter(dataset -> dataset.getStatus() != Dataset.Status.DELETED.getValue() &&
dataset.getStatus() != Dataset.Status.CANCELED.getValue())
.filter(dataset -> !isPublic && !isFinalized || dataset.getStatus() == Dataset.Status.FINALISED.getValue())
.collect(Collectors.toList());
/*String fileName = dmp.getLabel();
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "");*/
String uuid = UUID.randomUUID().toString();
@ -1499,6 +1508,13 @@ public class DataManagementPlanManager {
if (!dmp.isPublic() && dmp.getUsers().stream().noneMatch(userInfo -> userInfo.getUser().getId() == principal.getId()))
throw new UnauthorisedException();
// RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal);
final Boolean isFinalized = dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue();
final Boolean isPublic = dmp.isPublic();
dmp.setDataset(dmp.getDataset().stream()
.filter(dataset -> dataset.getStatus() != Dataset.Status.DELETED.getValue() &&
dataset.getStatus() != Dataset.Status.CANCELED.getValue())
.filter(dataset -> !isPublic && !isFinalized || dataset.getStatus() == Dataset.Status.FINALISED.getValue())
.collect(Collectors.toSet()));
String result = rdaManager.convertToRDA(dmp);
/*ObjectMapper mapper = new ObjectMapper();