/* * Copyright (c) 2013 ulno (http://contact.ulno.net) * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * The Software shall be used for Good, not Evil. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package org.sdmlib.test.examples.studyrightWithAssignments; import static org.sdmlib.models.pattern.Pattern.CREATE; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import org.junit.Assert; import org.sdmlib.CGUtil; import org.sdmlib.models.YamlIdMap; import org.sdmlib.models.tables.Row; import org.sdmlib.models.tables.Table; import org.sdmlib.models.tables.util.CellPO; import org.sdmlib.models.tables.util.ColumnPO; import org.sdmlib.models.tables.util.RowPO; import org.sdmlib.models.tables.util.TablePO; import org.sdmlib.storyboards.Storyboard; import org.sdmlib.test.examples.studyrightWithAssignments.model.Assignment; import org.sdmlib.test.examples.studyrightWithAssignments.model.President; import org.sdmlib.test.examples.studyrightWithAssignments.model.Room; import org.sdmlib.test.examples.studyrightWithAssignments.model.Student; import org.sdmlib.test.examples.studyrightWithAssignments.model.TeachingAssistant; import org.sdmlib.test.examples.studyrightWithAssignments.model.University; import org.sdmlib.test.examples.studyrightWithAssignments.model.util.AssignmentPO; import org.sdmlib.test.examples.studyrightWithAssignments.model.util.AssignmentSet; import org.sdmlib.test.examples.studyrightWithAssignments.model.util.RoomPO; import org.sdmlib.test.examples.studyrightWithAssignments.model.util.RoomSet; import org.sdmlib.test.examples.studyrightWithAssignments.model.util.StudentSet; import org.sdmlib.test.examples.studyrightWithAssignments.model.util.TeachingAssistantSet; import org.sdmlib.test.examples.studyrightWithAssignments.model.util.UniversityCreator; import org.sdmlib.test.examples.studyrightWithAssignments.model.util.UniversityPO; import de.uniks.networkparser.IdMap; import de.uniks.networkparser.json.JsonArray; import de.uniks.networkparser.list.SimpleSet; public class StudyRightWithAssignmentsStoryboards { /** * *
* - studyRight: University * name: "\"Study \" Right\"And\"Fast now\"" * students: karli * rooms: mathRoom artsRoom sportsRoom examRoom softwareEngineering * * - karli: Student * id: 4242 * name: karli * * * - Assignment content: points: * matrixMult: "Matrix Multiplication" 5 * series: "Series" 6 * a3: Integrals 8 * * - Room topic: credits: doors: students: assignments: * mathRoom: math 17 null karli [matrixMult series a3] * artsRoom: arts 16 mathRoom null null * sportsRoom: sports 25 [mathRoom artsRoom] * examRoom: exam 0 [sportsRoom artsRoom] * softwareEngineering: "Software Engineering" 42 [artsRoom examRoom] ** *
*
* YamlIdMap yamlIdMap = new YamlIdMap("org.sdmlib.test.examples.studyrightWithAssignments.model");
*
* University studyRight = (University) yamlIdMap.decode(yaml);
*
*
*
* * Check: root object exists "Study " Right"And"Fast now" *
** - u1: University * name: "\"Study \" Right\"And\"Fast now\"" * students: s2 * rooms: r3 r4 r5 r6 r7 * * - s2: Student * assignmentPoints: 0 * credits: 0 * id: 4242 * motivation: 0 * name: karli * in: r3 * university: u1 * * - r3: Room * credits: 17 * topic: math * doors: r4 r5 * students: s2 * assignments: a8 a9 a10 * university: u1 * * - r4: Room * credits: 16 * topic: arts * doors: r3 r5 r6 r7 * university: u1 * * - r5: Room * credits: 25 * topic: sports * doors: r3 r4 r6 * university: u1 * * - r6: Room * credits: 0 * topic: exam * doors: r5 r4 r7 * university: u1 * * - r7: Room * credits: 42 * topic: "Software Engineering" * doors: r4 r6 * university: u1 * * - a8: Assignment * content: "Matrix Multiplication" * points: 5 * room: r3 * * - a9: Assignment * content: Series * points: 6 * room: r3 * * - a10: Assignment * content: Integrals * points: 8 * room: r3 * **
* Check: yaml starts with - u... true *
*
*
* byte[] readAllBytes = Files.readAllBytes(Paths.get("doc/StudyRightStartSituation.txt"));
* String excelText = new String(readAllBytes);
*
* YamlIdMap excelIdMap = new YamlIdMap("org.sdmlib.test.examples.studyrightWithAssignments.model");
*
* studyRight = (University) excelIdMap.decode(excelText);
*
*
* * doc/StudyRightStartSituation.txt *
* ** - studyRight: University * name: """Study Right""" * students: karli * rooms: mathRoom artsRoom sportsRoom examRoom softwareEngineering * * - karli: Student * id: 4242 * name: karli * * - Assignment content: points: * matrixMult: """Matrix Multiplication""" 5 * series: Series 6 * a3: Integrals 8 * * - Room topic: credits: doors: students: assignments: * mathRoom: math 17 null karli [matricMult series a3] * artsRoom: arts 25 mathRoom * sportsRoom: sports 25 [mathRoom artsRoom] * examRoom: exam 0 [sportsRoom artsRoom] * softwareEngineering: """Software Engineering""" 42 [artsRoom examRoom] **
* result: *
* * * @throws IOException */ // @Test public void testYaml() throws IOException { System.out.println(" (StudyRightWithAssignmentsStoryboards.java:85)"); Storyboard story = new Storyboard(); story.addStep("Read graph from yaml text:"); String yaml = "" + "- studyRight: University \n" + " name: \"\\\"Study \\\" Right\\\"And\\\"Fast now\\\"\"\n" + " students: karli\n" + " rooms: mathRoom artsRoom sportsRoom examRoom softwareEngineering \n" + "\n" + "- karli: Student\n" + " id: 4242\n" + " name: karli\n" + "\n" // + "- albert: Prof\n" // + " topic: SE\n" + "\n" + "- Assignment content: points: \n" + " matrixMult: \"Matrix Multiplication\" 5\n" + " series: \"Series\" 6\n" + " a3: Integrals 8\n" + "\n" + "- Room topic: credits: doors: students: assignments: \n" + " mathRoom: math 17 null karli [matrixMult series a3]\n" + " artsRoom: arts 16 mathRoom null null\n" + " sportsRoom: sports 25 [mathRoom artsRoom]\n" + " examRoom: exam 0 [sportsRoom artsRoom]\n" + " softwareEngineering: \"Software Engineering\" 42 [artsRoom examRoom]\n" + ""; story.addPreformatted(yaml); story.addStep("Call YamlIdMap.decode:"); story.markCodeStart(); YamlIdMap yamlIdMap = new YamlIdMap("org.sdmlib.test.examples.studyrightWithAssignments.model"); University studyRight = (University) yamlIdMap.decode(yaml); story.addCode(); story.addStep("Decoded object structure:"); story.addObjectDiagram(studyRight); story.assertNotNull("root object exists", studyRight); // Object albert = yamlIdMap.getObject("albert"); // // story.assertNotNull("pojo albert exists", albert); // // story.assertEquals("pojo attr", "SE", ((Prof)albert).getTopic()); story.addStep("Generate Yaml from model:"); YamlIdMap yamlEncodeMap = new YamlIdMap("org.sdmlib.test.examples.studyrightWithAssignments.model"); String newYaml = yamlEncodeMap.encode(studyRight); story.addPreformatted(newYaml); story.assertTrue("yaml starts with - u...", newYaml.startsWith("- u")); YamlIdMap yamlDecodeMap = new YamlIdMap("org.sdmlib.test.examples.studyrightWithAssignments.model"); University newStudyRight = (University) yamlIdMap.decode(newYaml); story.addStep("decoded again:"); story.addObjectDiagram(newStudyRight); story.addStep("now read from excel file"); story.markCodeStart(); byte[] readAllBytes = Files.readAllBytes(Paths.get("doc/StudyRightStartSituation.txt")); String excelText = new String(readAllBytes); YamlIdMap excelIdMap = new YamlIdMap("org.sdmlib.test.examples.studyrightWithAssignments.model"); studyRight = (University) excelIdMap.decode(excelText); story.addCode(); story.add("doc/StudyRightStartSituation.txt"); story.addPreformatted(excelText); story.add("result:"); story.addObjectDiagram(studyRight); story.dumpJavaDoc(YamlIdMap.class.getName()); story.dumpHTML(); } /** * ** 1. (start situation/pre-condition) Karli enters the Study-Right University in the math room. * Karli has no credits yet and still a motivation of 214. *
* *
*
* // =============================================================
* storyboard.add("1. (start situation/pre-condition) Karli enters the Study-Right University \n"
* + "in the math room. Karli has no credits yet and still a motivation of 214. ");
*
* storyboard.markCodeStart();
* University university = new University()
* .withName("StudyRight");
*
* Student karli = university.createStudents()
* .withId("4242")
* .withName("Karli");
*
* Assignment matrixMult = new Assignment()
* .withContent("Matrix Multiplication")
* .withPoints(5);
*
* Assignment series = new Assignment()
* .withContent("Series")
* .withPoints(6);
*
* Assignment a3 = new Assignment()
* .withContent("Integrals")
* .withPoints(8);
*
* Room mathRoom = university.createRooms()
* .withName("senate")
* .withTopic("math")
* .withCredits(17)
* .withStudents(karli)
* .withAssignments(matrixMult, series, a3);
*
* Room artsRoom = university.createRooms()
* .withName("7522")
* .withTopic("arts")
* .withCredits(16)
* .withDoors(mathRoom);
*
* Room sportsRoom = university.createRooms()
* .withName("gymnasium")
* .withTopic("sports")
* .withCredits(25)
* .withDoors(mathRoom, artsRoom);
*
* Room examRoom = university.createRooms()
* .withName("The End")
* .withTopic("exam")
* .withCredits(0)
* .withDoors(sportsRoom, artsRoom);
*
*
*
*
*
*
* 2. Karli does assignment a1 on Matrix Multiplication and earns 5 points
* (general rule: the student earns always full points for doing an assignment).
* Karli's motivation is reduced by 5 points to now 209.
*
*
* storyboard.add("2. Karli does assignment a1 on Matrix Multiplication and earns 5 points <br>\n"
* + "(general rule: the student earns always full points for doing an assignment). <br>\n"
*
*
*
*
*
* 3. Karli does assignment a2 on Series and earns another 6 points.
* Thus Karli has 11 points now. Motivation is reduced to 203.
*
*
* // ===============================================================================================
* storyboard.add("3. Karli does assignment a2 on Series and earns another 6 points. <br>\n"
*
*
*
*
*
* 4. Karli does the third assignment on Integrals, earns
* another 8 points and thus Karli has now 19 points and a motivation of 195.
*
*
* // ===============================================================================================
* storyboard.add("4. Karli does the third assignment on Integrals, earns <br>\n"
*
*
*
*
*
* 5. Since 19 points are more than the 17 points required for the 17 math credits, Karli hands the
* points in and earns the credits and has his assignmnet points reset to 0.
* (General rule: if the points earned by the assignments are higher or equal than the credit
* points, the credit points will be awarded to the student.)
*
*
* + "and has his assignmnet points reset to 0. <br>\n"
* + "(General rule: if the points earned by the assignments are higher or equal than \n"
* + "the credit points, the credit points will be awarded to the student.)");
*
* storyboard.markCodeStart();
*
*
*
*
* * 6. (end situation/post-condition) Karli has completed the math topic and moves to sports. *
** Check: Karli's credits: 17 actual 17 *
** Check: Karli's assignment points: 0 actual 0 *
** Check: Number of students: 1 actual 1 *
*/ // @Test public void testStudyRightWithAssignmentsStoryboard() { Storyboard storyboard = new Storyboard(); // ============================================================= storyboard.add("1. (start situation/pre-condition) Karli enters the Study-Right University \n" + "in the math room. Karli has no credits yet and still a motivation of 214. "); storyboard.markCodeStart(); University university = new University() .withName("StudyRight"); Student karli = university.createStudents() .withId("4242") .withName("Karli"); Assignment matrixMult = new Assignment() .withContent("Matrix Multiplication") .withPoints(5); Assignment series = new Assignment() .withContent("Series") .withPoints(6); Assignment a3 = new Assignment() .withContent("Integrals") .withPoints(8); Room mathRoom = university.createRooms() .withName("senate") .withTopic("math") .withCredits(17) .withStudents(karli) .withAssignments(matrixMult, series, a3); Room artsRoom = university.createRooms() .withName("7522") .withTopic("arts") .withCredits(16) .withDoors(mathRoom); Room sportsRoom = university.createRooms() .withName("gymnasium") .withTopic("sports") .withCredits(25) .withDoors(mathRoom, artsRoom); Room examRoom = university.createRooms() .withName("The End") .withTopic("exam") .withCredits(0) .withDoors(sportsRoom, artsRoom); Room softwareEngineering = university.createRooms() .withName("7422") .withTopic("Software Engineering") .withCredits(42) .withDoors(artsRoom, examRoom); storyboard.addCode(); storyboard.addObjectDiagram( "studyRight", university, "karli", "icons/karli.png", karli, "mathRoom", "icons/mathroom.png", mathRoom, "artsRoom", artsRoom, "sportsRoom", sportsRoom, "examRoom", examRoom, "placeToBe", softwareEngineering, "icons/matrix.png", matrixMult, "icons/limes.png", series, "icons/integralAssignment.png", a3); // =============================================================================================== storyboard.add("2. Karli does assignment a1 on Matrix Multiplication and earns 5 points* How to serialize an object model to json and how to read json into an object model *
*
*
*
* // =====================================================
* storyboard.addStep("Serialize to json:");
*
* storyboard.markCodeStart();
*
* IdMap idMap = UniversityCreator.createIdMap("demo");
*
* JsonArray jsonArray = idMap.toJsonArray(university);
*
*
* * Results in: *
* ** [ * { * "session":"demo", * "class":"org.sdmlib.test.examples.studyrightWithAssignments.model.University", * "id":"U611694416394763", * "timestamp":"611694416394763", * "prop":{ * "name":"StudyRight", * "students":[ * { * "session":"demo", * "class":"org.sdmlib.test.examples.studyrightWithAssignments.model.Student", * "id":"S611694416636540", * "timestamp":"611694416636540" * } * ] * } * }, * { * "session":"demo", * "class":"org.sdmlib.test.examples.studyrightWithAssignments.model.Student", * "id":"S611694416636540", * "timestamp":"611694416636540", * "prop":{ * "id":"4242", * "name":"Karli", * "university":{ * "class":"org.sdmlib.test.examples.studyrightWithAssignments.model.University", * "id":"U611694416394763" * } * } * } * ] ** *
*
*
* // =====================================================
* storyboard.addStep("Now read it back again");
*
* storyboard.markCodeStart();
*
* // read jsonText from file
*
*
*
*
*/
// @Test
public void testJsonPersistency() {
Storyboard storyboard = new Storyboard();
storyboard.add("How to serialize an object model to json and how to read json into an object model");
storyboard.addStep("Example object structure:");
University university = new University()
.withName("StudyRight");
Student karli = university.createStudents()
.withId("4242")
.withName("Karli");
Assignment a1 = new Assignment()
.withContent("Matrix Multiplication")
.withPoints(5);
Assignment a2 = new Assignment()
.withContent("Series")
.withPoints(6);
Assignment integrals = new Assignment()
.withContent("Integrals")
.withPoints(8);
// Room mathRoom = university.createRooms()
// .withName("senate")
// .withTopic("math")
// .withCredits(17)
// .withStudents(karli)
// .withAssignments(a1, a2, integrals);
// Room artsRoom = university.createRooms()
// .withName("7522")
// .withTopic("arts")
// .withCredits(16)
// .withDoors(mathRoom);
//
// Room sportsRoom = university.createRooms()
// .withName("gymnasium")
// .withTopic("sports")
// .withCredits(25)
// .withDoors(mathRoom, artsRoom);
// Room examRoom = university.createRooms()
// .withName("The End")
// .withTopic("exam")
// .withCredits(0)
// .withDoors(sportsRoom, artsRoom);
//
// Room softwareEngineering = university.createRooms()
// .withName("7422")
// .withTopic("Software Engineering")
// .withCredits(42)
// .withDoors(artsRoom, examRoom);
// storyboard.addObjectDiagram(
// "studyRight", university,
// "karli", "icons/karli.png", karli,
// "mathRoom", "icons/mathroom.png", mathRoom,
// "artsRoom", artsRoom,
// "sportsRoom", sportsRoom,
// "examRoom", examRoom,
// "placeToBe", softwareEngineering,
// "icons/matrix.png", a1,
// "icons/limes.png", a2, "icons/integralAssignment.png", integrals);
// =====================================================
storyboard.addStep("Serialize to json:");
storyboard.markCodeStart();
IdMap idMap = UniversityCreator.createIdMap("demo");
JsonArray jsonArray = idMap.toJsonArray(university);
String jsonText = jsonArray.toString(3);
// you might write jsonText into a file
storyboard.addCode();
storyboard.add("Results in:");
storyboard.add("" + jsonText + ""); // ===================================================== storyboard.addStep("Now read it back again"); storyboard.markCodeStart(); // read jsonText from file IdMap readerMap = UniversityCreator.createIdMap("demo"); Object rootObject = readerMap.decode(jsonText); University readUniversity = (University) rootObject; storyboard.addCode(); storyboard.addObjectDiagram(rootObject); storyboard.dumpHTML(); } /** * *
* Extend the class model: *
** How to navigate and query an object model. *
*
*
*
* double assignmentPoints = university.getRooms().getAssignments().getPoints().sum();
*
* double donePoints = university.getStudents().getDone().getPoints().sum();
*
*
*
* * Results in: *
* ** Sum of assignment points: 23.0. * Sum of points of assignments that have been done by at least one students: 15.0. **
* Check: Assignment points: 23.0 actual 23.0 *
** Check: donePoints: 15.0 actual 15.0 *
*
*
*
* AssignmentSet availableAssignments = university.getRooms().getAssignments().minus(karli.getDone());
*
* RoomSet rooms = availableAssignments.getRoom();
*
*
*
* * Results in: *
* ** (17 senate math, 25 gymnasium sports) **
* Check: rooms.size(): 2 actual 2 *
*
*
*
* RoomSet rooms17 = university.getRooms().createCreditsCondition(17);
* RoomSet roomsGE20 = university.getRooms().createCreditsCondition(20, Integer.MAX_VALUE);
*
*
*
* * Results in: *
* ** rooms17: (17 senate math) * roomsGE20: (25 gymnasium sports, 42 7422 Software Engineering) ** *
*
*
* SimpleSet<Room> roomsEven = university.getRooms().filter(r -> r.getCredits() % 2 == 0);
*
*
*
* * Results in: *
* ** (16 7522 arts, 0 The End exam, 42 7422 Software Engineering) ** *
*
*
* // TOODO TeachingAssistantSet taStudents = university.getRooms().getStudents().instanceOfTeachingAssistant();
* StudentSet taStuds = university.getRooms().getStudents().filter(s -> s instanceof TeachingAssistant);
* TeachingAssistantSet taStudents = new TeachingAssistantSet().with(taStuds);
*
*
*
*
* * (0 0 4242 0 Karli) ** *
*
*
* university.getStudents().withMotivation(42);
*
*
*
*
*
*/
// @Test
public void testStudyRightObjectModelNavigationAndQueries() {
Storyboard story = new Storyboard();
story.add("Extend the class model:");
story.add("How to navigate and query an object model.");
story.addStep("Example object structure:");
University university = new University()
.withName("StudyRight");
Student abu = university.createStudents()
.withId("1337")
.withName("Abu");
Student karli = new TeachingAssistant().withCertified(true);
university.withStudents(karli
.withId("4242")
.withName("Karli"));
Student alice = university.createStudents()
.withId("2323")
.withName("Alice");
abu.withFriends(alice);
Assignment a1 = new Assignment()
.withContent("Matrix Multiplication")
.withPoints(5)
.withStudents(abu);
Assignment a2 = new Assignment()
.withContent("Series")
.withPoints(6);
Assignment a3 = new Assignment()
.withContent("Integrals")
.withPoints(8);
karli.withDone(a1, a2);
Room mathRoom = university.createRooms()
.withName("senate")
.withTopic("math")
.withCredits(17)
.withStudents(karli)
.withAssignments(a1, a2, a3);
Room artsRoom = university.createRooms()
.withName("7522")
.withTopic("arts")
.withCredits(16)
.withDoors(mathRoom);
Room sportsRoom = university.createRooms()
.withName("gymnasium")
.withTopic("sports")
.withCredits(25)
.withDoors(mathRoom, artsRoom)
.withStudents(abu, alice);
Assignment a4 = sportsRoom.createAssignments()
.withContent("Pushups")
.withPoints(4)
.withStudents(abu);
Room examRoom = university.createRooms()
.withName("The End")
.withTopic("exam")
.withCredits(0)
.withDoors(sportsRoom, artsRoom);
Room softwareEngineering = university.createRooms()
.withName("7422")
.withTopic("Software Engineering")
.withCredits(42)
.withDoors(artsRoom, examRoom);
story.addObjectDiagram(university);
// =====================================================
story.addStep("Simple set based navigation:");
story.markCodeStart();
double assignmentPoints = university.getRooms().getAssignments().getPoints().sum();
double donePoints = university.getStudents().getDone().getPoints().sum();
story.addCode();
story.add("Results in:");
String text = CGUtil.replaceAll("" +
" Sum of assignment points: 42. \n" +
" Sum of points of assignments that have been done by at least one students: 84.",
"42", assignmentPoints,
"84", donePoints);
story.addPreformatted(text);
story.assertEquals("Assignment points: ", 23.0, assignmentPoints);
story.assertEquals("donePoints: ", 15.0, donePoints);
// =====================================================
story.addStep("Rooms with assignments not yet done by Karli:");
story.markCodeStart();
AssignmentSet availableAssignments = university.getRooms().getAssignments().minus(karli.getDone());
RoomSet rooms = availableAssignments.getRoom();
story.addCode();
story.add("Results in:");
story.addPreformatted(" " + rooms.toString());
story.assertEquals("rooms.size(): ", 2, rooms.size());
story.addStep("Filter for attribute:");
story.markCodeStart();
RoomSet rooms17 = university.getRooms().createCreditsCondition(17);
RoomSet roomsGE20 = university.getRooms().createCreditsCondition(20, Integer.MAX_VALUE);
story.addCode();
story.add("Results in:");
story.addPreformatted(" rooms17: " + rooms17.toString()
+ "\n roomsGE20: " + roomsGE20);
story.addStep("Filter for even values:");
story.markCodeStart();
SimpleSet* How to generate table reports from a model. *
*
*
*
* UniversityPO universityPO = new UniversityPO(university);
*
* RoomPO createRoomsPO = universityPO.createRoomsPO();
*
* Table table = universityPO.createResultTable();
*
*
*
*
*
* * Results in: *
*A | *B | *
---|---|
StudyRight | *17 senate math | *
StudyRight | *16 7522 arts | *
StudyRight | *25 gymnasium sports | *
*
*
* 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 | *
*
*
* 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 | *
*
*
* 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 | *
*
|
* 1 | *||||||||
arts | *
*
|
* 0 | *||||||||
sports | *
*
|
* 2 | *