Search in sources :

Example 16 with ValueOverTimeCollection

use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection in project geoprism-registry by terraframe.

the class UpdateChangeOverTimeAttributeView method execute.

@Override
public void execute(VertexServerGeoObject go) {
    String attributeName = this.getAttributeNameGeomAccounting(go);
    // This list is intentionally NOT a ValueOverTimeCollection. The reason for this is because we
    // DON'T want any of the reordering or splitting logic to happen until AFTER we have applied
    // all of the actions. The logic we want to avoid is ValueOverTimeCollection.calculateStartDates
    List<ValueOverTime> looseVotc = new ArrayList<ValueOverTime>(go.getValuesOverTime(attributeName));
    for (UpdateValueOverTimeView vot : this.valuesOverTime) {
        vot.execute(this, go, looseVotc);
    }
    ValueOverTimeCollection newVotc = new ValueOverTimeCollection();
    newVotc.addAll(looseVotc);
    this.validateValuesOverTime(newVotc);
    go.getVertex().getGraphObjectDAO().getAttribute(attributeName).setValuesOverTime(newVotc);
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) ArrayList(java.util.ArrayList) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)

Example 17 with ValueOverTimeCollection

use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection 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 18 with ValueOverTimeCollection

use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection in project geoprism-registry by terraframe.

the class ChangeRequestServiceTest method testImplementDecisionsVerify.

@Request
private void testImplementDecisionsVerify(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.CAMBODIA.getServerObject();
    ValueOverTimeCollection votc = serverGo.getValuesOverTime(FastTestDataset.AT_National_Anthem.getAttributeName());
    Assert.assertEquals(1, votc.size());
    ValueOverTime vot = votc.get(0);
    Assert.assertEquals(newStartDate, vot.getStartDate());
    Assert.assertEquals(newEndDate, vot.getEndDate());
    Assert.assertEquals(NEW_ANTHEM, vot.getValue());
    Assert.assertEquals(NEW_ANTHEM, serverGo.getValue(FastTestDataset.AT_National_Anthem.getAttributeName(), newStartDate));
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) ChangeRequest(net.geoprism.registry.action.ChangeRequest) AbstractAction(net.geoprism.registry.action.AbstractAction) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 19 with ValueOverTimeCollection

use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection 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)

Example 20 with ValueOverTimeCollection

use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection 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());
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)30 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)29 Request (com.runwaysdk.session.Request)22 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)18 Test (org.junit.Test)16 Date (java.util.Date)10 ChangeRequest (net.geoprism.registry.action.ChangeRequest)7 SimpleDateFormat (java.text.SimpleDateFormat)6 AbstractAction (net.geoprism.registry.action.AbstractAction)6 QueryFactory (com.runwaysdk.query.QueryFactory)5 ChangeRequestQuery (net.geoprism.registry.action.ChangeRequestQuery)5 UpdateAttributeAction (net.geoprism.registry.action.geoobject.UpdateAttributeAction)5 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)5 VertexObject (com.runwaysdk.business.graph.VertexObject)4 EdgeObject (com.runwaysdk.business.graph.EdgeObject)3 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)3 Calendar (java.util.Calendar)3 LineString (com.vividsolutions.jts.geom.LineString)2 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)2 LocalDate (java.time.LocalDate)2