use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testUpdateGeoObjectDateCR_applyCR.
@Request
private Object[] testUpdateGeoObjectDateCR_applyCR() throws Exception {
final Long newValue = new Date().getTime();
final String attrName = FastTestDataset.AT_DATE_OF_FORMATION.getAttributeName();
ChangeRequest cr = new ChangeRequest();
cr.addApprovalStatus(AllGovernanceStatus.PENDING);
cr.setOrganizationCode(FastTestDataset.ORG_CGOV.getCode());
cr.setGeoObjectCode(FastTestDataset.CAMBODIA.getCode());
cr.setGeoObjectTypeCode(FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
cr.apply();
UpdateAttributeAction action = new UpdateAttributeAction();
action.setApiVersion("1.0");
((UpdateAttributeActionBase) action).setAttributeName(attrName);
JsonObject diff = new JsonObject();
VertexServerGeoObject cambodia = (VertexServerGeoObject) FastTestDataset.CAMBODIA.getServerObject();
ValueOverTime vot = cambodia.getValuesOverTime(attrName).getValueOverTime(FastTestDataset.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
JsonArray valuesOverTime = JsonParser.parseString("[" + "{" + " \"oid\": \"" + vot.getOid() + "\"," + " \"action\": \"UPDATE\"," + " \"oldEndDate\": \"" + OLD_END_DATE + "\"," + " \"oldStartDate\": \"" + OLD_START_DATE + "\"," + " \"oldValue\": \"\"," + " \"newValue\": \"\"," + " \"newStartDate\": \"" + NEW_START_DATE + "\"," + " \"newEndDate\": \"" + NEW_END_DATE + "\"" + "}" + "]").getAsJsonArray();
valuesOverTime.get(0).getAsJsonObject().addProperty("oldValue", ((Date) FastTestDataset.CAMBODIA.getDefaultValue(attrName)).getTime());
valuesOverTime.get(0).getAsJsonObject().addProperty("newValue", newValue);
diff.add("valuesOverTime", valuesOverTime);
((UpdateAttributeActionBase) action).setJson(diff.toString());
action.addApprovalStatus(AllGovernanceStatus.ACCEPTED);
action.setCreateActionDate(new Date());
action.apply();
cr.addAction(action).apply();
String serializedCR = cr.toJSON().toString();
return new Object[] { serializedCR, vot.getOid(), newValue };
}
use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testUpdateGeoObjectGeometryCR_Verify.
@Request
private void testUpdateGeoObjectGeometryCR_Verify(String[] data) throws Exception {
final String oldOid = data[1];
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
sdf.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
final Date newStartDate = sdf.parse(NEW_START_DATE);
final Date newEndDate = sdf.parse(NEW_END_DATE);
ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
Assert.assertEquals(1, crq.getCount());
ChangeRequest cr = crq.getIterator().next();
Assert.assertEquals(AllGovernanceStatus.ACCEPTED.name(), cr.getGovernanceStatus().name());
AbstractAction action = cr.getAllAction().next();
Assert.assertTrue(action instanceof UpdateAttributeAction);
Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), cr.getGeoObjectCode());
Assert.assertEquals(FastTestDataset.CAMBODIA.getGeoObjectType().getCode(), cr.getGeoObjectTypeCode());
Assert.assertEquals(FastTestDataset.ORG_CGOV.getCode(), cr.getOrganizationCode());
VertexServerGeoObject cambodia = (VertexServerGeoObject) FastTestDataset.CAMBODIA.getServerObject();
ValueOverTimeCollection votc = cambodia.getValuesOverTime(cambodia.getGeometryAttributeName());
Assert.assertEquals(1, votc.size());
ValueOverTime vot1 = votc.get(0);
Assert.assertNotNull(vot1.getOid());
Assert.assertEquals(oldOid, vot1.getOid());
Assert.assertEquals(newStartDate, vot1.getStartDate());
Assert.assertEquals(newEndDate, vot1.getEndDate());
Assert.assertTrue(vot1.getValue() instanceof Geometry);
}
use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testUpdateGeoObjectGeometryCR_applyCR.
@Request
private String[] testUpdateGeoObjectGeometryCR_applyCR() throws Exception {
AttributeGeometryType geomType = FastTestDataset.CAMBODIA.fetchGeoObjectOverTime().getGeometryAttributeType();
ChangeRequest cr = new ChangeRequest();
cr.addApprovalStatus(AllGovernanceStatus.PENDING);
cr.setOrganizationCode(FastTestDataset.ORG_CGOV.getCode());
cr.setGeoObjectCode(FastTestDataset.CAMBODIA.getCode());
cr.setGeoObjectTypeCode(FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
cr.apply();
UpdateAttributeAction action = new UpdateAttributeAction();
action.setApiVersion("1.0");
((UpdateAttributeActionBase) action).setAttributeName(geomType.getName());
JsonObject diff = new JsonObject();
VertexServerGeoObject cambodia = (VertexServerGeoObject) FastTestDataset.CAMBODIA.getServerObject();
ValueOverTime vot = cambodia.getValuesOverTime(cambodia.getGeometryAttributeName()).getValueOverTime(FastTestDataset.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
GeoJSONWriter gw = new GeoJSONWriter();
org.wololo.geojson.Geometry gJSON = gw.write((Geometry) vot.getValue());
JsonObject geojson = JsonParser.parseString(gJSON.toString()).getAsJsonObject();
JsonArray valuesOverTime = JsonParser.parseString("[" + "{" + " \"oid\": \"" + vot.getOid() + "\"," + " \"action\": \"UPDATE\"," + " \"oldEndDate\": \"" + OLD_END_DATE + "\"," + " \"oldStartDate\": \"" + OLD_START_DATE + "\"," + " \"oldValue\": \"\"," + " \"newValue\": \"\"," + " \"newStartDate\": \"" + NEW_START_DATE + "\"," + " \"newEndDate\": \"" + NEW_END_DATE + "\"" + "}" + "]").getAsJsonArray();
valuesOverTime.get(0).getAsJsonObject().add("oldValue", geojson);
valuesOverTime.get(0).getAsJsonObject().add("newValue", geojson);
diff.add("valuesOverTime", valuesOverTime);
((UpdateAttributeActionBase) action).setJson(diff.toString());
action.addApprovalStatus(AllGovernanceStatus.ACCEPTED);
action.setCreateActionDate(new Date());
action.apply();
cr.addAction(action).apply();
String serializedCR = cr.toJSON().toString();
return new String[] { serializedCR, vot.getOid() };
}
use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.
the class ValueOverTimeParentTest method testFullConsumeDifferentValue.
/**
* Imported data completely consumes existing data, and the values are different.
*/
@Test
@Request
public void testFullConsumeDifferentValue() {
ServerGeoObjectIF go = TEST_GO.getServerObject();
go.addParent(BELIZE.getServerObject(), FastTestDataset.HIER_ADMIN.getServerObject(), addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, -5), addDay(TestDataSet.DEFAULT_END_TIME_DATE, 5));
go.apply(false);
go = TEST_GO.getServerObject();
ValueOverTimeCollection votc = go.getParentCollection(FastTestDataset.HIER_ADMIN.getServerObject());
Assert.assertEquals(1, votc.size());
ValueOverTime vot = votc.get(0);
Assert.assertEquals(BELIZE.getCode(), ((ServerGeoObjectIF) vot.getValue()).getCode());
Assert.assertEquals(addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, -5), vot.getStartDate());
Assert.assertEquals(addDay(TestDataSet.DEFAULT_END_TIME_DATE, 5), vot.getEndDate());
}
use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.
the class ValueOverTimeParentTest method testFullConsumeSameValue.
/**
* Imported data completely consumes existing data, and the values are the same.
*/
@Test
@Request
public void testFullConsumeSameValue() {
ServerGeoObjectIF go = TEST_GO.getServerObject();
go.addParent(FastTestDataset.CAMBODIA.getServerObject(), FastTestDataset.HIER_ADMIN.getServerObject(), addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, -5), addDay(TestDataSet.DEFAULT_END_TIME_DATE, 5));
go.apply(false);
go = TEST_GO.getServerObject();
ValueOverTimeCollection votc = go.getParentCollection(FastTestDataset.HIER_ADMIN.getServerObject());
Assert.assertEquals(1, votc.size());
ValueOverTime vot = votc.get(0);
Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), ((ServerGeoObjectIF) vot.getValue()).getCode());
Assert.assertEquals(addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, -5), vot.getStartDate());
Assert.assertEquals(addDay(TestDataSet.DEFAULT_END_TIME_DATE, 5), vot.getEndDate());
}
Aggregations