In Velocity, whenever you want to reference to a Java object you need to manually add the object to the Velocity template and name it. In Report Wizard, however, this process is done automatically. What you need to understand is how it is done as it will help you to call the modeling tool elements. All elements in the modeling tool such as Class, Use Case, and Activity are the sub-classes of elements. During report generation, the report engine will get all the elements from a project within a selected scope that you have defined in Report Wizard, and then classify and add them to a list of the same type. The list will then be added to the Velocity Context with its type as its name. For instance, in a project where there are two types of Element, Class, and Use Case, all the elements that are identified as Classes will be kept on the same list and the list will be added to the Velocity Context and labeled as "Class" during report generation. This process also applies to the Use Case elements. To reference to a specific Class element, first you will have to make a reference to $Class (list of Class elements), and then iterate through the list to find that particular Class element by using the #foreach, #forrow, #forcol, or #forpage directive, followed by the #if directive to search for the name of the class. This section will use part of the "Inventory Control System.mdzip" file in <install.root>/samples/casestudies as an example to show you how to reference elements. Use Case View.You need to know the elements inside the "Use Case View" package before using it, see figure above. To do this, follow the instructions in the previous section, Creating your first template. The "Use Case View" package contains three element types: (i) Actor, (ii) UseCase, and (iii) Diagram that you can call in a template by typing "$Actor," "$UseCase," and "$Diagram" respectively. In this example you will create a report that will print the names of the Actors, UseCases, and diagram image. |