/**
* @see org.andromda.metafacades.uml.ServiceOperation#getRoles()
*/
public java.util.Collection handleGetRoles()
{
final Collection roles = new LinkedHashSet();
if (this.getOwner() instanceof Service)
{
roles.addAll(((Service)this.getOwner()).getRoles());
}
final Collection operationRoles = new ArrayList(this.getTargetDependencies());
CollectionUtils.filter(
operationRoles,
new Predicate()
{
public boolean evaluate(Object object)
{
DependencyFacade dependency = (DependencyFacade)object;
return dependency != null && dependency.getSourceElement() != null &&
Role.class.isAssignableFrom(dependency.getSourceElement().getClass());
}
});
CollectionUtils.transform(
operationRoles,
new Transformer()
{
public Object transform(Object object)
{
return ((DependencyFacade)object).getSourceElement();
}
});
roles.addAll(operationRoles);
final Collection allRoles = new LinkedHashSet(roles);
// add all roles which are specializations of this one
CollectionUtils.forAllDo(
roles,
new Closure()
{
public void execute(Object object)
{
if (object instanceof Role)
{
allRoles.addAll(((Role)object).getAllSpecializations());
}
}
});
return allRoles;
}