# HG changeset patch # User Ioritz Cia # Date 1355416844 -3600 # Node ID ae9a14d16fd0e47e5d926e5c31699d87eecd5e9f # Parent eed6453e586623fa10f52bf189d48df5ea2f38fa Fixes issue 21938: Payment date should be mandatory. diff --git a/modules/org.openbravo.advpaymentmngt/build/classes/org/openbravo/advpaymentmngt/buildvalidation/NullPaymentDate.class b/modules/org.openbravo.advpaymentmngt/build/classes/org/openbravo/advpaymentmngt/buildvalidation/NullPaymentDate.class new file mode 100644 index 0000000000000000000000000000000000000000..9a98571de25390613d04002c1db9250a6b5bd642 GIT binary patch literal 5520 zc$~#p`F9&v75>KCjAeOK!50)fqu^Nu&nb9b!50;LNx=&WUKC7U7KVI9KradClo-A$hOY_S*9G(q0i71m zH^uNR8Q+%i9SL;@P20>Ll2F|dIU=EE%+U=A%^A}+CJQSIhC8b*Sj2=fPFAyyXs#*d zC1g#0+4LkF$~f*)kCQX(1y@^jdNh4Cr>(6Rc7DZP%J(c3OiN$YEK}F=repU^7A)&< zaXqQ!jS&g5al*(J@0#GdHFd)!OP%4mj_Ym8^xc?nU2U!8%WJpBaV=Ml zWn?FYgWLCTh(a1?@>=%TgqHJp{Z#rc3q;2EWZc10kWfEkF4uH!Pce&w*3nAQrC zx$(*5)EpyUNmWKRYGPN@1zaPRB`98Al-sy2p@HC>Y3t5$f40dh zX7!sh8Q*7tYj%h_#Rl;Teke(= z9(4+8R@sj8_t*Vum{RNd-$UZqOk0?TraQ)}K)3%Mm% z(+vUo7L}zhYpcvAwG?|#J#OZgokG5h(1i=sSw~$oPZSxMax{2FsNP~xmk?#p9LsTz z2{lWGZMbCDRp0%d+EH?=I&Sw&QH5pN$GEzK#)$78&&Z42m6!y+XuYxBS~K6RP6@Y| z{@!UU1=Bp$cDU^I@TMF_79K72BN*`bRrr}4fPK72`RDkf%I_SKspiYO-IK@lfwha zvA*O$A`u&orG{cD3A-@w)TxFG$GEQMXM}~cIM+Q>$O){mHDx#%3*@90|4yqqQm%Ya= zGD(1h(=&#}7NzF87fpMRRnzCQj#XH(IVYjHXc}%u zdj)HI*EUgIYP(_2-#ybFDGJRxu3i$?D=?HP`dA5Nvk{cAEI+q|ZD$8-7ij%LBkE$V zh^3?cg6V1Ow5tZO&BW%qDS*9J@UzpEFv^mE+e6zByA&RC%+gpKJSi6|E zkkd=Ft!3I0YIIH5l%AfNP}6L*+MCEa?7%*Ciah zlCws_{;lj6)BE{;WOL4w`7NJB-1yS~BuGY1_|}{c>(60n?jZX6h$w z#DSg#ae0_pc$kF#YS{A&u6(naE4I?2$1m$95xFY&!iHtG2g^u_ z>zIW0N~33&UFW#y-y=KRb?eyB4Oh-E*lc2FY7|KP1z3nVccX*pK_Ocg*V!$f$wZ(<1~DsN%gtL}`Q!c$MR(@s(2Q&(N%RmpTk)5{j_s*IqKHFKu_)wcTo z2xG+mA`_SAiah45!bI%hCwm;?Up0?xUWz&1##s;FJjGGF?<}NO2vp$^$2uQ*Bi_j| zSR}yhNI;zTqZlIvTOf3^>O)7d8^ew9rf}2wSaWr(rLCo{`4skso7!6XZT(4z}zc-fr(tb7uRwe<}A*P8bJd~u9+(% z%pH$ec#?Ve0(0;sX5T+?kHo-B*E1b%#r;x09*{D4PZQvAIFU7d+ccF;e(fAg*SlA7F;4lg`G%~;^=NJ1U{{@4Q1*HH0 diff --git a/modules/org.openbravo.advpaymentmngt/build/classes/org/openbravo/advpaymentmngt/buildvalidation/NullPaymentDateData.class b/modules/org.openbravo.advpaymentmngt/build/classes/org/openbravo/advpaymentmngt/buildvalidation/NullPaymentDateData.class new file mode 100644 index 0000000000000000000000000000000000000000..54147095cc0fd0cca55e7bdc295596a25b51b7a6 GIT binary patch literal 16237 zc%1E83w)HtwLd5O_`dzJBoIho6=Xq6o)9b=Fc2h<4X%U)^8f)gZn7U?WwRUh!AnK0 zXi?N^i&|Q3t?ezntyV-uzzV2Esd}sSUEAB2wpRP_QCr0q_doM}`(<~tL2S9b_t#$o zneWWZnKLtI&i|Y<15bXicOMaboG;NRNk3QVzg<*Dzf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s*8DS?#V^uq{w>Yrm#Cg!rUm>8E#p5>i2q3I_)oN%Uxlob@A6;heSQ;{&A;NR`4;AS8}q))3;8g&@jKiJdI`TTal8o^ zt1p-cbO9{}K3(*_iBA`|nY|)|TxQ{OnUyIoqaU02TxMm;%jhREQ?~PB6Q8qj=@$91 z6FVC(QK?{m9*Ig-BJVtrA7jFyx$e=E execute() { + ConnectionProvider cp = getConnectionProvider(); + ArrayList errors = new ArrayList(); + try{ + if (NullPaymentDateData.isThereAny(cp)) { + String message = "You cannot apply this Advanced Payables and Receivables Management module version because your instance fails in a pre-validation. " + + "It is not allowed to upgrade to this version having payments without paymentdate. " + + "To fix this problem in your instance, have a look to generated alerts (Payment In/Out linked without paymentdate) and set a payment date to the payments without it. " + + "Once it is fixed you should be able to apply this module version"; + errors.add(message); + + NullPaymentDateData[] listOfPayments = NullPaymentDateData.selectPaymentsWithoutDate(cp); + for (NullPaymentDateData payment : listOfPayments) { + processAlert(cp, payment); + } + + } + } catch (Exception e) { + return handleError(e); + } + + // TODO Auto-generated method stub + return errors; + } + + private void processAlert(ConnectionProvider cp, NullPaymentDateData payment) throws Exception{ + final String PAYMENT_IN_TAB = "C4B6506838E14A349D6717D6856F1B56"; + final String PAYMENT_OUT_TAB = "F7A52FDAAA0346EFA07D53C125B40404"; + final String PAYMENT_IN_WINDOW = "E547CE89D4C04429B6340FFA44E70716"; + final String PAYMENT_OUT_WINDOW = "6F8F913FA60F4CBD93DC1D3AA696E76E"; + + String alertRuleName = "Payment " + ("Y".equals(payment.isreceipt) ? "In" : "Out") + + " has no payment date."; + String alertDescription = "Payment " + ("Y".equals(payment.isreceipt) ? "In: " : "Out: ") + + payment.identifier + " has no payment date. " + + "Navigate to the document and set the proper date."; + + String strTabId = "Y".equals(payment.isreceipt) ? PAYMENT_IN_TAB : PAYMENT_OUT_TAB; + String strWindowId = "Y".equals(payment.isreceipt) ? PAYMENT_IN_WINDOW : PAYMENT_OUT_WINDOW; + String alertRuleId = ""; + + String alertRule = "Select p.fin_payment_id as referencekey_id," + + " ad_column_identifier('fin_payment', p.fin_payment_id, 'en_US') as record_id," + + " 0 as ad_role_id," + + " null as ad_user_id," + + " '" + alertDescription + "' as description," + + " 'Y' as isactive," + + " p.ad_org_id," + + " p.ad_client_id," + + " now() as created," + + " 0 as createdby," + + " now() as updated," + + " 0 as updatedBy" + + " FROM FIN_Payment p" + + " WHERE p.paymentdate is null" + + " AND p.isreceipt = '" + payment.isreceipt + "' "; + + if (!NullPaymentDateData.existsAlertRule(cp, alertRuleName, payment.adClientId)) { + NullPaymentDateData.insertAlertRule(cp, payment.adClientId, payment.adOrgId, alertRuleName, strTabId, alertRule); + + alertRuleId = NullPaymentDateData.getAlertRuleId(cp, alertRuleName, payment.adClientId); + NullPaymentDateData[] roles = NullPaymentDateData.getRoleId(cp, strWindowId, payment.adClientId); + for (NullPaymentDateData role : roles) { + NullPaymentDateData.insertAlertRecipient(cp, payment.adClientId, payment.adOrgId, alertRuleId, role.adRoleId); + } + } else { + alertRuleId = NullPaymentDateData.getAlertRuleId(cp, alertRuleName, payment.adClientId); + } + + if (!NullPaymentDateData.existsAlert(cp, alertRuleId, payment.id)) { + NullPaymentDateData.insertAlert(cp, payment.adClientId, alertDescription, alertRuleId, payment.identifier, payment.id); + } + } + +} diff --git a/modules/org.openbravo.advpaymentmngt/src-util/buildvalidation/src/org/openbravo/advpaymentmngt/buildvalidation/NullPaymentDate_data.xsql b/modules/org.openbravo.advpaymentmngt/src-util/buildvalidation/src/org/openbravo/advpaymentmngt/buildvalidation/NullPaymentDate_data.xsql new file mode 100644 --- /dev/null +++ b/modules/org.openbravo.advpaymentmngt/src-util/buildvalidation/src/org/openbravo/advpaymentmngt/buildvalidation/NullPaymentDate_data.xsql @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/org.openbravo.advpaymentmngt/src-util/buildvalidation/src/src/org/openbravo/advpaymentmngt/buildvalidation/NullPaymentDateData.java b/modules/org.openbravo.advpaymentmngt/src-util/buildvalidation/src/src/org/openbravo/advpaymentmngt/buildvalidation/NullPaymentDateData.java new file mode 100644 --- /dev/null +++ b/modules/org.openbravo.advpaymentmngt/src-util/buildvalidation/src/src/org/openbravo/advpaymentmngt/buildvalidation/NullPaymentDateData.java @@ -0,0 +1,511 @@ +//Sqlc generated V1.O00-1 +package org.openbravo.advpaymentmngt.buildvalidation; + +import java.sql.*; + +import org.apache.log4j.Logger; + +import javax.servlet.ServletException; + +import org.openbravo.data.FieldProvider; +import org.openbravo.database.ConnectionProvider; +import org.openbravo.data.UtilSql; +import java.util.*; + +class NullPaymentDateData implements FieldProvider { +static Logger log4j = Logger.getLogger(NullPaymentDateData.class); + private String InitRecordNumber="0"; + public String existing; + public String id; + public String isreceipt; + public String identifier; + public String adClientId; + public String adOrgId; + public String adRoleId; + + public String getInitRecordNumber() { + return InitRecordNumber; + } + + public String getField(String fieldName) { + if (fieldName.equalsIgnoreCase("existing")) + return existing; + else if (fieldName.equalsIgnoreCase("id")) + return id; + else if (fieldName.equalsIgnoreCase("isreceipt")) + return isreceipt; + else if (fieldName.equalsIgnoreCase("identifier")) + return identifier; + else if (fieldName.equalsIgnoreCase("ad_client_id") || fieldName.equals("adClientId")) + return adClientId; + else if (fieldName.equalsIgnoreCase("ad_org_id") || fieldName.equals("adOrgId")) + return adOrgId; + else if (fieldName.equalsIgnoreCase("ad_role_id") || fieldName.equals("adRoleId")) + return adRoleId; + else { + log4j.debug("Field does not exist: " + fieldName); + return null; + } + } + + public static NullPaymentDateData[] dummy(ConnectionProvider connectionProvider) throws ServletException { + return dummy(connectionProvider, 0, 0); + } + + public static NullPaymentDateData[] dummy(ConnectionProvider connectionProvider, int firstRegister, int numberRegisters) throws ServletException { + String strSql = ""; + strSql = strSql + + " SELECT '' AS existing, '' AS ID, '' AS isreceipt, '' AS identifier," + + " '' AS ad_client_id, '' AS ad_org_id, '' AS ad_role_id" + + " FROM DUAL"; + + ResultSet result; + Vector vector = new Vector(0); + PreparedStatement st = null; + + try { + st = connectionProvider.getPreparedStatement(strSql); + + result = st.executeQuery(); + long countRecord = 0; + long countRecordSkip = 1; + boolean continueResult = true; + while(countRecordSkip < firstRegister && continueResult) { + continueResult = result.next(); + countRecordSkip++; + } + while(continueResult && result.next()) { + countRecord++; + NullPaymentDateData objectNullPaymentDateData = new NullPaymentDateData(); + objectNullPaymentDateData.existing = UtilSql.getValue(result, "existing"); + objectNullPaymentDateData.id = UtilSql.getValue(result, "id"); + objectNullPaymentDateData.isreceipt = UtilSql.getValue(result, "isreceipt"); + objectNullPaymentDateData.identifier = UtilSql.getValue(result, "identifier"); + objectNullPaymentDateData.adClientId = UtilSql.getValue(result, "ad_client_id"); + objectNullPaymentDateData.adOrgId = UtilSql.getValue(result, "ad_org_id"); + objectNullPaymentDateData.adRoleId = UtilSql.getValue(result, "ad_role_id"); + objectNullPaymentDateData.InitRecordNumber = Integer.toString(firstRegister); + vector.addElement(objectNullPaymentDateData); + if (countRecord >= numberRegisters && numberRegisters != 0) { + continueResult = false; + } + } + result.close(); + } catch(SQLException e){ + log4j.error("SQL error in query: " + strSql + "Exception:"+ e); + throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage()); + } catch(Exception ex){ + log4j.error("Exception in query: " + strSql + "Exception:"+ ex); + throw new ServletException("@CODE=@" + ex.getMessage()); + } finally { + try { + connectionProvider.releasePreparedStatement(st); + } catch(Exception ignore){ + ignore.printStackTrace(); + } + } + NullPaymentDateData objectNullPaymentDateData[] = new NullPaymentDateData[vector.size()]; + vector.copyInto(objectNullPaymentDateData); + return(objectNullPaymentDateData); + } + + public static boolean isThereAny(ConnectionProvider connectionProvider) throws ServletException { + String strSql = ""; + strSql = strSql + + " SELECT COUNT(1) AS EXISTING" + + " FROM FIN_Payment" + + " WHERE paymentDate is null"; + + ResultSet result; + boolean boolReturn = false; + PreparedStatement st = null; + + try { + st = connectionProvider.getPreparedStatement(strSql); + + result = st.executeQuery(); + if(result.next()) { + boolReturn = !UtilSql.getValue(result, "existing").equals("0"); + } + result.close(); + } catch(SQLException e){ + log4j.error("SQL error in query: " + strSql + "Exception:"+ e); + throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage()); + } catch(Exception ex){ + log4j.error("Exception in query: " + strSql + "Exception:"+ ex); + throw new ServletException("@CODE=@" + ex.getMessage()); + } finally { + try { + connectionProvider.releasePreparedStatement(st); + } catch(Exception ignore){ + ignore.printStackTrace(); + } + } + return(boolReturn); + } + + public static NullPaymentDateData[] selectPaymentsWithoutDate(ConnectionProvider connectionProvider) throws ServletException { + return selectPaymentsWithoutDate(connectionProvider, 0, 0); + } + + public static NullPaymentDateData[] selectPaymentsWithoutDate(ConnectionProvider connectionProvider, int firstRegister, int numberRegisters) throws ServletException { + String strSql = ""; + strSql = strSql + + " SELECT FIN_Payment_ID AS ID, isReceipt, ad_column_identifier('fin_payment', fin_payment_id, 'en_US') as identifier," + + " ad_client_id, ad_org_id" + + " FROM FIN_Payment" + + " WHERE paymentDate is null"; + + ResultSet result; + Vector vector = new Vector(0); + PreparedStatement st = null; + + try { + st = connectionProvider.getPreparedStatement(strSql); + + result = st.executeQuery(); + long countRecord = 0; + long countRecordSkip = 1; + boolean continueResult = true; + while(countRecordSkip < firstRegister && continueResult) { + continueResult = result.next(); + countRecordSkip++; + } + while(continueResult && result.next()) { + countRecord++; + NullPaymentDateData objectNullPaymentDateData = new NullPaymentDateData(); + objectNullPaymentDateData.id = UtilSql.getValue(result, "id"); + objectNullPaymentDateData.isreceipt = UtilSql.getValue(result, "isreceipt"); + objectNullPaymentDateData.identifier = UtilSql.getValue(result, "identifier"); + objectNullPaymentDateData.adClientId = UtilSql.getValue(result, "ad_client_id"); + objectNullPaymentDateData.adOrgId = UtilSql.getValue(result, "ad_org_id"); + objectNullPaymentDateData.InitRecordNumber = Integer.toString(firstRegister); + vector.addElement(objectNullPaymentDateData); + if (countRecord >= numberRegisters && numberRegisters != 0) { + continueResult = false; + } + } + result.close(); + } catch(SQLException e){ + log4j.error("SQL error in query: " + strSql + "Exception:"+ e); + throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage()); + } catch(Exception ex){ + log4j.error("Exception in query: " + strSql + "Exception:"+ ex); + throw new ServletException("@CODE=@" + ex.getMessage()); + } finally { + try { + connectionProvider.releasePreparedStatement(st); + } catch(Exception ignore){ + ignore.printStackTrace(); + } + } + NullPaymentDateData objectNullPaymentDateData[] = new NullPaymentDateData[vector.size()]; + vector.copyInto(objectNullPaymentDateData); + return(objectNullPaymentDateData); + } + + public static boolean existsAlert(ConnectionProvider connectionProvider, String alertRule, String payment) throws ServletException { + String strSql = ""; + strSql = strSql + + " SELECT COUNT(*) AS EXISTING" + + " FROM AD_ALERT" + + " WHERE AD_ALERTRULE_ID = ?" + + " AND REFERENCEKEY_ID = ?" + + " AND ISFIXED = 'N'"; + + ResultSet result; + boolean boolReturn = false; + PreparedStatement st = null; + + int iParameter = 0; + try { + st = connectionProvider.getPreparedStatement(strSql); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, alertRule); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, payment); + + result = st.executeQuery(); + if(result.next()) { + boolReturn = !UtilSql.getValue(result, "existing").equals("0"); + } + result.close(); + } catch(SQLException e){ + log4j.error("SQL error in query: " + strSql + "Exception:"+ e); + throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage()); + } catch(Exception ex){ + log4j.error("Exception in query: " + strSql + "Exception:"+ ex); + throw new ServletException("@CODE=@" + ex.getMessage()); + } finally { + try { + connectionProvider.releasePreparedStatement(st); + } catch(Exception ignore){ + ignore.printStackTrace(); + } + } + return(boolReturn); + } + + public static boolean existsAlertRule(ConnectionProvider connectionProvider, String alertRule, String client) throws ServletException { + String strSql = ""; + strSql = strSql + + " SELECT COUNT(*) AS EXISTING" + + " FROM AD_ALERTRULE" + + " WHERE NAME = ?" + + " AND ISACTIVE = 'Y'" + + " AND AD_CLIENT_ID = ?"; + + ResultSet result; + boolean boolReturn = false; + PreparedStatement st = null; + + int iParameter = 0; + try { + st = connectionProvider.getPreparedStatement(strSql); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, alertRule); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, client); + + result = st.executeQuery(); + if(result.next()) { + boolReturn = !UtilSql.getValue(result, "existing").equals("0"); + } + result.close(); + } catch(SQLException e){ + log4j.error("SQL error in query: " + strSql + "Exception:"+ e); + throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage()); + } catch(Exception ex){ + log4j.error("Exception in query: " + strSql + "Exception:"+ ex); + throw new ServletException("@CODE=@" + ex.getMessage()); + } finally { + try { + connectionProvider.releasePreparedStatement(st); + } catch(Exception ignore){ + ignore.printStackTrace(); + } + } + return(boolReturn); + } + + public static int insertAlertRule(ConnectionProvider connectionProvider, String clientId, String orgId, String name, String tabId, String sql) throws ServletException { + String strSql = ""; + strSql = strSql + + " INSERT INTO AD_ALERTRULE (" + + " AD_ALERTRULE_ID, AD_CLIENT_ID, AD_ORG_ID,ISACTIVE," + + " CREATED, CREATEDBY, UPDATED, UPDATEDBY," + + " NAME, AD_TAB_ID, FILTERCLAUSE, TYPE," + + " SQL" + + " ) VALUES (" + + " get_uuid(), ?, ?, 'Y'," + + " now(), '100', now(), '100'," + + " ?, ?, '', 'D'," + + " ?" + + " )"; + + int updateCount = 0; + PreparedStatement st = null; + + int iParameter = 0; + try { + st = connectionProvider.getPreparedStatement(strSql); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, clientId); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, orgId); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, name); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, tabId); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, sql); + + updateCount = st.executeUpdate(); + } catch(SQLException e){ + log4j.error("SQL error in query: " + strSql + "Exception:"+ e); + throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage()); + } catch(Exception ex){ + log4j.error("Exception in query: " + strSql + "Exception:"+ ex); + throw new ServletException("@CODE=@" + ex.getMessage()); + } finally { + try { + connectionProvider.releasePreparedStatement(st); + } catch(Exception ignore){ + ignore.printStackTrace(); + } + } + return(updateCount); + } + + public static int insertAlert(ConnectionProvider connectionProvider, String client, String description, String adAlertRuleId, String recordId, String referencekey_id) throws ServletException { + String strSql = ""; + strSql = strSql + + " INSERT INTO AD_Alert (" + + " AD_Alert_ID, AD_Client_ID, AD_Org_ID, IsActive," + + " Created, CreatedBy, Updated, UpdatedBy," + + " Description, AD_AlertRule_ID, Record_Id, Referencekey_ID" + + " ) VALUES (" + + " get_uuid(), ?, '0', 'Y'," + + " NOW(), '0', NOW(), '0'," + + " ?, ?, ?, ?)"; + + int updateCount = 0; + PreparedStatement st = null; + + int iParameter = 0; + try { + st = connectionProvider.getPreparedStatement(strSql); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, client); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, description); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, adAlertRuleId); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, recordId); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, referencekey_id); + + updateCount = st.executeUpdate(); + } catch(SQLException e){ + log4j.error("SQL error in query: " + strSql + "Exception:"+ e); + throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage()); + } catch(Exception ex){ + log4j.error("Exception in query: " + strSql + "Exception:"+ ex); + throw new ServletException("@CODE=@" + ex.getMessage()); + } finally { + try { + connectionProvider.releasePreparedStatement(st); + } catch(Exception ignore){ + ignore.printStackTrace(); + } + } + return(updateCount); + } + + public static String getAlertRuleId(ConnectionProvider connectionProvider, String name, String client) throws ServletException { + String strSql = ""; + strSql = strSql + + " SELECT MAX(ad_alertrule_id) AS name" + + " FROM AD_ALERTRULE" + + " WHERE NAME = ?" + + " AND ISACTIVE = 'Y'" + + " AND AD_CLIENT_ID = ?"; + + ResultSet result; + String strReturn = null; + PreparedStatement st = null; + + int iParameter = 0; + try { + st = connectionProvider.getPreparedStatement(strSql); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, name); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, client); + + result = st.executeQuery(); + if(result.next()) { + strReturn = UtilSql.getValue(result, "name"); + } + result.close(); + } catch(SQLException e){ + log4j.error("SQL error in query: " + strSql + "Exception:"+ e); + throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage()); + } catch(Exception ex){ + log4j.error("Exception in query: " + strSql + "Exception:"+ ex); + throw new ServletException("@CODE=@" + ex.getMessage()); + } finally { + try { + connectionProvider.releasePreparedStatement(st); + } catch(Exception ignore){ + ignore.printStackTrace(); + } + } + return(strReturn); + } + + public static NullPaymentDateData[] getRoleId(ConnectionProvider connectionProvider, String window, String clientId) throws ServletException { + return getRoleId(connectionProvider, window, clientId, 0, 0); + } + + public static NullPaymentDateData[] getRoleId(ConnectionProvider connectionProvider, String window, String clientId, int firstRegister, int numberRegisters) throws ServletException { + String strSql = ""; + strSql = strSql + + " SELECT distinct r.ad_role_id" + + " FROM ad_window_access wa join ad_role r on (wa.ad_role_id=r.ad_role_id)" + + " WHERE wa.ad_window_id = ?" + + " AND wa.ad_client_id = ?" + + " AND wa.isactive = 'Y'" + + " AND r.ismanual = 'Y'"; + + ResultSet result; + Vector vector = new Vector(0); + PreparedStatement st = null; + + int iParameter = 0; + try { + st = connectionProvider.getPreparedStatement(strSql); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, window); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, clientId); + + result = st.executeQuery(); + long countRecord = 0; + long countRecordSkip = 1; + boolean continueResult = true; + while(countRecordSkip < firstRegister && continueResult) { + continueResult = result.next(); + countRecordSkip++; + } + while(continueResult && result.next()) { + countRecord++; + NullPaymentDateData objectNullPaymentDateData = new NullPaymentDateData(); + objectNullPaymentDateData.adRoleId = UtilSql.getValue(result, "ad_role_id"); + objectNullPaymentDateData.InitRecordNumber = Integer.toString(firstRegister); + vector.addElement(objectNullPaymentDateData); + if (countRecord >= numberRegisters && numberRegisters != 0) { + continueResult = false; + } + } + result.close(); + } catch(SQLException e){ + log4j.error("SQL error in query: " + strSql + "Exception:"+ e); + throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage()); + } catch(Exception ex){ + log4j.error("Exception in query: " + strSql + "Exception:"+ ex); + throw new ServletException("@CODE=@" + ex.getMessage()); + } finally { + try { + connectionProvider.releasePreparedStatement(st); + } catch(Exception ignore){ + ignore.printStackTrace(); + } + } + NullPaymentDateData objectNullPaymentDateData[] = new NullPaymentDateData[vector.size()]; + vector.copyInto(objectNullPaymentDateData); + return(objectNullPaymentDateData); + } + + public static int insertAlertRecipient(ConnectionProvider connectionProvider, String client, String org, String adAlertRuleId, String role) throws ServletException { + String strSql = ""; + strSql = strSql + + " INSERT INTO ad_alertrecipient(" + + " ad_user_id, ad_client_id, ad_org_id, isactive, created, createdby, " + + " updated, updatedby, ad_alertrecipient_id, ad_alertrule_id, ad_role_id, " + + " sendemail)" + + " VALUES (null, ?, ?, 'Y', now(), '100', " + + " now(), '100', get_uuid(), ?, ?, " + + " 'N')"; + + int updateCount = 0; + PreparedStatement st = null; + + int iParameter = 0; + try { + st = connectionProvider.getPreparedStatement(strSql); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, client); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, org); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, adAlertRuleId); + iParameter++; UtilSql.setValue(st, iParameter, 12, null, role); + + updateCount = st.executeUpdate(); + } catch(SQLException e){ + log4j.error("SQL error in query: " + strSql + "Exception:"+ e); + throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage()); + } catch(Exception ex){ + log4j.error("Exception in query: " + strSql + "Exception:"+ ex); + throw new ServletException("@CODE=@" + ex.getMessage()); + } finally { + try { + connectionProvider.releasePreparedStatement(st); + } catch(Exception ignore){ + ignore.printStackTrace(); + } + } + return(updateCount); + } +} diff --git a/src-db/database/model/tables/FIN_PAYMENT.xml b/src-db/database/model/tables/FIN_PAYMENT.xml --- a/src-db/database/model/tables/FIN_PAYMENT.xml +++ b/src-db/database/model/tables/FIN_PAYMENT.xml @@ -41,7 +41,7 @@ - + diff --git a/src-db/database/sourcedata/AD_COLUMN.xml b/src-db/database/sourcedata/AD_COLUMN.xml --- a/src-db/database/sourcedata/AD_COLUMN.xml +++ b/src-db/database/sourcedata/AD_COLUMN.xml @@ -258720,7 +258720,7 @@ - +