final ProcessingContext prc = new DefaultProcessingContext();
final GlobalMasterRow gmr = GlobalMasterRow.createReportRow
(prc, new DefaultDataSchemaDefinition(), new ParameterDataRow(), null, false);
final TableModel data = createTableModel();
MasterDataRow wdata = gmr.deriveWithQueryData(new ReportDataRow(data));
final CrosstabSpecification cs = new SortedMergeCrosstabSpecification
(createDummyKey(), new String[]{"Product", "Time"});
int advanceCount = 0;
System.out.println(wdata.getReportDataRow().getCursor());
cs.startRow();
cs.add(wdata.getGlobalView());
Object grpVal = wdata.getGlobalView().get("Region");
while (wdata.isAdvanceable())
{
final MasterDataRow nextdata = wdata.advance();
Object nextGrpVal = nextdata.getGlobalView().get("Region");
if (ObjectUtilities.equal(grpVal, nextGrpVal) == false)
{
cs.endRow();
cs.startRow();
}
cs.add(nextdata.getGlobalView());
logger.debug("Prepare Advance Count: " + nextdata.getReportDataRow().getCursor());
advanceCount += 1;
wdata = nextdata;
grpVal = nextGrpVal;
}
cs.endRow();
if (advanceCount != (data.getRowCount() - 1))
{
throw new IllegalStateException("Expected 6 but got " + advanceCount);
}
return cs;