Search in sources :

Example 26 with GeoObjectOverTime

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

the class GeoObjectOverTimeServiceTest method testCreateGeoObjectOverTimeBadGeometry.

@Test
public void testCreateGeoObjectOverTimeBadGeometry() {
    GeometryBuilder builder = new GeometryBuilder(new GeometryFactory());
    Point point = builder.point(48.44, -123.37);
    GeoObjectOverTime geoObj = TEST_GO.newGeoObjectOverTime(testData.adapter);
    geoObj.setGeometry(point, TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_OVER_TIME_DATE);
    try {
        testData.adapter.createGeoObjectOverTime(geoObj.toJSON().toString());
        Assert.fail("Able to create a GeoObject with a wrong geometry type");
    } catch (SmartExceptionDTO e) {
        // This is expected
        Assert.assertEquals(GeometryTypeException.CLASS, e.getType());
    }
}
Also used : GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) Point(com.vividsolutions.jts.geom.Point) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO) GeometryBuilder(org.geotools.geometry.jts.GeometryBuilder) Test(org.junit.Test)

Example 27 with GeoObjectOverTime

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

the class GeoObjectOverTimeServiceTest method testGetGeoObjectOverTime.

@Test
public void testGetGeoObjectOverTime() {
    // 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.getGeoObjectOverTime(FastTestDataset.CAMBODIA.getRegistryId(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
            FastTestDataset.CAMBODIA.assertEquals(geoObj);
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) Test(org.junit.Test)

Example 28 with GeoObjectOverTime

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

the class GovernanceTest method testActionSerialization.

/**
 * Tests serialization on the DTOs and also conversion to/from DTO
 */
@Test
public void testActionSerialization() {
    TestGeoObjectInfo testGo = FastTestDataset.CAMBODIA;
    // GeoObjectOverTime go = testGo.asGeoObject();
    GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.CAMBODIA.getCode(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
    testGo.setRegistryId(goTime.getUid());
    /*
     * UpdateGeoObject
     */
    UpdateGeoObjectActionDTO updateDTO = new UpdateGeoObjectActionDTO();
    updateDTO.setGeoObject(goTime.toJSON());
    updateDTO.setCreateActionDate(Date.from(Instant.now().minus(6, ChronoUnit.HOURS)));
    updateDTO.setContributorNotes("UPDATE_CONTRIB_NOTES");
    updateDTO.setMaintainerNotes("UPDATE_MAINTAIN_NOTES");
    String updateJson = updateDTO.toJSON().toString();
    String updateJson2 = AbstractActionDTO.parseAction(updateJson).toJSON().toString();
    Assert.assertEquals(updateJson, updateJson2);
    UpdateGeoObjectAction updateRA = (UpdateGeoObjectAction) AbstractAction.dtoToRegistry(updateDTO);
    GeoObjectOverTime updateRAGO = GeoObjectOverTime.fromJSON(testData.adapter, updateRA.getGeoObjectJson());
    // testGo.assertEquals(updateRAGO);
    Assert.assertEquals(updateDTO.getContributorNotes(), updateRA.getContributorNotes());
    Assert.assertEquals(updateDTO.getMaintainerNotes(), updateRA.getMaintainerNotes());
    Assert.assertEquals(updateDTO.getApiVersion(), updateRA.getApiVersion());
// Assert.assertEquals(updateDTO.getCreateActionDate().getTime(),
// updateRA.getCreateActionDate().getTime()); // TODO : Runway dates are
// accurate to the second, but epoch is accurate to the milisecond.
/*
     * TODO : The rest of the supported actions
     */
}
Also used : UpdateGeoObjectActionDTO(org.commongeoregistry.adapter.action.geoobject.UpdateGeoObjectActionDTO) UpdateGeoObjectAction(net.geoprism.registry.action.geoobject.UpdateGeoObjectAction) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) TestGeoObjectInfo(net.geoprism.registry.test.TestGeoObjectInfo) Test(org.junit.Test)

Example 29 with GeoObjectOverTime

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

the class GovernanceTest method testUpdateAction.

@Test
public void testUpdateAction() {
    Date startDate = new Date();
    Date endDate = new Date();
    GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.CAMBODIA.getCode(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
    goTime.setDisplayLabel(new LocalizedValue("test 123"), startDate, endDate);
    UpdateGeoObjectActionDTO updateDTO = new UpdateGeoObjectActionDTO();
    updateDTO.setGeoObject(goTime.toJSON());
    updateDTO.setCreateActionDate(Date.from(Instant.now().minus(6, ChronoUnit.HOURS)));
    updateDTO.setContributorNotes("UPDATE_CONTRIB_NOTES");
    updateDTO.setMaintainerNotes("UPDATE_MAINTAIN_NOTES");
    UpdateGeoObjectAction updateRA = (UpdateGeoObjectAction) AbstractAction.dtoToRegistry(updateDTO);
    execute(updateRA);
    GeoObjectOverTime goTime2 = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.CAMBODIA.getCode(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
    Assert.assertEquals("test 123", goTime2.getDisplayLabel(startDate).getValue());
}
Also used : UpdateGeoObjectActionDTO(org.commongeoregistry.adapter.action.geoobject.UpdateGeoObjectActionDTO) UpdateGeoObjectAction(net.geoprism.registry.action.geoobject.UpdateGeoObjectAction) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) Date(java.util.Date) Test(org.junit.Test)

Example 30 with GeoObjectOverTime

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

the class RegistryVersionTest method genericDuplicateDatatypeTest.

private void genericDuplicateDatatypeTest(String attributeName, Object value) throws ParseException {
    final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    // Initial Setup : Create a VOT with a large date range
    VertexServerGeoObject serverObj = (VertexServerGeoObject) FastTestDataset.PROV_CENTRAL.getServerObject();
    serverObj.getValuesOverTime(attributeName).clear();
    serverObj.setValue(attributeName, value, dateFormat.parse("1990-01-01"), dateFormat.parse("1990-02-01"));
    serverObj.apply(false);
    Assert.assertEquals(1, FastTestDataset.PROV_CENTRAL.getServerObject().getValuesOverTime(attributeName).size());
    // Set a value inside that date range with the same value
    VertexServerGeoObject serverObj2 = (VertexServerGeoObject) FastTestDataset.PROV_CENTRAL.getServerObject();
    serverObj2.setValue(attributeName, value, dateFormat.parse("1990-01-05"), dateFormat.parse("1990-01-10"));
    serverObj2.apply(false);
    // Fetch the object and assert values on it
    Assert.assertEquals(1, FastTestDataset.PROV_CENTRAL.getServerObject().getValuesOverTime(attributeName).size());
    GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode());
    Assert.assertEquals(1, goTime.getAllValues(attributeName).size());
    ValueOverTimeCollectionDTO all = goTime.getAllValues(attributeName);
    Assert.assertEquals("1990-01-01", dateFormat.format(all.get(0).getStartDate()));
    Assert.assertEquals("1990-02-01", dateFormat.format(all.get(0).getEndDate()));
    Assert.assertTrue(value.equals(all.get(0).getValue()));
}
Also used : ValueOverTimeCollectionDTO(org.commongeoregistry.adapter.dataaccess.ValueOverTimeCollectionDTO) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) SimpleDateFormat(java.text.SimpleDateFormat)

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