public class ComplexActivityAdapter implements Adapter{
public Object convert(Object src, Hashtable keyedContext) throws Exception {
ActivityUtil activityUtil = new ActivityUtil();
ComplexActivity srcDef = (ComplexActivity)src;
GraphActivity previousGraphAct = null;//graphActivity;
GraphActivity headerGA = null;
for(int i=0; i<srcDef.getChildActivities().size(); i++){
Activity childAct = (Activity) srcDef.getChildActivities().get(i);
GraphActivity currGraphAct;
if (childAct instanceof Activity) {
Adapter adapter = ProcessDefinitionAdapter.getAdapter(childAct.getClass());
currGraphAct = (GraphActivity) adapter.convert(childAct, keyedContext);
} else {
currGraphAct = new GraphActivity(childAct);
}
if (previousGraphAct != null) {
if(previousGraphAct.getReferenceActivity() instanceof BackActivity) {
previousGraphAct.addNext(currGraphAct);
} else {
GraphActivity tracing = previousGraphAct;
Hashtable graphList = new Hashtable();
Vector<GraphActivity> endNodeList = new Vector<GraphActivity>();
tracing.getEndNodeList(tracing, graphList,endNodeList);
for (GraphActivity tracingTemp : endNodeList) {
if (!activityUtil.isVisible(childAct, keyedContext)) tracingTemp.addNext(currGraphAct);
}
}
} else {
headerGA = currGraphAct;
}
if (!activityUtil.isVisible(childAct, keyedContext)) {
previousGraphAct = currGraphAct;
String tt = currGraphAct.getReferenceActivity().getTracingTag();
if (!keyedContext.containsKey(tt)) {
keyedContext.put(tt, currGraphAct);