Search in sources :

Example 1 with GPViewport

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

the class MapService method convertServerViewportToDTO.

private List<GPClientViewport> convertServerViewportToDTO(Collection<GPViewport> viewportCollection) {
    List<GPClientViewport> clientViewportList = Lists.<GPClientViewport>newArrayList();
    GPClientViewport clientViewport;
    GPBBox serverBBOX;
    BBoxClientInfo clientBBOX;
    if (viewportCollection != null) {
        for (GPViewport viewport : viewportCollection) {
            serverBBOX = viewport.getBbox();
            clientBBOX = new BBoxClientInfo(serverBBOX.getMinX(), serverBBOX.getMinY(), serverBBOX.getMaxX(), serverBBOX.getMaxY());
            clientViewport = new GPClientViewport(viewport.getName(), viewport.getDescription(), clientBBOX, viewport.getZoomLevel(), viewport.isIsDefault());
            clientViewportList.add(clientViewport);
        }
    }
    return clientViewportList;
}
Also used : BBoxClientInfo(org.geosdi.geoplatform.gui.configuration.map.client.geometry.BBoxClientInfo) GPViewport(org.geosdi.geoplatform.core.model.GPViewport) GPClientViewport(org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport) GPBBox(org.geosdi.geoplatform.core.model.GPBBox)

Example 2 with GPViewport

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

the class GPViewportDelegate method replaceViewportList.

@Override
public void replaceViewportList(ManageViewportRequest request) throws ResourceNotFoundFault, IllegalParameterFault {
    if (request == null) {
        throw new IllegalParameterFault("The ManageViewportRequest must " + "not be null.");
    }
    Long accountProjectID = request.getAccountProjectID();
    ArrayList<GPViewport> viewportList = request.getViewportList();
    GPAccountProject accountProject = this.accountProjectDao.find(accountProjectID);
    if (accountProject == null) {
        throw new ResourceNotFoundFault("AccountProject not found", accountProjectID);
    }
    List<GPViewport> oldViewportList = this.viewportDao.findByAccountProjectID(accountProjectID);
    for (GPViewport viewport : oldViewportList) {
        this.viewportDao.removeById(viewport.getId());
    }
    if (viewportList != null) {
        for (GPViewport viewport : viewportList) {
            this.insertViewport(accountProjectID, viewport);
        }
    }
}
Also used : GPViewport(org.geosdi.geoplatform.core.model.GPViewport) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPAccountProject(org.geosdi.geoplatform.core.model.GPAccountProject) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault)

Example 3 with GPViewport

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

the class GPViewportDelegate method deleteViewport.

@Override
public Boolean deleteViewport(Long viewportID) throws ResourceNotFoundFault {
    GPViewport viewport = viewportDao.find(viewportID);
    if (viewport == null) {
        throw new ResourceNotFoundFault("Viewport not found", viewportID);
    }
    // TODO assert
    EntityCorrectness.checkViewportLog(viewport);
    return viewportDao.removeById(viewport.getId());
}
Also used : GPViewport(org.geosdi.geoplatform.core.model.GPViewport) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault)

Example 4 with GPViewport

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

the class RSViewportTest method updateViewportTestRest.

@Test
public void updateViewportTestRest() throws Exception {
    Long idViewportDefault = gpWSClient.insertViewport(new InsertViewportRequest(idAccountProject, new GPViewport("Viewport-To-Save-RS", "This is the viewport to save", 22, new GPBBox(10, 10, 20, 20), Boolean.TRUE)));
    Assert.assertNotNull(idViewportDefault);
    Long idViewport = gpWSClient.insertViewport(new InsertViewportRequest(idAccountProject, new GPViewport("Viewport-To-Save-New-RS", "This is the viewport to save New", 18, new GPBBox(18, 20, 40, 29), Boolean.FALSE)));
    Assert.assertNotNull(idViewport);
    Long idViewport1 = gpWSClient.insertViewport(new InsertViewportRequest(idAccountProject, new GPViewport("Viewport-To-Save-New-1-RS", "This is the viewport to save New", 31, new GPBBox(21, 33, 50, 79), Boolean.FALSE)));
    Assert.assertNotNull(idViewport1);
    Collection<GPViewport> viewports = gpWSClient.getAccountProjectViewports(idAccountProject).getViewports();
    Assert.assertEquals(3, viewports.size());
    GPViewport viewport = gpWSClient.getDefaultViewport(idAccountProject);
    Assert.assertEquals(Boolean.TRUE, viewport.isIsDefault());
    Assert.assertEquals("Viewport-To-Save-RS", viewport.getName());
    viewport.setName("Viewport-Updated-RS");
    viewport.setDescription("New Description");
    viewport.setIsDefault(Boolean.FALSE);
    gpWSClient.updateViewport(viewport);
    GPViewport v = gpWSClient.getViewportById(idViewport1);
    v.setIsDefault(Boolean.TRUE);
    gpWSClient.updateViewport(v);
    GPViewport df = gpWSClient.getDefaultViewport(idAccountProject);
    Assert.assertEquals(idViewport1, df.getId());
}
Also used : InsertViewportRequest(org.geosdi.geoplatform.request.viewport.InsertViewportRequest) GPViewport(org.geosdi.geoplatform.core.model.GPViewport) GPBBox(org.geosdi.geoplatform.core.model.GPBBox) Test(org.junit.Test)

Example 5 with GPViewport

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

the class RSViewportTest method deleteViewportTestRest.

@Test
public void deleteViewportTestRest() throws Exception {
    Long idViewport = gpWSClient.insertViewport(new InsertViewportRequest(idAccountProject, new GPViewport("Viewport-To-Delete-RS", "This is the viewport to Delete", 26, new GPBBox(15, 15, 22, 30), Boolean.TRUE)));
    Assert.assertNotNull(idViewport);
    GPViewport viewport = gpWSClient.getViewportById(idViewport);
    Assert.assertNotNull(viewport);
    logger.trace("\n\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@VIEWPORT_FOUND :" + " {}\n\n", viewport);
    Assert.assertTrue(gpWSClient.deleteViewport(idViewport));
}
Also used : InsertViewportRequest(org.geosdi.geoplatform.request.viewport.InsertViewportRequest) GPViewport(org.geosdi.geoplatform.core.model.GPViewport) GPBBox(org.geosdi.geoplatform.core.model.GPBBox) Test(org.junit.Test)

Aggregations

GPViewport (org.geosdi.geoplatform.core.model.GPViewport)13 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)6 GPBBox (org.geosdi.geoplatform.core.model.GPBBox)4 Test (org.junit.Test)4 GPAccountProject (org.geosdi.geoplatform.core.model.GPAccountProject)3 ArrayList (java.util.ArrayList)2 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)2 GPClientViewport (org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport)2 BBoxClientInfo (org.geosdi.geoplatform.gui.configuration.map.client.geometry.BBoxClientInfo)2 InsertViewportRequest (org.geosdi.geoplatform.request.viewport.InsertViewportRequest)2 ManageViewportRequest (org.geosdi.geoplatform.request.viewport.ManageViewportRequest)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)1 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)1 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)1 GPDAOException (org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)1