use of org.geosdi.geoplatform.core.model.GPProject in project geo-platform by geosdi.
the class LayerService method setDefaultProject.
@Override
public void setDefaultProject(Long projectID, HttpServletRequest httpServletRequest) throws GeoPlatformException {
try {
GPAccount account = this.sessionUtility.getLoggedAccount(httpServletRequest);
GPProject updatedProjecd = this.geoPlatformServiceClient.updateDefaultProject(account.getId(), projectID);
this.sessionUtility.storeLoggedAccountAndDefaultProject(account, updatedProjecd.getId(), httpServletRequest);
} catch (GPSessionTimeout timeout) {
throw new GeoPlatformException(timeout);
} catch (ResourceNotFoundFault ex) {
logger.error("An Error Occured : " + ex.getMessage());
throw new GeoPlatformException(ex);
}
}
use of org.geosdi.geoplatform.core.model.GPProject in project geo-platform by geosdi.
the class GPProjectDAOImpl method findExternalPublic.
/**
* @param size
* @param page
* @return {@link List<GPProject>}
* @throws GPDAOException
*/
@Override
public List<GPProject> findExternalPublic(int size, int page) throws GPDAOException {
try {
CriteriaBuilder builder = super.criteriaBuilder();
CriteriaQuery<GPProject> criteriaQuery = super.createCriteriaQuery();
Root<GPProject> root = criteriaQuery.from(this.persistentClass);
criteriaQuery.select(root);
criteriaQuery.where(builder.equal(root.get("externalPublic"), TRUE));
TypedQuery<GPProject> typedQuery = this.entityManager.createQuery(criteriaQuery);
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);
}
}
use of org.geosdi.geoplatform.core.model.GPProject in project geo-platform by geosdi.
the class GPFolderDelegate method saveAddedFolderAndTreeModifications.
@Override
public Long saveAddedFolderAndTreeModifications(WSAddFolderAndTreeModificationsRequest sftModificationRequest) throws ResourceNotFoundFault, IllegalParameterFault {
Long projectId = sftModificationRequest.getProjectID();
Long parentId = sftModificationRequest.getParentID();
GPFolder folder = sftModificationRequest.getFolder();
GPWebServiceMapData descendantsMapData = sftModificationRequest.getDescendantsMapData();
logger.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@SERVER SIDE @@@@@@@@@@@@@@ {}", descendantsMapData);
GPProject project = projectDao.find(projectId);
if (project == null) {
throw new ResourceNotFoundFault("Project not found", projectId);
}
// TODO assert
EntityCorrectness.checkProjectLog(project);
folder.setProject(project);
if (parentId != null) {
if (descendantsMapData.getDescendantsMap().isEmpty()) {
// TODO assert
throw new IllegalParameterFault("descendantsMapData must have one or more entries if the folder has a parent");
}
GPFolder parentFolder = folderDao.find(parentId);
if (parentFolder == null) {
throw new ResourceNotFoundFault("Folder parent not found", parentId);
}
// TODO assert
EntityCorrectness.checkFolderLog(parentFolder);
folder.setParent(parentFolder);
}
// TODO assert
EntityCorrectness.checkFolder(folder);
int newPosition = folder.getPosition();
int increment = 1;
// Shift positions
folderDao.updatePositionsLowerBound(projectId, newPosition, increment);
layerDao.updatePositionsLowerBound(projectId, newPosition, increment);
folderDao.persist(folder);
folderDao.updateAncestorsDescendants(descendantsMapData.getDescendantsMap());
this.updateNumberOfElements(project, increment);
return folder.getId();
}
use of org.geosdi.geoplatform.core.model.GPProject in project geo-platform by geosdi.
the class GPFolderDelegate method saveDeletedFolderAndTreeModifications.
@Override
public Boolean saveDeletedFolderAndTreeModifications(WSDeleteFolderAndTreeModifications sdfModificationRequest) throws ResourceNotFoundFault {
Long folderID = sdfModificationRequest.getFolderID();
GPWebServiceMapData descendantsMapData = sdfModificationRequest.getDescendantsMapData();
GPFolder folder = folderDao.find(folderID);
if (folder == null) {
throw new ResourceNotFoundFault("Folder not found", folderID);
}
// TODO assert
EntityCorrectness.checkFolderLog(folder);
int oldPosition = folder.getPosition();
int decrement = -(folder.getNumberOfDescendants() + 1);
boolean result = folderDao.removeById(folder.getId());
GPProject project = folder.getProject();
// Shift positions (shift must be done only after removing folder)
folderDao.updatePositionsLowerBound(project.getId(), oldPosition, decrement);
layerDao.updatePositionsLowerBound(project.getId(), oldPosition, decrement);
folderDao.updateAncestorsDescendants(descendantsMapData.getDescendantsMap());
this.updateNumberOfElements(project, decrement);
return result;
}
use of org.geosdi.geoplatform.core.model.GPProject in project geo-platform by geosdi.
the class GPJacksonProjectSupportTest method projectDataMapperTest.
@Test
public void projectDataMapperTest() throws Exception {
GPProject project = jacksonSupport.getDefaultMapper().readValue(Thread.currentThread().getContextClassLoader().getResourceAsStream(PROJECT_DATA_JSON), GPProject.class);
logger.info("\n\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@PROJECT_DATA_MAPPING" + " : {}\n\n", project);
super.marshall(project);
}
Aggregations