logger.info("step has prerequisite " + preReqStep.getName() + " adding constraint");
logger.info("step has prerequisite " + preReqStep.getName() + ", adding constraint");
    private NewTask makeTask(Step step) {        NewTask parentTask = factory.newTask();        parentTask.setVerb(new Verb(step.getName()));        logger.debug("created task " + parentTask.getVerb());        // get subsets of this step and create tasks for those, and a workflow to put them in        NewWorkflow workflow = factory.newWorkflow();        // NOTE: tasks are returned in the correct order (according to Little-JIL API docs)        Task lastTask = null;        for (Enumeration substepsEnum = step.substeps(); substepsEnum.hasMoreElements();) {            Step substep = (Step) ((SubstepBinding) substepsEnum.nextElement()).getTarget();            NewTask task = makeTask(substep);            logger.debug("adding task " + task.getVerb() + " to workflow of task " + parentTask.getVerb());            task.setParentTask(parentTask);            workflow.addTask(task);            task.setWorkflow(workflow);            // TODO: should I use different END_TIME prefs? mhmm...            ScoringFunction scorefcn = ScoringFunction.createStrictlyAtValue                    (new AspectValue(AspectType.END_TIME, 1.0));            Preference pref = factory.newPreference(AspectType.END_TIME, scorefcn);            task.setPreference(pref);            // if the parent step is sequential, set this task so it starts after the previous ends            if (step.getStepKind() == Step.SEQUENTIAL && lastTask != null) {                logger.info("making constraint so that task " + task.getVerb() + " goes after " + lastTask.getVerb());                NewConstraint constraint = factory.newConstraint();                constraint.setConstrainingTask(lastTask);                constraint.setConstrainingAspect(AspectType.END_TIME);                constraint.setConstrainedTask(task);                constraint.setConstrainedAspect(AspectType.START_TIME);                constraint.setConstraintOrder(Constraint.BEFORE);                workflow.addConstraint(constraint);            }            // TODO: choice and try            if (substep.getPrerequisite() != null) {                final Step preReqStep = ((Reference) substep.getPrerequisite().getTarget()).refersTo();                logger.info("step has prerequisite " + preReqStep.getName() + " adding constraint");                NewTask preReqTask = makeTask(preReqStep);                preReqTask.setPreference(pref);                workflow.addTask(preReqTask);                preReqTask.setWorkflow(workflow);                // add constraint so that this task gets done before                NewConstraint constraint = factory.newConstraint();                constraint.setConstrainingTask(preReqTask);                constraint.setConstrainingAspect(AspectType.END_TIME);                constraint.setConstrainedTask(task);                constraint.setConstrainedAspect(AspectType.START_TIME);                constraint.setConstraintOrder(Constraint.BEFORE);                workflow.addConstraint(constraint);            }            lastTask = task;        }        if (lastTask != null) {            workflow.setParentTask(parentTask);            NewExpansion expansion = (NewExpansion) factory.createExpansion(parentTask.getPlan(), parentTask, workflow, null);            logger.debug("publishing parent task " + parentTask);            blackboard.publishAdd(parentTask);            logger.debug("publishing expansion " + expansion);            blackboard.publishAdd(expansion);        }        return parentTask;    }