use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.
the class MapService method loadViewportElements.
@Override
public List<GPClientViewport> loadViewportElements(HttpServletRequest httpServletRequest) throws GeoPlatformException {
GPAccount account;
Long projectID;
try {
account = this.sessionUtility.getLoggedAccount(httpServletRequest);
projectID = this.sessionUtility.getDefaultProject(httpServletRequest);
} catch (GPSessionTimeout timeout) {
throw new GeoPlatformException(timeout);
}
Collection<GPViewport> viewportCollectionElements = null;
try {
GPAccountProject accountProject = this.geoPlatformServiceClient.getAccountProjectByAccountAndProjectIDs(account.getId(), projectID);
viewportCollectionElements = this.geoPlatformServiceClient.getAccountProjectViewports(accountProject.getId()).getViewports();
} catch (ResourceNotFoundFault rnff) {
logger.error("Error on MapService: " + rnff);
throw new GeoPlatformException(rnff);
}
return this.convertServerViewportToDTO(viewportCollectionElements);
}
use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.
the class GPAccountProjectDAOImpl method count.
/**
* @param accountID
* @param nameProject
* @return {@link Number}
* @throws GPDAOException
*/
@Override
public Number count(Long accountID, String nameProject) throws GPDAOException {
checkArgument(accountID != null, "The Parameter accountID must not be null.");
try {
CriteriaBuilder builder = super.criteriaBuilder();
CriteriaQuery<Long> criteriaQuery = builder.createQuery(Long.class);
Root<GPAccountProject> root = criteriaQuery.from(this.persistentClass);
criteriaQuery.select(builder.count(root));
List<Predicate> predicates = Lists.newArrayList();
predicates.add(builder.equal(root.join("account").get("id"), accountID));
if ((nameProject != null) && !(nameProject.trim().isEmpty()))
predicates.add(builder.like(builder.lower(root.get("project").get("name")), nameProject.toLowerCase()));
criteriaQuery.where(predicates.stream().toArray(size -> new Predicate[size]));
return this.entityManager.createQuery(criteriaQuery).getSingleResult();
} catch (Exception ex) {
ex.printStackTrace();
throw new GPDAOException(ex);
}
}
use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.
the class GPAccountProjectDAOImpl method removeByProjectID.
/**
* @param projectID
* @return {@link Boolean}
* @throws GPDAOException
*/
@Override
public Boolean removeByProjectID(Long projectID) throws GPDAOException {
checkArgument(projectID != null, "The Parameter projectID must not be null.");
try {
CriteriaBuilder builder = super.criteriaBuilder();
CriteriaDelete<GPAccountProject> criteriaDelete = super.createCriteriaDelete();
Root<GPAccountProject> root = criteriaDelete.from(super.getPersistentClass());
criteriaDelete.where(builder.equal(root.join("project").get("id"), projectID));
return ((this.entityManager.createQuery(criteriaDelete).executeUpdate() == 1) ? TRUE : FALSE);
} catch (Exception ex) {
ex.printStackTrace();
throw new GPDAOException(ex);
}
}
use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.
the class GPAccountProjectDAOImpl method findByAccountID.
/**
* @param accountID
* @return {@link List<GPAccountProject>}
* @throws GPDAOException
*/
@Override
public List<GPAccountProject> findByAccountID(Long accountID) throws GPDAOException {
checkArgument(accountID != null, "The Parameter accountID must not be null.");
try {
CriteriaQuery<GPAccountProject> criteriaQuery = super.createCriteriaQuery();
Root<GPAccountProject> root = criteriaQuery.from(this.persistentClass);
criteriaQuery.select(root);
criteriaQuery.where(super.criteriaBuilder().equal(root.join("account").get("id"), accountID));
return this.entityManager.createQuery(criteriaQuery).getResultList();
} catch (Exception ex) {
ex.printStackTrace();
throw new GPDAOException(ex);
}
}
use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.
the class GPAccountProjectDAOImpl method searchAccountProjectsByAccountID.
/**
* @param page
* @param size
* @param accountID
* @param projectName
* @return {@link List < GPAccountProject >}
* @throws GPDAOException
*/
@Override
public List<GPAccountProject> searchAccountProjectsByAccountID(Integer page, Integer size, Long accountID, String projectName) throws GPDAOException {
checkArgument(accountID != null, "The Parameter accountID must not be null.");
try {
CriteriaBuilder builder = super.criteriaBuilder();
CriteriaQuery<GPAccountProject> criteriaQuery = super.createCriteriaQuery();
Root<GPAccountProject> root = criteriaQuery.from(this.persistentClass);
criteriaQuery.select(root);
List<Predicate> predicates = Lists.newArrayList();
predicates.add(builder.equal(root.join("account").get("id"), accountID));
if ((projectName != null) && !(projectName.trim().isEmpty()))
predicates.add(builder.like(builder.lower(root.get("project").get("name")), projectName.toLowerCase()));
criteriaQuery.where(predicates.stream().toArray(Predicate[]::new)).orderBy(builder.asc(root.get("defaultProject")));
TypedQuery<GPAccountProject> typedQuery = this.entityManager.createQuery(criteriaQuery);
if ((page != null) && (size != null)) {
Integer firstResult = (page == 0) ? 0 : ((page * size));
typedQuery.setFirstResult(firstResult);
typedQuery.setMaxResults(size);
}
return typedQuery.getResultList();
} catch (Exception ex) {
ex.printStackTrace();
throw new GPDAOException(ex);
}
}
Aggregations