コード例 #1
0
  /**
   * Recipe: Iterating a View object using a secondary RowSet iterator.
   *
   * <p>Adjusts all the employees commission by a certain percentage.
   *
   * @param commissionPctAdjustment, the commission percent adjustment
   */
  public void adjustCommission(Number commissionPctAdjustment) {
    // check for valid commission adjustment
    if (commissionPctAdjustment != null) {
      // create an employee secondary RowSet iterator
      RowSetIterator employees = this.createRowSetIterator(null);
      // reset the iterator
      employees.reset();
      // iterate the employees
      while (employees.hasNext()) {
        // get the employee
        EmployeesRowImpl employee = (EmployeesRowImpl) employees.next();
        // check for employee belonging to the sales department
        if (employee.getDepartmentId() != null
            && SALES_DEPARTMENT_ID == employee.getDepartmentId().intValue()) {
          // calculate adjusted commission
          Number commissionPct = employee.getCommissionPct();
          Number adjustedCommissionPct =
              (commissionPct != null)
                  ? commissionPct.add(commissionPctAdjustment)
                  : commissionPctAdjustment;
          // set the employee's new commission
          employee.setCommissionPct(adjustedCommissionPct);
        }
      }

      // done with the RowSet iterator
      employees.closeRowSetIterator();
    }
  }
コード例 #2
0
  private Row getFirstDateForPlate(String plate) {
    Map<String, Object> resultMap = new HashMap<String, Object>();
    XxntcCsCalendarActivitiesEOVOImpl searchVo = getXxntcCsCalendarActivitiesEOVOSearch();
    searchVo.setApplyViewCriteriaName("GetDateCriteria");
    VariableValueManager vvm = searchVo.ensureVariableManager();
    vvm.setVariableValue("pTitle", plate);
    vvm.setVariableValue("pResourceId", getResourceId());
    searchVo.executeQuery();
    if (searchVo.getRowCount() == 0) return null;

    RowSetIterator iterator = searchVo.createRowSetIterator(null);
    iterator.reset();
    List<Row> rows = new ArrayList<Row>();
    while (iterator.hasNext()) {
      Row row = iterator.next();
      rows.add(row);
    }
    iterator.closeRowSetIterator();
    return getMaxStartTimeActRow(rows);
  }