* @param int ruleid Rule Id for getting details.
*/
public RuleDetails getRuleDetails(int ruleid)
{
RuleDetails rd = new RuleDetails();
HashMap hashmap = new HashMap();
try
{
CVDal cvdl = new CVDal(dataSource);
cvdl.setSql("email.selectemailrule");
cvdl.setInt(1,ruleid);
//System.out.println (" ** EJB rule id " + ruleid);
Collection col = cvdl.executeQuery();
if (col != null)
{
Iterator it = col.iterator();
HashMap hm = ( HashMap )it.next();
cvdl.clearParameters();
String RuleId = hm.get("ruleid" ).toString();
String name = ( String )hm.get("rulename" );
String description = ( String )hm.get("description" );
String enabled = ( String )hm.get("enabledstatus" );
String AccountID = hm.get("accountid" ).toString();
String rulestatement = (String )hm.get("rulestatement");
//System.out.println (" **** RuleManageEJB -- GetRuleDetails Method ");
//System.out.println ( " rule id " + ruleid);
//System.out.println ( " rule name " + name);
//System.out.println ( " description " + description);
//System.out.println ( " enabled " + enabled);
//System.out.println ( " account id " + AccountID);
//System.out.println ( " rules statement " + rulestatement);
rd.setRuleID (RuleId);
rd.setAccountID(AccountID);
rd.setName(name);
rd.setDescription(description);
rd.setEnabled(enabled);
StringTokenizer st = new StringTokenizer(rulestatement,"<");
StringTokenizer st1 = new StringTokenizer(rulestatement,"<");
int x=0;
while(st1.hasMoreTokens())
{
String strcolA = ( String )st1.nextToken();
String strcolB = ( String )st1.nextToken();
String strcolC = ( String )st1.nextToken();
String strcolD = ( String )st1.nextToken();
x++;
}
String colA[] = new String[x];
String colB[] = new String[x];
String colC[] = new String[x];
String colD[] = new String[x];
for (int i=0; (st.hasMoreTokens()); i++)
{
String strcolA = ( String )st.nextToken();
String strcolB = ( String )st.nextToken();
String strcolC = ( String )st.nextToken();
String strcolD = ( String )st.nextToken();
//System.out.println("strcolA :: "+strcolA);
//System.out.println("strcolB :: "+strcolB);
//System.out.println("strcolC :: "+strcolC);
//System.out.println("strcolD :: "+strcolD);
colA[i] = strcolA;
colB[i] = strcolB;
colC[i] = strcolC;
colD[i] = strcolD;
//st.nextToken();
}
cvdl.setSql("email.selectemailaction");
cvdl.setInt(1,ruleid);
Collection col1 = cvdl.executeQuery();
//System.out.println (" col1 " + col1);
Iterator it1 = col1.iterator();
HashMap hm1 = new HashMap();
while ( it1.hasNext())
{
hm1 = ( HashMap )it1.next();
if (hm1 != null)
{
//System.out.println (" hm1 " + hm1.size());
//System.out.println (" In while loop ");
String actionname = ( String )hm1.get("ActionName" );
String ID = hm1.get("TargetID" ).toString();
//System.out.println (" Action Name " + actionname);
//System.out.println (" Target ID " + ID);
actionname = actionname.trim();
if (actionname.equals("MOVE"))
{
//System.out.println (" In Move ");
rd.setMovemessageto("1");
}
rd.setMovemessagetofolder(ID);
if (actionname.equals("DELETE"))
{
//System.out.println (" In Delete ");
rd.setDeleteMessage("1");
}
if (actionname.equals("MARK_AS_READ"))
{
//System.out.println (" In Mark Read ");
rd.setMarkasread("1");
}
}
}
//System.out.println (" Movemessageto: "+rd.getMovemessageto());
//System.out.println (" DeleteMessage: "+rd.getDeleteMessage());
//System.out.println (" Markasread: "+rd.getMarkasread());
rd.setcolA(colA);
rd.setcolB(colB);
rd.setcolC(colC);
rd.setcolD(colD);
}
cvdl.clearParameters();
cvdl.destroy();
}