Enhanced the behaviour of finalising DMP's with Dataset withdrawal

This commit is contained in:
Ioannis Kalyvas 2018-10-15 12:04:20 +03:00
parent b660176534
commit 099a839e80
5 changed files with 19 additions and 5 deletions

View File

@ -18,7 +18,7 @@ import java.util.stream.Collectors;
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode(value = "datasetDataRepositories", subgraph = "datasetDataRepositories"), @NamedAttributeNode("datasetExternalDatasets"), @NamedAttributeNode("registries"),
@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")},
subgraphs = {
@NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("project"),@NamedAttributeNode("organisations")}),
@NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("project"), @NamedAttributeNode("organisations")}),
@NamedSubgraph(name = "datasetDataRepositories", attributeNodes = {@NamedAttributeNode("dataRepository")})
}),
@ -44,7 +44,7 @@ public class Dataset implements DataEntity<Dataset, UUID> {
private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetListingModel"));
public enum Status {
SAVED((short) 0), FINALISED((short) 1), DELETED((short) 99);
SAVED((short) 0), FINALISED((short) 1), WITHDRAWN((short) 2), DELETED((short) 99);
private short value;
@ -62,8 +62,12 @@ public class Dataset implements DataEntity<Dataset, UUID> {
return SAVED;
case 1:
return FINALISED;
case 2:
return WITHDRAWN;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Project Status");
throw new RuntimeException("Unsupported Dataset Status");
}
}
}

View File

@ -172,6 +172,12 @@ public class DataManagementPlanManager {
.asQueryable().where((builder, root) -> root.get("id").in(dataManagementPlan.getDatasets()
.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList())))
.update(root -> root.<Integer>get("status"), Dataset.Status.FINALISED.getValue());
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
.asQueryable().where((builder, root) -> builder.and(
builder.equal(root.get("dmp").get("id"), dataManagementPlan.getId()),
builder.not(root.get("id").in(dataManagementPlan.getDatasets().stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList()))),
builder.equal(root.get("status"), Dataset.Status.SAVED.getValue())))
.update(root -> root.<Integer>get("status"), Dataset.Status.WITHDRAWN.getValue());
}
if (dataManagementPlan.getAssociatedUsers().stream().filter(item -> item.getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
assignUser(newDmp, user, apiContext);

View File

@ -16,7 +16,9 @@ import { TagModel } from '../tags/TagModel';
export enum DatasetStatus {
Draft = 0,
Finalised = 1
Finalised = 1,
WithDrawn = 2,
Deleted = 99
}
export class DatasetWizardModel implements Serializable<DatasetWizardModel> {

View File

@ -39,6 +39,7 @@ export class Utilities {
switch (status) {
case DatasetStatus.Draft: return this.language.instant('TYPES.DATASET-STATUS.DRAFT');
case DatasetStatus.Finalised: return this.language.instant('TYPES.DATASET-STATUS.FINALISED');
case DatasetStatus.WithDrawn: return this.language.instant('TYPES.DATASET-STATUS.WITHDRAWN');
}
}

View File

@ -285,7 +285,8 @@
},
"DATASET-STATUS": {
"DRAFT": "Draft",
"FINALISED": "Finalised"
"FINALISED": "Finalised",
"WITHDRAWN": "Withdrawn"
},
"EXTERNAL-DATASET-TYPE": {
"SOURCE": "Source",