Search in sources :

Example 11 with ChangeRequestQuery

use of net.geoprism.registry.action.ChangeRequestQuery in project geoprism-registry by terraframe.

the class ChangeRequestServiceTest method testUpdateGeoObjectDateCR_Verify.

@Request
private void testUpdateGeoObjectDateCR_Verify(Object[] data) throws Exception {
    final String attrName = FastTestDataset.AT_DATE_OF_FORMATION.getAttributeName();
    final String oldOid = (String) 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(attrName);
    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());
    Calendar expected = Calendar.getInstance();
    expected.setTime(new Date((Long) data[2]));
    // It's surprising how imprecise Runway's dates are...
    expected.set(Calendar.SECOND, 0);
    expected.set(Calendar.MILLISECOND, 0);
    Calendar actual = Calendar.getInstance();
    actual.setTime((Date) cambodia.getValue(attrName));
    actual.set(Calendar.SECOND, 0);
    actual.set(Calendar.MILLISECOND, 0);
    Assert.assertEquals(expected.getTime(), actual.getTime());
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) Calendar(java.util.Calendar) ChangeRequest(net.geoprism.registry.action.ChangeRequest) UpdateAttributeAction(net.geoprism.registry.action.geoobject.UpdateAttributeAction) Date(java.util.Date) ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) SimpleDateFormat(java.text.SimpleDateFormat) AbstractAction(net.geoprism.registry.action.AbstractAction) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 12 with ChangeRequestQuery

use of net.geoprism.registry.action.ChangeRequestQuery 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);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) QueryFactory(com.runwaysdk.query.QueryFactory) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest) SimpleDateFormat(java.text.SimpleDateFormat) AbstractAction(net.geoprism.registry.action.AbstractAction) UpdateAttributeAction(net.geoprism.registry.action.geoobject.UpdateAttributeAction) Date(java.util.Date) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Aggregations

QueryFactory (com.runwaysdk.query.QueryFactory)12 ChangeRequest (net.geoprism.registry.action.ChangeRequest)12 ChangeRequestQuery (net.geoprism.registry.action.ChangeRequestQuery)12 Request (com.runwaysdk.session.Request)9 AbstractAction (net.geoprism.registry.action.AbstractAction)8 UpdateAttributeAction (net.geoprism.registry.action.geoobject.UpdateAttributeAction)7 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)5 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Date (java.util.Date)5 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)4 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)2 CreateGeoObjectAction (net.geoprism.registry.action.geoobject.CreateGeoObjectAction)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 OIterator (com.runwaysdk.query.OIterator)1 Selectable (com.runwaysdk.query.Selectable)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 Calendar (java.util.Calendar)1 Classifier (net.geoprism.ontology.Classifier)1