use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testImplementParentDecisionsVerify.
@Request
private void testImplementParentDecisionsVerify(String crOid) throws Exception {
ChangeRequest cr = ChangeRequest.get(crOid);
Assert.assertEquals(AllGovernanceStatus.ACCEPTED.name(), cr.getApprovalStatus().get(0).name());
AbstractAction action = cr.getAllAction().next();
Assert.assertEquals(AllGovernanceStatus.ACCEPTED.name(), action.getApprovalStatus().get(0).name());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
sdf.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
Date newStartDate = sdf.parse(NEW_START_DATE);
Date newEndDate = sdf.parse(NEW_END_DATE);
ServerGeoObjectIF serverGo = FastTestDataset.PROV_CENTRAL.getServerObject();
List<ServerParentTreeNode> ptns = serverGo.getParentsOverTime(new String[] { FastTestDataset.COUNTRY.getCode() }, false).getEntries(FastTestDataset.HIER_ADMIN.getServerObject());
Assert.assertEquals(1, ptns.size());
ServerParentTreeNode ptn = ptns.get(0);
List<ServerParentTreeNode> parents = ptn.getParents();
Assert.assertEquals(1, parents.size());
ServerParentTreeNode parent = parents.get(0);
Assert.assertEquals(newStartDate, ptn.getStartDate());
Assert.assertEquals(newEndDate, ptn.getEndDate());
Assert.assertEquals(BELIZE.getCode(), parent.getGeoObject().getCode());
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testComplexUpdateGeoObjectCR_Verify.
@Request
private void testComplexUpdateGeoObjectCR_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);
final Date oldStartDate = sdf.parse(OLD_START_DATE);
final Date oldEndDate = sdf.parse(OLD_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());
ServerGeoObjectIF cambodia = FastTestDataset.CAMBODIA.getServerObject();
ValueOverTimeCollection votc = cambodia.getValuesOverTime(FastTestDataset.AT_National_Anthem.getAttributeName());
Assert.assertEquals(2, votc.size());
ValueOverTime vot1 = votc.get(0);
Assert.assertNotNull(vot1.getOid());
Assert.assertTrue(!(vot1.getOid().equals(oldOid)));
Assert.assertEquals(NEW_ANTHEM, vot1.getValue());
Assert.assertEquals(oldStartDate, vot1.getStartDate());
Assert.assertEquals(oldEndDate, vot1.getEndDate());
ValueOverTime vot2 = votc.get(1);
Assert.assertNotNull(vot2.getOid());
Assert.assertTrue(!(vot2.getOid().equals(oldOid)));
Assert.assertEquals(NEW_ANTHEM, vot2.getValue());
Assert.assertEquals(newStartDate, vot2.getStartDate());
Assert.assertEquals(newEndDate, vot2.getEndDate());
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testComplexUpdateGeoObjectCR_applyCR.
@Request
private String[] testComplexUpdateGeoObjectCR_applyCR() throws Exception {
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(FastTestDataset.AT_National_Anthem.getAttributeName());
JsonObject diff = new JsonObject();
ServerGeoObjectIF cambodia = FastTestDataset.CAMBODIA.getServerObject();
String votOid = cambodia.getValuesOverTime(FastTestDataset.AT_National_Anthem.getAttributeName()).getValueOverTime(FastTestDataset.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE).getOid();
JsonArray valuesOverTime = JsonParser.parseString("[" + "{" + " \"oid\": \"" + votOid + "\"," + " \"action\": \"DELETE\"" + "}," + "{" + " \"action\": \"CREATE\"," + " \"newValue\": \"" + NEW_ANTHEM + "\"," + " \"newStartDate\": \"" + NEW_START_DATE + "\"," + " \"newEndDate\": \"" + NEW_END_DATE + "\"" + "}," + "{" + " \"action\": \"CREATE\"," + " \"newValue\": \"" + NEW_ANTHEM + "\"," + " \"newStartDate\": \"" + OLD_START_DATE + "\"," + " \"newEndDate\": \"" + OLD_END_DATE + "\"" + "}" + "]").getAsJsonArray();
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, votOid };
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class GeoObjectServiceTest method testCodeStripWhitespace.
@Test
@Request
public void testCodeStripWhitespace() {
TEST_GO.apply();
ServerGeoObjectIF serverGo = TEST_GO.getServerObject();
serverGo.setCode("\t" + serverGo.getCode() + " ");
serverGo.apply(false);
Assert.assertEquals(TEST_GO.getCode(), TEST_GO.getServerObject().getCode());
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class ValueOverTimeParentTest method testPartialOverlapDifferentValue.
/**
* Imported data partially overlaps an existing range, and the values are different.
*/
@Test
@Request
public void testPartialOverlapDifferentValue() {
ServerGeoObjectIF go = TEST_GO.getServerObject();
go.addParent(BELIZE.getServerObject(), FastTestDataset.HIER_ADMIN.getServerObject(), addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, -30), addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, 5));
go.apply(false);
go = TEST_GO.getServerObject();
ValueOverTimeCollection votc = go.getParentCollection(FastTestDataset.HIER_ADMIN.getServerObject());
Assert.assertEquals(2, votc.size());
ValueOverTime vot = votc.get(0);
Assert.assertEquals(BELIZE.getCode(), ((ServerGeoObjectIF) vot.getValue()).getCode());
Assert.assertEquals(addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, -30), vot.getStartDate());
Assert.assertEquals(addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, 5), vot.getEndDate());
ValueOverTime vot2 = votc.get(1);
Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), ((ServerGeoObjectIF) vot2.getValue()).getCode());
Assert.assertEquals(addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, 6), vot2.getStartDate());
Assert.assertEquals(TestDataSet.DEFAULT_END_TIME_DATE, vot2.getEndDate());
}
Aggregations