Search in sources :

Example 1 with GPFolder

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

the class LayerService method saveFolder.

@Override
public Long saveFolder(Long idParentFolder, String folderName, int position, int numberOfDescendants, boolean isChecked, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    try {
        this.sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    GPFolder gpFolder = null;
    try {
        gpFolder = geoPlatformServiceClient.getFolderDetail(idParentFolder);
    } catch (Exception e) {
        logger.error("LayerService", "Ubable to load Folder with ID : " + idParentFolder);
        throw new GeoPlatformException("The Folder with ID : " + idParentFolder + " was deleted.");
    }
    GPFolder folder = new GPFolder();
    folder.setName(folderName);
    folder.setPosition(position);
    folder.setShared(false);
    folder.setParent(gpFolder);
    folder.setNumberOfDescendants(numberOfDescendants);
    folder.setChecked(isChecked);
    Long projectId;
    // folder.setProject(project);
    Long savedFolderId = null;
    try {
        projectId = this.sessionUtility.getDefaultProject(httpServletRequest);
        savedFolderId = this.geoPlatformServiceClient.insertFolder(new InsertFolderRequest(projectId, folder));
    } catch (IllegalParameterFault ilg) {
        logger.error("Error on LayerService: " + ilg);
        throw new GeoPlatformException("Parameter incorrect on saveFolde");
    } catch (ResourceNotFoundFault rnff) {
        logger.error("Error on LayerService: " + rnff);
        throw new GeoPlatformException(rnff);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    return savedFolderId;
}
Also used : GPFolder(org.geosdi.geoplatform.core.model.GPFolder) InsertFolderRequest(org.geosdi.geoplatform.request.folder.InsertFolderRequest) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) 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 GPFolder

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

the class LayerService method saveAddedFolderAndTreeModifications.

@Override
public Long saveAddedFolderAndTreeModifications(MementoSaveAddedFolder memento, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    try {
        this.sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    GPWebServiceMapData map = this.dtoMementoConverter.convertDescendantMap(memento.getWsDescendantMap());
    Long idSavedFolder;
    try {
        Long projectId = this.sessionUtility.getDefaultProject(httpServletRequest);
        GPFolder gpFolder = this.dtoLayerConverter.convertMementoFolder(memento.getAddedFolder());
        idSavedFolder = this.geoPlatformServiceClient.saveAddedFolderAndTreeModifications(new WSAddFolderAndTreeModificationsRequest(projectId, memento.getAddedFolder().getIdParent(), gpFolder, map));
    } catch (ResourceNotFoundFault ex) {
        this.logger.error("Failed to save folder on LayerService: " + ex);
        throw new GeoPlatformException(ex);
    } catch (IllegalParameterFault ilg) {
        logger.error("Error on LayerService: " + ilg);
        throw new GeoPlatformException("Parameter incorrect on saveAddedFolderAndTreeModifications");
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    } catch (Exception ex) {
        throw new GeoPlatformException(ex.getMessage());
    }
    return idSavedFolder;
}
Also used : GPFolder(org.geosdi.geoplatform.core.model.GPFolder) WSAddFolderAndTreeModificationsRequest(org.geosdi.geoplatform.request.folder.WSAddFolderAndTreeModificationsRequest) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPWebServiceMapData(org.geosdi.geoplatform.response.collection.GPWebServiceMapData) 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 3 with GPFolder

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

the class DTOLayerConverter method convertMementoFolder.

/**
 * @param memento
 * @return {@link GPFolder}
 * @throws Exception
 */
public GPFolder convertMementoFolder(@Nonnull(when = NEVER) MementoFolder memento) throws Exception {
    checkArgument(memento != null, "The Parameter memento must not be null.");
    GPFolder gpFolder = new GPFolder();
    gpFolder.setId(memento.getIdBaseElement());
    gpFolder.setName(memento.getFolderName());
    gpFolder.setNumberOfDescendants(memento.getNumberOfDescendants());
    gpFolder.setPosition(memento.getzIndex());
    /*
         * TODO: Once implemented shared function you must set this property
         * gpFolder.setShared(true);
         */
    return gpFolder;
}
Also used : GPFolder(org.geosdi.geoplatform.core.model.GPFolder)

Example 4 with GPFolder

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

the class GPFolderDAOImpl method persistCheckStatusFolder.

/**
 * @param folderID
 * @param checked
 * @return {@link Boolean}
 * @throws GPDAOException
 */
@Override
public Boolean persistCheckStatusFolder(Long folderID, boolean checked) throws GPDAOException {
    checkArgument(folderID != null, "The Parameter folderID must not be null.");
    GPFolder folder = super.find(folderID);
    if (folder == null) {
        logger.debug("\n*** The Folder with ID \"{}\" is NOT exist into DB ***", folderID);
        return FALSE;
    }
    logger.trace("\n*** Folder RETRIEVED:\n{}\n*** MOD checked to {} ***", folder, checked);
    // Merge iff the check status is different
    if (folder.isChecked() != checked) {
        folder.setChecked(checked);
        GPFolder folderUpdated = super.update(folder);
        if (folderUpdated.isChecked() != checked) {
            return FALSE;
        }
    }
    return TRUE;
}
Also used : GPFolder(org.geosdi.geoplatform.core.model.GPFolder)

Example 5 with GPFolder

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

the class GPFolderDAOImpl method find.

/**
 * @param ids
 * @return {@link }
 * @throws GPDAOException
 */
@Override
public List<GPFolder> find(Long... ids) throws GPDAOException {
    checkArgument(ids != null, "The Parameter ids must not be null.");
    try {
        List<Long> values = Stream.of(ids).filter(Objects::nonNull).collect(toList());
        checkArgument((values != null) && !(values.isEmpty()), "The Parameter ids must contains element.");
        CriteriaQuery<GPFolder> criteriaQuery = super.createCriteriaQuery();
        Root<GPFolder> root = criteriaQuery.from(this.persistentClass);
        criteriaQuery.select(root);
        criteriaQuery.where(root.get("id").in(values));
        return this.entityManager.createQuery(criteriaQuery).getResultList();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GPDAOException(ex);
    }
}
Also used : GPFolder(org.geosdi.geoplatform.core.model.GPFolder) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)

Aggregations

GPFolder (org.geosdi.geoplatform.core.model.GPFolder)41 GPDAOException (org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)14 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)13 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)11 GPWebServiceMapData (org.geosdi.geoplatform.response.collection.GPWebServiceMapData)9 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)7 Test (org.junit.Test)7 WSAddFolderAndTreeModificationsRequest (org.geosdi.geoplatform.request.folder.WSAddFolderAndTreeModificationsRequest)6 HashMap (java.util.HashMap)4 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)4 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)4 WSDeleteFolderAndTreeModifications (org.geosdi.geoplatform.request.folder.WSDeleteFolderAndTreeModifications)4 GPProject (org.geosdi.geoplatform.core.model.GPProject)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 GPLayer (org.geosdi.geoplatform.core.model.GPLayer)2 InsertFolderRequest (org.geosdi.geoplatform.request.folder.InsertFolderRequest)2 FolderDTO (org.geosdi.geoplatform.response.FolderDTO)2 ArrayList (java.util.ArrayList)1 SaveAddedFolderAndTreeModificationsResponse (org.geosdi.geoplatform.gui.client.command.memento.toolbar.SaveAddedFolderAndTreeModificationsResponse)1