From ab73f2ad62a70a8b392afd43b343397611cc2374 Mon Sep 17 00:00:00 2001 From: Ioannis Kalyvas Date: Fri, 2 Feb 2018 13:09:38 +0200 Subject: [PATCH 1/4] no message --- .../DataManagementPlanListingModel.java | 12 ++++++------ .../app/dmps/listing/dmp-listing.component.html | 14 +++++++------- .../src/app/dmps/listing/dmp-listing.component.ts | 5 ++++- .../DataManagementPlanListingModel.ts | 4 ++-- dmp-frontend/src/assets/lang/en.json | 2 +- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/dmp-backend/src/main/java/eu/eudat/models/listingmodels/DataManagementPlanListingModel.java b/dmp-backend/src/main/java/eu/eudat/models/listingmodels/DataManagementPlanListingModel.java index b10ab6a5f..8cbdd317f 100644 --- a/dmp-backend/src/main/java/eu/eudat/models/listingmodels/DataManagementPlanListingModel.java +++ b/dmp-backend/src/main/java/eu/eudat/models/listingmodels/DataManagementPlanListingModel.java @@ -18,7 +18,7 @@ public class DataManagementPlanListingModel implements DataModel { private String label; private String project; private String profile; - private String researchers; + private String creationTime; private String organisations; private String version; private Integer numOfDatasets; @@ -55,12 +55,12 @@ public class DataManagementPlanListingModel implements DataModel { this.profile = profile; } - public String getResearchers() { - return researchers; + public String getCreationTime() { + return creationTime; } - public void setResearchers(String researchers) { - this.researchers = researchers; + public void setCreationTime(String creationTime) { + this.creationTime = creationTime; } public String getOrganisations() { @@ -94,7 +94,7 @@ public class DataManagementPlanListingModel implements DataModel { this.project = entity.getProject().getLabel(); if(entity.getProfile()!=null)this.profile = entity.getProfile().getLabel(); this.organisations =LabelBuilder.getLabel(new DomainModelConverter().fromDataModel(entity.getOrganisations().stream().collect(Collectors.toList()),Organisation.class)); - this.researchers =LabelBuilder.getLabel(new DomainModelConverter().fromDataModel(entity.getResearchers().stream().collect(Collectors.toList()),Researcher.class)); + this.creationTime = entity.getCreated().toString(); this.version = ""+entity.getVersion(); this.numOfDatasets = entity.getDataset().size(); } diff --git a/dmp-frontend/src/app/dmps/listing/dmp-listing.component.html b/dmp-frontend/src/app/dmps/listing/dmp-listing.component.html index 797fa99fa..94bed3d58 100644 --- a/dmp-frontend/src/app/dmps/listing/dmp-listing.component.html +++ b/dmp-frontend/src/app/dmps/listing/dmp-listing.component.html @@ -11,13 +11,13 @@ - {{'DMP-LISTING.COLUMNS.NAME' | translate}} + {{'DMP-LISTING.COLUMNS.NAME' | translate}} {{row.label}} - {{'DMP-LISTING.COLUMNS.PROJECT' | translate}} + {{'DMP-LISTING.COLUMNS.PROJECT' | translate}} {{row.project}} @@ -28,9 +28,9 @@ --> - - {{'DMP-LISTING.COLUMNS.RESEARCHERS' | translate}} - {{row.researchers}} + + {{'DMP-LISTING.COLUMNS.CREATION-TIME' | translate}} + {{row.creationTime | date:'shortDate'}} @@ -41,13 +41,13 @@ - {{'DMP-LISTING.COLUMNS.VERSION' | translate}} + {{'DMP-LISTING.COLUMNS.VERSION' | translate}} {{row.version}} - {{'DMP-LISTING.COLUMNS.DATASETS' | translate}} + {{'DMP-LISTING.COLUMNS.DATASETS' | translate}} {{row.numOfDatasets}} diff --git a/dmp-frontend/src/app/dmps/listing/dmp-listing.component.ts b/dmp-frontend/src/app/dmps/listing/dmp-listing.component.ts index 827604c24..32dbabb30 100644 --- a/dmp-frontend/src/app/dmps/listing/dmp-listing.component.ts +++ b/dmp-frontend/src/app/dmps/listing/dmp-listing.component.ts @@ -22,13 +22,14 @@ import { Observable } from "rxjs/Observable"; providers: [DataManagementPlanService] }) export class DataManagementPlanListingComponent implements OnInit { + @ViewChild(MatPaginator) _paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; @ViewChild(DataManagementPlanCriteriaComponent) criteria: DataManagementPlanCriteriaComponent; dataSource: DataManagementPlanDataSource | null; - displayedColumns: String[] = ['name', 'project', 'researchers', 'organisations', 'version', 'numOfDatasets', 'actions']; + displayedColumns: String[] = ['name', 'project', 'creationTime', 'organisations', 'version', 'numOfDatasets', 'actions']; constructor( private dataManagementPlanService: DataManagementPlanService, @@ -46,6 +47,8 @@ export class DataManagementPlanListingComponent implements OnInit { this.criteria.setRefreshCallback(() => this.refresh()); } + + refresh() { this.dataSource = new DataManagementPlanDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, ); } diff --git a/dmp-frontend/src/app/models/data-managemnt-plans/DataManagementPlanListingModel.ts b/dmp-frontend/src/app/models/data-managemnt-plans/DataManagementPlanListingModel.ts index 8930e9e09..81c85b2e8 100644 --- a/dmp-frontend/src/app/models/data-managemnt-plans/DataManagementPlanListingModel.ts +++ b/dmp-frontend/src/app/models/data-managemnt-plans/DataManagementPlanListingModel.ts @@ -5,7 +5,7 @@ export class DataManagementPlanListingModel implements Serializable Date: Fri, 2 Feb 2018 17:24:06 +0200 Subject: [PATCH 2/4] no message --- .../src/main/java/eu/eudat/entities/DMP.java | 2 +- .../eu/eudat/managers/PaginationManager.java | 41 +++++++++++++++--- .../helpers/common/ColumnOrderings.java | 9 ++-- .../eudat/models/helpers/common/Ordering.java | 43 +++++++++++++++---- .../eu/eudat/queryable/QueryableList.java | 4 +- .../QueryableHibernateList.java | 23 ++++++---- .../predicates/OrderByPredicate.java | 2 +- .../listing/dataset-listing.component.ts | 16 ++++--- .../dmps/listing/dmp-listing.component.html | 12 +++--- .../app/dmps/listing/dmp-listing.component.ts | 8 ++-- .../app/models/data-table/ColumnOrderings.ts | 3 ++ .../app/models/data-table/DataTableRequest.ts | 6 ++- .../listing/project-listing.component.ts | 4 +- .../app/users/components/users.component.ts | 4 +- 14 files changed, 125 insertions(+), 52 deletions(-) create mode 100644 dmp-frontend/src/app/models/data-table/ColumnOrderings.ts diff --git a/dmp-backend/src/main/java/eu/eudat/entities/DMP.java b/dmp-backend/src/main/java/eu/eudat/entities/DMP.java index 2a6d665d4..68bebb450 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/DMP.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/DMP.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators; @NamedEntityGraph( name = "dataManagementPlanListingModel", attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"), - @NamedAttributeNode("project"), @NamedAttributeNode("profile")} + @NamedAttributeNode("project"), @NamedAttributeNode("profile"),@NamedAttributeNode("dataset")} ), @NamedEntityGraph( name = "fullyDetailed", diff --git a/dmp-backend/src/main/java/eu/eudat/managers/PaginationManager.java b/dmp-backend/src/main/java/eu/eudat/managers/PaginationManager.java index 4d4a94bda..7d644b9ac 100644 --- a/dmp-backend/src/main/java/eu/eudat/managers/PaginationManager.java +++ b/dmp-backend/src/main/java/eu/eudat/managers/PaginationManager.java @@ -6,21 +6,48 @@ import eu.eudat.models.helpers.common.Ordering; import eu.eudat.models.helpers.requests.TableRequest; import eu.eudat.queryable.QueryableList; +import java.util.Collection; + public class PaginationManager { public static > QueryableList applyPaging(QueryableList items, TableRequest tableRequest) throws Exception { - if(tableRequest.getOrderings()!=null) applyOrder(items,tableRequest); - if(tableRequest.getLength()!=null)items.take(tableRequest.getLength()); - if(tableRequest.getOffset()!=null)items.skip(tableRequest.getOffset()); + if (tableRequest.getOrderings() != null) applyOrder(items, tableRequest); + if (tableRequest.getLength() != null) items.take(tableRequest.getLength()); + if (tableRequest.getOffset() != null) items.skip(tableRequest.getOffset()); return items; } - public static > void applyOrder(QueryableList items, TableRequest tableRequest) throws Exception { + public static > void applyOrder(QueryableList items, TableRequest tableRequest) throws Exception { ColumnOrderings columnOrderings = tableRequest.getOrderings(); - for(Ordering ordering:columnOrderings.getFieldOrderings()){ - if(ordering.getType() == Ordering.OrderByType.ASC) items.orderByAsc(root -> root.get(ordering.getFieldName())); - if(ordering.getType() == Ordering.OrderByType.DESC) items.orderByDesc(root -> root.get(ordering.getFieldName())); + for (Ordering ordering : columnOrderings.getFieldOrderings()) { + if (ordering.getOrderByType() == Ordering.OrderByType.ASC) + applyAscOrder(items,ordering); + if (ordering.getOrderByType() == Ordering.OrderByType.DESC) { + applyDescOrder(items,ordering); + } } return; } + + private static > void applyAscOrder(QueryableList items, Ordering ordering) { + if (ordering.getColumnType() == Ordering.ColumnType.COUNT) { + items.orderBy((builder, root) -> builder.asc(builder.size(root.get(ordering.getFieldName())))); + } else if (ordering.getColumnType() == Ordering.ColumnType.JOIN_COLUMN) { + String[] fields = ordering.getFieldName().split(":"); + items.orderBy((builder, root) -> builder.asc(root.get(fields[0]).get(fields[1]))); + } else { + items.orderBy((builder, root) -> builder.asc(root.get(ordering.getFieldName()))); + } + } + + private static > void applyDescOrder(QueryableList items, Ordering ordering) { + if (ordering.getColumnType() == Ordering.ColumnType.COUNT) { + items.orderBy((builder, root) -> builder.desc(builder.size(root.get(ordering.getFieldName())))); + } else if (ordering.getColumnType() == Ordering.ColumnType.JOIN_COLUMN) { + String[] fields = ordering.getFieldName().split(":"); + items.orderBy((builder, root) -> builder.desc(root.get(fields[0]).get(fields[1]))); + } else { + items.orderBy((builder, root) -> builder.desc(root.get(ordering.getFieldName()))); + } + } } diff --git a/dmp-backend/src/main/java/eu/eudat/models/helpers/common/ColumnOrderings.java b/dmp-backend/src/main/java/eu/eudat/models/helpers/common/ColumnOrderings.java index 504669e36..e8c03d728 100644 --- a/dmp-backend/src/main/java/eu/eudat/models/helpers/common/ColumnOrderings.java +++ b/dmp-backend/src/main/java/eu/eudat/models/helpers/common/ColumnOrderings.java @@ -25,8 +25,11 @@ public class ColumnOrderings { } private Ordering orderingFromString(String field) throws Exception { - if(field.startsWith("+")) return new Ordering(field.replace("+",""), Ordering.OrderByType.ASC); - else if(field.startsWith("-")) return new Ordering(field.replace("-",""), Ordering.OrderByType.DESC); - else throw new Exception("Unsupported Field Order Type"); + Ordering ordering = new Ordering(field); + if(ordering.getFieldName().contains("+")) ordering.fieldName(ordering.getFieldName().replace("+","")).orderByType(Ordering.OrderByType.ASC); + else if(ordering.getFieldName().startsWith("-")) ordering.fieldName(ordering.getFieldName().replace("-","")).orderByType(Ordering.OrderByType.DESC); + if(ordering.getFieldName().contains("|count|")) ordering.fieldName(ordering.getFieldName().replace("|count|","")).columnType(Ordering.ColumnType.COUNT); + else if(ordering.getFieldName().contains("|join|")) ordering.fieldName(ordering.getFieldName().replace("|join|","")).columnType(Ordering.ColumnType.JOIN_COLUMN); + return ordering; } } diff --git a/dmp-backend/src/main/java/eu/eudat/models/helpers/common/Ordering.java b/dmp-backend/src/main/java/eu/eudat/models/helpers/common/Ordering.java index 9109ba2cb..c904ee008 100644 --- a/dmp-backend/src/main/java/eu/eudat/models/helpers/common/Ordering.java +++ b/dmp-backend/src/main/java/eu/eudat/models/helpers/common/Ordering.java @@ -6,12 +6,16 @@ public class Ordering { ASC, DESC } - private String fieldName; - private OrderByType type; + public enum ColumnType { + COUNT, COLUMN , JOIN_COLUMN + } - public Ordering(String fieldName, OrderByType type) { + private String fieldName; + private OrderByType orderByType; + private ColumnType columnType; + + public Ordering(String fieldName) { this.fieldName = fieldName; - this.type = type; } public String getFieldName() { @@ -22,11 +26,34 @@ public class Ordering { this.fieldName = fieldName; } - public OrderByType getType() { - return type; + public OrderByType getOrderByType() { + return orderByType; } - public void setType(OrderByType type) { - this.type = type; + public void setOrderByType(OrderByType orderByType) { + this.orderByType = orderByType; + } + + public Ordering fieldName(String fieldName) { + this.fieldName = fieldName; + return this; + } + + public Ordering orderByType(OrderByType orderByType) { + this.orderByType = orderByType; + return this; + } + + public ColumnType getColumnType() { + return columnType; + } + + public void setColumnType(ColumnType columnType) { + this.columnType = columnType; + } + + public Ordering columnType(ColumnType columnType) { + this.columnType = columnType; + return this; } } diff --git a/dmp-backend/src/main/java/eu/eudat/queryable/QueryableList.java b/dmp-backend/src/main/java/eu/eudat/queryable/QueryableList.java index e19ab2fd7..27e30bb97 100644 --- a/dmp-backend/src/main/java/eu/eudat/queryable/QueryableList.java +++ b/dmp-backend/src/main/java/eu/eudat/queryable/QueryableList.java @@ -27,9 +27,7 @@ public interface QueryableList> { QueryableList distinct(); - QueryableList orderByAsc(OrderByPredicate predicate); - - QueryableList orderByDesc(OrderByPredicate predicate); + QueryableList orderBy(OrderByPredicate predicate); QueryableList setHints(Set hints); diff --git a/dmp-backend/src/main/java/eu/eudat/queryable/hibernatequeryablelist/QueryableHibernateList.java b/dmp-backend/src/main/java/eu/eudat/queryable/hibernatequeryablelist/QueryableHibernateList.java index 864ac7e8f..5e73538bb 100644 --- a/dmp-backend/src/main/java/eu/eudat/queryable/hibernatequeryablelist/QueryableHibernateList.java +++ b/dmp-backend/src/main/java/eu/eudat/queryable/hibernatequeryablelist/QueryableHibernateList.java @@ -23,7 +23,7 @@ public class QueryableHibernateList> implements Queryabl private Class tClass; private Root root; private List> predicates = new LinkedList<>(); - private List orderings = new LinkedList<>(); + private List> orderings = new LinkedList<>(); private List fields = new LinkedList<>(); private Integer length; private Integer offset; @@ -93,13 +93,8 @@ public class QueryableHibernateList> implements Queryabl return this; } - public QueryableList orderByAsc(OrderByPredicate predicate) { - this.orderings.add(this.manager.getCriteriaBuilder().asc(predicate.applyPredicate(this.root))); - return this; - } - - public QueryableList orderByDesc(OrderByPredicate predicate) { - this.orderings.add(this.manager.getCriteriaBuilder().desc(predicate.applyPredicate(this.root))); + public QueryableList orderBy(OrderByPredicate predicate) { + this.orderings.add(predicate); return this; } @@ -120,10 +115,18 @@ public class QueryableHibernateList> implements Queryabl return predicates.toArray(new Predicate[predicates.size()]); } + private Order[] generateOrderPredicates(List> orderByPredicates, Root root) { + List predicates = new LinkedList<>(); + for (OrderByPredicate orderPredicate : orderByPredicates) { + predicates.add(orderPredicate.applyPredicate(this.manager.getCriteriaBuilder(), root)); + } + return predicates.toArray(new Order[predicates.size()]); + } + public List toList() { this.query.where(this.generateWherePredicates(this.predicates, this.root)); - if (!this.orderings.isEmpty()) this.query.orderBy(this.orderings); + if (!this.orderings.isEmpty()) this.query.orderBy(this.generateOrderPredicates(this.orderings, this.root)); TypedQuery typedQuery = this.manager.createQuery(this.query); if (this.offset != null) typedQuery.setFirstResult(this.offset); if (this.length != null) typedQuery.setMaxResults(this.length); @@ -156,6 +159,8 @@ public class QueryableHibernateList> implements Queryabl Root criteriaRoot = criteriaQuery.from(this.tClass); criteriaQuery.where(criteriaRoot.get("id").in(ids)); + if (!this.orderings.isEmpty()) criteriaQuery.orderBy(this.generateOrderPredicates(this.orderings, criteriaRoot)); + TypedQuery typedQuery = this.manager.createQuery(criteriaQuery); typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint)); return typedQuery; diff --git a/dmp-backend/src/main/java/eu/eudat/queryable/predicates/OrderByPredicate.java b/dmp-backend/src/main/java/eu/eudat/queryable/predicates/OrderByPredicate.java index 346bfd253..650727a3d 100644 --- a/dmp-backend/src/main/java/eu/eudat/queryable/predicates/OrderByPredicate.java +++ b/dmp-backend/src/main/java/eu/eudat/queryable/predicates/OrderByPredicate.java @@ -6,6 +6,6 @@ import javax.persistence.criteria.Path; import javax.persistence.criteria.Root; public interface OrderByPredicate { - Path applyPredicate(Root root); + Order applyPredicate(CriteriaBuilder builder, Root root); } diff --git a/dmp-frontend/src/app/datasets/listing/dataset-listing.component.ts b/dmp-frontend/src/app/datasets/listing/dataset-listing.component.ts index 4f7abec1c..13f7ddfbf 100644 --- a/dmp-frontend/src/app/datasets/listing/dataset-listing.component.ts +++ b/dmp-frontend/src/app/datasets/listing/dataset-listing.component.ts @@ -1,3 +1,4 @@ +import { Field } from '../../models/Field'; import { DataTableRequest } from '../../models/data-table/DataTableRequest'; import { DatasetListingModel } from '../../models/datasets/DatasetListingModel'; import { DatasetCriteria } from '../../models/criteria/dataset/DatasetCriteria'; @@ -54,7 +55,7 @@ export class DatasetListingComponent implements OnInit { ngOnInit() { this.route.params.subscribe((params: Params) => { this.dmpId = params['dmpId']; - if(this.dmpId != null) this.setDmpTitle(this.dmpId); + if (this.dmpId != null) this.setDmpTitle(this.dmpId); this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId)); this.refresh(); this.criteria.setRefreshCallback(() => this.refresh()); @@ -63,9 +64,9 @@ export class DatasetListingComponent implements OnInit { setDmpTitle(dmpId: String) { this.dataManagementPlanService.getSingle(dmpId).map(data => data as DataManagementPlanModel) - .subscribe(data => { - this.titlePrefix = data.label; - }); + .subscribe(data => { + this.titlePrefix = data.label; + }); } refresh() { @@ -84,7 +85,8 @@ export class DatasetListingComponent implements OnInit { return defaultCriteria; } - makeItPublic(id:String){debugger; + makeItPublic(id: String) { + debugger; this.datasetService.makeDatasetPublic(id).subscribe(); } @@ -121,7 +123,9 @@ export class DatasetDataSource extends DataSource { this.isLoadingResults = true; }); const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - const request = new DataTableRequest(startIndex, this._paginator.pageSize); + let fields: Array = new Array() + if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active]; + const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); request.criteria = this._criteria.criteria; return this._service.getPaged(request); }) diff --git a/dmp-frontend/src/app/dmps/listing/dmp-listing.component.html b/dmp-frontend/src/app/dmps/listing/dmp-listing.component.html index 94bed3d58..d5fb341bb 100644 --- a/dmp-frontend/src/app/dmps/listing/dmp-listing.component.html +++ b/dmp-frontend/src/app/dmps/listing/dmp-listing.component.html @@ -6,18 +6,18 @@ - + - {{'DMP-LISTING.COLUMNS.NAME' | translate}} + {{'DMP-LISTING.COLUMNS.NAME' | translate}} {{row.label}} - {{'DMP-LISTING.COLUMNS.PROJECT' | translate}} + {{'DMP-LISTING.COLUMNS.PROJECT' | translate}} {{row.project}} @@ -29,7 +29,7 @@ - {{'DMP-LISTING.COLUMNS.CREATION-TIME' | translate}} + {{'DMP-LISTING.COLUMNS.CREATION-TIME' | translate}} {{row.creationTime | date:'shortDate'}} @@ -41,13 +41,13 @@ - {{'DMP-LISTING.COLUMNS.VERSION' | translate}} + {{'DMP-LISTING.COLUMNS.VERSION' | translate}} {{row.version}} - {{'DMP-LISTING.COLUMNS.DATASETS' | translate}} + {{'DMP-LISTING.COLUMNS.DATASETS' | translate}} {{row.numOfDatasets}} diff --git a/dmp-frontend/src/app/dmps/listing/dmp-listing.component.ts b/dmp-frontend/src/app/dmps/listing/dmp-listing.component.ts index 32dbabb30..e9f3ac3ae 100644 --- a/dmp-frontend/src/app/dmps/listing/dmp-listing.component.ts +++ b/dmp-frontend/src/app/dmps/listing/dmp-listing.component.ts @@ -22,7 +22,7 @@ import { Observable } from "rxjs/Observable"; providers: [DataManagementPlanService] }) export class DataManagementPlanListingComponent implements OnInit { - + @ViewChild(MatPaginator) _paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; @@ -47,8 +47,6 @@ export class DataManagementPlanListingComponent implements OnInit { this.criteria.setRefreshCallback(() => this.refresh()); } - - refresh() { this.dataSource = new DataManagementPlanDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, ); } @@ -114,7 +112,9 @@ export class DataManagementPlanDataSource extends DataSource(startIndex, this._paginator.pageSize); + let fields: Array = new Array() + if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active]; + const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); request.criteria = this._criteria.criteria; return this._service.getPaged(request); }) diff --git a/dmp-frontend/src/app/models/data-table/ColumnOrderings.ts b/dmp-frontend/src/app/models/data-table/ColumnOrderings.ts new file mode 100644 index 000000000..0d3e445b7 --- /dev/null +++ b/dmp-frontend/src/app/models/data-table/ColumnOrderings.ts @@ -0,0 +1,3 @@ +export class ColumnOrderings{ + public fields:Array = new Array(); +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/data-table/DataTableRequest.ts b/dmp-frontend/src/app/models/data-table/DataTableRequest.ts index b85da378f..00ec8dcef 100644 --- a/dmp-frontend/src/app/models/data-table/DataTableRequest.ts +++ b/dmp-frontend/src/app/models/data-table/DataTableRequest.ts @@ -1,13 +1,15 @@ +import { ColumnOrderings } from './ColumnOrderings'; import { BaseCriteria } from "../criteria/BaseCriteria"; import { RequestItem } from "../criteria/RequestItem"; export class DataTableRequest extends RequestItem { offset = 0; length = 0; - - constructor(offset: number, length: number) { + public orderings: ColumnOrderings; + constructor(offset: number, length: number, orderings: ColumnOrderings) { super(); this.length = length; this.offset = offset; + this.orderings = orderings; } } diff --git a/dmp-frontend/src/app/projects/listing/project-listing.component.ts b/dmp-frontend/src/app/projects/listing/project-listing.component.ts index e20003bb7..e95751e62 100644 --- a/dmp-frontend/src/app/projects/listing/project-listing.component.ts +++ b/dmp-frontend/src/app/projects/listing/project-listing.component.ts @@ -93,7 +93,9 @@ export class ProjectDataSource extends DataSource { this.isLoadingResults = true; }); const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - const request = new DataTableRequest(startIndex, this._paginator.pageSize); + let fields: Array = new Array() + if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active]; + const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); request.criteria = this._criteria.criteria; return this._service.getPaged(request); }) diff --git a/dmp-frontend/src/app/users/components/users.component.ts b/dmp-frontend/src/app/users/components/users.component.ts index 502c785bc..32e5bc47f 100644 --- a/dmp-frontend/src/app/users/components/users.component.ts +++ b/dmp-frontend/src/app/users/components/users.component.ts @@ -53,7 +53,9 @@ export class UsersDataSource extends DataSource { this.isLoadingResults = true; }); const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - const request = new DataTableRequest(startIndex, this._paginator.pageSize); + let fields: Array = new Array() + if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active]; + const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); request.criteria = this._criteria.getFormData(); return this._service.getPaged(request); }) From c36fa5e6f8f9126de5117afb0566fc6899001c9f Mon Sep 17 00:00:00 2001 From: Ioannis Kalyvas Date: Fri, 2 Feb 2018 17:24:30 +0200 Subject: [PATCH 3/4] no message --- .../datasets/listing/dataset-listing.component.html | 10 +++++----- .../projects/listing/project-listing.component.html | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dmp-frontend/src/app/datasets/listing/dataset-listing.component.html b/dmp-frontend/src/app/datasets/listing/dataset-listing.component.html index fec878524..d950b8246 100644 --- a/dmp-frontend/src/app/datasets/listing/dataset-listing.component.html +++ b/dmp-frontend/src/app/datasets/listing/dataset-listing.component.html @@ -7,23 +7,23 @@ - + - {{'DATASET-LISTING.COLUMNS.NAME' | translate}} + {{'DATASET-LISTING.COLUMNS.NAME' | translate}} {{row.label}} - {{'DATASET-LISTING.COLUMNS.DMP' | translate}} + {{'DATASET-LISTING.COLUMNS.DMP' | translate}} {{row.dmp}} - {{'DATASET-LISTING.COLUMNS.PROFILE' | translate}} + {{'DATASET-LISTING.COLUMNS.PROFILE' | translate}} {{row.profile}} @@ -60,7 +60,7 @@ - {{'DATASET-LISTING.COLUMNS.CREATED' | translate}} + {{'DATASET-LISTING.COLUMNS.CREATED' | translate}} {{row.created | date:'shortDate'}} diff --git a/dmp-frontend/src/app/projects/listing/project-listing.component.html b/dmp-frontend/src/app/projects/listing/project-listing.component.html index 4811b5a99..509047b02 100644 --- a/dmp-frontend/src/app/projects/listing/project-listing.component.html +++ b/dmp-frontend/src/app/projects/listing/project-listing.component.html @@ -7,29 +7,29 @@ - + - {{'PROJECT-LISTING.COLUMNS.NAME' | translate}} + {{'PROJECT-LISTING.COLUMNS.NAME' | translate}} {{row.label}} - {{'PROJECT-LISTING.COLUMNS.ABBREVIATION' | translate}} + {{'PROJECT-LISTING.COLUMNS.ABBREVIATION' | translate}} {{row.abbreviation}} - {{'PROJECT-LISTING.COLUMNS.START' | translate}} + {{'PROJECT-LISTING.COLUMNS.START' | translate}} {{row.startDate | date:'shortDate'}} - {{'PROJECT-LISTING.COLUMNS.END' | translate}} + {{'PROJECT-LISTING.COLUMNS.END' | translate}} {{row.endDate | date:'shortDate'}} From e437ae354e73e45894959ab1d7f2040f17ea3c19 Mon Sep 17 00:00:00 2001 From: Ioannis Kalyvas Date: Fri, 2 Feb 2018 18:21:46 +0200 Subject: [PATCH 4/4] no message --- .../eu/eudat/dao/entities/ProjectDaoImpl.java | 80 ++++++++++--------- .../src/main/java/eu/eudat/entities/DMP.java | 1 + .../managers/DataManagementPlanManager.java | 6 +- .../models/criteria/ProjectCriteria.java | 10 ++- .../java/eu/eudat/models/project/Project.java | 6 +- 5 files changed, 57 insertions(+), 46 deletions(-) diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/ProjectDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/ProjectDaoImpl.java index fc60106c0..899b95084 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/ProjectDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/ProjectDaoImpl.java @@ -1,6 +1,7 @@ package eu.eudat.dao.entities; import java.util.UUID; + import eu.eudat.dao.DatabaseAccess; import eu.eudat.dao.databaselayer.service.DatabaseService; import eu.eudat.entities.*; @@ -13,48 +14,53 @@ import org.springframework.stereotype.Component; @Component("projectDao") public class ProjectDaoImpl extends DatabaseAccess implements ProjectDao { - @Autowired - public ProjectDaoImpl(DatabaseService databaseService) { - this.setDatabaseService(databaseService); - } + @Autowired + public ProjectDaoImpl(DatabaseService databaseService) { + this.setDatabaseService(databaseService); + } - @Override - public QueryableList getWithCriteria(ProjectCriteria criteria) { - QueryableList query = getDatabaseService().getQueryable(Project.class); - if(criteria.getLike()!=null&&!criteria.getLike().isEmpty())query.where((builder, root) -> builder.like(root.get("label"),"%"+criteria.getLike()+"%")); - if(criteria.getPeriodEnd()!=null)query.where((builder, root) -> builder.lessThan(root.get("enddate"),criteria.getPeriodEnd())); - if(criteria.getPeriodStart()!=null)query.where((builder, root) -> builder.greaterThan(root.get("startdate"),criteria.getPeriodStart())); - query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue())); - return query; - } + @Override + public QueryableList getWithCriteria(ProjectCriteria criteria) { + QueryableList query = getDatabaseService().getQueryable(Project.class); + if (criteria.getLike() != null && !criteria.getLike().isEmpty()) + query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%")); + if (criteria.getPeriodEnd() != null) + query.where((builder, root) -> builder.lessThan(root.get("enddate"), criteria.getPeriodEnd())); + if (criteria.getPeriodStart() != null) + query.where((builder, root) -> builder.greaterThan(root.get("startdate"), criteria.getPeriodStart())); + if (criteria.getReference() != null) + query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getReference())); + query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue())); + return query; + } - @Override - public Project createOrUpdate(Project item) { - return getDatabaseService().createOrUpdate(item,Project.class); - } + @Override + public Project createOrUpdate(Project item) { + return getDatabaseService().createOrUpdate(item, Project.class); + } - @Override - public Project find(UUID id) { - return getDatabaseService().getQueryable(Project.class).where((builder, root) -> builder.equal((root.get("id")),id)).getSingle(); - } + @Override + public Project find(UUID id) { + return getDatabaseService().getQueryable(Project.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle(); + } - @Override - public Long count() { - return this.getDatabaseService().count(Project.class); - } + @Override + public Long count() { + return this.getDatabaseService().count(Project.class); + } - @Override - public void delete(Project item) { - this.getDatabaseService().delete(item); - } + @Override + public void delete(Project item) { + this.getDatabaseService().delete(item); + } - @Override - public QueryableList asQueryable() { - return this.getDatabaseService().getQueryable(Project.class); - } + @Override + public QueryableList asQueryable() { + return this.getDatabaseService().getQueryable(Project.class); + } - public QueryableList getAuthenticated(QueryableList query, UserInfo principal) { - query.where((builder, root) -> builder.equal(root.get("creator"), principal)); - return query; - } + public QueryableList getAuthenticated(QueryableList query, UserInfo principal) { + query.where((builder, root) -> builder.equal(root.get("creator"), principal)); + return query; + } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/DMP.java b/dmp-backend/src/main/java/eu/eudat/entities/DMP.java index 68bebb450..acc9935ca 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/DMP.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/DMP.java @@ -258,6 +258,7 @@ public class DMP implements Serializable, DataEntity { this.label = entity.getLabel(); this.status = entity.getStatus(); this.created = entity.created; + this.project = entity.getProject(); this.description = entity.getDescription(); this.researchers = entity.getResearchers(); this.organisations = entity.getOrganisations(); diff --git a/dmp-backend/src/main/java/eu/eudat/managers/DataManagementPlanManager.java b/dmp-backend/src/main/java/eu/eudat/managers/DataManagementPlanManager.java index e7d26aa5b..374094630 100644 --- a/dmp-backend/src/main/java/eu/eudat/managers/DataManagementPlanManager.java +++ b/dmp-backend/src/main/java/eu/eudat/managers/DataManagementPlanManager.java @@ -106,9 +106,9 @@ public class DataManagementPlanManager { if (newDmp.getProject() != null) { Project project = newDmp.getProject(); ProjectCriteria criteria = new ProjectCriteria(); - criteria.setLike(project.getReference()); - List entries = projectDao.getWithCriteria(criteria).toList(); - if (entries != null && !entries.isEmpty()) project.setId(entries.get(0).getId()); + criteria.setReference(project.getReference()); + eu.eudat.entities.Project projectEntity = projectDao.getWithCriteria(criteria).getSingleOrDefault(); + if (projectEntity != null) project.setId(projectEntity.getId()); else { project.setCreationUser(userInfo); projectDao.createOrUpdate(project); diff --git a/dmp-backend/src/main/java/eu/eudat/models/criteria/ProjectCriteria.java b/dmp-backend/src/main/java/eu/eudat/models/criteria/ProjectCriteria.java index 9255fffef..e8b1216d7 100644 --- a/dmp-backend/src/main/java/eu/eudat/models/criteria/ProjectCriteria.java +++ b/dmp-backend/src/main/java/eu/eudat/models/criteria/ProjectCriteria.java @@ -7,7 +7,7 @@ import java.util.Date; public class ProjectCriteria extends Criteria{ private Date periodStart; private Date periodEnd; - + private String reference; public Date getPeriodStart() { return periodStart; } @@ -23,4 +23,12 @@ public class ProjectCriteria extends Criteria{ public void setPeriodEnd(Date periodEnd) { this.periodEnd = periodEnd; } + + public String getReference() { + return reference; + } + + public void setReference(String reference) { + this.reference = reference; + } } diff --git a/dmp-backend/src/main/java/eu/eudat/models/project/Project.java b/dmp-backend/src/main/java/eu/eudat/models/project/Project.java index 8bba817b1..d6dfb2876 100644 --- a/dmp-backend/src/main/java/eu/eudat/models/project/Project.java +++ b/dmp-backend/src/main/java/eu/eudat/models/project/Project.java @@ -12,9 +12,6 @@ import eu.eudat.models.dmp.DataManagementPlan; public class Project implements DataModel { - - - private UUID id; private List dmps; @@ -170,7 +167,6 @@ public class Project implements DataModel { this.created = entity.getCreated(); this.modified = entity.getModified(); this.description = entity.getDescription(); - } @Override @@ -179,7 +175,7 @@ public class Project implements DataModel { entity.setId(this.id); entity.setAbbreviation(this.abbreviation); entity.setLabel(this.label); - entity.setReference(this.reference); + entity.setReference(this.reference == null ? "dmp:"+this.label : this.reference); entity.setUri(this.uri); entity.setDefinition(this.definition); entity.setStartdate(this.startDate);