Search in sources :

Example 11 with GeoObjectOverTime

use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.

the class GeoObjectOverTimeServiceTest method testGetGeoObjectOverTimeByCode.

@Test
public void testGetGeoObjectOverTimeByCode() {
    // Allowed Users
    TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
    for (TestUserInfo user : allowedUsers) {
        FastTestDataset.runAsUser(user, (request, adapter) -> {
            GeoObjectOverTime geoObj = adapter.getGeoObjectOverTimeByCode(FastTestDataset.CAMBODIA.getCode(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
            Assert.assertEquals(geoObj.toJSON().toString(), GeoObjectOverTime.fromJSON(adapter, geoObj.toJSON().toString()).toJSON().toString());
            Assert.assertEquals(true, geoObj.getExists(TestDataSet.DEFAULT_OVER_TIME_DATE));
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) Test(org.junit.Test)

Example 12 with GeoObjectOverTime

use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.

the class RegistryVersionTest method testInsertDuplicateBetween.

/**
 * Tests to make sure if we set a value which is encompassed by a larger surrounding date range
 * that the operation is ignored.
 */
@Test
public void testInsertDuplicateBetween() throws ParseException {
    final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    this.addVersionData(FastTestDataset.PROV_CENTRAL);
    Assert.assertEquals(3, FastTestDataset.PROV_CENTRAL.getServerObject().getValuesOverTime(DefaultAttribute.EXISTS.getName()).size());
    FastTestDataset.PROV_CENTRAL.getServerObject().setExists(Boolean.TRUE, dateFormat.parse("02-10-1990"), dateFormat.parse("02-15-1990"));
    Assert.assertEquals(3, FastTestDataset.PROV_CENTRAL.getServerObject().getValuesOverTime(DefaultAttribute.EXISTS.getName()).size());
    GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode());
    Assert.assertEquals(3, goTime.getAllValues(DefaultAttribute.EXISTS.getName()).size());
    Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getCode(), goTime.getCode());
    Assert.assertEquals(Boolean.FALSE, goTime.getExists(dateFormat.parse("1990-01-01")));
    Assert.assertEquals(Boolean.TRUE, goTime.getExists(dateFormat.parse("1990-02-01")));
    Assert.assertEquals(Boolean.FALSE, goTime.getExists(dateFormat.parse("1990-03-01")));
    ValueOverTimeCollectionDTO allStatus = goTime.getAllValues(DefaultAttribute.EXISTS.getName());
    Assert.assertEquals("1990-01-01", dateFormat.format(allStatus.get(0).getStartDate()));
    Assert.assertEquals("1990-01-31", dateFormat.format(allStatus.get(0).getEndDate()));
    Assert.assertEquals("1990-02-01", dateFormat.format(allStatus.get(1).getStartDate()));
    Assert.assertEquals("1990-02-28", dateFormat.format(allStatus.get(1).getEndDate()));
    Assert.assertEquals("1990-03-01", dateFormat.format(allStatus.get(2).getStartDate()));
    Assert.assertEquals("1990-03-31", dateFormat.format(allStatus.get(2).getEndDate()));
    Geometry expectedGeom = FastTestDataset.PROV_CENTRAL.fetchGeoObject().getGeometry();
    Geometry actualGeom = ((AttributeGeometry) goTime.getAttributeOnDate(DefaultAttribute.GEOMETRY.getName(), FastTestDataset.DEFAULT_OVER_TIME_DATE)).getValue();
    Assert.assertTrue(expectedGeom.equalsTopo(actualGeom));
}
Also used : AttributeGeometry(org.commongeoregistry.adapter.dataaccess.AttributeGeometry) Geometry(com.vividsolutions.jts.geom.Geometry) ValueOverTimeCollectionDTO(org.commongeoregistry.adapter.dataaccess.ValueOverTimeCollectionDTO) AttributeGeometry(org.commongeoregistry.adapter.dataaccess.AttributeGeometry) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 13 with GeoObjectOverTime

use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.

the class RegistryVersionTest method testGetGeoObjectOverTimeByCode.

@Test
public void testGetGeoObjectOverTimeByCode() throws ParseException {
    this.addVersionData(FastTestDataset.PROV_CENTRAL);
    GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode());
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getCode(), goTime.getCode());
    Assert.assertEquals(Boolean.FALSE, goTime.getExists(dateFormat.parse("1990-01-01")));
    Assert.assertEquals(Boolean.TRUE, goTime.getExists(dateFormat.parse("1990-02-01")));
    Assert.assertEquals(Boolean.FALSE, goTime.getExists(dateFormat.parse("1990-03-01")));
    ValueOverTimeCollectionDTO allStatus = goTime.getAllValues(DefaultAttribute.EXISTS.getName());
    Assert.assertEquals("1990-01-01", dateFormat.format(allStatus.get(0).getStartDate()));
    Assert.assertEquals("1990-01-31", dateFormat.format(allStatus.get(0).getEndDate()));
    Assert.assertEquals("1990-02-01", dateFormat.format(allStatus.get(1).getStartDate()));
    Assert.assertEquals("1990-02-28", dateFormat.format(allStatus.get(1).getEndDate()));
    Assert.assertEquals("1990-03-01", dateFormat.format(allStatus.get(2).getStartDate()));
    Assert.assertEquals("1990-03-31", dateFormat.format(allStatus.get(2).getEndDate()));
    Geometry expectedGeom = FastTestDataset.PROV_CENTRAL.fetchGeoObject().getGeometry();
    Geometry actualGeom = ((AttributeGeometry) goTime.getAttributeOnDate(DefaultAttribute.GEOMETRY.getName(), FastTestDataset.DEFAULT_OVER_TIME_DATE)).getValue();
    Assert.assertTrue(expectedGeom.equalsTopo(actualGeom));
}
Also used : AttributeGeometry(org.commongeoregistry.adapter.dataaccess.AttributeGeometry) Geometry(com.vividsolutions.jts.geom.Geometry) ValueOverTimeCollectionDTO(org.commongeoregistry.adapter.dataaccess.ValueOverTimeCollectionDTO) AttributeGeometry(org.commongeoregistry.adapter.dataaccess.AttributeGeometry) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 14 with GeoObjectOverTime

use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.

the class CreateGeoObjectAction method execute.

@Override
public void execute() {
    String sJson = this.getGeoObjectJson();
    GeoObjectOverTime geoObject = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), sJson);
    ServerGeoObjectService service = new ServerGeoObjectService();
    service.apply(geoObject, true, false);
    ServerGeoObjectIF child = service.getGeoObjectByCode(geoObject.getCode(), geoObject.getType().getCode());
    ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(child.getType(), this.getParentJson());
    child.setParents(ptnOt);
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime)

Example 15 with GeoObjectOverTime

use of org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime in project geoprism-registry by terraframe.

the class UpdateGeoObjectAction method getMessage.

@Override
protected String getMessage() {
    GeoObjectOverTime go = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), this.getGeoObjectJson());
    GeoObjectType got = go.getType();
    String message = LocalizationFacade.getFromBundles("change.request.email.update.object");
    message = message.replaceAll("\\{0\\}", go.getCode());
    message = message.replaceAll("\\{1\\}", got.getLabel().getValue(Session.getCurrentLocale()));
    return message;
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)

Aggregations

GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)30 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)9 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)9 Test (org.junit.Test)9 Geometry (com.vividsolutions.jts.geom.Geometry)5 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)4 Endpoint (com.runwaysdk.mvc.Endpoint)4 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)4 Request (com.runwaysdk.session.Request)4 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)4 ServerParentTreeNodeOverTime (net.geoprism.registry.view.ServerParentTreeNodeOverTime)4 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)4 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)4 ValueOverTimeCollectionDTO (org.commongeoregistry.adapter.dataaccess.ValueOverTimeCollectionDTO)4 JsonObject (com.google.gson.JsonObject)3 VertexObject (com.runwaysdk.business.graph.VertexObject)3 SimpleDateFormat (java.text.SimpleDateFormat)3 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)3 TestUserInfo (net.geoprism.registry.test.TestUserInfo)3 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)3