Large diffs are not rendered by default.

@@ -21,6 +21,16 @@ First, to make our code more modular we made two different types of class method
We also fixed the visitors for our model, to make it so that you can swap out different type of printing if we need to print UMLs differently in the future.
Finally, to detect singleton we created another Model visitor which will looks for classes with private constructors, a private static field of itself, and a public getter method with the return type of the class.

##Milestone 5
![Milestone 5 updates](./Docs/MS5_Turnin/MS5_ProjectUML)
We refactored our detection visitors to be more modular and easily expandable by programmers using our library. We used the Template pattern to define an algorithm for how all pattern detection visitors should function, and always pass in our data storage so that any user can access the entirety of our model. We also fixed up our singleton pattern detection to be less coupled with our model and added test cases.
We implemented the fundamental logic of our adaptor and decorator pattern recognition code.

##Milestone 6
![Milestone 6 updates](./Docs/MS6_Turning/...)
We realized that we had to do a lot of refactoring from the previous milestone to make our detection code much more modular and easily usable by and potential user trying to add onto our code. We realized our adaptor and decorator detection logic was flawed and fixed them in this milestone, and implemented extensive testing on both patterns.
This milestone we were unable to implement our Composite pattern detection logic, however we set the stage for this through our refactoring. At this point we know how we want to implement this logic and have refactored our code base to make this logic a single file addition.

##How to Use
In order to use this, you will need to call our application from the command line.
the first argument should be the type of diagram you would like generated, these inputs are:
@@ -51,5 +61,10 @@ The final argument is optional and only matters if you are making a sequence dia
| 3 | handle different types of command line arguments||
| 4 | converted visitors to new version discussed in class | refactored ASM visitors|
| 4 | wrote singleton visitor | wrote unit tests |
| 4 | restructured packages | did bug fixes |
| 4 | restructured packages | did bug fixes |
| 5 | bug fixes on singleton | bug fixes on singleton |
| 5 | refactoring | refactoring |
| 6 | heavily restructured packages | wrote testing code for Adaptor |
| 6 | fixes on decorator | fixes on adaptor |
| 6 | testing code on decorator | refactoring on pattern detection visitor |

@@ -1,7 +1,6 @@
package DataStorage.DataStore;

import DataStorage.ParseClasses.ClassTypes.AbstractData;
import DataStorage.ParseClasses.ClassTypes.AbstractJavaClassRep;
import DataStorage.ParseClasses.ClassTypes.*;
import DataStorage.ParseClasses.Internals.IRelation;
import DataStorage.ParseClasses.Internals.MethodCall;
import Visitors.DefaultVisitors.ITraverser;
@@ -213,6 +212,32 @@ public void removeRelation(IRelation rel) {
}
}

public void removeNonSpecificJavaClass(String toRm) {
if (this.classes.containsKey(toRm)) {
this.classes.remove(toRm);
}
if (this.abstractClasses.containsKey(toRm)) {
this.abstractClasses.remove(toRm);
}
if (this.interfaces.containsKey(toRm)) {
this.interfaces.remove(toRm);
}
}

public void addNonSpecificJavaClass(AbstractJavaClassRep toAdd) {
if (toAdd instanceof ClassRep) {
this.classes.put(toAdd.getName(), toAdd);
}
if (toAdd instanceof AbstractClassRep) {
this.abstractClasses.put(toAdd.getName(), toAdd);
}
if (toAdd instanceof InterfaceRep) {
this.interfaces.put(toAdd.getName(), toAdd);
}

}


@Override
public void accept(IVisitor v) {
v.preVisit(this);
@@ -0,0 +1,147 @@
package DataStorage.ParseClasses.Decorators;

import DataStorage.ParseClasses.ClassTypes.AbstractData;
import DataStorage.ParseClasses.ClassTypes.AbstractJavaClassRep;
import DataStorage.ParseClasses.ClassTypes.ClassRep;
import Visitors.DefaultVisitors.IVisitor;

import java.util.List;
import java.util.Map;

/**
* Created by efronbs on 2/4/2016.
*/
public class PatternTypeClassDecorator extends AbstractJavaClassRep {
private ClassRep classToDecorate;
private String patternName;

public PatternTypeClassDecorator(ClassRep c, String patternName) {
super(c.getName(), c.getAccessibility());
this.classToDecorate = c;
this.patternName = patternName;
}

@Override
public void accept(IVisitor v) {
v.preVisit(this);
v.visit(this);
v.postVisit(this);
}

public void setPublicStaticGetInstance(boolean inst) {
this.classToDecorate.setPublicStaticGetInstance(inst);
}

public void setPrivateSingletonInit(boolean inst) {
this.classToDecorate.setPrivateSingletonInit(inst);
}

public void setPrivateSingletonField(boolean inst) {
this.classToDecorate.setPrivateSingletonField(inst);
}

public boolean isSingleton() {
return this.classToDecorate.isSingleton();
}

@Override
public void addField(String fieldName, AbstractData fieldRep) {
this.classToDecorate.addField(fieldName, fieldRep);
}

public String getExtendedClassName() {
return this.classToDecorate.getExtendedClassName();
}

public String getFillColor() {
return this.classToDecorate.getFillColor();
}

public void setFillColor(String color) {
this.classToDecorate.setFillColor(color);
}

public void addMethod(String methodName, AbstractData methodStructure) {
this.classToDecorate.addMethod(methodName, methodStructure);
}

public AbstractData getMethod(String methodName) {
return this.classToDecorate.getMethod(methodName);
}

public Map<String, AbstractData> getMethodsMap() {
return this.methodsMap;
}

public AbstractData getField(String fieldName) {
return this.classToDecorate.getField(fieldName);
}

public Map<String, AbstractData> getFieldsMap() {
return this.classToDecorate.getFieldsMap();
}

public void addImplements(String interfaceName) {
this.classToDecorate.addImplements(interfaceName);
}

public List<String> getImplementsList() {
return this.classToDecorate.getImplementsList();
}

public void addProfileTag(String profile) {
this.classToDecorate.addProfileTag(profile);
}

public List<String> getProfileTags() {
return this.classToDecorate.getProfileTags();
}

public boolean isDecorator() {
return true;
}

public void setDecorator(boolean decorator) {
this.classToDecorate.setDecorator(decorator);
}

public String getColor() {
return this.classToDecorate.getColor();
}

public void setColor(String c) {
this.classToDecorate.setColor(c);
}

public String getName() {
return this.classToDecorate.getName();
}

public String getInnermostName() {
return this.classToDecorate.getInnermostName();
}

public String getDisplayName() {
return classToDecorate.getDisplayName() + "\n" + this.patternName;
}

public void addToDisplayName(String textToAdd) {
return;
}

public int getAccessibility() {
return this.classToDecorate.getAccessibility();
}

public String getTranslatedAccessibility() {
return "";
}

public boolean isComponent() {
return this.classToDecorate.isComponent();
}

public void setComponent(boolean component) {
this.classToDecorate.setComponent(component);
}
}
@@ -63,23 +63,47 @@ public void performAnalysis() {
addNewClasses();

List<IRelation> newAssoc = new ArrayList<IRelation>();
List<AbstractJavaClassRep> newClasses = new ArrayList<AbstractJavaClassRep>();

for (AdaptorNameSet s : adaptorSets) {
ParsedDataStorage.getInstance().getNonSpecificJavaClass(s.adaptorName.replace("/", ".")).addToDisplayName("\\<\\<adaptor\\>\\>");

//replacing base classes with decorators
// AbstractJavaClassRep nadaptor = ParsedDataStorage.getInstance().getNonSpecificJavaClass(s.adaptorName.replace("/", "."));
// if (nadaptor instanceof ClassRep) {
// ParsedDataStorage.getInstance().removeNonSpecificJavaClass(nadaptor.getName());
// PatternTypeClassDecorator newP = new PatternTypeClassDecorator((ClassRep) nadaptor, "\\<\\<adaptor\\>\\>");
// newP.setColor("maroon");
// }
// } else if (nadaptor instanceof ClassRep)
// {
// //
// }
// else
// {
// //
// }
ParsedDataStorage.getInstance().getNonSpecificJavaClass(s.adaptorName.replace("/", ".")).setColor("maroon");
ParsedDataStorage.getInstance().getNonSpecificJavaClass(s.adapteeName.replace("/", ".")).addToDisplayName("\\<\\<adaptee\\>\\>");
ParsedDataStorage.getInstance().getNonSpecificJavaClass(s.adapteeName.replace("/", ".")).setColor("maroon");
ParsedDataStorage.getInstance().getNonSpecificJavaClass(s.targetName.replace("/", ".")).addToDisplayName("\\<\\<target\\>\\>");
ParsedDataStorage.getInstance().getNonSpecificJavaClass(s.targetName.replace("/", ".")).setColor("maroon");
ParsedDataStorage.getInstance().getNonSpecificJavaClass(s.adaptorName.replace("/", ".")).addToDisplayName("\\<\\<adaptor\\>\\>");
ParsedDataStorage.getInstance().getNonSpecificJavaClass(s.adapteeName.replace("/", ".")).addToDisplayName("\\<\\<adaptee\\>\\>");
ParsedDataStorage.getInstance().getNonSpecificJavaClass(s.targetName.replace("/", ".")).addToDisplayName("\\<\\<target\\>\\>");

for (IRelation r : ParsedDataStorage.getInstance().getAssociationRels()) {
if (r.getFrom().equals(s.adaptorName) && r.getTo().equals(s.adapteeName)) {
System.out.println("|from| " + r.getFrom() + " |adaptorName| " + s.adaptorName + " |to| " + r.getTo() + " |adapteeName| " + s.adapteeName);
//System.out.println("|from| " + r.getFrom() + " |adaptorName| " + s.adaptorName + " |to| " + r.getTo() + " |adapteeName| " + s.adapteeName);
ParsedDataStorage.getInstance().removeRelation(r);
newAssoc.add(new NamedRelationDecorator(r, "\\<\\<adapts\\>\\>"));
}
}

}

// for (AbstractJavaClassRep r : newClasses )
// {
// ParsedDataStorage.getInstance().addNonSpecificJavaClass(r);
// }

for (IRelation newRel : newAssoc) {
ParsedDataStorage.getInstance().addAssociationRelation(newRel);
}