/** Business logic to execute. */ public VOListResponse insertCharges( ArrayList list, String serverLanguageId, String username, ArrayList customizedFields) throws Throwable { Connection conn = null; try { if (this.conn == null) conn = getConn(); else conn = this.conn; ChargeVO vo = null; Map attribute2dbField = new HashMap(); attribute2dbField.put("companyCodeSys01SAL06", "COMPANY_CODE_SYS01"); attribute2dbField.put("chargeCodeSAL06", "CHARGE_CODE"); attribute2dbField.put("chargeCodeSAL06", "CHARGE_CODE"); attribute2dbField.put("progressiveSys10SAL06", "PROGRESSIVE_SYS10"); attribute2dbField.put("valueSAL06", "VALUE"); attribute2dbField.put("percSAL06", "PERC"); attribute2dbField.put("vatCodeReg01SAL06", "VAT_CODE_REG01"); attribute2dbField.put("currencyCodeReg03SAL06", "CURRENCY_CODE_REG03"); attribute2dbField.put("enabledSAL06", "ENABLED"); BigDecimal progressiveSYS10 = null; Response res = null; for (int i = 0; i < list.size(); i++) { vo = (ChargeVO) list.get(i); vo.setEnabledSAL06("Y"); // insert record in SYS10... progressiveSYS10 = TranslationUtils.insertTranslations( vo.getDescriptionSYS10(), vo.getCompanyCodeSys01SAL06(), conn); vo.setProgressiveSys10SAL06(progressiveSYS10); // insert into SAL06... res = CustomizeQueryUtil.insertTable( conn, new UserSessionParameters(username), vo, "SAL06_CHARGES", attribute2dbField, "Y", "N", null, true, customizedFields); if (res.isError()) { throw new Exception(res.getErrorMessage()); } } return new VOListResponse(list, false, list.size()); } catch (Throwable ex) { Logger.error( username, this.getClass().getName(), "executeCommand", "Error while inserting new charges", ex); try { if (this.conn == null && conn != null) // rollback only local connection conn.rollback(); } catch (Exception ex3) { } throw new Exception(ex.getMessage()); } finally { try { if (this.conn == null && conn != null) { // close only local connection conn.commit(); conn.close(); } } catch (Exception exx) { } } }
/** Business logic to execute. */ public VOListResponse updateCharges( ArrayList oldVOs, ArrayList newVOs, String serverLanguageId, String username, ArrayList customizedFields) throws Throwable { Connection conn = null; try { if (this.conn == null) conn = getConn(); else conn = this.conn; ChargeVO oldVO = null; ChargeVO newVO = null; Response res = null; for (int i = 0; i < oldVOs.size(); i++) { oldVO = (ChargeVO) oldVOs.get(i); newVO = (ChargeVO) newVOs.get(i); // update SYS10 table... TranslationUtils.updateTranslation( oldVO.getDescriptionSYS10(), newVO.getDescriptionSYS10(), newVO.getProgressiveSys10SAL06(), serverLanguageId, conn); HashSet pkAttrs = new HashSet(); pkAttrs.add("companyCodeSys01SAL06"); pkAttrs.add("chargeCodeSAL06"); HashMap attr2dbFields = new HashMap(); attr2dbFields.put("companyCodeSys01SAL06", "COMPANY_CODE_SYS01"); attr2dbFields.put("chargeCodeSAL06", "CHARGE_CODE"); attr2dbFields.put("progressiveSys10SAL06", "PROGRESSIVE_SYS10"); attr2dbFields.put("valueSAL06", "VALUE"); attr2dbFields.put("percSAL06", "PERC"); attr2dbFields.put("vatCodeReg01SAL06", "VAT_CODE_REG01"); attr2dbFields.put("currencyCodeReg03SAL06", "CURRENCY_CODE_REG03"); res = new CustomizeQueryUtil() .updateTable( conn, new UserSessionParameters(username), pkAttrs, oldVO, newVO, "SAL06_CHARGES", attr2dbFields, "Y", "N", null, true, customizedFields); if (res.isError()) { throw new Exception(res.getErrorMessage()); } } return new VOListResponse(newVOs, false, newVOs.size()); } catch (Throwable ex) { Logger.error( username, this.getClass().getName(), "executeCommand", "Error while updating existing charges", ex); try { if (this.conn == null && conn != null) // rollback only local connection conn.rollback(); } catch (Exception ex3) { } throw new Exception(ex.getMessage()); } finally { try { if (this.conn == null && conn != null) { // close only local connection conn.commit(); conn.close(); } } catch (Exception exx) { } } }