Storyboard StudyRightTablesAndReports
How to generate table reports from a model.
Start: Example object structure:
Step 1: Query for table
UniversityPO universityPO = new UniversityPO(university);
RoomPO createRoomsPO = universityPO.createRoomsPO();
Table table = universityPO.createResultTable();
Results in:
A |
B |
StudyRight |
senate math 17 |
StudyRight |
7522 arts 16 |
StudyRight |
gymnasium sports 25 |
table.createColumns("Topic", row -> {
Room r = row.getCellValue("B");
return r.getTopic();
});
table.createColumns("Credits", row -> ((Room) row.getCellValue("B")).getCredits())
.withTdCssClass("text-right");
table.createColumns("Students", row -> ((Room) row.getCellValue("B")).getStudents().size())
.withTdCssClass("text-right");
table.withoutColumns("A", "B");
Topic |
Credits |
Students |
math |
17 |
1 |
arts |
16 |
0 |
sports |
25 |
2 |
Step 2: List all topics:
UniversityPO universityPO = new UniversityPO(university);
TablePO tablePO = new TablePO(CREATE);
universityPO.addToPattern(tablePO);
tablePO.createNameAssignment("University");
ColumnPO col1PO = tablePO.createColumnsPO(CREATE).createNameAssignment("Topic");
ColumnPO col2PO = tablePO.createColumnsPO(CREATE)
.createNameAssignment("Credits")
.createTdCssClassAssignment("text-right");
ColumnPO col3PO = tablePO.createColumnsPO(CREATE)
.createNameAssignment("Students")
.createTdCssClassAssignment("text-right");
RoomPO roomsPO = universityPO.createRoomsPO();
RowPO rowPO = tablePO.createRowsPO(CREATE);
CellPO cell1PO = rowPO.createCellsPO(CREATE).createColumnLink(col1PO, CREATE);
cell1PO.createCondition(cell -> cell.withValue(roomsPO.getTopic()) != null);
CellPO cell2PO = rowPO.createCellsPO(CREATE).createColumnLink(col2PO, CREATE);
cell2PO.createCondition(cell -> cell.withValue(roomsPO.getCredits()) != null);
CellPO cell3PO = rowPO.createCellsPO(CREATE).createColumnLink(col3PO, CREATE);
cell3PO.createCondition(cell -> cell.withValue(roomsPO.getStudents().size()) != null);
universityPO.doAllMatches();
Results in:
Topic |
Credits |
Students |
math |
17 |
1 |
arts |
16 |
0 |
sports |
25 |
2 |
Step 3: Do a nested table
UniversityPO universityPO = new UniversityPO(university);
RoomPO createRoomsPO = universityPO.createRoomsPO();
Table table = universityPO.createResultTable();
table.createColumns("Topic", row -> ((Room) row.getCellValue("B")).getTopic());
table.createColumns("Assignments", row -> addAssignments(row));
table.createColumns("Students", row -> ((Room) row.getCellValue("B")).getStudents().size())
.withTdCssClass("text-right");
table.withoutColumns("A", "B");
Topic |
Assignments |
Students |
math |
Content |
Points |
Matrix Multiplication |
5 |
Series |
6 |
Integrals |
8 |
|
1 |
arts |
|
0 |
sports |
|
2 |