if (isCountedAR && (TaskUtils.isProjection(aTask))) { startTime = logInvPG.getEffectiveProjectionStart(aTask, startTime); if (startTime >= endTime) { return; } } String outputStr = taskStr + getDateString(startTime, expandTimestamp) + ","; outputStr = outputStr + getDateString(endTime, expandTimestamp) + ",";
String endTimeString = getDateString(endTime, expandTimestamp); long startTime=0; String outputStr=null;  if(TaskUtils.isProjection(aTask)) { startTime = (long) TaskUtils.getStartTime(ar); if (isCountedAR) { startTime = logInvPG.getEffectiveProjectionStart(aTask, startTime); if (startTime >= endTime) { return; } } outputStr = taskStr + getDateString(startTime, expandTimestamp) + ","; outputStr = outputStr + endTimeString + ","; } else {  outputStr = taskStr + "," + endTimeString + ","; }   if(((endTime <= 0) || endTimeString.equals("0")) && (logger.isWarnEnabled())) { logger.warn("For Org " + getOrgName() + "-" + getSupplyType() + " item: " + taskUtils.getTaskItemName(aTask) + " - " + getInvNomenclatureName() + " the endTime (" + endTime + ") for the " + "non-phased allocation result prints out to " + endTimeString); }
  protected void logAllocationResult(Task aTask, boolean expandTimestamp, boolean isCountedAR) {    if (aTask == null) {      return;    }    PlanElement pe = aTask.getPlanElement();    if (pe == null) {      return;    }    String resultType = AR_REPORTED_STR;    AllocationResult ar = pe.getReportedResult();    if (ar == null) {      resultType = AR_ESTIMATED_STR;      ar = pe.getEstimatedResult();    }    if (ar != null) {      String taskStr = buildTaskPrefixString(aTask);      taskStr = taskStr + resultType + ",";      if (ar.isSuccess()) {        taskStr = taskStr + AR_SUCCESS_STR + ",";      } else {        taskStr = taskStr + AR_FAILURE_STR + ",";      }      if (!ar.isPhased()) {        long startTime = (long) TaskUtils.getStartTime(ar);        long endTime = (long) TaskUtils.getEndTime(ar);        if (isCountedAR &&            (TaskUtils.isProjection(aTask))) {          startTime = logInvPG.getEffectiveProjectionStart(aTask, startTime);          if (startTime >= endTime) {            return;          }        }        String outputStr = taskStr + getDateString(startTime, expandTimestamp) + ",";        outputStr = outputStr + getDateString(endTime, expandTimestamp) + ",";	try {        outputStr = outputStr + taskUtils.getQuantity(aTask, ar);   } catch (RuntimeException re) {      if (re.getMessage().indexOf("Assertion botch:") > -1) {        String errorString = "Assertion Botch: start time: " + startTime;        errorString += (" end time: " + endTime);	errorString += (" UID: " + aTask.getUID());        double d = taskUtils.getQuantity(aTask,ar); // don't print me!!!        long dbits = Double.doubleToLongBits(d);        long rbits = Double.doubleToRawLongBits(d);        errorString += ("quantity_d: " + Long.toHexString(dbits));        errorString += ("quantity_r: " + Long.toHexString(rbits));        logger.error(errorString);      }      throw re;  // re-throw for now    }        writeln(outputStr);      } else {        int[] ats = ar.getAspectTypes();        int qtyInd = -1;        if (taskUtils.isProjection(aTask)) {          qtyInd = getIndexForType(ats, AlpineAspectType.DEMANDRATE);        } else {          qtyInd = getIndexForType(ats, AspectType.QUANTITY);        }        int startInd = getIndexForType(ats, AspectType.START_TIME);        int endInd = getIndexForType(ats, AspectType.END_TIME);        Enumeration phasedResults = ar.getPhasedResults();        while (phasedResults.hasMoreElements()) {          double[] results = (double[]) phasedResults.nextElement();          String outputStr = taskStr;          long startTime = 0;          long endTime;          if (startInd == -1) {            outputStr += ",";          } else {            startTime = (long) results[startInd];            if (isCountedAR &&                (TaskUtils.isProjection(aTask))) {              startTime = logInvPG.getEffectiveProjectionStart(aTask, startTime);            }            outputStr += getDateString(startTime, expandTimestamp) + ",";          }          if (endInd == -1) {            /** MWD The following line of code which replaces the             *  allocation result end time with the task end time             *  is only due to a current error in the             *  UniversalAllocator.   The UA is only setting             *  the start time in the allocation result. There             *  is a bug in and when the UA is fixed this line             *  of code should be removed. If there is no end time             *  in the allocation result, none should be appended.             *  GUI needs the end             *  times for the rates.             */            endTime = TaskUtils.getEndTime(aTask);            outputStr += getDateString(endTime, expandTimestamp);            outputStr += ",";          } else {            endTime = (long) results[endInd];            outputStr += getDateString(endTime, expandTimestamp) + ",";          }          if ((qtyInd >= results.length) ||              (qtyInd < 0)) {            logger.error("qtyInd is " + qtyInd + " - No Qty in this phase of allocation results: " + outputStr);          } else {            outputStr += taskUtils.convertResultsToDailyRate(aTask, results[qtyInd]);            if (startTime <= endTime) {              writeln(outputStr);            } else if (!isCountedAR) {              logger.warn("logAllocationResult: not going to log an allocation result where endTime is less than start time.  CSV line is is:" + outputStr);            }          }        }      }    }  }