From 28440a550c057a9fd04b86711c35d659ad734232 Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Mon, 3 Nov 2008 14:50:31 +0000 Subject: [PATCH] FR: [ 2214883 ] Remove SQL code and Replace for Query Compiled and run server. Alert processor works on new alert record. Not sure if any other tests for this MAlert class. Anyone please review --- base/src/org/compiere/model/MAlert.java | 66 +++++-------------------- 1 file changed, 11 insertions(+), 55 deletions(-) diff --git a/base/src/org/compiere/model/MAlert.java b/base/src/org/compiere/model/MAlert.java index f88b160bcf..e8d19abede 100644 --- a/base/src/org/compiere/model/MAlert.java +++ b/base/src/org/compiere/model/MAlert.java @@ -16,15 +16,11 @@ *****************************************************************************/ package org.compiere.model; -import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; import java.util.Collection; +import java.util.List; import java.util.Properties; import java.util.TreeSet; -import java.util.logging.Level; - -import org.compiere.util.DB; /** * Alert Model @@ -34,6 +30,8 @@ import org.compiere.util.DB; * * @author Teo Sarca, SC ARHIPAC SERVICE SRL *
  • FR [ 1894573 ] Alert Processor Improvements + * Victor Perez, Trifon, red1 + *
  • FR: [ 2214883 ] Remove SQL code and Replace for Query */ public class MAlert extends X_AD_Alert { @@ -84,34 +82,10 @@ public class MAlert extends X_AD_Alert { if (m_rules != null && !reload) return m_rules; - String sql = "SELECT * FROM AD_AlertRule " - + "WHERE AD_Alert_ID=?" - + " ORDER BY Name, AD_AlertRule_ID"; - ArrayList list = new ArrayList(); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (sql, null); - pstmt.setInt (1, getAD_Alert_ID()); - rs = pstmt.executeQuery (); - while (rs.next ()) - { - MAlertRule rule = new MAlertRule (getCtx(), rs, null); - rule.setParent(this); - list.add (rule); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - + //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 + String whereClause = "AD_Alert_ID=?"; + List list = new Query(getCtx(),MBPartner.Table_Name,whereClause.toString(),null) + .setParameters(new Object[]{getAD_Alert_ID()}).setOrderBy("Name, AD_AlertRule_ID").list(); // m_rules = new MAlertRule[list.size ()]; list.toArray (m_rules); @@ -127,28 +101,10 @@ public class MAlert extends X_AD_Alert { if (m_recipients != null && !reload) return m_recipients; - String sql = "SELECT * FROM AD_AlertRecipient " - + "WHERE AD_Alert_ID=?"; - ArrayList list = new ArrayList(); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (sql, null); - pstmt.setInt (1, getAD_Alert_ID()); - rs = pstmt.executeQuery (); - while (rs.next ()) - list.add (new MAlertRecipient (getCtx(), rs, null)); - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } + //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 + String whereClause = "AD_Alert_ID=?"; + List list = new Query(getCtx(),MBPartner.Table_Name,whereClause.toString(),null) + .setParameters(new Object[]{getAD_Alert_ID()}).list(); // m_recipients = new MAlertRecipient[list.size ()]; list.toArray (m_recipients);