no message
This commit is contained in:
parent
9f324b9f19
commit
cd8b338d06
|
@ -28,7 +28,7 @@ public class DashBoardController extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dashboard/getStatistics" }, produces="application/json")
|
||||
public ResponseEntity<ResponseItem<DashBoardStatistics>> getStatistics(Principal principal){
|
||||
public ResponseEntity<ResponseItem<DashBoardStatistics>> getStatistics(){
|
||||
try {
|
||||
DashBoardStatistics statistics = new DashBoardManager().getStatistics(this.getApiContext().getDatabaseRepository().getDatasetDao(), this.getApiContext().getDatabaseRepository().getDmpDao()
|
||||
, this.getApiContext().getDatabaseRepository().getProjectDao());
|
||||
|
@ -39,4 +39,17 @@ public class DashBoardController extends BaseController{
|
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DashBoardStatistics>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dashboard/me/getStatistics" }, produces="application/json")
|
||||
public ResponseEntity<ResponseItem<DashBoardStatistics>> getStatistics(Principal principal){
|
||||
try {
|
||||
DashBoardStatistics statistics = new DashBoardManager().getMeStatistics(this.getApiContext().getDatabaseRepository().getDatasetDao(), this.getApiContext().getDatabaseRepository().getDmpDao()
|
||||
, this.getApiContext().getDatabaseRepository().getProjectDao(),principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DashBoardStatistics>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DashBoardStatistics>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package eu.eudat.dao;
|
||||
|
||||
|
||||
public interface DatabaseAccessLayer<T, I> {
|
||||
import eu.eudat.entities.DataEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
public interface DatabaseAccessLayer<T extends DataEntity<T>, I> {
|
||||
T createOrUpdate(T item);
|
||||
|
||||
T find(I id);
|
||||
|
||||
void delete(T item);
|
||||
|
||||
QueryableList<T> asQueryable();
|
||||
}
|
||||
|
|
|
@ -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.DatasetProfile;
|
||||
|
@ -25,10 +26,14 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
@Override
|
||||
public QueryableList<DMP> getWithCriteria(DataManagementPlanCriteria criteria) {
|
||||
QueryableList<DMP> query = getDatabaseService().getQueryable(DMP.getHints(), DMP.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("created"),criteria.getPeriodEnd()));
|
||||
if(criteria.getPeriodStart()!=null)query.where((builder, root) -> builder.greaterThan(root.get("created"),criteria.getPeriodStart()));
|
||||
if(criteria.getProjects()!=null&&!criteria.getProjects().isEmpty())query.where(((builder, root) -> root.get("project").in(criteria.getProjectEntities())));
|
||||
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("created"), criteria.getPeriodEnd()));
|
||||
if (criteria.getPeriodStart() != null)
|
||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||
if (criteria.getProjects() != null && !criteria.getProjects().isEmpty())
|
||||
query.where(((builder, root) -> root.get("project").in(criteria.getProjectEntities())));
|
||||
return query;
|
||||
}
|
||||
|
||||
|
@ -65,4 +70,9 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
public void delete(DMP item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMP> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DMP.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,4 +41,9 @@ public class DataRepositoryDaoImpl extends DatabaseAccess<DataRepository> implem
|
|||
public void delete(DataRepository item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DataRepository> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DataRepository.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,4 +56,9 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
|||
public void delete(Dataset item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Dataset> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Dataset.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,4 +45,9 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
|
|||
public void delete(DatasetProfile item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DatasetProfile> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DatasetProfile.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,4 +41,9 @@ public class ExternalDatasetDaoImpl extends DatabaseAccess<ExternalDataset> impl
|
|||
public void delete(ExternalDataset item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<ExternalDataset> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(ExternalDataset.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,4 +39,9 @@ public class InvitationDaoImpl extends DatabaseAccess<Invitation> implements Inv
|
|||
public void delete(Invitation item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Invitation> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Invitation.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,4 +42,9 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
|
|||
public void delete(Organisation item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Organisation> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Organisation.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,10 @@ package eu.eudat.dao.entities;
|
|||
import java.util.UUID;
|
||||
|
||||
import eu.eudat.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.Organisation;
|
||||
import eu.eudat.entities.Project;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.models.criteria.ProjectCriteria;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
|
@ -12,5 +14,7 @@ public interface ProjectDao extends DatabaseAccessLayer<Project, UUID> {
|
|||
|
||||
QueryableList<Project> getWithCriteria(ProjectCriteria criteria);
|
||||
|
||||
QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal);
|
||||
|
||||
Long count();
|
||||
}
|
|
@ -3,11 +3,10 @@ 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.Organisation;
|
||||
import eu.eudat.entities.*;
|
||||
import eu.eudat.models.criteria.ProjectCriteria;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import eu.eudat.entities.Project;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -48,4 +47,14 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
|
|||
public void delete(Project item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Project> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Project.class);
|
||||
}
|
||||
|
||||
public QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal) {
|
||||
query.where((builder, root) -> builder.equal(root.get("creator"), principal));
|
||||
return query;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,4 +41,9 @@ public class RegistryDaoImpl extends DatabaseAccess<Registry> implements Registr
|
|||
public void delete(Registry item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Registry> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Registry.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,4 +41,9 @@ public class ResearcherDaoImpl extends DatabaseAccess<Researcher> implements Res
|
|||
public void delete(Researcher item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Researcher> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Researcher.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,4 +41,9 @@ public class ServiceDaoImpl extends DatabaseAccess<Service> implements ServiceDa
|
|||
public void delete(Service item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Service> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Service.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.dao.entities;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
import eu.eudat.dao.DatabaseAccess;
|
||||
|
@ -22,6 +23,8 @@ public class UserInfoDaoImpl extends DatabaseAccess<UserInfo> implements UserInf
|
|||
@Override
|
||||
public QueryableList<UserInfo> getWithCriteria(UserInfoCriteria criteria) {
|
||||
QueryableList<UserInfo> users = this.getDatabaseService().getQueryable(UserInfo.class);
|
||||
if (criteria.getAppRoles() != null && !criteria.getAppRoles().isEmpty())
|
||||
users.where((builder, root) -> root.join("userRoles").get("role").in(criteria.getAppRoles()));
|
||||
if (criteria.getLike() != null)
|
||||
users.where((builder, root) -> builder.or(builder.like(root.get("name"), "%" + criteria.getLike() + "%"), builder.like(root.get("email"), "%" + criteria.getLike() + "%")));
|
||||
if (criteria.getEmail() != null)
|
||||
|
@ -43,4 +46,9 @@ public class UserInfoDaoImpl extends DatabaseAccess<UserInfo> implements UserInf
|
|||
public void delete(UserInfo item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<UserInfo> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(UserInfo.class);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,8 @@ package eu.eudat.dao.entities;
|
|||
import eu.eudat.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.entities.UserRole;
|
||||
import eu.eudat.models.criteria.UserRoleCriteria;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -10,5 +12,6 @@ import java.util.UUID;
|
|||
|
||||
public interface UserRoleDao extends DatabaseAccessLayer<UserRole, UUID> {
|
||||
|
||||
QueryableList<UserRole> getWithCriteria(UserRoleCriteria criteria);
|
||||
List<UserRole> getUserRoles(UserInfo userInfo);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import eu.eudat.dao.DatabaseAccessLayer;
|
|||
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.entities.UserRole;
|
||||
import eu.eudat.models.criteria.UserRoleCriteria;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -39,4 +41,19 @@ public class UserRoleDaoImpl extends DatabaseAccess<UserRole> implements UserRo
|
|||
public void delete(UserRole item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<UserRole> getWithCriteria(UserRoleCriteria criteria) {
|
||||
QueryableList<UserRole> query = this.getDatabaseService().getQueryable(UserRole.class);
|
||||
if (criteria.getLike() != null)
|
||||
query.where((builder, root) -> builder.equal(root.get("userInfo").get("name"), criteria.getLike()));
|
||||
if (criteria.getAppRoles() != null && !criteria.getAppRoles().isEmpty())
|
||||
query.where((builder, root) -> root.get("role").in(criteria.getAppRoles()));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<UserRole> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(UserRole.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import eu.eudat.dao.databaselayer.service.DatabaseService;
|
|||
import eu.eudat.entities.Credential;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.models.login.Credentials;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.security.validators.TokenValidatorFactoryImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -44,4 +45,9 @@ public class CredentialDaoImpl extends DatabaseAccess<Credential> implements Cre
|
|||
public void delete(Credential item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Credential> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Credential.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package eu.eudat.dao.entities.security;
|
||||
|
||||
import eu.eudat.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.entities.Credential;
|
||||
import eu.eudat.entities.UserToken;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public interface UserTokenDao {
|
||||
public interface UserTokenDao extends DatabaseAccessLayer<UserToken,UUID> {
|
||||
|
||||
UserToken createOrUpdate(UserToken item);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.dao.entities.security;
|
|||
import eu.eudat.dao.DatabaseAccess;
|
||||
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.entities.UserToken;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -31,4 +32,9 @@ public class UserTokenDaoImpl extends DatabaseAccess<UserToken> implements UserT
|
|||
public void delete(UserToken userToken) {
|
||||
this.getDatabaseService().delete(userToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<UserToken> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(UserToken.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,10 +62,10 @@ public class UserInfo implements DataEntity<UserInfo>{
|
|||
private Set<DMP> dmps;
|
||||
|
||||
@OneToMany(mappedBy="userInfo",fetch = FetchType.LAZY)
|
||||
Set<Credential> credentials = new HashSet<>();
|
||||
private Set<Credential> credentials = new HashSet<>();
|
||||
|
||||
@OneToMany(mappedBy="userInfo",fetch = FetchType.LAZY)
|
||||
Set<UserRole> userRoles = new HashSet<>();
|
||||
@OneToMany(mappedBy="userInfo",fetch = FetchType.EAGER)
|
||||
private Set<UserRole> userRoles = new HashSet<>();
|
||||
|
||||
public Set<DMP> getDmps() {
|
||||
return dmps;
|
||||
|
|
|
@ -3,7 +3,15 @@ package eu.eudat.managers;
|
|||
import eu.eudat.dao.entities.DMPDao;
|
||||
import eu.eudat.dao.entities.DatasetDao;
|
||||
import eu.eudat.dao.entities.ProjectDao;
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.Project;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.models.dashboard.DashBoardStatistics;
|
||||
import eu.eudat.models.security.Principal;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class DashBoardManager {
|
||||
|
||||
|
@ -15,4 +23,14 @@ public class DashBoardManager {
|
|||
return statistics;
|
||||
}
|
||||
|
||||
public DashBoardStatistics getMeStatistics(DatasetDao datasetRepository, DMPDao dataManagementPlanRepository, ProjectDao projectRepository, Principal principal) {
|
||||
DashBoardStatistics statistics = new DashBoardStatistics();
|
||||
UserInfo user = new UserInfo();
|
||||
user.setId(principal.getId());
|
||||
statistics.setTotalDataManagementPlanCount(dataManagementPlanRepository.asQueryable().where((builder, root) -> builder.equal(root.get("creator").get("id"), principal.getId())).count());
|
||||
statistics.setTotalDataSetCount(datasetRepository.asQueryable().where((builder, root) -> builder.equal(root.get("creator").get("id"), principal.getId())).count());
|
||||
statistics.setTotalProjectCount(projectRepository.asQueryable().where((builder, root) -> builder.equal(root.get("creationUser").get("id"), principal.getId())).count());
|
||||
return statistics;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public class UserManager {
|
|||
public static DataTableData<UserListingModel> getPaged(UserInfoDao userInfoDao, UserInfoTableRequestItem userInfoTableRequestItem) throws Exception {
|
||||
QueryableList<eu.eudat.entities.UserInfo> users = userInfoDao.getWithCriteria(userInfoTableRequestItem.getCriteria());
|
||||
QueryableList<eu.eudat.entities.UserInfo> pagedUsers = PaginationManager.applyPaging(users, userInfoTableRequestItem);
|
||||
|
||||
List<UserListingModel> modelUsers = new DomainModelConverter<eu.eudat.entities.UserInfo, UserListingModel>().fromDataModel(pagedUsers.toList(), UserListingModel.class);
|
||||
DataTableData<UserListingModel> dataTableData = new DataTableData<>();
|
||||
dataTableData.setData(modelUsers);
|
||||
|
|
|
@ -2,9 +2,20 @@ package eu.eudat.models.criteria;
|
|||
|
||||
import eu.eudat.entities.UserInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class UserInfoCriteria extends Criteria<UserInfo> {
|
||||
private String email;
|
||||
private List<Integer> appRoles;
|
||||
|
||||
public List<Integer> getAppRoles() {
|
||||
return appRoles;
|
||||
}
|
||||
|
||||
public void setAppRoles(List<Integer> appRoles) {
|
||||
this.appRoles = appRoles;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package eu.eudat.models.criteria;
|
||||
|
||||
import eu.eudat.entities.UserRole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/1/2018.
|
||||
*/
|
||||
public class UserRoleCriteria extends Criteria<UserRole> {
|
||||
private List<Integer> appRoles;
|
||||
|
||||
public List<Integer> getAppRoles() {
|
||||
return appRoles;
|
||||
}
|
||||
|
||||
public void setAppRoles(List<Integer> appRoles) {
|
||||
this.appRoles = appRoles;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,12 @@
|
|||
package eu.eudat.models.userinfo;
|
||||
|
||||
import eu.eudat.models.criteria.UserInfoCriteria;
|
||||
import eu.eudat.models.criteria.UserRoleCriteria;
|
||||
import eu.eudat.models.helpers.requests.TableRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class UserInfoTableRequestItem extends TableRequest<UserInfoCriteria> {
|
||||
|
||||
}
|
||||
|
|
|
@ -36,4 +36,5 @@ public interface QueryableList<T extends DataEntity<T>> {
|
|||
QueryableList<T> withHint(String hint);
|
||||
|
||||
Long count();
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
private CriteriaQuery<T> query;
|
||||
private Class<T> tClass;
|
||||
private Root<T> root;
|
||||
private List<Predicate> predicates = new LinkedList<Predicate>();
|
||||
private List<SinglePredicate<T>> predicates = new LinkedList<>();
|
||||
private List<Order> orderings = new LinkedList<>();
|
||||
private List<Selection> fields = new LinkedList<>();
|
||||
private Integer length;
|
||||
|
@ -75,7 +75,7 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
}
|
||||
|
||||
public QueryableList<T> where(SinglePredicate<T> predicate) {
|
||||
this.predicates.add(predicate.applyPredicate(this.manager.getCriteriaBuilder(), this.root));
|
||||
this.predicates.add(predicate);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -106,14 +106,23 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
public Long count() {
|
||||
CriteriaBuilder criteriaBuilder = this.manager.getCriteriaBuilder();
|
||||
CriteriaQuery<Long> criteriaQuery = criteriaBuilder.createQuery(Long.class);
|
||||
criteriaQuery.select(criteriaBuilder.count(criteriaQuery.from(this.tClass)));
|
||||
criteriaQuery.where(this.predicates.toArray(new Predicate[this.predicates.size()]));
|
||||
Root<T> root = criteriaQuery.from(tClass);
|
||||
criteriaQuery.select(criteriaBuilder.count(root));
|
||||
criteriaQuery.where(this.generateWherePredicates(this.predicates, root));
|
||||
return this.manager.createQuery(criteriaQuery).getSingleResult();
|
||||
}
|
||||
|
||||
private Predicate[] generateWherePredicates(List<SinglePredicate<T>> singlePredicates, Root<T> root) {
|
||||
List<Predicate> predicates = new LinkedList<>();
|
||||
for (SinglePredicate<T> singlePredicate : singlePredicates) {
|
||||
predicates.add(singlePredicate.applyPredicate(this.manager.getCriteriaBuilder(), root));
|
||||
}
|
||||
return predicates.toArray(new Predicate[predicates.size()]);
|
||||
}
|
||||
|
||||
public List<T> toList() {
|
||||
|
||||
this.query.where(this.predicates.toArray(new Predicate[this.predicates.size()]));
|
||||
this.query.where(this.generateWherePredicates(this.predicates, this.root));
|
||||
if (!this.orderings.isEmpty()) this.query.orderBy(this.orderings);
|
||||
TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
|
||||
if (this.offset != null) typedQuery.setFirstResult(this.offset);
|
||||
|
@ -126,18 +135,13 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
}
|
||||
|
||||
public T getSingle() {
|
||||
Predicate[] array = new Predicate[this.predicates.size()];
|
||||
this.predicates.toArray(array);
|
||||
this.query.where(array);
|
||||
|
||||
this.query.where(this.generateWherePredicates(this.predicates, this.root));
|
||||
TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
|
||||
return typedQuery.getSingleResult();
|
||||
}
|
||||
|
||||
public T getSingleOrDefault() {
|
||||
Predicate[] array = new Predicate[this.predicates.size()];
|
||||
this.predicates.toArray(array);
|
||||
this.query.where(array);
|
||||
this.query.where(this.generateWherePredicates(this.predicates, this.root));
|
||||
|
||||
TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
|
||||
List<T> results = typedQuery.getResultList();
|
||||
|
|
|
@ -782,7 +782,7 @@
|
|||
"integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"core-js": "2.5.0",
|
||||
"core-js": "2.4.1",
|
||||
"regenerator-runtime": "0.11.1"
|
||||
}
|
||||
},
|
||||
|
@ -1617,9 +1617,9 @@
|
|||
}
|
||||
},
|
||||
"core-js": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.0.tgz",
|
||||
"integrity": "sha1-VpwFCRi+ZIazg3VSAorgRmtxcIY="
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.4.1.tgz",
|
||||
"integrity": "sha1-TekR5mew6ukSTjQlS1OupvxhjT4="
|
||||
},
|
||||
"core-object": {
|
||||
"version": "3.1.5",
|
||||
|
@ -6456,11 +6456,11 @@
|
|||
}
|
||||
},
|
||||
"rxjs": {
|
||||
"version": "5.4.3",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.4.3.tgz",
|
||||
"integrity": "sha512-fSNi+y+P9ss+EZuV0GcIIqPUK07DEaMRUtLJvdcvMyFjc9dizuDjere+A4V7JrLGnm9iCc+nagV/4QdMTkqC4A==",
|
||||
"version": "5.5.6",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.6.tgz",
|
||||
"integrity": "sha512-v4Q5HDC0FHAQ7zcBX7T2IL6O5ltl1a2GX4ENjPXg6SjDY69Cmx9v4113C99a4wGF16ClPv5Z8mghuYorVkg/kg==",
|
||||
"requires": {
|
||||
"symbol-observable": "1.0.4"
|
||||
"symbol-observable": "1.0.1"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
|
@ -7136,9 +7136,9 @@
|
|||
}
|
||||
},
|
||||
"symbol-observable": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.4.tgz",
|
||||
"integrity": "sha1-Kb9hXUqnEhvdiYsi1LP5vE4qoD0="
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz",
|
||||
"integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ="
|
||||
},
|
||||
"tapable": {
|
||||
"version": "0.2.8",
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
"@ngx-translate/core": "^9.0.1",
|
||||
"@ngx-translate/http-loader": "^2.0.0",
|
||||
"core-js": "^2.4.1",
|
||||
"rxjs": "^5.4.2",
|
||||
"rxjs": "^5.5.6",
|
||||
"zone.js": "^0.8.17"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { BaseCriteria } from '../BaseCriteria';
|
||||
import { Principal } from "@app/models/login/Principal";
|
||||
import { Principal } from '../../login/Principal';
|
||||
|
||||
|
||||
|
||||
export class UserCriteria extends BaseCriteria {
|
||||
public Label: String;
|
||||
public Roles: Principal.AppRole[];
|
||||
public label: String;
|
||||
public appRoles: Principal.AppRole[];
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ export class Principal implements Serializable<Principal> {
|
|||
|
||||
export namespace Principal {
|
||||
export enum AppRole {
|
||||
Manager = 2,
|
||||
Admin = 1,
|
||||
Admin = 2,
|
||||
Manager = 1,
|
||||
User = 0,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
<mat-form-field>
|
||||
<input matInput
|
||||
placeholder="{{'CRITERIA.USERS.LABEL'| translate}}"
|
||||
formControlName="label"
|
||||
formControlName="like"
|
||||
(ngModelChange)="controlModified()">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-4">
|
||||
<mat-form-field>
|
||||
<mat-select placeholder="{{'CRITERIA.USERS.ROLE' | translate}}"
|
||||
formControlName="roles"
|
||||
formControlName="appRoles"
|
||||
(change)="controlModified()"
|
||||
multiple>
|
||||
<mat-option *ngFor="let role of getPrincipalAppRoleValues()" [value]="role">{{getPrincipalAppRoleWithLanguage(role)}}</mat-option>
|
||||
|
|
|
@ -40,8 +40,8 @@ export class UsersCriteriaComponent extends BaseCriteriaComponent implements OnI
|
|||
|
||||
public fromJSONObject(item: any): UserCriteria {
|
||||
this.criteria = new UserCriteria();
|
||||
this.criteria.Label = item.Label;
|
||||
this.criteria.Roles = item.Roles;
|
||||
this.criteria.label = item.Label;
|
||||
this.criteria.appRoles = item.appRoles;
|
||||
return this.criteria;
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ export class UsersCriteriaComponent extends BaseCriteriaComponent implements OnI
|
|||
const context: ValidationContext = this.createValidationContext();
|
||||
|
||||
return this.formBuilder.group({
|
||||
label: [this.criteria.Label, context.getValidation('label').validators],
|
||||
roles: [this.criteria.Roles, context.getValidation('roles').validators],
|
||||
like: [this.criteria.label, context.getValidation('label').validators],
|
||||
appRoles: [this.criteria.appRoles, context.getValidation('appRoles').validators],
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ export class UsersCriteriaComponent extends BaseCriteriaComponent implements OnI
|
|||
const validationArray: Validation[] = new Array<Validation>();
|
||||
|
||||
validationArray.push({ key: 'label' });
|
||||
validationArray.push({ key: 'roles' });
|
||||
validationArray.push({ key: 'appRoles' });
|
||||
|
||||
validationContext.validation = validationArray;
|
||||
return validationContext;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<button mat-button class="navbar-button" routerLink="/projects">{{'NAV-BAR.PROJECTS' | translate}}</button>
|
||||
<button mat-button class="navbar-button" routerLink="/dmps">{{'NAV-BAR.DMPS' | translate}}</button>
|
||||
<button mat-button class="navbar-button" routerLink="/datasets">{{'NAV-BAR.DATASETS' | translate}}</button>
|
||||
<button *ngIf="isAdmin()" mat-button class="navbar-button" routerLink="/users">{{'NAV-BAR.USERS' | translate}}</button>
|
||||
</div>
|
||||
<span class="navbar-spacer"></span>
|
||||
<div *ngIf="isAuthenticated()">
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
"TITLE": "Data Management Plans",
|
||||
"PROJECTS": "Projects",
|
||||
"DMPS": "Plans",
|
||||
"DATASETS": "Datasets"
|
||||
"DATASETS": "Datasets",
|
||||
"USERS": "Users"
|
||||
|
||||
},
|
||||
"PROJECT-LISTING": {
|
||||
"TITLE": "Projects",
|
||||
|
|
Loading…
Reference in New Issue