FR: [ 2214883 ] Remove SQL code and Replace for Query
-- JUnit test in next commit (no failures) Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883
This commit is contained in:
parent
dfe03fabfa
commit
ab5b31fe9a
|
@ -22,6 +22,7 @@ import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@ -92,26 +93,11 @@ public class MRule extends X_AD_Rule
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
MRule retValue = null;
|
final String whereClause = "Value=?";
|
||||||
String sql = "SELECT * FROM AD_Rule WHERE Value=? AND IsActive='Y'";
|
MRule retValue = new Query(ctx,I_AD_Rule.Table_Name,whereClause,null)
|
||||||
PreparedStatement pstmt = null;
|
.setParameters(ruleValue)
|
||||||
ResultSet rs = null;
|
.setOnlyActiveRecords(true)
|
||||||
try
|
.first();
|
||||||
{
|
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
|
||||||
pstmt.setString(1, ruleValue);
|
|
||||||
rs = pstmt.executeQuery ();
|
|
||||||
if (rs.next ())
|
|
||||||
retValue = new MRule (ctx, rs, null);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
s_log.log(Level.SEVERE, sql, e);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
DB.close(rs, pstmt);
|
|
||||||
rs = null; pstmt = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (retValue != null)
|
if (retValue != null)
|
||||||
{
|
{
|
||||||
|
@ -128,30 +114,13 @@ public class MRule extends X_AD_Rule
|
||||||
*/
|
*/
|
||||||
public static ArrayList<MRule> getModelValidatorLoginRules (Properties ctx)
|
public static ArrayList<MRule> getModelValidatorLoginRules (Properties ctx)
|
||||||
{
|
{
|
||||||
|
final String whereClause = "EventType=?";
|
||||||
|
List<MRule>list = new Query(ctx,I_AD_Rule.Table_Name,whereClause,null)
|
||||||
|
.setParameters(EVENTTYPE_ModelValidatorLoginEvent)
|
||||||
|
.setOnlyActiveRecords(true)
|
||||||
|
.list();
|
||||||
ArrayList<MRule> rules = new ArrayList<MRule>();
|
ArrayList<MRule> rules = new ArrayList<MRule>();
|
||||||
MRule rule = null;
|
rules.addAll(list);
|
||||||
String sql = "SELECT * FROM AD_Rule WHERE EventType=? AND IsActive='Y'";
|
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
|
||||||
pstmt.setString(1, EVENTTYPE_ModelValidatorLoginEvent);
|
|
||||||
rs = pstmt.executeQuery ();
|
|
||||||
while (rs.next ()) {
|
|
||||||
rule = new MRule (ctx, rs, null);
|
|
||||||
rules.add(rule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
s_log.log(Level.SEVERE, sql, e);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
DB.close(rs, pstmt);
|
|
||||||
rs = null; pstmt = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rules != null && rules.size() > 0)
|
if (rules != null && rules.size() > 0)
|
||||||
return rules;
|
return rules;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue