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