((NewTask)sub).setWorkflow(wf);
  private Expansion createExpansion(Task sub) {    RootFactory factory = getFactory();        //make a bogus bulk estimate parent task    NewTask betask = factory.newTask();    betask.setVerb(Constants.Verb.BulkEstimate);    betask.setPlan(sub.getPlan());    publishAdd(betask);        // expand the bulkestimate task    NewWorkflow wf = factory.newWorkflow();    wf.setParentTask(betask);    ((NewTask)sub).setParentTask(betask);    wf.addTask(sub);    wf.setIsPropagatingToSubtasks(true);        // create the actual Expansion PlanElement    Expansion exp = factory.createExpansion(sub.getPlan(), betask, wf, null);        // publish the expansion    publishAdd(exp);        // publish the single subtask of the workflow    publishAdd(sub);        return exp;      }