From 39f124cd63528bcd091640b3bfde0d9396a84686 Mon Sep 17 00:00:00 2001 From: Ioannis Kalyvas Date: Tue, 20 Feb 2018 09:50:17 +0200 Subject: [PATCH] no message --- .../src/main/java/eu/eudat/dao/DatabaseAccess.java | 2 +- .../main/java/eu/eudat/dao/DatabaseAccessLayer.java | 2 +- .../dao/databaselayer/context/DatabaseContext.java | 6 +++--- .../dao/databaselayer/service/DatabaseService.java | 2 +- .../src/main/java/eu/eudat/dao/entities/DMPDao.java | 1 - .../main/java/eu/eudat/dao/entities/DMPDaoImpl.java | 4 ---- .../main/java/eu/eudat/dao/entities/DatasetDao.java | 1 - .../java/eu/eudat/dao/entities/DatasetDaoImpl.java | 5 ----- .../main/java/eu/eudat/dao/entities/ProjectDao.java | 1 - .../java/eu/eudat/dao/entities/ProjectDaoImpl.java | 5 ----- .../src/main/java/eu/eudat/entities/Credential.java | 6 +++--- .../src/main/java/eu/eudat/entities/DMP.java | 6 +++--- .../java/eu/eudat/entities/DMPOrganisation.java | 2 +- .../src/main/java/eu/eudat/entities/DataEntity.java | 4 ++-- .../main/java/eu/eudat/entities/DataRepository.java | 6 +++--- .../src/main/java/eu/eudat/entities/Dataset.java | 6 +++--- .../main/java/eu/eudat/entities/DatasetProfile.java | 6 +++--- .../eu/eudat/entities/DatasetProfileRuleset.java | 2 +- .../java/eu/eudat/entities/DatasetRegistry.java | 2 +- .../main/java/eu/eudat/entities/DatasetService.java | 2 +- .../java/eu/eudat/entities/ExternalDataset.java | 6 +++--- .../src/main/java/eu/eudat/entities/Invitation.java | 6 +++--- .../main/java/eu/eudat/entities/Organisation.java | 6 +++--- .../src/main/java/eu/eudat/entities/Project.java | 6 +++--- .../src/main/java/eu/eudat/entities/Registry.java | 6 +++--- .../src/main/java/eu/eudat/entities/Researcher.java | 6 +++--- .../src/main/java/eu/eudat/entities/Service.java | 6 +++--- .../src/main/java/eu/eudat/entities/UserDMP.java | 6 +++--- .../src/main/java/eu/eudat/entities/UserInfo.java | 6 +++--- .../src/main/java/eu/eudat/entities/UserRole.java | 6 +++--- .../src/main/java/eu/eudat/entities/UserToken.java | 6 +++--- .../java/eu/eudat/managers/DashBoardManager.java | 6 +++--- .../java/eu/eudat/managers/PaginationManager.java | 8 ++++---- .../main/java/eu/eudat/queryable/QueryableList.java | 2 +- .../QueryableHibernateList.java | 13 ++++++------- 35 files changed, 74 insertions(+), 92 deletions(-) diff --git a/dmp-backend/src/main/java/eu/eudat/dao/DatabaseAccess.java b/dmp-backend/src/main/java/eu/eudat/dao/DatabaseAccess.java index e5f7aaa32..94d45316c 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/DatabaseAccess.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/DatabaseAccess.java @@ -4,7 +4,7 @@ import eu.eudat.dao.databaselayer.service.DatabaseService; import eu.eudat.entities.DataEntity; -public class DatabaseAccess> { +public class DatabaseAccess { private DatabaseService databaseService; public DatabaseService getDatabaseService() { diff --git a/dmp-backend/src/main/java/eu/eudat/dao/DatabaseAccessLayer.java b/dmp-backend/src/main/java/eu/eudat/dao/DatabaseAccessLayer.java index 44f179f0e..f094ea6dc 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/DatabaseAccessLayer.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/DatabaseAccessLayer.java @@ -4,7 +4,7 @@ package eu.eudat.dao; import eu.eudat.entities.DataEntity; import eu.eudat.queryable.QueryableList; -public interface DatabaseAccessLayer, I> { +public interface DatabaseAccessLayer { T createOrUpdate(T item); T find(I id); diff --git a/dmp-backend/src/main/java/eu/eudat/dao/databaselayer/context/DatabaseContext.java b/dmp-backend/src/main/java/eu/eudat/dao/databaselayer/context/DatabaseContext.java index a72ed4c77..6d1d4c820 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/databaselayer/context/DatabaseContext.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/databaselayer/context/DatabaseContext.java @@ -13,7 +13,7 @@ import javax.persistence.PersistenceContext; @Repository("databaseCtx") -public class DatabaseContext> { +public class DatabaseContext { @PersistenceContext private EntityManager entityManager; @@ -30,8 +30,8 @@ public class DatabaseContext> { @Transactional public T createOrUpdate(T item, Class type) { EntityManager entityManager = this.entityManager; - if (item.getKeys()[0] != null) { - T oldItem = entityManager.find(type, item.getKeys()[0]); + if (item.getKeys() != null) { + T oldItem = entityManager.find(type, item.getKeys()); if (oldItem != null) { oldItem.update(item); entityManager.merge(oldItem); diff --git a/dmp-backend/src/main/java/eu/eudat/dao/databaselayer/service/DatabaseService.java b/dmp-backend/src/main/java/eu/eudat/dao/databaselayer/service/DatabaseService.java index b452284c8..ac997dfaf 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/databaselayer/service/DatabaseService.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/databaselayer/service/DatabaseService.java @@ -11,7 +11,7 @@ import java.util.Set; @Service("databaseService") -public class DatabaseService> { +public class DatabaseService { private DatabaseContext databaseCtx; diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/DMPDao.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/DMPDao.java index a8077a286..cfb6c1025 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/DMPDao.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/DMPDao.java @@ -17,5 +17,4 @@ public interface DMPDao extends DatabaseAccessLayer { QueryableList getAuthenticated(QueryableList query, UserInfo principal); - Long count(); } \ No newline at end of file diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/DMPDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/DMPDaoImpl.java index 959ed94ba..8f208abf1 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/DMPDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/DMPDaoImpl.java @@ -77,8 +77,4 @@ public class DMPDaoImpl extends DatabaseAccess implements DMPDao { return this.getDatabaseService().getQueryable(DMP.class); } - @Override - public Long count() { - return this.getDatabaseService().count(DMP.class); - } } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/DatasetDao.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/DatasetDao.java index f6ff6cb24..5cb766447 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/DatasetDao.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/DatasetDao.java @@ -19,5 +19,4 @@ public interface DatasetDao extends DatabaseAccessLayer { Dataset find(UUID id, String hint); - Long count(); } \ No newline at end of file diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/DatasetDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/DatasetDaoImpl.java index ca1c87710..a15177d98 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/DatasetDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/DatasetDaoImpl.java @@ -61,11 +61,6 @@ public class DatasetDaoImpl extends DatabaseAccess implements DatasetDa return query; } - @Override - public Long count() { - return this.getDatabaseService().count(Dataset.class); - } - @Override public void delete(Dataset item) { this.getDatabaseService().delete(item); diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/ProjectDao.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/ProjectDao.java index 6683ce2f0..0a2f9b6ac 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/ProjectDao.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/ProjectDao.java @@ -14,5 +14,4 @@ public interface ProjectDao extends DatabaseAccessLayer { QueryableList getAuthenticated(QueryableList query, UserInfo principal); - Long count(); } \ No newline at end of file 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 6c208ef10..74e64f236 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 @@ -44,11 +44,6 @@ public class ProjectDaoImpl extends DatabaseAccess implements ProjectDa 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 void delete(Project item) { this.getDatabaseService().delete(item); diff --git a/dmp-backend/src/main/java/eu/eudat/entities/Credential.java b/dmp-backend/src/main/java/eu/eudat/entities/Credential.java index ef22f8dba..254ce8188 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/Credential.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/Credential.java @@ -7,7 +7,7 @@ import java.util.UUID; @Entity @Table(name = "\"Credential\"") -public class Credential implements DataEntity { +public class Credential implements DataEntity { @Id @Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @@ -119,7 +119,7 @@ public class Credential implements DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } 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 29e8da2c3..146031b16 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/DMP.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/DMP.java @@ -23,7 +23,7 @@ import java.util.*; @NamedAttributeNode("project"), @NamedAttributeNode("profile"), @NamedAttributeNode("users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")}) }) -public class DMP implements Serializable, DataEntity { +public class DMP implements DataEntity { public enum DMPStatus { ACTIVE((short) 0), DELETED((short) 1); @@ -286,8 +286,8 @@ public class DMP implements Serializable, DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/DMPOrganisation.java b/dmp-backend/src/main/java/eu/eudat/entities/DMPOrganisation.java index 2ee1288c9..e3fee9f24 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/DMPOrganisation.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/DMPOrganisation.java @@ -10,7 +10,7 @@ import java.util.UUID; @Entity @Table(name = "\"DMPOrganisation\"") -public class DMPOrganisation implements Serializable { +public class DMPOrganisation { @Id @GeneratedValue diff --git a/dmp-backend/src/main/java/eu/eudat/entities/DataEntity.java b/dmp-backend/src/main/java/eu/eudat/entities/DataEntity.java index 1be39124a..6ebe0080e 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/DataEntity.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/DataEntity.java @@ -1,7 +1,7 @@ package eu.eudat.entities; -public interface DataEntity { +public interface DataEntity { void update(T entity); - Object[] getKeys(); + K getKeys(); } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/DataRepository.java b/dmp-backend/src/main/java/eu/eudat/entities/DataRepository.java index 52c5247c8..6407186b6 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/DataRepository.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/DataRepository.java @@ -12,7 +12,7 @@ import java.util.UUID; @Entity @Table(name = "\"DataRepository\"") -public class DataRepository implements Serializable, DataEntity { +public class DataRepository implements Serializable, DataEntity { @Id @GeneratedValue @@ -147,7 +147,7 @@ public class DataRepository implements Serializable, DataEntity } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/Dataset.java b/dmp-backend/src/main/java/eu/eudat/entities/Dataset.java index d8cae40c0..00648db49 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/Dataset.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/Dataset.java @@ -20,7 +20,7 @@ import java.util.*; attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("dataRepositories"), @NamedAttributeNode("externalDatasets"), @NamedAttributeNode("registries"), @NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")}) }) -public class Dataset implements DataEntity { +public class Dataset implements DataEntity { public static Set getHints() { return hints; @@ -313,7 +313,7 @@ public class Dataset implements DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/DatasetProfile.java b/dmp-backend/src/main/java/eu/eudat/entities/DatasetProfile.java index bdb5c79d4..4ecafda14 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/DatasetProfile.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/DatasetProfile.java @@ -13,7 +13,7 @@ import java.util.UUID; @Entity @Table(name = "\"DatasetProfile\"") -public class DatasetProfile implements Serializable, DataEntity { +public class DatasetProfile implements DataEntity { @Id @GeneratedValue @@ -132,7 +132,7 @@ public class DatasetProfile implements Serializable, DataEntity } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/DatasetProfileRuleset.java b/dmp-backend/src/main/java/eu/eudat/entities/DatasetProfileRuleset.java index 42fd02b92..223c86411 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/DatasetProfileRuleset.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/DatasetProfileRuleset.java @@ -11,7 +11,7 @@ import java.util.UUID; @Entity @Table(name = "\"DatasetProfileRuleset\"") -public class DatasetProfileRuleset implements Serializable { +public class DatasetProfileRuleset { @Id @GeneratedValue diff --git a/dmp-backend/src/main/java/eu/eudat/entities/DatasetRegistry.java b/dmp-backend/src/main/java/eu/eudat/entities/DatasetRegistry.java index 9628ac2d0..a223c8a2f 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/DatasetRegistry.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/DatasetRegistry.java @@ -11,7 +11,7 @@ import java.util.UUID; @Entity @Table(name = "\"DatasetRegistry\"") -public class DatasetRegistry implements Serializable { +public class DatasetRegistry { @Id @GeneratedValue diff --git a/dmp-backend/src/main/java/eu/eudat/entities/DatasetService.java b/dmp-backend/src/main/java/eu/eudat/entities/DatasetService.java index 872abb822..259589db2 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/DatasetService.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/DatasetService.java @@ -11,7 +11,7 @@ import java.util.UUID; @Entity @Table(name = "\"DatasetService\"") -public class DatasetService implements Serializable { +public class DatasetService { @Id @GeneratedValue diff --git a/dmp-backend/src/main/java/eu/eudat/entities/ExternalDataset.java b/dmp-backend/src/main/java/eu/eudat/entities/ExternalDataset.java index 334c07c22..ebe7e438e 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/ExternalDataset.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/ExternalDataset.java @@ -10,7 +10,7 @@ import java.util.UUID; @Entity @Table(name = "\"ExternalDataset\"") -public class ExternalDataset implements DataEntity { +public class ExternalDataset implements DataEntity { @Id @GeneratedValue @@ -104,7 +104,7 @@ public class ExternalDataset implements DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/Invitation.java b/dmp-backend/src/main/java/eu/eudat/entities/Invitation.java index 57764e202..04503cca6 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/Invitation.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/Invitation.java @@ -9,7 +9,7 @@ import java.util.UUID; @Entity @Table(name = "\"Invitation\"") -public class Invitation implements DataEntity { +public class Invitation implements DataEntity { @Id @GeneratedValue @@ -100,7 +100,7 @@ public class Invitation implements DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/Organisation.java b/dmp-backend/src/main/java/eu/eudat/entities/Organisation.java index 910005dc5..7916166f8 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/Organisation.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/Organisation.java @@ -13,7 +13,7 @@ import java.util.UUID; @Entity @Table(name = "\"Organisation\"") -public class Organisation implements Serializable, DataEntity { +public class Organisation implements Serializable, DataEntity { @Id @GeneratedValue @@ -151,7 +151,7 @@ public class Organisation implements Serializable, DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/Project.java b/dmp-backend/src/main/java/eu/eudat/entities/Project.java index 1d9c0fd18..de8bd0a42 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/Project.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/Project.java @@ -15,7 +15,7 @@ import java.util.UUID; @Entity @Table(name = "\"Project\"") -public class Project implements DataEntity { +public class Project implements DataEntity { public enum Status { ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99); @@ -248,7 +248,7 @@ public class Project implements DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/Registry.java b/dmp-backend/src/main/java/eu/eudat/entities/Registry.java index 57a1a882b..80e601592 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/Registry.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/Registry.java @@ -12,7 +12,7 @@ import java.util.UUID; @Entity @Table(name = "\"Registry\"") -public class Registry implements DataEntity { +public class Registry implements DataEntity { @Id @@ -149,7 +149,7 @@ public class Registry implements DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/Researcher.java b/dmp-backend/src/main/java/eu/eudat/entities/Researcher.java index de296f2f9..f37a4a5b8 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/Researcher.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/Researcher.java @@ -12,7 +12,7 @@ import java.util.UUID; @Entity @Table(name = "\"Researcher\"") -public class Researcher implements DataEntity { +public class Researcher implements DataEntity { @Id @GeneratedValue @@ -150,7 +150,7 @@ public class Researcher implements DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/Service.java b/dmp-backend/src/main/java/eu/eudat/entities/Service.java index 3a8f16ff1..0c03a245e 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/Service.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/Service.java @@ -12,7 +12,7 @@ import java.util.UUID; @Entity @Table(name = "\"Service\"") -public class Service implements DataEntity { +public class Service implements DataEntity { @Id @GeneratedValue @@ -150,7 +150,7 @@ public class Service implements DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/UserDMP.java b/dmp-backend/src/main/java/eu/eudat/entities/UserDMP.java index ab145e910..a2235a940 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/UserDMP.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/UserDMP.java @@ -7,7 +7,7 @@ import java.util.UUID; @Entity @Table(name = "\"UserDMP\"") -public class UserDMP implements DataEntity { +public class UserDMP implements DataEntity { public enum UserDMPRoles { OWNER(0), USER(1); @@ -90,7 +90,7 @@ public class UserDMP implements DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/UserInfo.java b/dmp-backend/src/main/java/eu/eudat/entities/UserInfo.java index 58e2ddfbc..07d98095f 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/UserInfo.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/UserInfo.java @@ -17,7 +17,7 @@ import java.util.UUID; name = "userInfo", attributeNodes = {@NamedAttributeNode("userRoles"), @NamedAttributeNode("credentials")}) }) -public class UserInfo implements DataEntity { +public class UserInfo implements DataEntity { @Id @GeneratedValue @@ -173,7 +173,7 @@ public class UserInfo implements DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/UserRole.java b/dmp-backend/src/main/java/eu/eudat/entities/UserRole.java index f63e8d4e6..0f0f76668 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/UserRole.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/UserRole.java @@ -8,7 +8,7 @@ import java.util.UUID; @Entity @Table(name = "\"UserRole\"") -public class UserRole implements DataEntity { +public class UserRole implements DataEntity { @Id @GeneratedValue @@ -53,7 +53,7 @@ public class UserRole implements DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.id == null ? null : this.id}; + public UUID getKeys() { + return this.id; } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/UserToken.java b/dmp-backend/src/main/java/eu/eudat/entities/UserToken.java index d53b68d3a..940812b84 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/UserToken.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/UserToken.java @@ -7,7 +7,7 @@ import java.util.UUID; @Entity @Table(name = "\"UserToken\"") -public class UserToken implements DataEntity { +public class UserToken implements DataEntity { @Id @Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @@ -62,7 +62,7 @@ public class UserToken implements DataEntity { } @Override - public Object[] getKeys() { - return new UUID[]{this.token == null ? null : this.token}; + public UUID getKeys() { + return this.token; } } diff --git a/dmp-backend/src/main/java/eu/eudat/managers/DashBoardManager.java b/dmp-backend/src/main/java/eu/eudat/managers/DashBoardManager.java index 12f9b865c..a109c12b4 100644 --- a/dmp-backend/src/main/java/eu/eudat/managers/DashBoardManager.java +++ b/dmp-backend/src/main/java/eu/eudat/managers/DashBoardManager.java @@ -11,9 +11,9 @@ public class DashBoardManager { public DashBoardStatistics getStatistics(DatasetDao datasetRepository, DMPDao dataManagementPlanRepository, ProjectDao projectRepository) { DashBoardStatistics statistics = new DashBoardStatistics(); - statistics.setTotalDataManagementPlanCount(dataManagementPlanRepository.count()); - statistics.setTotalDataSetCount(datasetRepository.count()); - statistics.setTotalProjectCount(projectRepository.count()); + statistics.setTotalDataManagementPlanCount(dataManagementPlanRepository.asQueryable().count()); + statistics.setTotalDataSetCount(datasetRepository.asQueryable().count()); + statistics.setTotalProjectCount(projectRepository.asQueryable().count()); return statistics; } 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 d4dad79f7..6473fc8b9 100644 --- a/dmp-backend/src/main/java/eu/eudat/managers/PaginationManager.java +++ b/dmp-backend/src/main/java/eu/eudat/managers/PaginationManager.java @@ -10,14 +10,14 @@ import java.util.Collection; public class PaginationManager { - public static > QueryableList applyPaging(QueryableList items, TableRequest tableRequest) throws Exception { + 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()); 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.getOrderByType() == Ordering.OrderByType.ASC) @@ -29,7 +29,7 @@ public class PaginationManager { return; } - private static > void applyAscOrder(QueryableList items, Ordering ordering) { + 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) { @@ -40,7 +40,7 @@ public class PaginationManager { } } - private static > void applyDescOrder(QueryableList items, Ordering ordering) { + 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) { 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 e208cccf6..054c6ad6b 100644 --- a/dmp-backend/src/main/java/eu/eudat/queryable/QueryableList.java +++ b/dmp-backend/src/main/java/eu/eudat/queryable/QueryableList.java @@ -13,7 +13,7 @@ import java.util.List; import java.util.Set; import java.util.concurrent.CompletableFuture; -public interface QueryableList> { +public interface QueryableList { QueryableList where(SinglePredicate predicate); List select(SelectPredicate predicate); 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 f68a60f2e..c09a986a8 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 @@ -21,12 +21,12 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -public class QueryableHibernateList> implements QueryableList { +public class QueryableHibernateList implements QueryableList { private EntityManager manager; - private CriteriaQuery query; + private CriteriaQuery query; private Class tClass; - private Root root; + private Root root; private Root nestedQueryRoot; private Subquery subquery; private List> singlePredicates = new LinkedList<>(); @@ -61,7 +61,7 @@ public class QueryableHibernateList> implements Queryabl public QueryableHibernateList setEntity(Class type) { CriteriaBuilder builder = this.manager.getCriteriaBuilder(); - this.query = builder.createQuery(type); + this.query = builder.createTupleQuery(); this.root = this.query.from(this.tClass); return this; } @@ -170,7 +170,7 @@ public class QueryableHibernateList> implements Queryabl if (this.offset != null) typedQuery.setFirstResult(this.offset); if (this.length != null) typedQuery.setMaxResults(this.length); if (this.hint != null && this.hints.contains(hint)) { - List ids = typedQuery.getResultList().stream().map(item -> item.getKeys()[0]).collect(Collectors.toList()); + List ids = typedQuery.getResultList().stream().map(item -> item.getKeys()).collect(Collectors.toList()); if (ids != null && !ids.isEmpty()) typedQuery = queryWithHint(ids); } return typedQuery.getResultList(); @@ -184,7 +184,7 @@ public class QueryableHibernateList> implements Queryabl if (this.length != null) typedQuery.setMaxResults(this.length); return CompletableFuture.supplyAsync(() -> { if (this.hint != null && this.hints.contains(hint)) { - List ids = typedQuery.getResultList().stream().map(item -> item.getKeys()[0]).collect(Collectors.toList()); + List ids = typedQuery.getResultList().stream().map(item -> item.getKeys()).collect(Collectors.toList()); if (ids != null && !ids.isEmpty()) return queryWithHint(ids).getResultList(); } return typedQuery.getResultList(); @@ -236,7 +236,6 @@ public class QueryableHibernateList> implements Queryabl CriteriaBuilder criteriaBuilder = this.manager.getCriteriaBuilder(); CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(tClass); Root criteriaRoot = criteriaQuery.from(this.tClass); - criteriaQuery.where(criteriaRoot.get("id").in(ids)); if (!this.orderings.isEmpty()) criteriaQuery.orderBy(this.generateOrderPredicates(this.orderings, criteriaRoot));