if (loadTask != null) {  constraint = ldmFactory_.newConstraint(); constraint.setConstrainedTask(loadTask); constraint.setConstrainedAspect(AspectType.START_TIME); constraint.setConstrainingTask(withdrawTask); constraint.setConstrainingAspect(AspectType.END_TIME); constraint.setConstraintOrder(Constraint.COINCIDENT); wf.addConstraint(constraint);  constraint = ldmFactory_.newConstraint(); constraint.setConstrainedTask(loadTask); constraint.setConstrainedAspect(AspectType.QUANTITY); constraint.setConstrainingTask(withdrawTask); constraint.setConstrainingAspect(AspectType.QUANTITY); constraint.setConstraintOrder(Constraint.EQUALTO); wf.addConstraint(constraint); }  constraint = ldmFactory_.newConstraint(); constraint.setConstrainedTask(parentTask); constraint.setConstrainedAspect(AspectType.END_TIME); if (transportTask != null) { constraint.setConstrainingTask(transportTask); } else if (loadTask != null) { constraint.setConstrainingTask(loadTask); } else { constraint.setConstrainingTask(withdrawTask); } constraint.setConstrainingAspect(AspectType.END_TIME); constraint.setConstraintOrder(Constraint.COINCIDENT); wf.addConstraint(constraint);  constraint = ldmFactory_.newConstraint(); constraint.setConstrainedTask(parentTask); constraint.setConstrainedAspect(AspectType.QUANTITY); if (transportTask != null) { constraint.setConstrainingTask(transportTask); } else if (loadTask != null) { constraint.setConstrainingTask(loadTask); } else { constraint.setConstrainingTask(withdrawTask); } constraint.setConstrainingAspect(AspectType.QUANTITY); constraint.setConstraintOrder(Constraint.EQUALTO); wf.addConstraint(constraint); }
    private void expandRealSupplyTask(Task parentTask) {	Vector expand_tasks = new Vector();	NewTask withdrawTask = createSupplyWithdrawTask(parentTask);	expand_tasks.addElement(withdrawTask);        NewTask transportTask = null;        NewTask loadTask = null;        withdrawTask.addObservableAspect(AspectType.END_TIME);        withdrawTask.addObservableAspect(AspectType.QUANTITY);        if (addLoad) {            loadTask = createLoadTask(parentTask, withdrawTask);            loadTask.addObservableAspect(AspectType.START_TIME);            loadTask.addObservableAspect(AspectType.END_TIME);            loadTask.addObservableAspect(AspectType.QUANTITY);            expand_tasks.addElement(loadTask);        }        if (addTransport) {            transportTask = createTransportTask(parentTask, withdrawTask);            transportTask.addObservableAspect(AspectType.START_TIME);            transportTask.addObservableAspect(AspectType.END_TIME);            transportTask.addObservableAspect(AspectType.QUANTITY);            expand_tasks.addElement(transportTask);        }        ((NewTask) parentTask).addObservableAspect(AspectType.END_TIME);        publishExpansion(parentTask, expand_tasks);        Expansion expansion = (Expansion) parentTask.getPlanElement();        AllocationResult ar = new AllocationResultHelper(parentTask, null).getAllocationResult(1.0);        expansion.setEstimatedResult(ar);        NewWorkflow wf = (NewWorkflow) expansion.getWorkflow();        wf.setAllocationResultAggregator(supplyARA);        NewConstraint constraint;        if (transportTask != null) {          // Constraint start of transport          constraint = ldmFactory_.newConstraint();          constraint.setConstrainedTask(transportTask);          constraint.setConstrainedAspect(AspectType.START_TIME);          if (loadTask != null) {            // Constrain load before transport            constraint.setConstrainingTask(loadTask);            constraint.setConstrainingAspect(AspectType.END_TIME);          } else {            // Constrain withdraw before transport            constraint.setConstrainingTask(withdrawTask);            constraint.setConstrainingAspect(AspectType.END_TIME);          }          constraint.setConstraintOrder(Constraint.COINCIDENT); // Artificial          wf.addConstraint(constraint);          // Constraint QUANTITY of transport          constraint = ldmFactory_.newConstraint();          constraint.setConstrainedTask(transportTask);          constraint.setConstrainedAspect(AspectType.QUANTITY);          if (loadTask != null) {            // Constrain transport quantity equal to load quantity            constraint.setConstrainingTask(loadTask);            constraint.setConstrainingAspect(AspectType.QUANTITY);          } else {            // Constrain transport quantity equal to withdraw quantity            constraint.setConstrainingTask(withdrawTask);            constraint.setConstrainingAspect(AspectType.QUANTITY);          }          constraint.setConstraintOrder(Constraint.EQUALTO); // Artificial          wf.addConstraint(constraint);        }        if (loadTask != null) {          // Constraint start of load          constraint = ldmFactory_.newConstraint();          constraint.setConstrainedTask(loadTask);          constraint.setConstrainedAspect(AspectType.START_TIME);          constraint.setConstrainingTask(withdrawTask);          constraint.setConstrainingAspect(AspectType.END_TIME);          constraint.setConstraintOrder(Constraint.COINCIDENT); // Artificial          wf.addConstraint(constraint);          // Constraint quantity of load          constraint = ldmFactory_.newConstraint();          constraint.setConstrainedTask(loadTask);          constraint.setConstrainedAspect(AspectType.QUANTITY);          constraint.setConstrainingTask(withdrawTask);          constraint.setConstrainingAspect(AspectType.QUANTITY);          constraint.setConstraintOrder(Constraint.EQUALTO); // Artificial          wf.addConstraint(constraint);        }        // Constraint end of parentTask        constraint = ldmFactory_.newConstraint();        constraint.setConstrainedTask(parentTask);        constraint.setConstrainedAspect(AspectType.END_TIME);        if (transportTask != null) {          constraint.setConstrainingTask(transportTask);        } else if (loadTask != null) {          constraint.setConstrainingTask(loadTask);        } else {          constraint.setConstrainingTask(withdrawTask);        }        constraint.setConstrainingAspect(AspectType.END_TIME);        constraint.setConstraintOrder(Constraint.COINCIDENT); // Artificial        wf.addConstraint(constraint);        // Constraint quantity of parent task        constraint = ldmFactory_.newConstraint();        constraint.setConstrainedTask(parentTask);        constraint.setConstrainedAspect(AspectType.QUANTITY);        if (transportTask != null) {          constraint.setConstrainingTask(transportTask);        } else if (loadTask != null) {          constraint.setConstrainingTask(loadTask);        } else {          constraint.setConstrainingTask(withdrawTask);        }        constraint.setConstrainingAspect(AspectType.QUANTITY);        constraint.setConstraintOrder(Constraint.EQUALTO); // Artificial        wf.addConstraint(constraint);    }