Search in sources :

Example 1 with HistoricalRow

use of net.geoprism.registry.view.HistoricalRow in project geoprism-registry by terraframe.

the class TransitionEventTest method testGetHistoricalReportWithPage.

@Test
@Request
public void testGetHistoricalReportWithPage() {
    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.setAfterTypeCode(FastTestDataset.PROVINCE.getCode());
        event.setBeforeTypeOrgCode(FastTestDataset.COUNTRY.getOrganization().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, 2, 10);
        Assert.assertEquals(new Long(1L), page.getCount());
        Assert.assertEquals(0, page.getResults().size());
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        event.delete();
    }
}
Also used : HistoricalRow(net.geoprism.registry.view.HistoricalRow) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) TransitionEvent(net.geoprism.registry.graph.transition.TransitionEvent) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) IOException(java.io.IOException) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 2 with HistoricalRow

use of net.geoprism.registry.view.HistoricalRow in project geoprism-registry by terraframe.

the class HistoricalReportExcelExporter method createDataSheet.

private void createDataSheet(Workbook workbook) {
    Sheet sheet = workbook.createSheet(WorkbookUtil.createSafeSheetName("Historical Report"));
    int rowNum = 0;
    this.writeHeader(sheet.createRow(rowNum++));
    Page<HistoricalRow> page = HistoricalRow.getHistoricalReport(type, startDate, endDate, 1000, 1);
    while (page.getResults().size() > 0) {
        List<HistoricalRow> results = page.getResults();
        for (HistoricalRow result : results) {
            this.writeRow(sheet.createRow(rowNum++), result);
        }
        page = HistoricalRow.getHistoricalReport(type, startDate, endDate, page.getPageSize(), page.getPageNumber() + 1);
    }
}
Also used : HistoricalRow(net.geoprism.registry.view.HistoricalRow) Sheet(org.apache.poi.ss.usermodel.Sheet)

Example 3 with HistoricalRow

use of net.geoprism.registry.view.HistoricalRow 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 4 with HistoricalRow

use of net.geoprism.registry.view.HistoricalRow in project geoprism-registry by terraframe.

the class TransitionEventTest method testGetHistoricalReportToJson.

@Test
@Request
public void testGetHistoricalReportToJson() {
    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.setAfterTypeCode(FastTestDataset.PROVINCE.getCode());
        event.setBeforeTypeOrgCode(FastTestDataset.COUNTRY.getOrganization().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);
        JsonObject json = page.toJSON().getAsJsonObject();
        Assert.assertEquals(1, json.get("count").getAsInt());
        Assert.assertTrue(json.get("pageNumber").isJsonNull());
        Assert.assertTrue(json.get("pageSize").isJsonNull());
        JsonArray results = json.get("resultSet").getAsJsonArray();
        Assert.assertEquals(1, results.size());
        JsonObject result = results.get(0).getAsJsonObject();
        Assert.assertEquals(event.getEventId(), new Long(result.get(HistoricalRow.EVENT_ID).getAsLong()));
        Assert.assertEquals("Reassign", result.get(HistoricalRow.EVENT_TYPE).getAsString());
    } finally {
        event.delete();
    }
}
Also used : JsonArray(com.google.gson.JsonArray) HistoricalRow(net.geoprism.registry.view.HistoricalRow) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) TransitionEvent(net.geoprism.registry.graph.transition.TransitionEvent) JsonObject(com.google.gson.JsonObject) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

HistoricalRow (net.geoprism.registry.view.HistoricalRow)4 Request (com.runwaysdk.session.Request)3 TransitionEvent (net.geoprism.registry.graph.transition.TransitionEvent)3 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)3 Test (org.junit.Test)3 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 IOException (java.io.IOException)1 Sheet (org.apache.poi.ss.usermodel.Sheet)1