Starting from:
$35

$29

Programming Assignment 4 Solution

In this assignment, you use the Visitor Pattern to implement the following two features for a GSN model:

Print all GSN elements in a top-down strategy (Starting with a root Goal and ending with all solution nodes) based on the GSN metamodel (See slide p. 1 at https://cs.wmich.edu/~wshen/cs331/GSN_Model_CS3310_F18.pptx)
(Optional) Convert a GSN model to an abstract GSN model (See slide p.2 at https://cs.wmich.edu/~wshen/cs331/GSN_Model_CS3310_F18.pptx), which includes only Goals and solution nodes as well as the SupportedBy relationship. Print out the abstract GSN model based on the abstract GSN metamodel, i.e., AGSN model. Here is the output model from (https://cs.wmich.edu/~wshen/cs660/GSNCS6600_F18_GSN_first_modified.jpg).










The input file is an XMI file of a GSN model. So, you need to use an XML DOM parser to read the XMI file. How to convert XMI element into GSN elements is referred to the class discussion.

When printing out the GSN elements, you need to show the following information

For Goal, Assumption, Justification, Solution, Context, and Strategy in GSN, you need to show the values of id, description, content as well as the value of assumed and toBeSupported if exist. Also all SupportedBy and InContextOf information is shown as well.




For instance, given by (https://cs.wmich.edu/~wshen/cs660/GSNCS6600_F18_GSN_first_modified.jpg, you need to show the following information:





Goal node G6.3 as target is in Context of context nodes C6.3 as source, A6.3a as source, and assumption node A6.3b as source; is Supported By strategy node S6.3 as source;





Strategy node S6.3 as target is in Context of assumption node A6.3c as source; is Supported by Goal nodes G6.3a as source,…





More Nodes here….









For InContextOf and SupportedBy, you need to show the source and target elements using their id value only.
(Optional ) When printing out the Abstract GSN elements, you need to show the information based on the AGSN metamodel using the Visitor Pattern. For a goal which has multiple SupportedBy relations, you need to show the following

Goal G6.3 is supported by G6.3a and G6.3b which belong to one inference rule.



There are several implementation issues regard PA4 you should follow:

Java Code Generation: You must implement the UML associations via a Java program appropriately. For instance, if you want to use interface to implement ArgumentElement, then you need to have the getter and setter method to implement each association end. If you want to use class to implement ArgumentElement, then you must have a private attribute with a getter/setter method to implement each association end. Otherwise, you will lose some points for this even if your program runs correctly. Please check the latest version of the GSN metamodel. Adjust your implementation accordingly. If you already started the code generation, please check the latest GSN model via the course website. I made some changes for the multiplicity.
Once you set up a data structure /object diagram via your program before printing the entire GSN tree/model, you need to the double dispatch technique, ie. finding the root goal node to start the printing process via calling root_goal.accept(printVisitor). During the printing process, on your Visitor Class side, when a node is visited, say a goal node is visited. In your visit(Goal g) method, besides printing the goal node information, you need to visit the other related nodes via InContextOf or SupportedBy relations. In the other words, your Visitor Class needs to call accept method back based on the related object for the further print-out. If a node is a leaf node in a GSN model, your visit method just returns. If you don’t have the double dispatch technique in your implementation, you will lose some points even if your program runs correctly.








More products