Change Dataset sorting on DMP overview and editor from last modified to last created

This commit is contained in:
George Kalampokis 2022-04-05 15:27:58 +03:00
parent b9f8d2e162
commit 2a12f1b5be
2 changed files with 12 additions and 2 deletions

View File

@ -291,7 +291,7 @@ public class DataManagementPlanManager {
if (includeDatasets) {
dataManagementPlan.fromDataModel(dataManagementPlanEntity);
dataManagementPlan.getDatasets().forEach(datasetWizardModel -> datasetWizardModel.setDescription(null));
dataManagementPlan.setDatasets(dataManagementPlan.getDatasets().stream().sorted(Comparator.comparing(DatasetWizardModel::getModified).reversed()).collect(Collectors.toList()));
dataManagementPlan.setDatasets(dataManagementPlan.getDatasets().stream().sorted(Comparator.comparing(DatasetWizardModel::getCreated).reversed()).collect(Collectors.toList()));
//List<Dataset> datasetEnities = new ArrayList<>(dataManagementPlanEntity.getDataset());
/*for (int i = 0; i < datasetEnities.size(); i++) {
for (int j = i; j < dataManagementPlan.getDatasets().size(); j++) {
@ -343,7 +343,7 @@ public class DataManagementPlanManager {
}
DataManagementPlanOverviewModel datamanagementPlan = new DataManagementPlanOverviewModel();
datamanagementPlan.fromDataModelDatasets(dataManagementPlanEntity);
datamanagementPlan.setDatasets(datamanagementPlan.getDatasets().stream().sorted(Comparator.comparing(DatasetOverviewModel::getModified).reversed()).collect(Collectors.toList()));
datamanagementPlan.setDatasets(datamanagementPlan.getDatasets().stream().sorted(Comparator.comparing(DatasetOverviewModel::getCreated).reversed()).collect(Collectors.toList()));
if (isPublic) {
datamanagementPlan.setDatasets(datamanagementPlan.getDatasets().stream().filter(dataset -> dataset.getStatus() == Dataset.Status.FINALISED.getValue()).collect(Collectors.toList()));
}

View File

@ -24,6 +24,7 @@ public class DatasetOverviewModel implements DataModel<Dataset, DatasetOverviewM
private String description;
private Boolean isPublic;
private Date modified;
private Date created;
public UUID getId() {
return id;
@ -101,6 +102,14 @@ public class DatasetOverviewModel implements DataModel<Dataset, DatasetOverviewM
this.modified = modified;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
@Override
public DatasetOverviewModel fromDataModel(Dataset entity) {
this.id = entity.getId();
@ -113,6 +122,7 @@ public class DatasetOverviewModel implements DataModel<Dataset, DatasetOverviewM
this.description = entity.getDescription();
this.isPublic = entity.getDmp().isPublic();
this.modified = entity.getModified();
this.created = entity.getCreated();
return this;
}