use of org.commongeoregistry.adapter.metadata.AttributeGeometryType 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() };
}
Aggregations