Skip to content

Instantly share code, notes, and snippets.

@edipofederle
Created November 25, 2013 13:12
Show Gist options
  • Save edipofederle/7641000 to your computer and use it in GitHub Desktop.
Save edipofederle/7641000 to your computer and use it in GitHub Desktop.
private void moveAttributeAllComponents(Architecture arch, Package sourceComp, Package targetComp, Class sourceClass, List<Attribute> AttributesClass, Class newClass) throws JMException {
Attribute targetAttribute = randomObject (AttributesClass);
sourceClass.moveAttributeToClass(targetAttribute, newClass);
for (Concern con: targetAttribute.getOwnConcerns()){
try {
newClass.addConcern(con.getName());
} catch (ConcernNotFoundException e) {
e.printStackTrace();
}
}
if (targetComp.equals(sourceComp)){
AssociationRelationship newRelationship = new AssociationRelationship(newClass, sourceClass);
arch.getAllRelationships().add(newRelationship);
}
else{
Collection<Interface> allItfsTargetComp = targetComp.getImplementedInterfaces();
Interface targetInterface = null;
for (Interface itf: allItfsTargetComp){
for (Concern con : targetAttribute.getOwnConcerns())
if (itf.containsConcern(con))
targetInterface = itf;
}
if (targetInterface==null){
if (targetComp.getImplementedInterfaces().isEmpty()) targetInterface=arch.createInterface("Interface"+ OPLA.contInt_++);
} else{ targetInterface= randomObject(new ArrayList<Interface> (targetComp.getImplementedInterfaces()));}
arch.addRequiredInterface(targetInterface, sourceComp);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment