use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.
the class GPAccountProjectDAOImpl method forceAsDefaultProject.
/**
* @param accountID
* @param projectID
* @return {@link GPAccountProject}
* @throws GPDAOException
*/
@Override
public GPAccountProject forceAsDefaultProject(Long accountID, Long projectID) throws GPDAOException {
GPAccountProject oldDefault = this.findDefaultProjectByAccountID(accountID);
if (oldDefault != null) {
oldDefault.setDefaultProject(FALSE);
super.update(oldDefault);
}
GPAccountProject newDefault = this.find(accountID, projectID);
if (newDefault == null)
return null;
newDefault.setDefaultProject(TRUE);
return super.update(newDefault);
}
use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.
the class GPAccountProjectDAOImpl method findByProjectID.
/**
* @param projectID
* @return {@link List<GPAccountProject>}
* @throws GPDAOException
*/
@Override
public List<GPAccountProject> findByProjectID(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);
criteriaQuery.where(super.criteriaBuilder().equal(root.join("project").get("id"), projectID));
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 findOwnerByProjectID.
/**
* @param projectID
* @return {@link GPAccountProject}
* @throws GPDAOException
*/
@Override
public GPAccountProject findOwnerByProjectID(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.equal(root.get("permissionMask"), ADMINISTRATION.getMask())));
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 GPViewportDelegate method saveOrUpdateViewportList.
@Override
public void saveOrUpdateViewportList(ManageViewportRequest request) throws ResourceNotFoundFault, IllegalParameterFault {
if (request == null) {
throw new IllegalParameterFault("The ManageViewportRequest " + "must not be null.");
}
Long accountProjectID = request.getAccountProjectID();
ArrayList<GPViewport> viewportList = request.getViewportList();
GPAccountProject accountProject = this.accountProjectDao.find(accountProjectID);
if (accountProject == null) {
throw new ResourceNotFoundFault("AccountProject not found", accountProjectID);
}
for (GPViewport viewport : viewportList) {
long idViewport = 0;
if (viewport != null && viewport.getId() != null) {
GPViewport orig = viewportDao.find(viewport.getId());
if (orig != null) {
// TODO assert
EntityCorrectness.checkViewport(orig);
viewport.setAccountProject(accountProject);
idViewport = this.updateAndMergeFields(orig, viewport);
}
} else if (idViewport == 0) {
idViewport = this.insertViewport(accountProjectID, viewport);
}
}
}
use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.
the class GPJacksonAccountSupportTest method accountProjectDataMapperTest.
@Test
public void accountProjectDataMapperTest() throws Exception {
GPAccountProject accountProject = jacksonSupport.getDefaultMapper().readValue(Thread.currentThread().getContextClassLoader().getResourceAsStream(ACCOUNT_PROJECT_DATA_JSON), GPAccountProject.class);
logger.info("\n\n@@@@@@@@@@@@@@@@@@@@@@@@@ACCOUNT_PROJECT_DATA_MAPPING" + " : {}\n\n", accountProject);
super.marshall(accountProject);
}
Aggregations