Search in sources :

Example 1 with GPProject

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

the class LayerService method loadDefaultProjectElements.

@Override
public GPClientProject loadDefaultProjectElements(HttpServletRequest httpServletRequest) throws GeoPlatformException {
    Long projectId;
    GPAccount account;
    try {
        account = this.sessionUtility.getLoggedAccount(httpServletRequest);
        projectId = this.sessionUtility.getDefaultProject(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        // System.out.println("Session timeout on loadDefaultProjectElements");
        throw new GeoPlatformException(timeout);
    }
    ProjectDTO projectDTO = null;
    try {
        GPProject project = this.geoPlatformServiceClient.getProjectDetail(projectId);
        if (account.isLoadExpandedFolders() || project.isShared()) {
            projectDTO = this.geoPlatformServiceClient.getProjectWithExpandedFolders(projectId, account.getId());
        } else {
            projectDTO = geoPlatformServiceClient.getProjectWithRootFolders(projectId, account.getId());
        }
    } catch (ResourceNotFoundFault rnf) {
        logger.error("Returning no elements: " + rnf);
    }
    try {
        return this.dtoLayerConverter.convertToGPClientProject(projectDTO);
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GeoPlatformException(ex.getMessage());
    }
}
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) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 2 with GPProject

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

the class LayerService method shareProjectToUsers.

@Override
public boolean shareProjectToUsers(long idSharedProject, List<Long> accountIDsProject, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    boolean result;
    try {
        GPAccount account = this.sessionUtility.getLoggedAccount(httpServletRequest);
        result = this.geoPlatformServiceClient.updateAccountsProjectSharing(new PutAccountsProjectRequest(idSharedProject, accountIDsProject));
        if (result) {
            MessageDTO message = new MessageDTO();
            message.setCommands(Lists.newArrayList(GPMessageCommandType.OPEN_PROJECT));
            message.setCommandsProperties("" + idSharedProject);
            message.setCreationDate(new Date());
            message.setSenderID(account.getId());
            message.setSubject("Project Shared");
            String sharerName;
            if (account instanceof GPUser) {
                GPUser user = (GPUser) account;
                sharerName = user.getName();
            } else {
                sharerName = account.getNaturalID();
            }
            GPProject project = this.geoPlatformServiceClient.getProjectDetail(idSharedProject);
            message.setText(sharerName + " shared with you the " + project.getName() + " project. Do you want to open it?");
            message.setRecipientIDs(accountIDsProject);
            this.geoPlatformServiceClient.insertMultiMessage(message);
        }
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    } catch (ResourceNotFoundFault | IllegalParameterFault rnf) {
        logger.error("Failed to save Shared project to Accounts for Shared Project with id: " + idSharedProject + "on SecurityService: " + rnf);
        throw new GeoPlatformException(rnf);
    }
    return result;
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPUser(org.geosdi.geoplatform.core.model.GPUser) PutAccountsProjectRequest(org.geosdi.geoplatform.request.PutAccountsProjectRequest) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) Date(java.util.Date) GPProject(org.geosdi.geoplatform.core.model.GPProject) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 3 with GPProject

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

the class DTOLayerConverter method convertToGProject.

/**
 * @param clientProject
 * @return {@link GPProject}
 * @throws Exception
 */
public GPProject convertToGProject(@Nonnull(when = NEVER) GPClientProject clientProject) throws Exception {
    checkArgument(clientProject != null, "The Parameter clientProject must not be null.");
    GPProject project = new GPProject();
    project.setName(clientProject.getName());
    project.setShared(clientProject.isProjectShared());
    project.setDescription(clientProject.getDescription());
    project.setInternalPublic(clientProject.isInternalPublic());
    project.setExternalPublic(clientProject.isExternalPublic());
    project.setImagePath(clientProject.getPathImage());
    return project;
}
Also used : GPProject(org.geosdi.geoplatform.core.model.GPProject)

Example 4 with GPProject

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

the class GPProjectDAOImpl method findByProjectName.

/**
 * @param projectName
 * @return {@link GPProject}
 * @throws GPDAOException
 */
@Override
public GPProject findByProjectName(String projectName) throws GPDAOException {
    checkArgument((projectName != null) && !(projectName.trim().isEmpty()), "The Parameter projectName must not be null or an empty string.");
    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("name"), projectName));
        List<GPProject> projects = this.entityManager.createQuery(criteriaQuery).getResultList();
        return ((projects != null) && !(projects.isEmpty()) ? projects.get(0) : null);
    } 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 5 with GPProject

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

the class GPProjectDAOImpl method getTotalInternalPublic.

/**
 * @return {@link int}
 */
@Override
public Integer getTotalInternalPublic() {
    try {
        CriteriaBuilder builder = super.criteriaBuilder();
        CriteriaQuery<Long> criteriaQuery = builder.createQuery(Long.class);
        Root<GPProject> root = criteriaQuery.from(this.persistentClass);
        criteriaQuery.select(builder.count(root));
        criteriaQuery.where(builder.equal(root.get("internalPublic"), TRUE));
        return this.entityManager.createQuery(criteriaQuery).getSingleResult().intValue();
    } 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)

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