コード例 #1
0
 /**
  * Retrieve an instance of the enum based on its int value.
  *
  * @param type int type
  * @return enum instance
  */
 public static TaskType getInstance(Number type) {
   int value;
   if (type == null) {
     value = -1;
   } else {
     value = NumberUtility.getInt(type);
   }
   return (getInstance(value));
 }
コード例 #2
0
  /**
   * Creates a CostRateTable instance from a block of data.
   *
   * @param resource parent resource
   * @param index cost rate table index
   * @param data data block
   */
  public void process(Resource resource, int index, byte[] data) {
    CostRateTable result = new CostRateTable();

    if (data != null) {
      for (int i = 16; i + 44 <= data.length; i += 44) {
        Rate standardRate = new Rate(MPPUtility.getDouble(data, i), TimeUnit.HOURS);
        TimeUnit standardRateFormat = getFormat(MPPUtility.getShort(data, i + 8));
        Rate overtimeRate = new Rate(MPPUtility.getDouble(data, i + 16), TimeUnit.HOURS);
        TimeUnit overtimeRateFormat = getFormat(MPPUtility.getShort(data, i + 24));
        Double costPerUse = NumberUtility.getDouble(MPPUtility.getDouble(data, i + 32) / 100.0);
        Date endDate = MPPUtility.getTimestampFromTenths(data, i + 40);
        CostRateTableEntry entry =
            new CostRateTableEntry(
                standardRate,
                standardRateFormat,
                overtimeRate,
                overtimeRateFormat,
                costPerUse,
                endDate);
        result.add(entry);
      }
      Collections.sort(result);
    } else {
      //
      // MS Project economises by not actually storing the first cost rate
      // table if it doesn't need to, so we take this into account here.
      //
      if (index == 0) {
        Rate standardRate = resource.getStandardRate();
        Rate overtimeRate = resource.getOvertimeRate();
        Number costPerUse = resource.getCostPerUse();
        CostRateTableEntry entry =
            new CostRateTableEntry(
                standardRate,
                standardRate.getUnits(),
                overtimeRate,
                overtimeRate.getUnits(),
                costPerUse,
                CostRateTableEntry.DEFAULT_ENTRY.getEndDate());
        result.add(entry);
      } else {
        result.add(CostRateTableEntry.DEFAULT_ENTRY);
      }
    }

    resource.setCostRateTable(index, result);
  }