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
This commit is contained in:
parent
383a68415d
commit
a0ede8fc6f
|
|
@ -22,6 +22,7 @@ import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
|
@ -105,33 +106,14 @@ public class MGoal extends X_PA_Goal
|
||||||
*/
|
*/
|
||||||
public static MGoal[] getGoals(Properties ctx)
|
public static MGoal[] getGoals(Properties ctx)
|
||||||
{
|
{
|
||||||
ArrayList<MGoal> list = new ArrayList<MGoal>();
|
List<MGoal> list = new Query(ctx,I_PA_Goal.Table_Name,null,null)
|
||||||
String sql = "SELECT * FROM PA_Goal WHERE IsActive='Y' "
|
.setOrderBy("SeqNo")
|
||||||
+ "ORDER BY SeqNo";
|
.setApplyAccessFilter(true)
|
||||||
sql = MRole.getDefault(ctx, false).addAccessSQL(sql, "PA_Goal",
|
.setOnlyActiveRecords(true)
|
||||||
false, true); // RW to restrict Access
|
.list();
|
||||||
PreparedStatement pstmt = null;
|
for(MGoal goal:list)
|
||||||
ResultSet rs = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
|
||||||
rs = pstmt.executeQuery ();
|
|
||||||
while (rs.next ())
|
|
||||||
{
|
|
||||||
MGoal goal = new MGoal (ctx, rs, null);
|
|
||||||
goal.updateGoal(false);
|
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 ()];
|
MGoal[] retValue = new MGoal[list.size ()];
|
||||||
list.toArray (retValue);
|
list.toArray (retValue);
|
||||||
return retValue;
|
return retValue;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue