Search in sources :

Example 6 with TransitionEvent

use of net.geoprism.registry.graph.transition.TransitionEvent in project geoprism-registry by terraframe.

the class TransitionEventTest method testGetHistoricalReport.

@Test
@Request
public void testGetHistoricalReport() {
    TransitionEvent event = new TransitionEvent();
    try {
        LocalizedValueConverter.populate(event, TransitionEvent.DESCRIPTION, new LocalizedValue("Test"));
        event.setEventDate(FastTestDataset.DEFAULT_OVER_TIME_DATE);
        event.setBeforeTypeCode(FastTestDataset.COUNTRY.getCode());
        event.setBeforeTypeOrgCode(FastTestDataset.COUNTRY.getOrganization().getCode());
        event.setAfterTypeCode(FastTestDataset.PROVINCE.getCode());
        event.setAfterTypeOrgCode(FastTestDataset.PROVINCE.getOrganization().getCode());
        event.apply();
        event.addTransition(FastTestDataset.CAMBODIA.getServerObject(), FastTestDataset.PROV_CENTRAL.getServerObject(), TransitionType.REASSIGN, TransitionImpact.FULL);
        Page<HistoricalRow> page = HistoricalRow.getHistoricalReport(FastTestDataset.PROVINCE.getServerObject(), FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE, null, null);
        List<HistoricalRow> results = page.getResults();
        Assert.assertEquals(1, results.size());
        HistoricalRow result = results.get(0);
        Assert.assertEquals(event.getEventId(), result.getEventId());
        Assert.assertEquals(TransitionType.REASSIGN.name(), result.getEventType());
        Assert.assertEquals(FastTestDataset.DEFAULT_OVER_TIME_DATE, result.getEventDate());
        Assert.assertEquals("Test", result.getDescription().getValue());
        Assert.assertEquals(event.getBeforeTypeCode(), result.getBeforeType());
        Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), result.getBeforeCode());
        Assert.assertEquals(FastTestDataset.CAMBODIA.getDisplayLabel(), result.getBeforeLabel().getValue());
        Assert.assertEquals(event.getAfterTypeCode(), result.getAfterType());
        Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getCode(), result.getAfterCode());
        Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getDisplayLabel(), result.getAfterLabel().getValue());
    } finally {
        event.delete();
    }
}
Also used : HistoricalRow(net.geoprism.registry.view.HistoricalRow) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) TransitionEvent(net.geoprism.registry.graph.transition.TransitionEvent) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 7 with TransitionEvent

use of net.geoprism.registry.graph.transition.TransitionEvent in project geoprism-registry by terraframe.

the class TransitionEventTest method testUpdateTransition.

@Test
@Request
public void testUpdateTransition() {
    TransitionEvent event = new TransitionEvent();
    try {
        LocalizedValueConverter.populate(event, TransitionEvent.DESCRIPTION, new LocalizedValue("Test"));
        event.setEventDate(FastTestDataset.DEFAULT_OVER_TIME_DATE);
        event.setBeforeTypeCode(FastTestDataset.COUNTRY.getCode());
        event.setBeforeTypeOrgCode(FastTestDataset.COUNTRY.getOrganization().getCode());
        event.setAfterTypeCode(FastTestDataset.PROVINCE.getCode());
        event.setAfterTypeOrgCode(FastTestDataset.PROVINCE.getOrganization().getCode());
        event.apply();
        Transition transition = event.addTransition(FastTestDataset.CAMBODIA.getServerObject(), FastTestDataset.PROV_CENTRAL.getServerObject(), TransitionType.REASSIGN, TransitionImpact.FULL);
        transition.apply(event, transition.getOrder(), (VertexServerGeoObject) FastTestDataset.CAMBODIA.getServerObject(), (VertexServerGeoObject) FastTestDataset.PROV_WESTERN.getServerObject());
        List<Task> tasks = Task.getTasks(transition.getOid());
        Assert.assertEquals(6, tasks.size());
    } finally {
        event.delete();
    }
}
Also used : Task(net.geoprism.registry.task.Task) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) TransitionEvent(net.geoprism.registry.graph.transition.TransitionEvent) Transition(net.geoprism.registry.graph.transition.Transition) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 8 with TransitionEvent

use of net.geoprism.registry.graph.transition.TransitionEvent in project geoprism-registry by terraframe.

the class TransitionEventTest method testAddTransitionSameType.

@Test
@Request
public void testAddTransitionSameType() {
    long beforeCount = new TaskQuery(new QueryFactory()).getCount();
    TransitionEvent event = new TransitionEvent();
    try {
        LocalizedValueConverter.populate(event, TransitionEvent.DESCRIPTION, new LocalizedValue("Test"));
        event.setEventDate(FastTestDataset.DEFAULT_OVER_TIME_DATE);
        event.setBeforeTypeCode(FastTestDataset.PROVINCE.getCode());
        event.setBeforeTypeOrgCode(FastTestDataset.PROVINCE.getOrganization().getCode());
        event.setAfterTypeCode(FastTestDataset.PROVINCE.getCode());
        event.setAfterTypeOrgCode(FastTestDataset.PROVINCE.getOrganization().getCode());
        event.apply();
        Transition transition = event.addTransition(FastTestDataset.PROV_WESTERN.getServerObject(), FastTestDataset.PROV_CENTRAL.getServerObject(), TransitionType.REASSIGN, TransitionImpact.FULL);
        Assert.assertEquals(3, Task.getTasks(transition.getOid()).size());
        List<Transition> transitions = event.getTransitions();
        Assert.assertEquals(1, transitions.size());
        transition = transitions.get(0);
        VertexServerGeoObject source = transition.getSourceVertex();
        VertexServerGeoObject target = transition.getTargetVertex();
        Assert.assertEquals(FastTestDataset.PROV_WESTERN.getCode(), source.getCode());
        Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getCode(), target.getCode());
    } finally {
        event.delete();
    }
    // Ensure that the unresolved tasks are deleted on event delete
    Assert.assertEquals(beforeCount, new TaskQuery(new QueryFactory()).getCount());
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) TaskQuery(net.geoprism.registry.task.TaskQuery) TransitionEvent(net.geoprism.registry.graph.transition.TransitionEvent) Transition(net.geoprism.registry.graph.transition.Transition) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 9 with TransitionEvent

use of net.geoprism.registry.graph.transition.TransitionEvent in project geoprism-registry by terraframe.

the class TransitionEventTest method testCreateBasicEvent.

@Test
@Request
public void testCreateBasicEvent() {
    TransitionEvent event = new TransitionEvent();
    try {
        LocalizedValueConverter.populate(event, TransitionEvent.DESCRIPTION, new LocalizedValue("Test"));
        event.setEventDate(FastTestDataset.DEFAULT_OVER_TIME_DATE);
        event.setBeforeTypeCode(FastTestDataset.COUNTRY.getCode());
        event.setBeforeTypeOrgCode(FastTestDataset.COUNTRY.getOrganization().getCode());
        event.setAfterTypeCode(FastTestDataset.PROVINCE.getCode());
        event.setAfterTypeOrgCode(FastTestDataset.PROVINCE.getOrganization().getCode());
        event.apply();
        Assert.assertTrue(event.isAppliedToDb());
    } finally {
        event.delete();
    }
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) TransitionEvent(net.geoprism.registry.graph.transition.TransitionEvent) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 10 with TransitionEvent

use of net.geoprism.registry.graph.transition.TransitionEvent in project geoprism-registry by terraframe.

the class TransitionEventTest method testAddTransitionBadType.

@Test(expected = ProgrammingErrorException.class)
@Request
public void testAddTransitionBadType() {
    TransitionEvent event = new TransitionEvent();
    try {
        LocalizedValueConverter.populate(event, TransitionEvent.DESCRIPTION, new LocalizedValue("Test"));
        event.setEventDate(FastTestDataset.DEFAULT_OVER_TIME_DATE);
        event.setBeforeTypeCode(FastTestDataset.COUNTRY.getCode());
        event.setBeforeTypeOrgCode(FastTestDataset.COUNTRY.getOrganization().getCode());
        event.setAfterTypeCode(FastTestDataset.PROVINCE.getCode());
        event.setAfterTypeOrgCode(FastTestDataset.PROVINCE.getOrganization().getCode());
        event.apply();
        event.addTransition(FastTestDataset.CAMBODIA.getServerObject(), FastTestDataset.DIST_CENTRAL.getServerObject(), TransitionType.REASSIGN, TransitionImpact.FULL);
    } finally {
        event.delete();
    }
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) TransitionEvent(net.geoprism.registry.graph.transition.TransitionEvent) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

Request (com.runwaysdk.session.Request)17 TransitionEvent (net.geoprism.registry.graph.transition.TransitionEvent)17 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)17 Test (org.junit.Test)16 HistoricalRow (net.geoprism.registry.view.HistoricalRow)4 Date (java.util.Date)3 Transition (net.geoprism.registry.graph.transition.Transition)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 QueryFactory (com.runwaysdk.query.QueryFactory)2 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)2 TaskQuery (net.geoprism.registry.task.TaskQuery)2 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Task (net.geoprism.registry.task.Task)1 Row (org.apache.poi.ss.usermodel.Row)1 Sheet (org.apache.poi.ss.usermodel.Sheet)1