31e47122658437dfa7865395552f2f0f156adcc6.svn-base 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package xin.glue.ui.K.K01;
  2. import com.posdata.glue.biz.activity.PosActivity;
  3. import com.posdata.glue.biz.constants.PosBizControlConstants;
  4. import com.posdata.glue.context.PosContext;
  5. import com.posdata.glue.dao.PosDaoException;
  6. import com.posdata.glue.dao.PosGenericDao;
  7. import com.posdata.glue.dao.vo.PosParameter;
  8. import com.posdata.glue.dao.vo.PosRowSet;
  9. public class InitParamManager extends PosActivity
  10. {
  11. public InitParamManager(){}
  12. public String runActivity(PosContext context)
  13. {
  14. try
  15. {
  16. if(context.get("success")==null)//若触发的非success事件,则不进行初始化查询
  17. {
  18. return PosBizControlConstants.SUCCESS;
  19. }
  20. String sCount = this.getProperty("param-count");
  21. //判断页面是否需要初始化
  22. if(sCount != null)
  23. {
  24. PosGenericDao posDao = this.getDao(this.getProperty("dao"));//获得数据访问对象
  25. String[] rkl = (String[])context.get("ResultKeyList");
  26. int rklLength = 0;
  27. if(rkl !=null)
  28. {
  29. rklLength = rkl.length;
  30. }
  31. int iCount = Integer.parseInt(sCount.trim());//获取所对应的sql语句的个数
  32. String[] arrSql = new String[iCount];//定义存放sqllist的数组
  33. String[] nodeList = new String[iCount];//定义存放各sql语句参数的数组
  34. int arrCount = iCount+rklLength;
  35. String[] arr = new String[arrCount];//各查询结果对象(PosRowSet)放入该数组, arr将存放到ResultKeyList中
  36. String[] initResult = this.getProperty("initResult").split("\\|");//分割resultkey
  37. //循环中存放参数及执行相应的SQL语句
  38. for(int i=0; i < iCount; i++)
  39. {
  40. PosParameter posParam = new PosParameter();
  41. arrSql[i] = this.getProperty("sqlkey"+i);//获得各条sql语句
  42. nodeList[i] = this.getProperty("param"+i);//获得各条sql语句的参数 如:"ID|NAME|CHARGE_NO|XIN_DATE"
  43. arr[i] = initResult[i]; //获得各具体的PosRowSet存放对象,如:EmpListResult
  44. if(nodeList[i] !=null && !"NULL".equalsIgnoreCase(String.valueOf(nodeList[i])))
  45. {
  46. String[] nodeName = nodeList[i].split("\\|");//获取各个具体的参数,即节点名称
  47. //sql预处理
  48. for(int j=0; j < nodeName.length; j++)
  49. {
  50. posParam.setWhereClauseParameter(j, ((String[])context.get(nodeName[j]))[0]);
  51. }
  52. }//if(isNull) end
  53. PosRowSet rowset = posDao.find(arrSql[i], posParam);
  54. context.put(arr[i], rowset);//将结果集放入相应的resultkey中
  55. }//for(iCount) end
  56. if(rkl!=null)
  57. {
  58. System.arraycopy(rkl, 0, arr, iCount, rklLength);//数组copy 将initResult初始化结果集也放到ResultKeyList中
  59. }//if(rkl) end
  60. context.put("ResultKeyList", arr);
  61. }//if(sCount)end
  62. }
  63. catch(Exception e)
  64. {
  65. throw new PosDaoException((new StringBuffer(400).append("Parameters initialize failed. detailMessage = ")).append(e.toString()).toString() , e);
  66. }
  67. return PosBizControlConstants.SUCCESS;
  68. }
  69. }