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();
}
}
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);
}
}
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();
}
}
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();
}
}
Aggregations