Search in sources :

Example 11 with GPProject

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);
    }
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) GPProject(org.geosdi.geoplatform.core.model.GPProject) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 12 with GPProject

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);
    }
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) GPProject(org.geosdi.geoplatform.core.model.GPProject) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)

Example 13 with GPProject

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();
}
Also used : GPFolder(org.geosdi.geoplatform.core.model.GPFolder) GPProject(org.geosdi.geoplatform.core.model.GPProject) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPWebServiceMapData(org.geosdi.geoplatform.response.collection.GPWebServiceMapData) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault)

Example 14 with GPProject

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;
}
Also used : GPFolder(org.geosdi.geoplatform.core.model.GPFolder) GPProject(org.geosdi.geoplatform.core.model.GPProject) GPWebServiceMapData(org.geosdi.geoplatform.response.collection.GPWebServiceMapData) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault)

Example 15 with GPProject

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);
}
Also used : GPProject(org.geosdi.geoplatform.core.model.GPProject) Test(org.junit.Test)

Aggregations

GPProject (org.geosdi.geoplatform.core.model.GPProject)15 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)7 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)5 GPDAOException (org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)5 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)4 GPFolder (org.geosdi.geoplatform.core.model.GPFolder)3 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)3 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)3 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)3 GPWebServiceMapData (org.geosdi.geoplatform.response.collection.GPWebServiceMapData)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 Date (java.util.Date)1 GPAccountProject (org.geosdi.geoplatform.core.model.GPAccountProject)1 GPUser (org.geosdi.geoplatform.core.model.GPUser)1 PutAccountsProjectRequest (org.geosdi.geoplatform.request.PutAccountsProjectRequest)1 EntityCorrectnessException (org.geosdi.geoplatform.services.development.EntityCorrectnessException)1 Roster (org.jivesoftware.smack.Roster)1 Message (org.jivesoftware.smack.packet.Message)1 Presence (org.jivesoftware.smack.packet.Presence)1