Search in sources :

Example 11 with GPViewport

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

the class GPViewportDelegate method saveOrUpdateViewportList.

@Override
public void saveOrUpdateViewportList(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);
    }
    for (GPViewport viewport : viewportList) {
        long idViewport = 0;
        if (viewport != null && viewport.getId() != null) {
            GPViewport orig = viewportDao.find(viewport.getId());
            if (orig != null) {
                // TODO assert
                EntityCorrectness.checkViewport(orig);
                viewport.setAccountProject(accountProject);
                idViewport = this.updateAndMergeFields(orig, viewport);
            }
        } else if (idViewport == 0) {
            idViewport = 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 12 with GPViewport

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

the class GPViewportDelegate method getDefaultViewport.

// <editor-fold defaultstate="collapsed" desc="Viewport">
// =========================================================================
// === Viewport
// =========================================================================
@Override
public GPViewport getDefaultViewport(Long accountProjectID) throws ResourceNotFoundFault {
    List<GPViewport> viewportList = viewportDao.findByAccountProjectID(accountProjectID);
    if (viewportList == null) {
        throw new ResourceNotFoundFault("Viewport not found using the accountProject id", accountProjectID);
    }
    GPViewport viewport = null;
    for (GPViewport viewportElement : viewportList) {
        if (viewportElement.isIsDefault()) {
            viewport = viewportElement;
            break;
        }
    }
    return viewport;
}
Also used : GPViewport(org.geosdi.geoplatform.core.model.GPViewport) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault)

Example 13 with GPViewport

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

the class RSViewportTest method insertMassiveViewportTestRest.

@Test
public void insertMassiveViewportTestRest() throws Exception {
    Collection<GPViewport> viewports = super.createMassiveViewports();
    gpWSClient.saveOrUpdateViewportList(new ManageViewportRequest(idAccountProject, new ArrayList<>(viewports)));
    Collection<GPViewport> viewportsFound = gpWSClient.getAccountProjectViewports(idAccountProject).getViewports();
    logger.trace("\n\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@FOUND {} " + "@@@@@@@@@@@@@@@@@@@@@@@@@\n\n", viewportsFound);
    Assert.assertEquals(80, viewportsFound.size());
    GPViewport defaultVieport = gpWSClient.getDefaultViewport(idAccountProject);
    logger.trace("\n\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@DEFAULT_VIEWPORT " + "Found : {}@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n", defaultVieport);
    Assert.assertEquals("Viewport0-Rest", defaultVieport.getName());
    Assert.assertEquals(0.0, defaultVieport.getZoomLevel(), 0.0);
}
Also used : GPViewport(org.geosdi.geoplatform.core.model.GPViewport) ManageViewportRequest(org.geosdi.geoplatform.request.viewport.ManageViewportRequest) ArrayList(java.util.ArrayList) 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