PrepositionalPhrase pPhrase = UTILPrepPhrase.getPrepNamed( task, Constants.Preposition.FOR);
PrepositionalPhrase pPhrase = prepHelper.getPrepNamed( task, Constants.Preposition.FOR);
    public String toString() {      String retVal = "";      if ( object instanceof String) {        retVal = (String)object;      }      if ( object instanceof PlanElement) {        PlanElement planElement = (PlanElement)object;        if ( planElement instanceof Allocation) {          Allocation allocation = (Allocation)planElement;          Asset asset = allocation.getAsset();          if ( asset instanceof Organization) {            retVal = "[Allocation Results]";          } else if ( asset instanceof AssetGroup) {            retVal = "[Allocated Item] Asset Group";          } else {            String assetName = asset.getTypeIdentificationPG().getNomenclature();            String assetID = asset.getItemIdentificationPG().getItemIdentification();            if ( !(asset instanceof Person)) {              retVal = "[Allocated Item] " + assetName;            } else {              String nameOfPerson = asset.getItemIdentificationPG().getNomenclature();              String jobDescription  = null;              String afsc            = null;              Person person = (Person)asset;              PersonPG personPG = (PersonPG)person.getPersonPG();              Collection skills = personPG.getSkills();              Iterator iter = skills.iterator();              while ( iter.hasNext()) {                Skill skill = (Skill)iter.next();                if ( skill instanceof AircrewSkill) {                  AircrewSkill aircrewSkill = (AircrewSkill) skill;                  jobDescription  = aircrewSkill.getPosition();                  afsc            = aircrewSkill.getQualification();                  break;                }              }              retVal = "[Allocated Person] " + jobDescription + ":" + afsc + " <" + nameOfPerson + ">";            }            if ( assetID != null) {              retVal += " <" + assetID + ">";            }          }        } else {          if ( planElement instanceof Disposition) {            AllocationResult allocationResult = planElement.getEstimatedResult();            if ( allocationResult.isSuccess() == false) {              retVal = "[Failed Allocation]";            }          }        }      } else if ( object instanceof Task) {        Task task = (Task)object;        if ( displaySourceDestination) {          if ( task.getParentTaskUID() == null) {            retVal += "(ROOT) ";          } else {            String source       = task.getSource().getAddress();            String destination  = task.getDestination().getAddress();            if ( displayTaskID) {              retVal += "(" + task.getUID() + ")";            }            if ( source.equals( destination) == false) {              retVal += "<" + source + " to " + destination + ">";            }          }        }        PlanElement planElement = task.getPlanElement();        if ( planElement != null) {          Asset asset = null;          if ( planElement instanceof AssetTransfer && displayAssetTransfers) {            retVal += "(AssetTransfer): ";            AssetTransfer assetTransfer = (AssetTransfer)planElement;            retVal += getDescription( assetTransfer.getAsset());            retVal += " to " + getDescription( assetTransfer.getAssignee());            Object directObject = task.getDirectObject();            if ( directObject != null) {              retVal += " " + getDescription( directObject);            }            PrepositionalPhrase pPhrase = UTILPrepPhrase.getPrepNamed( task, Constants.Preposition.FOR);            if ( pPhrase != null) {              retVal += " For " + getDescription( pPhrase.getIndirectObject());            }          } else {            if ( planElement instanceof Allocation) {              asset = ((Allocation)planElement).getAsset();              if ( asset instanceof Organization) {                if ( task.getParentTaskUID() != null) {                  retVal += "(Allocated to " + getDescription( asset) + ")";                }              }            }            retVal += task.getVerb().toString();            if ( displayDates) {              Date date = new Date( (long)(task.getPreferredValue( AspectType.START_TIME)));              Calendar calendar = new GregorianCalendar();              calendar.setTime( date);              int month = calendar.get( Calendar.MONTH);              int day = calendar.get( Calendar.DAY_OF_MONTH);              int year = calendar.get( Calendar.YEAR);              int hour = calendar.get( Calendar.HOUR_OF_DAY);              int minute = calendar.get( Calendar.MINUTE);              String am_pm = (hour < 12) ? "am" : "pm";              retVal += "[";              if ( hour > 12) {                hour -= 12;              }              retVal += month + "/" + day + "/"+ year + " ";              if ( hour <= 9) {                retVal += "0";              }              retVal += hour + ":";              if ( minute <= 9) {                retVal += "0";              }              retVal += minute + am_pm;              retVal += " thru ";              date = new Date( (long)(task.getPreferredValue( AspectType.END_TIME)));              calendar = new GregorianCalendar();              calendar.setTime( date);              month = calendar.get( Calendar.MONTH);              day = calendar.get( Calendar.DAY_OF_MONTH);              year = calendar.get( Calendar.YEAR);              hour = calendar.get( Calendar.HOUR_OF_DAY);              minute = calendar.get( Calendar.MINUTE);              am_pm = (hour < 12) ? "am" : "pm";              if ( hour > 12) {                hour -= 12;              }              retVal += month + "/" + day + "/"+ year + " ";              if ( hour <= 9) {                retVal += "0";              }              retVal += hour + ":";              if ( minute <= 9) {                retVal += "0";              }              retVal += minute + am_pm + "]";            }            Preference preference = task.getPreference( AspectType.QUANTITY);            if ( preference != null) {              ScoringFunction sf = preference.getScoringFunction();              double score = ((AspectScorePoint)sf.getBest()).getValue();              if ( score >= 1) {                retVal += " [qty=" + (int)score;              } else {                retVal += " [qty=" + score;              }              AspectScorePoint aspectScorePoint = sf.getBest();              AspectValue aspectValue = aspectScorePoint.getAspectValue();              if ( aspectValue instanceof TypedQuantityAspectValue) {                TypedQuantityAspectValue typedQuantityAV = (TypedQuantityAspectValue)aspectValue;                String assetName = typedQuantityAV.getAsset().getTypeIdentificationPG().getNomenclature();                retVal += "," + assetName;              }              retVal += "]";            }            Object directObject = task.getDirectObject();            if ( directObject != null)              retVal += " " + getDescription( directObject);            if ( displayTaskDetail) {              Enumeration pPhrases = task.getPrepositionalPhrases();              boolean first = true;              while ( pPhrases.hasMoreElements()) {                if ( !first) {                  retVal += ",";                } else {                  first = false;                }                PrepositionalPhrase pPhrase = (PrepositionalPhrase)pPhrases.nextElement();                retVal += " " + pPhrase.getPreposition() + " " + getDescription( pPhrase.getIndirectObject());              }            }          }        } else {          retVal += task.getVerb().toString();          Preference preference = task.getPreference( AspectType.QUANTITY);          if ( preference != null) {            ScoringFunction sf = preference.getScoringFunction();            double score = ((AspectScorePoint)sf.getBest()).getValue();            if ( score >= 1) {              retVal += " [qty=" + (int)score;            } else {              retVal += " [qty=" + score;            }            AspectScorePoint aspectScorePoint = sf.getBest();            AspectValue aspectValue = aspectScorePoint.getAspectValue();            if ( aspectValue instanceof TypedQuantityAspectValue) {              TypedQuantityAspectValue typedQuantityAV = (TypedQuantityAspectValue)aspectValue;              String assetName = typedQuantityAV.getAsset().getTypeIdentificationPG().getNomenclature();              retVal += "," + assetName;            }            retVal += "]";          }          Object directObject = task.getDirectObject();          if ( directObject != null) {            retVal += " " + getDescription( directObject);          }          if ( displayTaskDetail) {            Enumeration pPhrases = task.getPrepositionalPhrases();            boolean first = true;            while ( pPhrases.hasMoreElements()) {              if ( !first) {                retVal += ",";              } else {                first = false;              }              PrepositionalPhrase pPhrase = (PrepositionalPhrase)pPhrases.nextElement();              retVal += " " + pPhrase.getPreposition() + " " + getDescription( pPhrase.getIndirectObject());            }          }        }      }      return retVal;    }