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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations