Esempio n. 1
0
 /**
  * Retrieve an instance of the enum based on its int value.
  *
  * @param type int type
  * @return enum instance
  */
 public static LineStyle getInstance(Number type) {
   int value;
   if (type == null) {
     value = -1;
   } else {
     value = NumberHelper.getInt(type);
   }
   return (getInstance(value));
 }
  /**
   * This method evaluates a if a graphical indicator should be displayed, given a set of Task or
   * Resource data. The method will return -1 if no indicator should be displayed.
   *
   * @param container Task or Resource instance
   * @return indicator index
   */
  public int evaluate(FieldContainer container) {
    //
    // First step - determine the list of criteria we are should use
    //
    List<GraphicalIndicatorCriteria> criteria;
    if (container instanceof Task) {
      Task task = (Task) container;
      if (NumberHelper.getInt(task.getUniqueID()) == 0) {
        if (m_projectSummaryInheritsFromSummaryRows == false) {
          criteria = m_projectSummaryCriteria;
        } else {
          if (m_summaryRowsInheritFromNonSummaryRows == false) {
            criteria = m_summaryRowCriteria;
          } else {
            criteria = m_nonSummaryRowCriteria;
          }
        }
      } else {
        if (task.getSummary() == true) {
          if (m_summaryRowsInheritFromNonSummaryRows == false) {
            criteria = m_summaryRowCriteria;
          } else {
            criteria = m_nonSummaryRowCriteria;
          }
        } else {
          criteria = m_nonSummaryRowCriteria;
        }
      }
    } else {
      // It is possible to have a resource summary row, but at the moment
      // I can't see how you can determine this.
      criteria = m_nonSummaryRowCriteria;
    }

    //
    // Now we have the criteria, evaluate each one until we get a result
    //
    int result = -1;
    for (GraphicalIndicatorCriteria gic : criteria) {
      result = gic.evaluate(container);
      if (result != -1) {
        break;
      }
    }

    //
    // If we still don't have a result at the end, return the
    // default value, which is 0
    //
    if (result == -1) {
      result = 0;
    }

    return (result);
  }
Esempio n. 3
0
  /**
   * Test the resource types present in an individual MPP file.
   *
   * @param file MPP file to test
   */
  private void testResourceType(File file) throws MPXJException {
    ProjectFile project = new MPPReader().read(file);
    List<Resource> resources = project.getAllResources();
    assertEquals(10, resources.size());

    testResource(file, project, 1, "Work 1", ResourceType.WORK);
    testResource(file, project, 2, "Work 2", ResourceType.WORK);
    testResource(file, project, 3, "Work 3", ResourceType.WORK);
    testResource(file, project, 4, "Material 1", ResourceType.MATERIAL);
    testResource(file, project, 5, "Material 2", ResourceType.MATERIAL);
    testResource(file, project, 6, "Material 3", ResourceType.MATERIAL);

    //
    // The cost resource type was introduced in MPP12
    //
    ResourceType expectedType =
        NumberHelper.getInt(project.getProjectProperties().getMppFileType()) > 9
            ? ResourceType.COST
            : ResourceType.MATERIAL;
    testResource(file, project, 7, "Cost 1", expectedType);
    testResource(file, project, 8, "Cost 2", expectedType);
    testResource(file, project, 9, "Cost 3", expectedType);
  }