From a0ede8fc6fc6921ecf1c99b4087631d6a85e573a Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Mon, 22 Mar 2010 01:36:12 +0000 Subject: [PATCH] FR: [ 2214883 ] Remove SQL code and Replace for Query -- JUnit test in progress, require Teo's advice on how to set Role, User and tearDown() trxName Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883 --- base/src/org/compiere/model/MGoal.java | 34 ++++++-------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/base/src/org/compiere/model/MGoal.java b/base/src/org/compiere/model/MGoal.java index 6d72cbbbc1..fa57bcef18 100644 --- a/base/src/org/compiere/model/MGoal.java +++ b/base/src/org/compiere/model/MGoal.java @@ -22,6 +22,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Timestamp; import java.util.ArrayList; +import java.util.List; import java.util.Properties; import java.util.logging.Level; @@ -105,33 +106,14 @@ public class MGoal extends X_PA_Goal */ public static MGoal[] getGoals(Properties ctx) { - ArrayList list = new ArrayList(); - String sql = "SELECT * FROM PA_Goal WHERE IsActive='Y' " - + "ORDER BY SeqNo"; - sql = MRole.getDefault(ctx, false).addAccessSQL(sql, "PA_Goal", - false, true); // RW to restrict Access - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (sql, null); - rs = pstmt.executeQuery (); - while (rs.next ()) - { - MGoal goal = new MGoal (ctx, rs, null); + List list = new Query(ctx,I_PA_Goal.Table_Name,null,null) + .setOrderBy("SeqNo") + .setApplyAccessFilter(true) + .setOnlyActiveRecords(true) + .list(); + for(MGoal goal:list) goal.updateGoal(false); - list.add (goal); - } - } - catch (Exception e) - { - s_log.log (Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } + MGoal[] retValue = new MGoal[list.size ()]; list.toArray (retValue); return retValue;