| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package xin.glue.ui.K.K01;
- import com.posdata.glue.biz.activity.PosActivity;
- import com.posdata.glue.biz.constants.PosBizControlConstants;
- import com.posdata.glue.context.PosContext;
- import com.posdata.glue.dao.PosDaoException;
- import com.posdata.glue.dao.PosGenericDao;
- import com.posdata.glue.dao.vo.PosParameter;
- import com.posdata.glue.dao.vo.PosRowSet;
- public class InitParamManager extends PosActivity
- {
- public InitParamManager(){}
-
- public String runActivity(PosContext context)
- {
- try
- {
- if(context.get("success")==null)//若触发的非success事件,则不进行初始化查询
- {
- return PosBizControlConstants.SUCCESS;
- }
-
- String sCount = this.getProperty("param-count");
- //判断页面是否需要初始化
- if(sCount != null)
- {
- PosGenericDao posDao = this.getDao(this.getProperty("dao"));//获得数据访问对象
-
- String[] rkl = (String[])context.get("ResultKeyList");
- int rklLength = 0;
- if(rkl !=null)
- {
- rklLength = rkl.length;
- }
-
- int iCount = Integer.parseInt(sCount.trim());//获取所对应的sql语句的个数
- String[] arrSql = new String[iCount];//定义存放sqllist的数组
- String[] nodeList = new String[iCount];//定义存放各sql语句参数的数组
- int arrCount = iCount+rklLength;
- String[] arr = new String[arrCount];//各查询结果对象(PosRowSet)放入该数组, arr将存放到ResultKeyList中
- String[] initResult = this.getProperty("initResult").split("\\|");//分割resultkey
- //循环中存放参数及执行相应的SQL语句
- for(int i=0; i < iCount; i++)
- {
- PosParameter posParam = new PosParameter();
- arrSql[i] = this.getProperty("sqlkey"+i);//获得各条sql语句
- nodeList[i] = this.getProperty("param"+i);//获得各条sql语句的参数 如:"ID|NAME|CHARGE_NO|XIN_DATE"
- arr[i] = initResult[i]; //获得各具体的PosRowSet存放对象,如:EmpListResult
- if(nodeList[i] !=null && !"NULL".equalsIgnoreCase(String.valueOf(nodeList[i])))
- {
- String[] nodeName = nodeList[i].split("\\|");//获取各个具体的参数,即节点名称
- //sql预处理
- for(int j=0; j < nodeName.length; j++)
- {
- posParam.setWhereClauseParameter(j, ((String[])context.get(nodeName[j]))[0]);
- }
- }//if(isNull) end
- PosRowSet rowset = posDao.find(arrSql[i], posParam);
- context.put(arr[i], rowset);//将结果集放入相应的resultkey中
- }//for(iCount) end
- if(rkl!=null)
- {
- System.arraycopy(rkl, 0, arr, iCount, rklLength);//数组copy 将initResult初始化结果集也放到ResultKeyList中
- }//if(rkl) end
- context.put("ResultKeyList", arr);
- }//if(sCount)end
- }
- catch(Exception e)
- {
- throw new PosDaoException((new StringBuffer(400).append("Parameters initialize failed. detailMessage = ")).append(e.toString()).toString() , e);
- }
- return PosBizControlConstants.SUCCESS;
- }
- }
|