Search in sources :

Example 1 with PaginatedSearchRequest

use of org.geosdi.geoplatform.request.PaginatedSearchRequest 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 PaginatedSearchRequest

use of org.geosdi.geoplatform.request.PaginatedSearchRequest 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 PaginatedSearchRequest

use of org.geosdi.geoplatform.request.PaginatedSearchRequest in project geo-platform by geosdi.

the class CSWCatalogServerTest method testSearchCSWServers.

@Test
public void testSearchCSWServers() {
    // wrt title
    PaginatedSearchRequest request = new PaginatedSearchRequest("test", 10, 0);
    List<ServerCSWDTO> search = cswService.searchCSWServers(request, super.organizationNameTest);
    Assert.assertNotNull(search);
    Assert.assertEquals(1, search.size());
}
Also used : ServerCSWDTO(org.geosdi.geoplatform.responce.ServerCSWDTO) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) Test(org.junit.Test)

Example 4 with PaginatedSearchRequest

use of org.geosdi.geoplatform.request.PaginatedSearchRequest in project geo-platform by geosdi.

the class CSWCatalogServerTest method testSearchCSWServersMore.

@Test
public void testSearchCSWServersMore() throws Exception {
    // Insert 27 servers (only 25 for matching wrt alias)
    Long[] serverIDs = new Long[27];
    for (int i = 1; i <= 27; i++) {
        GeoPlatformServer server = super.createCSWServer("Mock title " + i, "http://url.mock-" + i, organizationTest);
        if (i >= 3) {
            server.setAliasName("Alias test " + i);
        }
        serverIDs[i - 1] = cswService.insertServerCSW(server);
        Assert.assertNotNull(serverIDs[i - 1]);
    }
    // First page
    // wrt title and alias
    PaginatedSearchRequest request = new PaginatedSearchRequest("test", 10, 0);
    List<ServerCSWDTO> search = cswService.searchCSWServers(request, super.organizationNameTest);
    Assert.assertNotNull(search);
    Assert.assertEquals(10, search.size());
    // Second page
    // wrt title and alias
    request = new PaginatedSearchRequest("test", 10, 1);
    search = cswService.searchCSWServers(request, super.organizationNameTest);
    Assert.assertNotNull(search);
    Assert.assertEquals(10, search.size());
    // Third page
    // wrt title and alias
    request = new PaginatedSearchRequest("test", 10, 2);
    search = cswService.searchCSWServers(request, super.organizationNameTest);
    Assert.assertNotNull(search);
    Assert.assertEquals(6, search.size());
    // Delete the servers
    for (Long serverID : serverIDs) {
        boolean deleted = cswService.deleteServerCSW(serverID);
        Assert.assertTrue(deleted);
    }
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) ServerCSWDTO(org.geosdi.geoplatform.responce.ServerCSWDTO) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) Test(org.junit.Test)

Example 5 with PaginatedSearchRequest

use of org.geosdi.geoplatform.request.PaginatedSearchRequest in project geo-platform by geosdi.

the class CSWCatalogServerTest method testSearchCSWServersNothing.

@Test
public void testSearchCSWServersNothing() {
    PaginatedSearchRequest request = new PaginatedSearchRequest("nothing", 10, 0);
    List<ServerCSWDTO> search = cswService.searchCSWServers(request, super.organizationNameTest);
    Assert.assertNull(search);
}
Also used : ServerCSWDTO(org.geosdi.geoplatform.responce.ServerCSWDTO) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) Test(org.junit.Test)

Aggregations

PaginatedSearchRequest (org.geosdi.geoplatform.request.PaginatedSearchRequest)6 ServerCSWDTO (org.geosdi.geoplatform.responce.ServerCSWDTO)4 BasePagingLoadResult (com.extjs.gxt.ui.client.data.BasePagingLoadResult)3 SearchRequest (org.geosdi.geoplatform.request.SearchRequest)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)2 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)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 GeoPlatformServer (org.geosdi.geoplatform.core.model.GeoPlatformServer)1 GPUserManageDetail (org.geosdi.geoplatform.gui.client.model.GPUserManageDetail)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 UserDTO (org.geosdi.geoplatform.response.UserDTO)1