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) {
if (principal.getId() == null) query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
else {
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)));
query.where((builder, root) -> builder.or(builder.equal(root.get("dmp").get("creator"), principal), builder.isMember(principal, root.get("dmp").get("users"))));
}
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"));
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;
@ -62,8 +62,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
return SAVED;
case 1:
return FINALISED;
case 2:
return WITHDRAWN;
case 99:
return DELETED;
default:

View File

@ -1,6 +1,7 @@
package eu.eudat.data.query.items.table.dataset;
import eu.eudat.data.dao.criteria.DatasetPublicCriteria;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
@ -19,6 +20,8 @@ public class DatasetPublicTableRequest extends TableQuery<DatasetPublicCriteria,
@Override
public QueryableList<Dataset> applyCriteria() {
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.<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)));

View File

@ -172,12 +172,6 @@ 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

@ -344,7 +344,6 @@ public class DatasetManager {
eu.eudat.data.entities.Dataset dataset = datasetDao.find(id);
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");
dataset.setPublic(true);
datasetDao.createOrUpdate(dataset);
}

View File

@ -35,12 +35,6 @@
<mat-cell *matCellDef="let row"> {{row.profile}} </mat-cell>
</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 -->
<!-- <ng-container cdkColumnDef="dataRepositories">
<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;
dataSource: DatasetDataSource | null;
displayedColumns: String[] = ['label', 'project', 'profile', 'status', 'description', 'created'];
displayedColumns: String[] = ['label', 'project', 'profile', 'description', 'created'];
pageEvent: PageEvent;
titlePrefix: String;
dmpId: string;

View File

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

View File

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

View File

@ -35,7 +35,7 @@ export class DatasetListingComponent implements OnInit, IBreadCrumbComponent {
breadCrumbs: Observable<BreadcrumbItem[]>;
dataSource: DatasetDataSource | null;
displayedColumns: String[] = ['label', 'project', 'dmp', 'profile', 'status', 'description', 'created', 'actions'];
displayedColumns: String[] = ['label', 'project', 'dmp', 'profile', 'status', 'description', 'created'];
pageEvent: PageEvent;
titlePrefix: String;
dmpId: string;

View File

@ -17,7 +17,6 @@ import { TagModel } from '../tags/TagModel';
export enum DatasetStatus {
Draft = 0,
Finalised = 1,
WithDrawn = 2,
Deleted = 99
}

View File

@ -39,7 +39,6 @@ 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,8 +285,7 @@
},
"DATASET-STATUS": {
"DRAFT": "Draft",
"FINALISED": "Finalised",
"WITHDRAWN": "Withdrawn"
"FINALISED": "Finalised"
},
"EXTERNAL-DATASET-TYPE": {
"SOURCE": "Source",