Implemented Publishing Datasets in finalised DMP's (Ticket #47 - Publishing Datasets - DMP Finalisation)

This commit is contained in:
Ioannis Kalyvas 2018-10-15 15:50:01 +03:00
parent d07c06df87
commit f1ff0ebf0b
13 changed files with 75 additions and 110 deletions

View File

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

View File

@ -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:

View File

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

View File

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

View File

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

View File

@ -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>

View File

@ -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;

View File

@ -480,7 +480,7 @@ export class DatasetWizardComponent implements OnInit, AfterViewInit, IBreadCrum
this.editMode = true; this.editMode = true;
this.viewOnly = false; this.viewOnly = false;
this.datasetWizardModel.status = DatasetStatus.Draft; this.datasetWizardModel.status = DatasetStatus.Draft;
this.formGroup.get('status').patchValue(DatasetStatus.Draft); this.formGroup.get('status').patchValue(DatasetStatus.Draft);
this.formGroup.enable(); this.formGroup.enable();
}); });
} }

View File

@ -1,116 +1,97 @@
<div> <div>
<h3>{{'DATASET-LISTING.TITLE' | translate}} {{titlePrefix}}</h3> <h3>{{'DATASET-LISTING.TITLE' | translate}} {{titlePrefix}}</h3>
<app-datasets-criteria-component></app-datasets-criteria-component> <app-datasets-criteria-component></app-datasets-criteria-component>
<mat-card class="mat-card"> <mat-card class="mat-card">
<mat-card-header> <mat-card-header>
<mat-progress-bar *ngIf="dataSource?.isLoadingResults" mode="query"></mat-progress-bar> <mat-progress-bar *ngIf="dataSource?.isLoadingResults" mode="query"></mat-progress-bar>
</mat-card-header> </mat-card-header>
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()"> <mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
<!-- Column Definition: Name --> <!-- Column Definition: Name -->
<ng-container cdkColumnDef="label"> <ng-container cdkColumnDef="label">
<mat-header-cell *matHeaderCellDef mat-sort-header="label">{{'DATASET-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header="label">{{'DATASET-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.label}}</mat-cell> <mat-cell *matCellDef="let row">{{row.label}}</mat-cell>
</ng-container> </ng-container>
<!-- 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>
<!-- Column Definition: Dmp --> <!-- Column Definition: Dmp -->
<ng-container cdkColumnDef="dmp"> <ng-container cdkColumnDef="dmp">
<mat-header-cell *matHeaderCellDef mat-sort-header="|join|dmp:label">{{'DATASET-LISTING.COLUMNS.DMP' | <mat-header-cell *matHeaderCellDef mat-sort-header="|join|dmp:label">{{'DATASET-LISTING.COLUMNS.DMP' |
translate}}</mat-header-cell> translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.dmp}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.dmp}} </mat-cell>
</ng-container> </ng-container>
<!-- Column Definition: Profile --> <!-- Column Definition: Profile -->
<ng-container cdkColumnDef="profile"> <ng-container cdkColumnDef="profile">
<mat-header-cell *matHeaderCellDef mat-sort-header="|join|profile:label">{{'DATASET-LISTING.COLUMNS.PROFILE' | <mat-header-cell *matHeaderCellDef mat-sort-header="|join|profile:label">{{'DATASET-LISTING.COLUMNS.PROFILE' |
translate}}</mat-header-cell> translate}}</mat-header-cell>
<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 --> <!-- Column Definition: Status -->
<ng-container cdkColumnDef="status"> <ng-container cdkColumnDef="status">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{this.utilities.convertFromDatasetStatus(row.status)}} </mat-cell> <mat-cell *matCellDef="let row"> {{this.utilities.convertFromDatasetStatus(row.status)}} </mat-cell>
</ng-container> </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>
<mat-cell *matCellDef="let row"> {{row.dataRepositories}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.dataRepositories}} </mat-cell>
</ng-container> --> </ng-container> -->
<!-- Column Definition: DataRepositories --> <!-- Column Definition: DataRepositories -->
<!-- <ng-container cdkColumnDef="registries"> <!-- <ng-container cdkColumnDef="registries">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.REGISTRIES' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.REGISTRIES' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.registries}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.registries}} </mat-cell>
</ng-container> --> </ng-container> -->
<!-- Column Definition: DataRepositories --> <!-- Column Definition: DataRepositories -->
<!-- <ng-container cdkColumnDef="services"> <!-- <ng-container cdkColumnDef="services">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.SERVICES' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.SERVICES' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.services}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.services}} </mat-cell>
</ng-container> --> </ng-container> -->
<!-- Column Definition: Status --> <!-- Column Definition: Status -->
<!-- <ng-container cdkColumnDef="status"> <!-- <ng-container cdkColumnDef="status">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.status}} <mat-cell *matCellDef="let row"> {{row.status}}
</mat-cell> </mat-cell>
</ng-container> --> </ng-container> -->
<!-- Column Definition: Description --> <!-- Column Definition: Description -->
<ng-container cdkColumnDef="description"> <ng-container cdkColumnDef="description">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.DESCRIPTION' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.DESCRIPTION' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.description}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.description}} </mat-cell>
</ng-container> </ng-container>
<!-- Column Definition: Created --> <!-- Column Definition: Created -->
<ng-container cdkColumnDef="created"> <ng-container cdkColumnDef="created">
<mat-header-cell *matHeaderCellDef mat-sort-header="created">{{'DATASET-LISTING.COLUMNS.CREATED' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header="created">{{'DATASET-LISTING.COLUMNS.CREATED' | translate}}</mat-header-cell>
<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 --> <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<ng-container cdkColumnDef="actions"> <mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row>
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.ACTIONS' | translate}}</mat-header-cell> <!-- (click)="rowClick(row.id)" -->
<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> </mat-table>
<button mat-icon-button [matMenuTriggerFor]="actionsMenu"> <mat-paginator #paginator [length]="dataSource?.totalCount" [pageSizeOptions]="[10, 25, 100]">
<mat-icon>more_vert</mat-icon> </mat-paginator>
</button> </mat-card>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> <button *ngIf="dmpId" mat-fab class="mat-fab-bottom-right" color="primary" [routerLink]="['/datasets/new/'+dmpId] ">
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row> <mat-icon class="mat-24">add</mat-icon>
<!-- (click)="rowClick(row.id)" --> </button>
<button *ngIf="!dmpId" mat-fab class="mat-fab-bottom-right" color="primary" [routerLink]="['/datasets/new'] ">
</mat-table> <mat-icon class="mat-24">add</mat-icon>
<mat-paginator #paginator [length]="dataSource?.totalCount" [pageSizeOptions]="[10, 25, 100]"> </button>
</mat-paginator>
</mat-card>
<button *ngIf="dmpId" mat-fab class="mat-fab-bottom-right" color="primary" [routerLink]="['/datasets/new/'+dmpId] ">
<mat-icon class="mat-24">add</mat-icon>
</button>
<button *ngIf="!dmpId" mat-fab class="mat-fab-bottom-right" color="primary" [routerLink]="['/datasets/new'] ">
<mat-icon class="mat-24">add</mat-icon>
</button>
</div> </div>

View File

@ -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;

View File

@ -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
} }

View File

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

View File

@ -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",