}
    public void publishAddToExpansion(Task parent, Task subtask) {        //attach the subtask to its parent and the parent's workflow        PlanElement pe = parent.getPlanElement();        Expansion expansion;        NewWorkflow wf;        ((NewTask) subtask).setParentTask(parent);        ((NewTask) subtask).setPlan(parent.getPlan());        // Task has not been expanded, create an expansion        if (pe == null) {            PlanningFactory factory = getPlanningFactory();            // Create workflow            wf = (NewWorkflow) factory.newWorkflow();            wf.setParentTask(parent);            wf.setIsPropagatingToSubtasks(true);            wf.addTask(subtask);            ((NewTask) subtask).setWorkflow(wf);            // Build Expansion            expansion = factory.createExpansion(parent.getPlan(), parent, wf, null);            // Publish Expansion            publishAdd(expansion);        }        // Task already has expansion, add task to the workflow and publish the change        else if (pe instanceof Expansion) {            expansion = (Expansion) pe;            wf = (NewWorkflow) expansion.getWorkflow();            wf.addTask(subtask);            ((NewTask) subtask).setWorkflow(wf);            publishChange(expansion);        } else {            if (logger.isErrorEnabled()) {                logger.error("publishAddToExpansion: problem pe not Expansion? " + pe);            }        }        // Publish new task        publishAdd(subtask);        if ((subtask.getVerb().equals(Constants.Verb.SUPPLY)) ||                (subtask.getVerb().equals(Constants.Verb.PROJECTSUPPLY))) {            newRefills.add(subtask);        }    }