/** * 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(); } }
public String getCDEId() { Number cdeId = null; try { oracle.jbo.ViewObject cdeIdView = getViewObject().getApplicationModule().findViewObject("DeCdeIdView"); cdeIdView.setWhereClause("AC_IDSEQ='" + getDeIdseq() + "'"); Row row = cdeIdView.first(); if (row != null) { cdeId = (Number) row.getAttribute("MinCdeId"); } return cdeId.toString(); } // end try catch (Exception e) { log.error("Error in getCDEId(): ", e); return null; } }
/** * Sets <code>value</code> as attribute value for DEPARTMENT_ID using the alias name DepartmentId. * * @param value value to set the DEPARTMENT_ID */ public void setDepartmentId(Number value) { // set the department identifier setAttributeInternal(DEPARTMENTID, value); // set employee's commission based on employee's department try { // check for Sales department if (value != null && SALES_DEPARTMENT_ID == value.intValue()) { // if the commission has not been set yet if (this.getCommissionPct() == null) { // set commission to default this.setCommissionPct(new Number(DEFAULT_COMMISSION)); } } else { // clear commission for non Sales department this.setCommissionPct(null); } } catch (SQLException e) { // log the exception LOGGER.severe(e); } }
public Map<String, String> updateTask(String taskStatus) { Map<String, String> resultMap = new HashMap<String, String>(); String status = "E"; String message = null; XxntcCsCalendarActivitiesEOVOImpl vo = getXxntcCsCalendarActivitiesEOVO2Update(); Row row = vo.getCurrentRow(); Date startTime = (Date) row.getAttribute("StartTime"); Date endTime = (Date) row.getAttribute("EndTime"); Number incidentId = (Number) row.getAttribute("IncidentId"); Number resourceId = (Number) row.getAttribute("ResourceId"); _logger.warning("Before Calling API"); _logger.warning("taskStatus:" + taskStatus.toString()); _logger.warning("startTime:" + startTime.toString()); _logger.warning("endTime:" + endTime.toString()); _logger.warning("incidentId:" + incidentId.toString()); _logger.warning("resourceId:" + resourceId.toString()); CallableStatement cs = null; String statement = "BEGIN XXNTC_CALENDAR_PKG.SCHEDULE_SR_PRC(?, ?, ?, ?, ?, ?, ?); END;"; try { cs = getDBTransaction().createCallableStatement(statement, 0); cs.registerOutParameter(6, Types.VARCHAR); cs.registerOutParameter(7, Types.VARCHAR); cs.setString(1, taskStatus); cs.setDate(2, startTime.dateValue()); cs.setDate(3, endTime.dateValue()); cs.setInt(4, incidentId.intValue()); cs.setLong(5, resourceId.longValue()); cs.executeUpdate(); status = cs.getString(6); message = cs.getString(7); } catch (SQLException e) { _logger.severe("Sql Exception during statement call", e); } finally { try { if (cs != null) cs.close(); } catch (SQLException e) { _logger.severe("Sql Exception While Closing Callable Statement", e); } } resultMap.put("x_status", status); resultMap.put("x_error_message", message); _logger.warning("After API is called"); _logger.warning("x_status:" + status); _logger.warning("x_error_message:" + message); return resultMap; }
public String getAvaliableViews(Number resourceId, java.sql.Date activeDate) { String avaliableViews = null; CallableStatement cs = null; String statement = "BEGIN ? := XXNTC_CALENDAR_PKG.GET_AVAILABLE_CALENDAR_VIEWS (?, ?); END;"; try { cs = getDBTransaction().createCallableStatement(statement, 0); cs.registerOutParameter(1, Types.VARCHAR); cs.setInt(2, resourceId.intValue()); cs.setDate(3, activeDate); cs.executeUpdate(); avaliableViews = cs.getString(1); } catch (SQLException e) { _logger.severe("SQL Exception getAvaliableViews", e); } finally { try { if (cs != null) { cs.close(); } } catch (SQLException e) { _logger.severe("SQL Exception getAvaliableViews", e); } } return avaliableViews; }