Search in sources :

Example 1 with GPAccountProject

use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.

the class GPAccountProjectDAOImpl method findNotOwnersByProjectID.

/**
 * @param projectID
 * @return {@link List<GPAccountProject>}
 * @throws GPDAOException
 */
@Override
public List<GPAccountProject> findNotOwnersByProjectID(Long projectID) throws GPDAOException {
    checkArgument(projectID != null, "The Parameter projectID must not be null");
    try {
        CriteriaQuery<GPAccountProject> criteriaQuery = super.createCriteriaQuery();
        Root<GPAccountProject> root = criteriaQuery.from(this.persistentClass);
        criteriaQuery.select(root);
        CriteriaBuilder criteriaBuilder = super.criteriaBuilder();
        criteriaQuery.where(criteriaBuilder.and(criteriaBuilder.equal(root.join("project").get("id"), projectID), criteriaBuilder.notEqual(root.get("permissionMask"), ADMINISTRATION.getMask())));
        return this.entityManager.createQuery(criteriaQuery).getResultList();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GPDAOException(ex);
    }
}
Also used : GPAccountProject(org.geosdi.geoplatform.core.model.GPAccountProject) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)

Example 2 with GPAccountProject

use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.

the class GPAccountProjectDAOImpl method findDefaultProjectByAccountID.

/**
 * @param accountID
 * @return {@link GPAccountProject}
 * @throws GPDAOException
 */
@Override
public GPAccountProject findDefaultProjectByAccountID(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);
        CriteriaBuilder criteriaBuilder = super.criteriaBuilder();
        criteriaQuery.where(criteriaBuilder.and(criteriaBuilder.equal(root.join("account").get("id"), accountID), criteriaBuilder.equal(root.get("defaultProject"), TRUE)));
        List<GPAccountProject> accountProjects = this.entityManager.createQuery(criteriaQuery).getResultList();
        return ((accountProjects != null) && !(accountProjects.isEmpty()) ? accountProjects.get(0) : null);
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GPDAOException(ex);
    }
}
Also used : GPAccountProject(org.geosdi.geoplatform.core.model.GPAccountProject) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)

Example 3 with GPAccountProject

use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.

the class GPAccountProjectDAOImpl method find.

/**
 * @param accountID
 * @param projectID
 * @return {@link GPAccountProject}
 * @throws GPDAOException
 */
@Override
public GPAccountProject find(Long accountID, Long projectID) throws GPDAOException {
    checkArgument(accountID != null, "The Parameter accountID must not be null.");
    checkArgument(projectID != null, "The Parameter projectID must not be null.");
    try {
        CriteriaQuery<GPAccountProject> criteriaQuery = super.createCriteriaQuery();
        Root<GPAccountProject> root = criteriaQuery.from(this.persistentClass);
        CriteriaBuilder criteriaBuilder = super.criteriaBuilder();
        criteriaQuery.select(root);
        criteriaQuery.where(criteriaBuilder.and(criteriaBuilder.equal(root.join("account").get("id"), accountID), criteriaBuilder.equal(root.join("project").get("id"), projectID)));
        List<GPAccountProject> accountProjects = this.entityManager.createQuery(criteriaQuery).getResultList();
        return ((accountProjects != null) && !(accountProjects.isEmpty()) ? accountProjects.get(0) : null);
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GPDAOException(ex);
    }
}
Also used : GPAccountProject(org.geosdi.geoplatform.core.model.GPAccountProject) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)

Example 4 with GPAccountProject

use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.

the class GPAccountProjectDAOImpl method findByOwnerAccountID.

/**
 * @param accountID
 * @return {@link List<GPAccountProject>}
 * @throws GPDAOException
 */
@Override
public List<GPAccountProject> findByOwnerAccountID(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);
        CriteriaBuilder criteriaBuilder = super.criteriaBuilder();
        criteriaQuery.where(criteriaBuilder.and(criteriaBuilder.equal(root.join("account").get("id"), accountID), criteriaBuilder.equal(root.get("permissionMask"), ADMINISTRATION.getMask())));
        return this.entityManager.createQuery(criteriaQuery).getResultList();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GPDAOException(ex);
    }
}
Also used : GPAccountProject(org.geosdi.geoplatform.core.model.GPAccountProject) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)

Example 5 with GPAccountProject

use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.

the class GPAccountProjectDAOImpl method removeByAccountID.

/**
 * @param accountID
 * @return {@link Boolean}
 * @throws GPDAOException
 */
@Override
public Boolean removeByAccountID(Long accountID) throws GPDAOException {
    checkArgument(accountID != null, "The Parameter accountID 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("account").get("id"), accountID));
        return ((this.entityManager.createQuery(criteriaDelete).executeUpdate() == 1) ? TRUE : FALSE);
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GPDAOException(ex);
    }
}
Also used : GPAccountProject(org.geosdi.geoplatform.core.model.GPAccountProject) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)

Aggregations

GPAccountProject (org.geosdi.geoplatform.core.model.GPAccountProject)20 GPDAOException (org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)11 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)7 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)4 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)4 GPViewport (org.geosdi.geoplatform.core.model.GPViewport)3 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)3 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Lists (com.google.common.collect.Lists)1 FALSE (java.lang.Boolean.FALSE)1 TRUE (java.lang.Boolean.TRUE)1 List (java.util.List)1 TypedQuery (javax.persistence.TypedQuery)1 javax.persistence.criteria (javax.persistence.criteria)1 GPAccountProjectDAO (org.geosdi.geoplatform.core.dao.GPAccountProjectDAO)1 GPProject (org.geosdi.geoplatform.core.model.GPProject)1 GPAbstractJpaDAO (org.geosdi.geoplatform.persistence.dao.jpa.GPAbstractJpaDAO)1 ManageViewportRequest (org.geosdi.geoplatform.request.viewport.ManageViewportRequest)1 EntityCorrectnessException (org.geosdi.geoplatform.services.development.EntityCorrectnessException)1