61714987c4d2d0cbcea88a487fc5067b005b8b5b.svn-base 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package xin.glue.ui.B.B02;
  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.PosGenericDao;
  6. import com.posdata.glue.dao.vo.PosParameter;
  7. import com.posdata.glue.dao.vo.PosRowSet;
  8. public class PosInitParam extends PosActivity {
  9. //@Override
  10. public String runActivity(PosContext ctx) {
  11. /*
  12. * InitParam 传入参数说明:
  13. * 1. class: 类名(com.xin.ui.PosInitParam)
  14. * 2. dao : dao 名(mesdao)
  15. 3. sqlkey-count: sqlkey 数量
  16. 4. sqlkey 命名规则:'sqlkey' + 序号(0, 1, ...),如 sqlkey0, sqlkey1, ...
  17. 5. sqlkey 参数规则:
  18. 1) 参数数量命名规则:'sqlkey' + 序号 + '-param-count'
  19. 2) 参数命名规则 :'sqlkey' + 序号 + '-param + 参数序号
  20. 6. resultkey:返回结果集前缀
  21. 1) 结果集命名规则:resultkey + '_' + 序号,如:
  22. resultkey 设置为 ListResult,返回结果集为 ListResult_0, ListResult_1, ...
  23. 7. ServiceTag: 当且仅当执行 'success' 事件时,进行初始化
  24. */
  25. if (ctx.get("success") == null) // ServiceTag: success
  26. return PosBizControlConstants.SUCCESS;
  27. PosGenericDao dao = getDao(getProperty("dao"));
  28. String sqlkeyCt = getProperty("sqlkey-count");
  29. if (sqlkeyCt == null) return PosBizControlConstants.SUCCESS;
  30. int count = Integer.parseInt(sqlkeyCt.trim());
  31. if (count == 0) return PosBizControlConstants.SUCCESS;
  32. String resultkey = getProperty("resultkey");
  33. System.out.println(resultkey);
  34. String[] sqlkey = new String[count];
  35. for(int i = 0; i < count; i++) {
  36. sqlkey[i] = getProperty("sqlkey" + i);
  37. String paramCt = getProperty("sqlkey" + i + "-param-count");
  38. String param[] = null;
  39. PosParameter posparameter = new PosParameter();
  40. if (paramCt != null) {
  41. int cnt = Integer.parseInt(paramCt.trim());
  42. param = new String[cnt];
  43. for (int j = 0; j < cnt; j++) {
  44. param[j] = getProperty("sqlkey" + i + "-param" + j);
  45. Object obj = ctx.get(param[j]);
  46. if(obj instanceof String[])
  47. posparameter.setWhereClauseParameter(j, ((String[])obj)[0]);
  48. else
  49. posparameter.setWhereClauseParameter(j, obj);
  50. }
  51. }
  52. PosRowSet posrowset = dao.find(sqlkey[i], posparameter);
  53. //ctx.setRowSet(resultkey + "_" + i, posrowset);
  54. ctx.put(resultkey + "_" + i, posrowset);
  55. }
  56. return PosBizControlConstants.SUCCESS;
  57. }
  58. }