Search in sources :

Example 1 with BasePagingLoadResult

use of com.extjs.gxt.ui.client.data.BasePagingLoadResult in project geo-platform by geosdi.

the class LayerService method searchProjects.

@Override
public BasePagingLoadResult<GPClientProject> searchProjects(PagingLoadConfig config, String searchText, String imageURL, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    GPAccount account;
    try {
        account = this.sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    int start = config.getOffset();
    SearchRequest srq = new SearchRequest(searchText);
    try {
        Long projectsCount = this.geoPlatformServiceClient.getAccountProjectsCount(account.getId(), srq);
        if (projectsCount == 0l) {
            throw new GeoPlatformException("There are no results");
        }
        logger.debug("#############################PROJECT_COUNT : {}\n", projectsCount);
        int page = start == 0 ? start : start / config.getLimit();
        PaginatedSearchRequest psr = new PaginatedSearchRequest(searchText, config.getLimit(), page);
        List<ProjectDTO> projectsDTO = this.geoPlatformServiceClient.searchAccountProjects(account.getId(), psr);
        if (projectsDTO == null) {
            throw new GeoPlatformException("There are no results");
        }
        ArrayList<GPClientProject> clientProjects = new ArrayList<GPClientProject>();
        for (ProjectDTO projectDTO : projectsDTO) {
            GPClientProject clientProject = this.dtoLayerConverter.convertToGPCLientProject(projectDTO, imageURL);
            clientProjects.add(clientProject);
        }
        return new BasePagingLoadResult<GPClientProject>(clientProjects, config.getOffset(), projectsCount.intValue());
    } catch (ResourceNotFoundFault ex) {
        ex.printStackTrace();
        throw new GeoPlatformException(ex.getMessage());
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GeoPlatformException(ex.getMessage());
    }
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) GPClientProject(org.geosdi.geoplatform.gui.client.model.projects.GPClientProject) SearchRequest(org.geosdi.geoplatform.request.SearchRequest) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) ArrayList(java.util.ArrayList) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) BasePagingLoadResult(com.extjs.gxt.ui.client.data.BasePagingLoadResult) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 2 with BasePagingLoadResult

use of com.extjs.gxt.ui.client.data.BasePagingLoadResult in project geo-platform by geosdi.

the class GPCatalogFinderService method searchCSWServers.

@Override
public PagingLoadResult<GPCSWServerBeanModel> searchCSWServers(PagingLoadConfig config, String searchText, String organization, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    SearchRequest srq = new SearchRequest(searchText);
    int serversCount = geoPlatformCSWClient.getCSWServersCount(srq, organization);
    ArrayList<GPCSWServerBeanModel> searchServers;
    if (serversCount == 0) {
        logger.info("\n*** No catalog found ***");
        searchServers = new ArrayList<GPCSWServerBeanModel>(0);
    } else {
        int start = config.getOffset();
        int page = start == 0 ? start : start / config.getLimit();
        PaginatedSearchRequest psr = new PaginatedSearchRequest(searchText, config.getLimit(), page);
        List<ServerCSWDTO> serverList = geoPlatformCSWClient.searchCSWServers(psr, organization);
        searchServers = new ArrayList<GPCSWServerBeanModel>(serverList.size());
        for (ServerCSWDTO serverDTO : serverList) {
            searchServers.add(this.convertServerDTO(serverDTO));
        }
    }
    return new BasePagingLoadResult<GPCSWServerBeanModel>(searchServers, config.getOffset(), serversCount);
}
Also used : PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) SearchRequest(org.geosdi.geoplatform.request.SearchRequest) ServerCSWDTO(org.geosdi.geoplatform.responce.ServerCSWDTO) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) GPCSWServerBeanModel(org.geosdi.geoplatform.gui.model.server.GPCSWServerBeanModel) BasePagingLoadResult(com.extjs.gxt.ui.client.data.BasePagingLoadResult)

Example 3 with BasePagingLoadResult

use of com.extjs.gxt.ui.client.data.BasePagingLoadResult in project geo-platform by geosdi.

the class GPCatalogFinderService method searchSummaryRecords.

@Override
public PagingLoadResult<SummaryRecord> searchSummaryRecords(PagingLoadConfig config, CatalogFinderBean catalogFinder, HttpServletRequest httpServletRequest) throws Exception {
    int recordsCount;
    ArrayList<SummaryRecord> searchRecords;
    try {
        recordsCount = geoPlatformCSWClient.getRecordsCount(catalogFinder);
        if (recordsCount == 0) {
            logger.info("\n*** No Summary Record found ***");
            searchRecords = new ArrayList<SummaryRecord>(0);
        } else {
            List<SummaryRecordDTO> recordList = geoPlatformCSWClient.searchSummaryRecords(config.getLimit(), config.getOffset() + 1, catalogFinder);
            searchRecords = new ArrayList<SummaryRecord>(recordList.size());
            for (SummaryRecordDTO recordDTO : recordList) {
                searchRecords.add(this.convertSummaryRecordDTO(recordDTO));
            }
        }
    } catch (IllegalParameterFault ex) {
        logger.error("\n*** IllegalParameterFault ***\n{}", ex.getMessage());
        throw new GeoPlatformException(ex.getMessage());
    } catch (ResourceNotFoundFault ex) {
        logger.error("\n*** ResourceNotFoundFault ***\n{}", ex.getMessage());
        throw new GeoPlatformException(ex.getMessage());
    } catch (ServerInternalFault ex) {
        logger.error("\n*** ServerInternalFault ***\n{}", ex.getMessage());
        throw new GeoPlatformException(ex.getMessage());
    }
    return new BasePagingLoadResult<SummaryRecord>(searchRecords, config.getOffset(), recordsCount);
}
Also used : IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) SummaryRecord(org.geosdi.geoplatform.gui.client.model.SummaryRecord) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) SummaryRecordDTO(org.geosdi.geoplatform.responce.SummaryRecordDTO) ServerInternalFault(org.geosdi.geoplatform.exception.ServerInternalFault) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) BasePagingLoadResult(com.extjs.gxt.ui.client.data.BasePagingLoadResult)

Example 4 with BasePagingLoadResult

use of com.extjs.gxt.ui.client.data.BasePagingLoadResult in project geo-platform by geosdi.

the class GPCatalogFinderService method searchFullRecords.

@Override
public PagingLoadResult<FullRecord> searchFullRecords(PagingLoadConfig config, CatalogFinderBean catalogFinder, HttpServletRequest httpServletRequest) throws Exception {
    logger.debug("\n--------------------------\n{}\n--------------------------\n", catalogFinder);
    int recordsCount;
    ArrayList<FullRecord> searchRecords;
    try {
        recordsCount = geoPlatformCSWClient.getRecordsCount(catalogFinder);
        if (recordsCount == 0) {
            logger.info("\n*** No Full Record found ***");
            searchRecords = new ArrayList<FullRecord>(0);
        } else {
            List<FullRecordDTO> recordList = geoPlatformCSWClient.searchFullRecords(config.getLimit(), config.getOffset() + 1, catalogFinder);
            searchRecords = new ArrayList<FullRecord>(recordList.size());
            for (FullRecordDTO recordDTO : recordList) {
                searchRecords.add(this.convertFullRecordDTO(recordDTO));
            }
        }
    } catch (IllegalParameterFault ex) {
        logger.error("\n*** IllegalParameterFault ***\n{}", ex.getMessage());
        throw new GeoPlatformException(ex.getMessage());
    } catch (ResourceNotFoundFault ex) {
        logger.error("\n*** ResourceNotFoundFault ***\n{}", ex.getMessage());
        throw new GeoPlatformException(ex.getMessage());
    } catch (ServerInternalFault ex) {
        logger.error("\n*** ServerInternalFault ***\n{}", ex.getMessage());
        throw new GeoPlatformException(ex.getMessage());
    }
    return new BasePagingLoadResult<FullRecord>(searchRecords, config.getOffset(), recordsCount);
}
Also used : IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) FullRecord(org.geosdi.geoplatform.gui.client.model.FullRecord) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) FullRecordDTO(org.geosdi.geoplatform.responce.FullRecordDTO) ServerInternalFault(org.geosdi.geoplatform.exception.ServerInternalFault) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) BasePagingLoadResult(com.extjs.gxt.ui.client.data.BasePagingLoadResult)

Example 5 with BasePagingLoadResult

use of com.extjs.gxt.ui.client.data.BasePagingLoadResult in project geo-platform by geosdi.

the class UserService method searchUsers.

@Override
public PagingLoadResult<GPUserManageDetail> searchUsers(PagingLoadConfig config, String searchText, String organization, HttpServletRequest httpServletRequest) {
    GPUser user = this.getCheckLoggedUser(httpServletRequest);
    SearchRequest srq = new SearchRequest(searchText);
    Long usersCount = this.geoPlatformServiceClient.getUsersCount(organization, srq);
    int start = config.getOffset();
    int page = start == 0 ? start : start / config.getLimit();
    PaginatedSearchRequest psr = new PaginatedSearchRequest(searchText, config.getLimit(), page);
    List<UserDTO> userList = null;
    try {
        userList = this.geoPlatformServiceClient.searchUsers(user.getId(), psr).getSearchUsers();
        if (userList == null) {
            throw new GeoPlatformException("There are no results");
        }
    } catch (ResourceNotFoundFault rnnf) {
        // TODO Better message
        throw new GeoPlatformException(rnnf.getMessage());
    }
    List<GPUserManageDetail> searchUsers = new ArrayList<GPUserManageDetail>();
    for (UserDTO userDTO : userList) {
        GPUserManageDetail userDetail = this.dtoUserConverter.convertToGPUserManageDetail(userDTO);
        searchUsers.add(userDetail);
    }
    return new BasePagingLoadResult<GPUserManageDetail>(searchUsers, config.getOffset(), usersCount.intValue());
}
Also used : PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) SearchRequest(org.geosdi.geoplatform.request.SearchRequest) GPUser(org.geosdi.geoplatform.core.model.GPUser) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) UserDTO(org.geosdi.geoplatform.response.UserDTO) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) ArrayList(java.util.ArrayList) BasePagingLoadResult(com.extjs.gxt.ui.client.data.BasePagingLoadResult) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) GPUserManageDetail(org.geosdi.geoplatform.gui.client.model.GPUserManageDetail) IGPUserManageDetail(org.geosdi.geoplatform.gui.global.security.IGPUserManageDetail)

Aggregations

BasePagingLoadResult (com.extjs.gxt.ui.client.data.BasePagingLoadResult)5 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)4 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)4 PaginatedSearchRequest (org.geosdi.geoplatform.request.PaginatedSearchRequest)3 SearchRequest (org.geosdi.geoplatform.request.SearchRequest)3 ArrayList (java.util.ArrayList)2 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)2 ServerInternalFault (org.geosdi.geoplatform.exception.ServerInternalFault)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)1 GPUser (org.geosdi.geoplatform.core.model.GPUser)1 FullRecord (org.geosdi.geoplatform.gui.client.model.FullRecord)1 GPUserManageDetail (org.geosdi.geoplatform.gui.client.model.GPUserManageDetail)1 SummaryRecord (org.geosdi.geoplatform.gui.client.model.SummaryRecord)1 GPClientProject (org.geosdi.geoplatform.gui.client.model.projects.GPClientProject)1 IGPUserManageDetail (org.geosdi.geoplatform.gui.global.security.IGPUserManageDetail)1 GPCSWServerBeanModel (org.geosdi.geoplatform.gui.model.server.GPCSWServerBeanModel)1 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)1 FullRecordDTO (org.geosdi.geoplatform.responce.FullRecordDTO)1