public final Response executeCommand( Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request, HttpServletResponse response, HttpSession userSession, ServletContext context) { ArrayList vos = (ArrayList) inputPar; try { ItemDiscounts bean = (ItemDiscounts) JAIOBeanFactory.getInstance().getBean(ItemDiscounts.class); Response answer = bean.deleteItemDiscounts( vos, ((JAIOUserSessionParameters) userSessionPars).getServerLanguageId(), userSessionPars.getUsername()); return answer; } catch (Throwable ex) { Logger.error( userSessionPars.getUsername(), this.getClass().getName(), "executeCommand", "Error while processing request", ex); return new ErrorResponse(ex.getMessage()); } }
/** Business logic to execute. */ public final Response executeCommand( Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request, HttpServletResponse response, HttpSession userSession, ServletContext context) { String serverLanguageId = ((JAIOUserSessionParameters) userSessionPars).getServerLanguageId(); Connection conn = null; Statement stmt = null; try { conn = ConnectionManager.getConnection(context); // fires the GenericEvent.CONNECTION_CREATED event... EventsManager.getInstance() .processEvent( new GenericEvent( this, getRequestName(), GenericEvent.CONNECTION_CREATED, (JAIOUserSessionParameters) userSessionPars, request, response, userSession, context, conn, inputPar, null)); java.util.List list = (ArrayList) inputPar; HierarItemDiscountVO vo = null; ResultSet rset = null; stmt = conn.createStatement(); for (int i = 0; i < list.size(); i++) { vo = (HierarItemDiscountVO) list.get(i); vo.setDiscountTypeSAL03(ApplicationConsts.DISCOUNT_CUSTOMER); // retrieve COMPANY_CODE from progressiveHIE01... rset = stmt.executeQuery( "select COMPANY_CODE_SYS01 from ITM02_ITEM_TYPES where PROGRESSIVE_HIE02 in " + "(select PROGRESSIVE_HIE02 from HIE01_LEVELS where PROGRESSIVE=" + vo.getProgressiveHie01SAL05() + ")"); if (rset.next()) vo.setCompanyCodeSys01SAL03(rset.getString(1)); else { rset.close(); conn.rollback(); return new ErrorResponse("Item hierarchy not found."); } rset.close(); DiscountBean.insertDiscount(conn, vo); stmt.execute( "insert into SAL05_ITEM_HIERAR_DISCOUNTS(COMPANY_CODE_SYS01,PROGRESSIVE_HIE01,DISCOUNT_CODE_SAL03) " + "values('" + vo.getCompanyCodeSys01SAL03() + "'," + vo.getProgressiveHie01SAL05() + ",'" + vo.getDiscountCodeSAL03() + "')"); } Response answer = new VOListResponse(list, false, list.size()); // fires the GenericEvent.BEFORE_COMMIT event... EventsManager.getInstance() .processEvent( new GenericEvent( this, getRequestName(), GenericEvent.BEFORE_COMMIT, (JAIOUserSessionParameters) userSessionPars, request, response, userSession, context, conn, inputPar, answer)); conn.commit(); // fires the GenericEvent.AFTER_COMMIT event... EventsManager.getInstance() .processEvent( new GenericEvent( this, getRequestName(), GenericEvent.AFTER_COMMIT, (JAIOUserSessionParameters) userSessionPars, request, response, userSession, context, conn, inputPar, answer)); return answer; } catch (Throwable ex) { Logger.error( userSessionPars.getUsername(), this.getClass().getName(), "executeCommand", "Error while inserting hierarchy item discounts", ex); try { conn.rollback(); } catch (Exception ex3) { } return new ErrorResponse(ex.getMessage()); } finally { try { stmt.close(); } catch (Exception ex2) { } try { ConnectionManager.releaseConnection(conn, context); } catch (Exception ex1) { } } }