Implemented Publishing Datasets in finalised DMP's (Ticket #47 - Publishing Datasets - DMP Finalisation)
This commit is contained in:
parent
d07c06df87
commit
f1ff0ebf0b
|
@ -63,8 +63,7 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
||||||
public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal) {
|
public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal) {
|
||||||
if (principal.getId() == null) query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
|
if (principal.getId() == null) query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
|
||||||
else {
|
else {
|
||||||
query.where((builder, root) -> builder.or(builder.equal(root.get("dmp").get("creator"), principal), builder.isMember(principal, root.get("dmp").get("users"))
|
query.where((builder, root) -> builder.or(builder.equal(root.get("dmp").get("creator"), principal), builder.isMember(principal, root.get("dmp").get("users"))));
|
||||||
, builder.equal(root.get("isPublic"), true)));
|
|
||||||
}
|
}
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
||||||
private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetListingModel"));
|
private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetListingModel"));
|
||||||
|
|
||||||
public enum Status {
|
public enum Status {
|
||||||
SAVED((short) 0), FINALISED((short) 1), WITHDRAWN((short) 2), DELETED((short) 99);
|
SAVED((short) 0), FINALISED((short) 1), DELETED((short) 99);
|
||||||
|
|
||||||
private short value;
|
private short value;
|
||||||
|
|
||||||
|
@ -62,8 +62,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
||||||
return SAVED;
|
return SAVED;
|
||||||
case 1:
|
case 1:
|
||||||
return FINALISED;
|
return FINALISED;
|
||||||
case 2:
|
|
||||||
return WITHDRAWN;
|
|
||||||
case 99:
|
case 99:
|
||||||
return DELETED;
|
return DELETED;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.data.query.items.table.dataset;
|
package eu.eudat.data.query.items.table.dataset;
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.DatasetPublicCriteria;
|
import eu.eudat.data.dao.criteria.DatasetPublicCriteria;
|
||||||
|
import eu.eudat.data.entities.DMP;
|
||||||
import eu.eudat.data.entities.Dataset;
|
import eu.eudat.data.entities.Dataset;
|
||||||
import eu.eudat.data.query.definition.TableQuery;
|
import eu.eudat.data.query.definition.TableQuery;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
@ -19,6 +20,8 @@ public class DatasetPublicTableRequest extends TableQuery<DatasetPublicCriteria,
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<Dataset> applyCriteria() {
|
public QueryableList<Dataset> applyCriteria() {
|
||||||
QueryableList<Dataset> query = this.getQuery();
|
QueryableList<Dataset> query = this.getQuery();
|
||||||
|
query.where((builder, root) -> builder.equal(root.get("dmp").get("status"), DMP.DMPStatus.FINALISED.getValue()));
|
||||||
|
query.where((builder, root) -> builder.equal(root.get("status"), Dataset.Status.FINALISED.getValue()));
|
||||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
|
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
|
||||||
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
|
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
|
||||||
Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
||||||
|
|
|
@ -172,12 +172,6 @@ public class DataManagementPlanManager {
|
||||||
.asQueryable().where((builder, root) -> root.get("id").in(dataManagementPlan.getDatasets()
|
.asQueryable().where((builder, root) -> root.get("id").in(dataManagementPlan.getDatasets()
|
||||||
.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList())))
|
.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList())))
|
||||||
.update(root -> root.<Integer>get("status"), Dataset.Status.FINALISED.getValue());
|
.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)
|
if (dataManagementPlan.getAssociatedUsers().stream().filter(item -> item.getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
|
||||||
assignUser(newDmp, user, apiContext);
|
assignUser(newDmp, user, apiContext);
|
||||||
|
|
|
@ -344,7 +344,6 @@ public class DatasetManager {
|
||||||
eu.eudat.data.entities.Dataset dataset = datasetDao.find(id);
|
eu.eudat.data.entities.Dataset dataset = datasetDao.find(id);
|
||||||
if (dataset.getStatus() != eu.eudat.data.entities.Dataset.Status.FINALISED.getValue())
|
if (dataset.getStatus() != eu.eudat.data.entities.Dataset.Status.FINALISED.getValue())
|
||||||
throw new Exception("You cannot make public a Dataset That Has not Been Finalised");
|
throw new Exception("You cannot make public a Dataset That Has not Been Finalised");
|
||||||
dataset.setPublic(true);
|
|
||||||
datasetDao.createOrUpdate(dataset);
|
datasetDao.createOrUpdate(dataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,12 +35,6 @@
|
||||||
<mat-cell *matCellDef="let row"> {{row.profile}} </mat-cell>
|
<mat-cell *matCellDef="let row"> {{row.profile}} </mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<!-- Column Definition: Status -->
|
|
||||||
<ng-container cdkColumnDef="status">
|
|
||||||
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell>
|
|
||||||
<mat-cell *matCellDef="let row"> {{row.status}} </mat-cell>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<!-- Column Definition: DataRepositories -->
|
<!-- Column Definition: DataRepositories -->
|
||||||
<!-- <ng-container cdkColumnDef="dataRepositories">
|
<!-- <ng-container cdkColumnDef="dataRepositories">
|
||||||
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.DATAREPOSITORIES' | translate}}</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.DATAREPOSITORIES' | translate}}</mat-header-cell>
|
||||||
|
|
|
@ -27,7 +27,7 @@ export class DatasetPublicListingComponent implements OnInit {
|
||||||
criteria: FacetSearchCriteriaModel;
|
criteria: FacetSearchCriteriaModel;
|
||||||
|
|
||||||
dataSource: DatasetDataSource | null;
|
dataSource: DatasetDataSource | null;
|
||||||
displayedColumns: String[] = ['label', 'project', 'profile', 'status', 'description', 'created'];
|
displayedColumns: String[] = ['label', 'project', 'profile', 'description', 'created'];
|
||||||
pageEvent: PageEvent;
|
pageEvent: PageEvent;
|
||||||
titlePrefix: String;
|
titlePrefix: String;
|
||||||
dmpId: string;
|
dmpId: string;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
<!-- Column Definition: Dmp -->
|
<!-- Column Definition: Dmp -->
|
||||||
<ng-container cdkColumnDef="project">
|
<ng-container cdkColumnDef="project">
|
||||||
<mat-header-cell *matHeaderCellDef >{{'DATASET-LISTING.COLUMNS.PROJECT' |
|
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.PROJECT' |
|
||||||
translate}}</mat-header-cell>
|
translate}}</mat-header-cell>
|
||||||
<mat-cell *matCellDef="let row"> {{row.project}} </mat-cell>
|
<mat-cell *matCellDef="let row"> {{row.project}} </mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@ -79,25 +79,6 @@
|
||||||
<mat-cell *matCellDef="let row">{{row.created | date:'shortDate'}}</mat-cell>
|
<mat-cell *matCellDef="let row">{{row.created | date:'shortDate'}}</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<!-- Column Definition: Submission Time -->
|
|
||||||
<ng-container cdkColumnDef="actions">
|
|
||||||
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.ACTIONS' | translate}}</mat-header-cell>
|
|
||||||
<mat-cell *matCellDef="let row" (click)="$event.stopPropagation()">
|
|
||||||
<mat-menu #actionsMenu="matMenu">
|
|
||||||
<button *ngIf="row.status == 0" (click)="rowClick(row.id)" mat-menu-item>
|
|
||||||
<mat-icon>mode_edit</mat-icon>{{'DATASET-LISTING.ACTIONS.EDIT' | translate}}
|
|
||||||
</button>
|
|
||||||
<button *ngIf="row.status != 0" (click)="makeItPublic(row.id)" mat-menu-item>
|
|
||||||
<mat-icon>public</mat-icon>{{'DATASET-LISTING.ACTIONS.MAKE-IT-PUBLIC' | translate}}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
</mat-menu>
|
|
||||||
<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
|
|
||||||
<mat-icon>more_vert</mat-icon>
|
|
||||||
</button>
|
|
||||||
</mat-cell>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||||
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row>
|
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row>
|
||||||
<!-- (click)="rowClick(row.id)" -->
|
<!-- (click)="rowClick(row.id)" -->
|
||||||
|
|
|
@ -35,7 +35,7 @@ export class DatasetListingComponent implements OnInit, IBreadCrumbComponent {
|
||||||
breadCrumbs: Observable<BreadcrumbItem[]>;
|
breadCrumbs: Observable<BreadcrumbItem[]>;
|
||||||
|
|
||||||
dataSource: DatasetDataSource | null;
|
dataSource: DatasetDataSource | null;
|
||||||
displayedColumns: String[] = ['label', 'project', 'dmp', 'profile', 'status', 'description', 'created', 'actions'];
|
displayedColumns: String[] = ['label', 'project', 'dmp', 'profile', 'status', 'description', 'created'];
|
||||||
pageEvent: PageEvent;
|
pageEvent: PageEvent;
|
||||||
titlePrefix: String;
|
titlePrefix: String;
|
||||||
dmpId: string;
|
dmpId: string;
|
||||||
|
|
|
@ -17,7 +17,6 @@ import { TagModel } from '../tags/TagModel';
|
||||||
export enum DatasetStatus {
|
export enum DatasetStatus {
|
||||||
Draft = 0,
|
Draft = 0,
|
||||||
Finalised = 1,
|
Finalised = 1,
|
||||||
WithDrawn = 2,
|
|
||||||
Deleted = 99
|
Deleted = 99
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ export class Utilities {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case DatasetStatus.Draft: return this.language.instant('TYPES.DATASET-STATUS.DRAFT');
|
case DatasetStatus.Draft: return this.language.instant('TYPES.DATASET-STATUS.DRAFT');
|
||||||
case DatasetStatus.Finalised: return this.language.instant('TYPES.DATASET-STATUS.FINALISED');
|
case DatasetStatus.Finalised: return this.language.instant('TYPES.DATASET-STATUS.FINALISED');
|
||||||
case DatasetStatus.WithDrawn: return this.language.instant('TYPES.DATASET-STATUS.WITHDRAWN');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -285,8 +285,7 @@
|
||||||
},
|
},
|
||||||
"DATASET-STATUS": {
|
"DATASET-STATUS": {
|
||||||
"DRAFT": "Draft",
|
"DRAFT": "Draft",
|
||||||
"FINALISED": "Finalised",
|
"FINALISED": "Finalised"
|
||||||
"WITHDRAWN": "Withdrawn"
|
|
||||||
},
|
},
|
||||||
"EXTERNAL-DATASET-TYPE": {
|
"EXTERNAL-DATASET-TYPE": {
|
||||||
"SOURCE": "Source",
|
"SOURCE": "Source",
|
||||||
|
|
Loading…
Reference in New Issue