From 70db1b2894d47735c6a7d04604fcc1be68dbea9c Mon Sep 17 00:00:00 2001 From: Ioannis Kalyvas Date: Wed, 21 Feb 2018 12:07:31 +0200 Subject: [PATCH] no message --- .../java/eu/eudat/dao/DatabaseAccessLayer.java | 7 +++++++ .../databaselayer/context/DatabaseContext.java | 5 ----- .../databaselayer/service/DatabaseService.java | 4 ---- .../java/eu/eudat/dao/entities/DMPDaoImpl.java | 10 ++++++++++ .../dao/entities/DataRepositoryDaoImpl.java | 11 +++++++++++ .../java/eu/eudat/dao/entities/DatasetDao.java | 4 ---- .../dao/entities/DatasetProfileDaoImpl.java | 11 +++++++++++ .../dao/entities/ExternalDatasetDaoImpl.java | 11 +++++++++++ .../eudat/dao/entities/InvitationDaoImpl.java | 11 +++++++++++ .../eudat/dao/entities/OrganisationDaoImpl.java | 11 +++++++++++ .../eu/eudat/dao/entities/ProjectDaoImpl.java | 11 +++++++++++ .../eu/eudat/dao/entities/RegistryDaoImpl.java | 11 +++++++++++ .../eudat/dao/entities/ResearcherDaoImpl.java | 11 +++++++++++ .../eu/eudat/dao/entities/ServiceDaoImpl.java | 11 +++++++++++ .../eu/eudat/dao/entities/UserDmpDaoImpl.java | 11 +++++++++++ .../eu/eudat/dao/entities/UserInfoDaoImpl.java | 11 +++++++++++ .../eu/eudat/dao/entities/UserRoleDaoImpl.java | 11 +++++++++++ .../entities/security/CredentialDaoImpl.java | 11 +++++++++++ .../dao/entities/security/UserTokenDaoImpl.java | 11 +++++++++++ .../managers/DataManagementPlanManager.java | 10 +++++----- .../java/eu/eudat/managers/DatasetManager.java | 8 +++----- .../eudat/managers/DatasetProfileManager.java | 6 +++--- .../eu/eudat/managers/DatasetWizardManager.java | 2 +- .../eudat/managers/ExternalDatasetManager.java | 4 ++-- .../eu/eudat/managers/InvitationsManager.java | 2 +- .../java/eu/eudat/managers/ProjectManager.java | 9 ++++----- .../java/eu/eudat/managers/UserManager.java | 2 +- .../java/eu/eudat/queryable/QueryableList.java | 2 ++ .../QueryableHibernateList.java | 17 ++++++++--------- dmp-frontend/src/environments/environment.ts | 2 +- 30 files changed, 202 insertions(+), 46 deletions(-) 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 f094ea6dc..0a5c4cd0a 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/DatabaseAccessLayer.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/DatabaseAccessLayer.java @@ -2,13 +2,20 @@ package eu.eudat.dao; import eu.eudat.entities.DataEntity; +import eu.eudat.entities.Dataset; import eu.eudat.queryable.QueryableList; +import java.util.concurrent.CompletableFuture; + public interface DatabaseAccessLayer { T createOrUpdate(T item); + CompletableFuture createOrUpdateAsync(T item); + T find(I id); + T find(I id, String hint); + void delete(T item); QueryableList asQueryable(); 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 6d1d4c820..d9defe1ae 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 @@ -43,11 +43,6 @@ public class DatabaseContext { return item; } - public long count(Class entityClass) { - EntityManager entityManager = this.entityManager; - return ((Number) entityManager.createQuery("select count(e) from " + entityClass.getSimpleName() + " e").getSingleResult()).longValue(); - } - public void delete(T item) { this.entityManager.remove(item); } 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 ac997dfaf..3146c49b8 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 @@ -32,10 +32,6 @@ public class DatabaseService { return this.databaseCtx.createOrUpdate(item, tClass); } - public Long count(Class tClass) { - return this.databaseCtx.count(tClass); - } - public void delete(T item) { this.databaseCtx.delete(item); } 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 8f208abf1..531d61456 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 @@ -14,6 +14,7 @@ import org.springframework.stereotype.Component; import java.util.Arrays; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Component("dMPDao") public class DMPDaoImpl extends DatabaseAccess implements DMPDao { @@ -77,4 +78,13 @@ public class DMPDaoImpl extends DatabaseAccess implements DMPDao { return this.getDatabaseService().getQueryable(DMP.class); } + @Override + public CompletableFuture createOrUpdateAsync(DMP item) { + return CompletableFuture.supplyAsync(()->this.createOrUpdate(item)); + } + + @Override + public DMP find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/DataRepositoryDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/DataRepositoryDaoImpl.java index 75599f3fa..2d20e6a77 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/DataRepositoryDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/DataRepositoryDaoImpl.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Component("dataRepositoryDao") public class DataRepositoryDaoImpl extends DatabaseAccess implements DataRepositoryDao { @@ -36,6 +37,16 @@ public class DataRepositoryDaoImpl extends DatabaseAccess implem return getDatabaseService().createOrUpdate(item, DataRepository.class); } + @Override + public CompletableFuture createOrUpdateAsync(DataRepository item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public DataRepository find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } + @Override public void delete(DataRepository item) { this.getDatabaseService().delete(item); 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 5cb766447..eb560faec 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 @@ -15,8 +15,4 @@ public interface DatasetDao extends DatabaseAccessLayer { QueryableList getAuthenticated(QueryableList query, UserInfo principal); - CompletableFuture createOrUpdateAsync(Dataset item); - - Dataset find(UUID id, String hint); - } \ No newline at end of file diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/DatasetProfileDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/DatasetProfileDaoImpl.java index fd986e635..9b2cc3920 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/DatasetProfileDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/DatasetProfileDaoImpl.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Component("datasetProfileDao") public class DatasetProfileDaoImpl extends DatabaseAccess implements DatasetProfileDao { @@ -50,4 +51,14 @@ public class DatasetProfileDaoImpl extends DatabaseAccess implem public QueryableList asQueryable() { return this.getDatabaseService().getQueryable(DatasetProfile.class); } + + @Override + public CompletableFuture createOrUpdateAsync(DatasetProfile item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public DatasetProfile find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/ExternalDatasetDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/ExternalDatasetDaoImpl.java index 3c12cf5df..6924ea09b 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/ExternalDatasetDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/ExternalDatasetDaoImpl.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Component("externalDatasetDao") @@ -46,4 +47,14 @@ public class ExternalDatasetDaoImpl extends DatabaseAccess impl public QueryableList asQueryable() { return this.getDatabaseService().getQueryable(ExternalDataset.class); } + + @Override + public CompletableFuture createOrUpdateAsync(ExternalDataset item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public ExternalDataset find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/InvitationDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/InvitationDaoImpl.java index 6191d615d..0a58a016f 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/InvitationDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/InvitationDaoImpl.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Service("invitationDao") @@ -43,4 +44,14 @@ public class InvitationDaoImpl extends DatabaseAccess implements Inv public QueryableList asQueryable() { return this.getDatabaseService().getQueryable(Invitation.class); } + + @Override + public CompletableFuture createOrUpdateAsync(Invitation item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public Invitation find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/OrganisationDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/OrganisationDaoImpl.java index e68de353d..4ef72dbaa 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/OrganisationDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/OrganisationDaoImpl.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Component("organisationDao") public class OrganisationDaoImpl extends DatabaseAccess implements OrganisationDao { @@ -45,4 +46,14 @@ public class OrganisationDaoImpl extends DatabaseAccess implements public QueryableList asQueryable() { return this.getDatabaseService().getQueryable(Organisation.class); } + + @Override + public CompletableFuture createOrUpdateAsync(Organisation item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public Organisation find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } 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 74e64f236..5d66389b9 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 @@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Component("projectDao") public class ProjectDaoImpl extends DatabaseAccess implements ProjectDao { @@ -58,4 +59,14 @@ public class ProjectDaoImpl extends DatabaseAccess implements ProjectDa query.where((builder, root) -> builder.equal(root.get("creator"), principal)); return query; } + + @Override + public CompletableFuture createOrUpdateAsync(Project item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public Project find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/RegistryDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/RegistryDaoImpl.java index 263e78161..65fe26a5c 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/RegistryDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/RegistryDaoImpl.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Component("registryDao") public class RegistryDaoImpl extends DatabaseAccess implements RegistryDao { @@ -45,4 +46,14 @@ public class RegistryDaoImpl extends DatabaseAccess implements Registr public QueryableList asQueryable() { return this.getDatabaseService().getQueryable(Registry.class); } + + @Override + public CompletableFuture createOrUpdateAsync(Registry item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public Registry find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/ResearcherDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/ResearcherDaoImpl.java index cfbaba4ac..a2e48cfac 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/ResearcherDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/ResearcherDaoImpl.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Component("researcherDao") public class ResearcherDaoImpl extends DatabaseAccess implements ResearcherDao { @@ -45,4 +46,14 @@ public class ResearcherDaoImpl extends DatabaseAccess implements Res public QueryableList asQueryable() { return this.getDatabaseService().getQueryable(Researcher.class); } + + @Override + public CompletableFuture createOrUpdateAsync(Researcher item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public Researcher find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/ServiceDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/ServiceDaoImpl.java index d56cdbddf..421f44cf1 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/ServiceDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/ServiceDaoImpl.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Component("serviceDao") public class ServiceDaoImpl extends DatabaseAccess implements ServiceDao { @@ -45,4 +46,14 @@ public class ServiceDaoImpl extends DatabaseAccess implements ServiceDa public QueryableList asQueryable() { return this.getDatabaseService().getQueryable(Service.class); } + + @Override + public CompletableFuture createOrUpdateAsync(Service item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public Service find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/UserDmpDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/UserDmpDaoImpl.java index 9213ffc45..1604223cf 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/UserDmpDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/UserDmpDaoImpl.java @@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; +import java.util.concurrent.CompletableFuture; /** * Created by ikalyvas on 2/8/2018. @@ -39,4 +40,14 @@ public class UserDmpDaoImpl extends DatabaseAccess implements UserDmpDa public QueryableList asQueryable() { return this.getDatabaseService().getQueryable(UserDMP.class); } + + @Override + public CompletableFuture createOrUpdateAsync(UserDMP item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public UserDMP find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/UserInfoDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/UserInfoDaoImpl.java index 20b2ff259..341c7cd8c 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/UserInfoDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/UserInfoDaoImpl.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Component("userInfoDao") public class UserInfoDaoImpl extends DatabaseAccess implements UserInfoDao { @@ -49,4 +50,14 @@ public class UserInfoDaoImpl extends DatabaseAccess implements UserInf public QueryableList asQueryable() { return this.getDatabaseService().getQueryable(UserInfo.class); } + + @Override + public CompletableFuture createOrUpdateAsync(UserInfo item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public UserInfo find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } \ No newline at end of file diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/UserRoleDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/UserRoleDaoImpl.java index 5d42da3f4..c48a9c581 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/UserRoleDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/UserRoleDaoImpl.java @@ -11,6 +11,7 @@ import org.springframework.stereotype.Component; import java.util.List; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Component("userRoleDao") @@ -55,4 +56,14 @@ public class UserRoleDaoImpl extends DatabaseAccess implements UserRol public QueryableList asQueryable() { return this.getDatabaseService().getQueryable(UserRole.class); } + + @Override + public CompletableFuture createOrUpdateAsync(UserRole item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public UserRole find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/security/CredentialDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/security/CredentialDaoImpl.java index 8add130f0..efe1487e0 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/security/CredentialDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/security/CredentialDaoImpl.java @@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Component("credentialDao") @@ -49,4 +50,14 @@ public class CredentialDaoImpl extends DatabaseAccess implements Cre public QueryableList asQueryable() { return this.getDatabaseService().getQueryable(Credential.class); } + + @Override + public CompletableFuture createOrUpdateAsync(Credential item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public Credential find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/security/UserTokenDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/security/UserTokenDaoImpl.java index 95717e47c..a2e4f5dcf 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/security/UserTokenDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/security/UserTokenDaoImpl.java @@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; +import java.util.concurrent.CompletableFuture; @Component("userTokenDao") @@ -37,4 +38,14 @@ public class UserTokenDaoImpl extends DatabaseAccess implements UserT public QueryableList asQueryable() { return this.getDatabaseService().getQueryable(UserToken.class); } + + @Override + public CompletableFuture createOrUpdateAsync(UserToken item) { + return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); + } + + @Override + public UserToken find(UUID id, String hint) { + throw new UnsupportedOperationException(); + } } 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 62877d8c0..9e9d45c05 100644 --- a/dmp-backend/src/main/java/eu/eudat/managers/DataManagementPlanManager.java +++ b/dmp-backend/src/main/java/eu/eudat/managers/DataManagementPlanManager.java @@ -39,10 +39,10 @@ public class DataManagementPlanManager { DataTableData dataTable = new DataTableData(); - CompletableFuture itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)).toListAsync().whenComplete((resultList, throwable) -> { - List datamanagementPlans = resultList.stream().map(item -> new DataManagementPlanListingModel().fromDataModel(item)).collect(Collectors.toList()); - dataTable.setData(datamanagementPlans); - }); + CompletableFuture itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)) + .selectAsync(item -> new DataManagementPlanListingModel().fromDataModel(item)).whenComplete((resultList, throwable) -> { + dataTable.setData(resultList); + }); CompletableFuture countFuture = items.countAsync().whenComplete((count, throwable) -> { dataTable.setTotalCount(count); @@ -62,7 +62,7 @@ public class DataManagementPlanManager { public List getWithCriteria(DMPDao dmpsRepository, DataManagementPlanCriteriaRequest dataManagementPlanCriteria) throws IllegalAccessException, InstantiationException { QueryableList items = dmpsRepository.getWithCriteria(dataManagementPlanCriteria.getCriteria()); - List datamanagementPlans = items.toList().stream().map(item -> new DataManagementPlan().fromDataModel(item)).collect(Collectors.toList()); + List datamanagementPlans = items.select(item -> new DataManagementPlan().fromDataModel(item)); return datamanagementPlans; } diff --git a/dmp-backend/src/main/java/eu/eudat/managers/DatasetManager.java b/dmp-backend/src/main/java/eu/eudat/managers/DatasetManager.java index f72a11fbf..d4c19a400 100644 --- a/dmp-backend/src/main/java/eu/eudat/managers/DatasetManager.java +++ b/dmp-backend/src/main/java/eu/eudat/managers/DatasetManager.java @@ -2,7 +2,6 @@ package eu.eudat.managers; import eu.eudat.builders.entity.UserInfoBuilder; import eu.eudat.dao.entities.*; -import eu.eudat.entities.Dataset; import eu.eudat.entities.UserInfo; import eu.eudat.models.HintedModelFactory; import eu.eudat.models.criteria.DataRepositoryCriteria; @@ -24,7 +23,6 @@ import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; public class DatasetManager { @@ -36,9 +34,9 @@ public class DatasetManager { QueryableList pagedItems = PaginationManager.applyPaging(authItems, datasetTableRequest); DataTableData dataTable = new DataTableData(); - CompletableFuture> itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DatasetListingModel.class)).toListAsync().whenComplete((resultList, throwable) -> { - List datasets = resultList.stream().map(item -> new DatasetListingModel().fromDataModel(item)).collect(Collectors.toList()); - dataTable.setData(datasets); + CompletableFuture> itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DatasetListingModel.class)). + selectAsync(item -> new DatasetListingModel().fromDataModel(item)).whenComplete((resultList, throwable) -> { + dataTable.setData(resultList); }); CompletableFuture countFuture = items.countAsync().whenComplete((count, throwable) -> { diff --git a/dmp-backend/src/main/java/eu/eudat/managers/DatasetProfileManager.java b/dmp-backend/src/main/java/eu/eudat/managers/DatasetProfileManager.java index ae30b4078..5580dc8fb 100644 --- a/dmp-backend/src/main/java/eu/eudat/managers/DatasetProfileManager.java +++ b/dmp-backend/src/main/java/eu/eudat/managers/DatasetProfileManager.java @@ -19,20 +19,20 @@ public class DatasetProfileManager { public static List getWithCriteria(DatasetProfileDao datasetProfileRepository, DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException { QueryableList items = datasetProfileRepository.getWithCriteria(datasetProfileAutocompleteRequest.getCriteria()); - List datasetProfiles = items.toList().stream().map(item -> new DatasetProfileAutocompleteItem().fromDataModel(item)).collect(Collectors.toList()); + List datasetProfiles = items.select(item -> new DatasetProfileAutocompleteItem().fromDataModel(item)); return datasetProfiles; } public static DataTableData getPaged(ApiContext apiContext, DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws Exception { QueryableList items = apiContext.getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria()); QueryableList pagedItems = PaginationManager.applyPaging(items, datasetProfileTableRequestItem); - List datasetProfiles = pagedItems.toList().stream().map(item -> new DatasetProfileListingModel().fromDataModel(item)).collect(Collectors.toList()); + List datasetProfiles = pagedItems.select(item -> new DatasetProfileListingModel().fromDataModel(item)); return apiContext.getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(datasetProfiles).totalCount(items.count()).build(); } public static List getAll(DatasetProfileDao datasetProfileRepository) throws IllegalAccessException, InstantiationException { QueryableList items = datasetProfileRepository.getAll(); - List datasetProfiles = items.toList().stream().map(item -> new DatasetProfileListingModel().fromDataModel(item)).collect(Collectors.toList()); + List datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item)); return datasetProfiles; } } diff --git a/dmp-backend/src/main/java/eu/eudat/managers/DatasetWizardManager.java b/dmp-backend/src/main/java/eu/eudat/managers/DatasetWizardManager.java index 864e12869..40cb2cb7e 100644 --- a/dmp-backend/src/main/java/eu/eudat/managers/DatasetWizardManager.java +++ b/dmp-backend/src/main/java/eu/eudat/managers/DatasetWizardManager.java @@ -22,7 +22,7 @@ public class DatasetWizardManager { UserInfo userInfo = new UserInfo(); userInfo.setId(principal.getId()); QueryableList items = dmpRepository.getUserDmps(datasetWizardAutocompleteRequest, userInfo); - List dataManagementPlans = items.toList().stream().map(item -> new DataManagentPlanListingModel().fromDataModel(item)).collect(Collectors.toList()); + List dataManagementPlans = items.select(item -> new DataManagentPlanListingModel().fromDataModel(item)); return dataManagementPlans; } diff --git a/dmp-backend/src/main/java/eu/eudat/managers/ExternalDatasetManager.java b/dmp-backend/src/main/java/eu/eudat/managers/ExternalDatasetManager.java index d9b62ed1c..c146680af 100644 --- a/dmp-backend/src/main/java/eu/eudat/managers/ExternalDatasetManager.java +++ b/dmp-backend/src/main/java/eu/eudat/managers/ExternalDatasetManager.java @@ -24,14 +24,14 @@ public class ExternalDatasetManager { public DataTableData getPaged(ApiContext apiContext, ExternalDatasetTableRequest externalDatasetTableRequest) throws Exception { QueryableList items = apiContext.getDatabaseRepository().getExternalDatasetDao().getWithCriteria(externalDatasetTableRequest.getCriteria()); QueryableList pagedItems = PaginationManager.applyPaging(items, externalDatasetTableRequest); - List externalDatasetListingmodels = pagedItems.toList().stream().map(item -> new ExternalDatasetListingModel().fromDataModel(item)).collect(Collectors.toList()); + List externalDatasetListingmodels = pagedItems.select(item -> new ExternalDatasetListingModel().fromDataModel(item)); return apiContext.getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(externalDatasetListingmodels).totalCount(items.count()).build(); } public List getWithExternal(ApiContext apiContext, String query, RemoteFetcher remoteFetcher) throws HugeResultSet, NoURLFound, InstantiationException, IllegalAccessException { ExternalDatasetCriteria criteria = apiContext.getBuilderFactory().getBuilder(ExternalDatasetCriteriaBuilder.class).like(query).build(); QueryableList items = apiContext.getDatabaseRepository().getExternalDatasetDao().getWithCriteria(criteria); - List externalDatasets = items.toList().stream().map(item -> new ExternalDatasetListingModel().fromDataModel(item)).collect(Collectors.toList()); + List externalDatasets = items.select(item -> new ExternalDatasetListingModel().fromDataModel(item)); return externalDatasets; } diff --git a/dmp-backend/src/main/java/eu/eudat/managers/InvitationsManager.java b/dmp-backend/src/main/java/eu/eudat/managers/InvitationsManager.java index e628ceaeb..351da67ba 100644 --- a/dmp-backend/src/main/java/eu/eudat/managers/InvitationsManager.java +++ b/dmp-backend/src/main/java/eu/eudat/managers/InvitationsManager.java @@ -29,7 +29,7 @@ public class InvitationsManager { public static List getUsers(ApiContext apiContext, UserInfoRequestItem userInfoRequestItem) throws InstantiationException, IllegalAccessException { QueryableList users = apiContext.getDatabaseRepository().getUserInfoDao().getWithCriteria(userInfoRequestItem.getCriteria()); - List userModels = users.toList().stream().map(item -> new UserInfoInvitationModel().fromDataModel(item)).collect(Collectors.toList()); + List userModels = users.select(item -> new UserInfoInvitationModel().fromDataModel(item)); return userModels; } diff --git a/dmp-backend/src/main/java/eu/eudat/managers/ProjectManager.java b/dmp-backend/src/main/java/eu/eudat/managers/ProjectManager.java index 15e11c098..ef2b3d508 100644 --- a/dmp-backend/src/main/java/eu/eudat/managers/ProjectManager.java +++ b/dmp-backend/src/main/java/eu/eudat/managers/ProjectManager.java @@ -32,9 +32,8 @@ public class ProjectManager { QueryableList pagedItems = PaginationManager.applyPaging(items, projectTableRequest); DataTableData dataTable = new DataTableData(); - CompletableFuture projectsFuture = pagedItems.withHint(HintedModelFactory.getHint(ProjectListingModel.class)).toListAsync().whenComplete((results, throwable) -> { - List projects = results.stream().map(item -> new ProjectListingModel().fromDataModel(item)).collect(Collectors.toList()); - dataTable.setData(projects); + CompletableFuture projectsFuture = pagedItems.withHint(HintedModelFactory.getHint(ProjectListingModel.class)).selectAsync(item -> new ProjectListingModel().fromDataModel(item)).whenComplete((results, throwable) -> { + dataTable.setData(results); }); CompletableFuture countFuture = pagedItems.countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count)); @@ -58,7 +57,7 @@ public class ProjectManager { public List getCriteriaWithExternal(ApiContext apiContext, ProjectCriteriaRequest projectCriteria, RemoteFetcher remoteFetcher) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound { QueryableList items = apiContext.getDatabaseRepository().getProjectDao().getWithCriteria(projectCriteria.getCriteria()); - List projects = items.toList().stream().map(item -> new Project().fromDataModel(item)).collect(Collectors.toList()); + List projects = items.select(item -> new Project().fromDataModel(item)); List> remoteRepos = remoteFetcher.getProjects(projectCriteria.getCriteria().getLike()); ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos); for (ExternalSourcesItemModel externalListingItem : projectsExternalSourcesModel) { @@ -76,7 +75,7 @@ public class ProjectManager { public List getCriteria(ProjectDao projectRepository, ProjectCriteriaRequest projectCriteria, RemoteFetcher remoteFetcher) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound { QueryableList items = projectRepository.getWithCriteria(projectCriteria.getCriteria()); - List projects = items.toList().stream().map(item -> new Project().fromDataModel(item)).collect(Collectors.toList()); + List projects = items.select(item -> new Project().fromDataModel(item)); return projects; } diff --git a/dmp-backend/src/main/java/eu/eudat/managers/UserManager.java b/dmp-backend/src/main/java/eu/eudat/managers/UserManager.java index b84c9dba4..c4eb0aaab 100644 --- a/dmp-backend/src/main/java/eu/eudat/managers/UserManager.java +++ b/dmp-backend/src/main/java/eu/eudat/managers/UserManager.java @@ -35,7 +35,7 @@ public class UserManager { QueryableList users = apiContext.getDatabaseRepository().getUserInfoDao().getWithCriteria(userInfoTableRequestItem.getCriteria()); QueryableList pagedUsers = PaginationManager.applyPaging(users, userInfoTableRequestItem); - List modelUsers = pagedUsers.toList().stream().map(item -> new UserListingModel().fromDataModel(item)).collect(Collectors.toList()); + List modelUsers = pagedUsers.select(item -> new UserListingModel().fromDataModel(item)); return apiContext.getBuilderFactory().getBuilder(DataTableDataBuilder.class).totalCount(users.count()).data(modelUsers).build(); } 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 054c6ad6b..60e633d2e 100644 --- a/dmp-backend/src/main/java/eu/eudat/queryable/QueryableList.java +++ b/dmp-backend/src/main/java/eu/eudat/queryable/QueryableList.java @@ -18,6 +18,8 @@ public interface QueryableList { List select(SelectPredicate predicate); + CompletableFuture> selectAsync(SelectPredicate predicate); + List toList(); CompletableFuture> toListAsync(); 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 c09a986a8..34608de0b 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 @@ -24,9 +24,9 @@ import java.util.stream.Collectors; 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 QueryableLi public QueryableHibernateList setEntity(Class type) { CriteriaBuilder builder = this.manager.getCriteriaBuilder(); - this.query = builder.createTupleQuery(); + this.query = builder.createQuery(type); this.root = this.query.from(this.tClass); return this; } @@ -94,12 +94,11 @@ public class QueryableHibernateList implements QueryableLi } public List select(SelectPredicate predicate) { - List list = this.toList(); - List newlist = new LinkedList(); - for (T item : list) { - newlist.add(predicate.applySelection(item)); - } - return newlist; + return this.toList().stream().map(item -> predicate.applySelection(item)).collect(Collectors.toList()); + } + + public CompletableFuture> selectAsync(SelectPredicate predicate) { + return this.toListAsync().thenApplyAsync(items-> items.stream().map(item -> predicate.applySelection(item)).collect(Collectors.toList())); } public QueryableList distinct() { diff --git a/dmp-frontend/src/environments/environment.ts b/dmp-frontend/src/environments/environment.ts index d8975f998..3751110b8 100644 --- a/dmp-frontend/src/environments/environment.ts +++ b/dmp-frontend/src/environments/environment.ts @@ -5,6 +5,6 @@ export const environment = { production: false, - Server: 'http://192.168.32.64:8080/api/', + Server: 'http://devel-21.local.cite.gr:8080/api/', App: 'localhost:4200/' };