Storyboard StudyRightWithAssignmentsClassGeneration

1. generate class University

      	  ClassModel model = new ClassModel("org.sdmlib.test.examples.studyrightWithAssignments.model");

      Clazz universityClass = model.createClazz("University")
            .withAttribute("name", DataType.STRING);
StudyRightWithAssignmentsClassGenerationStep2.png

2. generate class Student

            Clazz studentClass = model.createClazz("Student")
            .withAttribute("name", DataType.STRING)
            .withAttribute("id", DataType.STRING)
            .withAttribute("assignmentPoints", DataType.INT)
            .withAttribute("motivation", DataType.INT) 
            .withAttribute("credits", DataType.INT);
StudyRightWithAssignmentsClassGenerationStep5.png

3. add University --> Student association

            universityClass.withBidirectional(studentClass, "students", Cardinality.MANY, "university", Cardinality.ONE);
StudyRightWithAssignmentsClassGenerationStep8.png

4. add University --> Room association

            Clazz roomClass = model.createClazz("Room")
            .withAttribute("name", DataType.STRING)
            .withAttribute("topic", DataType.STRING)
            .withAttribute("credits", DataType.INT);

      roomClass.withMethod("findPath", DataType.STRING, new Parameter(DataType.INT).with("motivation"));

      //Association universityToRoom = 
      universityClass.createBidirectional(roomClass, "rooms", Cardinality.MANY, "university", Cardinality.ONE).with(AssociationTypes.AGGREGATION);
      
      // Association doors = 
      roomClass.createBidirectional(roomClass, "doors", Cardinality.MANY, "doors", Cardinality.MANY);

      // Association studentsInRoom = 
      studentClass.createBidirectional(roomClass, "in", Cardinality.ONE, "students", Cardinality.MANY);
      studentClass.createBidirectional(studentClass, "friends", Cardinality.MANY, "friends", Cardinality.MANY);
      
StudyRightWithAssignmentsClassGenerationStep11.png

5. add assignments:

            Clazz assignmentClass = model.createClazz("Assignment")
               .withAttribute("content", DataType.STRING)
               .withAttribute("points", DataType.INT);

      assignmentClass.createBidirectional(roomClass, "room", Cardinality.ONE, "assignments", Cardinality.MANY);
      
      studentClass.createBidirectional(assignmentClass, "done", Cardinality.MANY, "students", Cardinality.MANY);
StudyRightWithAssignmentsClassGenerationStep14.png

6. generate class source files.

            model.generate("src/test/java"); // usually don't specify anything here, then it goes into src