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());
}
}
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);
}
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());
}
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);
}
}
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);
}
Aggregations