Borrow.java
上传用户:hbzhoufeng
上传日期:2009-12-23
资源大小:75k
文件大小:21k
源码类别:

OA系统

开发平台:

Java

  1. package com.jat.test;
  2. import java.net.*;
  3. import java.sql.*;
  4. import java.text.*;
  5. import java.util.*;
  6. import javax.servlet.*;
  7. import javax.servlet.http.*;
  8. import javax.mail.*;
  9. import javax.mail.internet.*;
  10. import org.ofbiz.core.entity.*;
  11. import org.ofbiz.core.service.*;
  12. import org.ofbiz.core.service.job.*;
  13. import org.ofbiz.core.stats.*;
  14. import org.ofbiz.core.util.*;
  15. import org.ofbiz.core.workflow.*;
  16. import org.ofbiz.core.security.*;
  17. import org.ofbiz.commonapp.order.order.*;
  18. import org.ofbiz.commonapp.party.contact.*;
  19. import org.ofbiz.commonapp.product.catalog.*;
  20. import org.ofbiz.commonapp.marketing.tracking.*;
  21. import org.ofbiz.core.workflow.definition.*;
  22. import org.ofbiz.core.workflow.client.*;
  23. public class Borrow
  24. {
  25. public static final String module = Borrow.class.getName();
  26. public static String dman(HttpServletRequest request, HttpServletResponse response)
  27. {
  28. try
  29. {
  30. GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator");
  31. LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
  32. String workEffortId=request.getParameter("workEffortId");
  33. String borrowId=request.getParameter("borrowId");
  34. String dman=request.getParameter("dman");
  35. if(dman==null)
  36. {
  37. dman="";
  38. }
  39. String roleTypeId=request.getParameter("roleTypeId");
  40. String fromDateS=request.getParameter("fromDate");
  41. int year=Integer.parseInt(fromDateS.substring(0,4))-1900;
  42. int month=Integer.parseInt(fromDateS.substring(5,7))-1;
  43. int day=Integer.parseInt(fromDateS.substring(8,10));
  44. int hour=Integer.parseInt(fromDateS.substring(11,13));
  45. int minute=Integer.parseInt(fromDateS.substring(14,16));
  46. int second=Integer.parseInt(fromDateS.substring(17,19));
  47. Timestamp fromDate=new Timestamp(year,month,day,hour,minute,second,0);
  48. //保存意见
  49. GenericValue borrow=delegator.findByPrimaryKey("Borrow",UtilMisc.toMap("borrowId",borrowId));
  50. borrow.set("dman",dman);
  51. borrow.store();
  52. //完成activity
  53. Security security = dispatcher.getSecurity();
  54. GenericValue userLogin=(GenericValue)request.getSession().getAttribute(SiteDefs.USER_LOGIN);
  55. String partyId = (String)userLogin.getString("partyId");
  56. if (!hasPermission(security, workEffortId, userLogin))
  57. {
  58. Debug.log("没有权限完成当前任务!");
  59. return "error";
  60. }
  61. try
  62. {
  63. Map actResults = new HashMap();
  64. WorkflowClient client=new WorkflowClient(delegator,dispatcher);
  65. client.complete(workEffortId,partyId,roleTypeId,fromDate,actResults);
  66. }
  67. catch(WfException we)
  68. {
  69. Debug.log(we);
  70. return "error";
  71. }
  72. return "success";
  73. }
  74. catch(Exception e)
  75. {
  76. Debug.log(e);
  77. return "error";
  78. }
  79. }
  80. public static String gman(HttpServletRequest request, HttpServletResponse response)
  81. {
  82. try
  83. {
  84. GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator");
  85. LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
  86. String workEffortId=request.getParameter("workEffortId");
  87. String borrowId=request.getParameter("borrowId");
  88. String gman=request.getParameter("gman");
  89. if(gman==null)
  90. {
  91. gman="";
  92. }
  93. String roleTypeId=request.getParameter("roleTypeId");
  94. String fromDateS=request.getParameter("fromDate");
  95. int year=Integer.parseInt(fromDateS.substring(0,4))-1900;
  96. int month=Integer.parseInt(fromDateS.substring(5,7))-1;
  97. int day=Integer.parseInt(fromDateS.substring(8,10));
  98. int hour=Integer.parseInt(fromDateS.substring(11,13));
  99. int minute=Integer.parseInt(fromDateS.substring(14,16));
  100. int second=Integer.parseInt(fromDateS.substring(17,19));
  101. Timestamp fromDate=new Timestamp(year,month,day,hour,minute,second,0);
  102. //保存意见
  103. GenericValue borrow=delegator.findByPrimaryKey("Borrow",UtilMisc.toMap("borrowId",borrowId));
  104. borrow.set("gman",gman);
  105. borrow.store();
  106. //完成activity
  107. Security security = dispatcher.getSecurity();
  108. GenericValue userLogin=(GenericValue)request.getSession().getAttribute(SiteDefs.USER_LOGIN);
  109. String partyId = (String)userLogin.getString("partyId");
  110. if (!hasPermission(security, workEffortId, userLogin))
  111. {
  112. Debug.log("没有权限完成当前任务!");
  113. return "error";
  114. }
  115. try
  116. {
  117. Map actResults = new HashMap();
  118. WorkflowClient client=new WorkflowClient(delegator,dispatcher);
  119. client.complete(workEffortId,partyId,roleTypeId,fromDate,actResults);
  120. }
  121. catch(WfException we)
  122. {
  123. Debug.log(we);
  124. return "error";
  125. }
  126. return "success";
  127. }
  128. catch(Exception e)
  129. {
  130. Debug.log(e);
  131. return "error";
  132. }
  133. }
  134. public static String financial(HttpServletRequest request, HttpServletResponse response)
  135. {
  136. try
  137. {
  138. GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator");
  139. LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
  140. String workEffortId=request.getParameter("workEffortId");
  141. String borrowId=request.getParameter("borrowId");
  142. String financial=request.getParameter("financial");
  143. if(financial==null)
  144. {
  145. financial="";
  146. }
  147. String roleTypeId=request.getParameter("roleTypeId");
  148. String fromDateS=request.getParameter("fromDate");
  149. int year=Integer.parseInt(fromDateS.substring(0,4))-1900;
  150. int month=Integer.parseInt(fromDateS.substring(5,7))-1;
  151. int day=Integer.parseInt(fromDateS.substring(8,10));
  152. int hour=Integer.parseInt(fromDateS.substring(11,13));
  153. int minute=Integer.parseInt(fromDateS.substring(14,16));
  154. int second=Integer.parseInt(fromDateS.substring(17,19));
  155. Timestamp fromDate=new Timestamp(year,month,day,hour,minute,second,0);
  156. //保存意见
  157. GenericValue borrow=delegator.findByPrimaryKey("Borrow",UtilMisc.toMap("borrowId",borrowId));
  158. borrow.set("financial",financial);
  159. borrow.store();
  160. //完成activity
  161. Security security = dispatcher.getSecurity();
  162. GenericValue userLogin=(GenericValue)request.getSession().getAttribute(SiteDefs.USER_LOGIN);
  163. String partyId = (String)userLogin.getString("partyId");
  164. if (!hasPermission(security, workEffortId, userLogin))
  165. {
  166. Debug.log("没有权限完成当前任务!");
  167. return "error";
  168. }
  169. try
  170. {
  171. Map actResults = new HashMap();
  172. WorkflowClient client=new WorkflowClient(delegator,dispatcher);
  173. client.complete(workEffortId,partyId,roleTypeId,fromDate,actResults);
  174. }
  175. catch(WfException we)
  176. {
  177. Debug.log(we);
  178. return "error";
  179. }
  180. return "success";
  181. }
  182. catch(Exception e)
  183. {
  184. Debug.log(e);
  185. return "error";
  186. }
  187. }
  188. public static String newborrow(HttpServletRequest request, HttpServletResponse response)
  189. {
  190. try
  191. {
  192. GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator");
  193. LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
  194. GenericValue userLogin=(GenericValue)request.getSession().getAttribute(SiteDefs.USER_LOGIN);
  195. //新建记录
  196. String borrowId=delegator.getNextSeqId("Borrow").toString();
  197. Double reqsum=new Double(request.getParameter("reqsum"));
  198. String bmemo=request.getParameter("bmemo");
  199.         Timestamp bdate = UtilDateTime.nowTimestamp();
  200.         Double actsum=new Double(0);
  201.         String userLoginId=userLogin.getString("userLoginId");
  202.         
  203.         Map map=new HashMap();
  204.         map.put("borrowId",borrowId);
  205.         map.put("reqsum",reqsum);
  206.         map.put("bmemo",bmemo);
  207.         map.put("bdate",bdate);
  208.         map.put("dman","");
  209.         map.put("gman","");
  210.         map.put("financial","");
  211.         map.put("actsum",actsum);
  212.         map.put("workEffortId","");
  213.         map.put("userLoginId",userLoginId);
  214. GenericValue borrow = delegator.create("Borrow",map);
  215. borrow.store();
  216. //启动process
  217. dispatcher.runAsync("processBorrow", UtilMisc.toMap("borrowId",borrowId,"sum",reqsum));
  218. }
  219. catch(Exception e)
  220. {
  221. Debug.log(e);
  222. return "error";
  223. }
  224. return "success";
  225. }
  226. public static String worklist(HttpServletRequest request, HttpServletResponse response)
  227. {
  228. GenericDelegator delegator=(GenericDelegator)request.getAttribute("delegator");
  229. GenericValue userLogin=(GenericValue)request.getSession().getAttribute(SiteDefs.USER_LOGIN);
  230. //取得partyAssignment
  231. List partyWorkEfforts = null;
  232. if (userLogin != null && userLogin.get("partyId") != null)
  233. {
  234. try
  235. {
  236. List constraints = new LinkedList();
  237. constraints.add(new EntityExpr("partyId", EntityOperator.EQUALS, userLogin.get("partyId")));
  238. constraints.add(new EntityExpr("workEffortTypeId", EntityOperator.EQUALS, "ACTIVITY"));
  239. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DECLINED"));
  240. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DELEGATED"));
  241. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_COMPLETED"));
  242. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED"));
  243. constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_COMPLETED"));
  244. constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_TERMINATED"));
  245. constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_ABORTED"));
  246. partyWorkEfforts = delegator.findByAnd("WorkEffortAndPartyAssign", constraints, UtilMisc.toList("priority","workEffortId"));
  247. }
  248. catch (GenericEntityException e)
  249. {
  250. Debug.logWarning(e);
  251. return "error";
  252. }
  253. }
  254. if (partyWorkEfforts == null) partyWorkEfforts = new LinkedList();
  255. request.setAttribute("partyAssignment",partyWorkEfforts);
  256. //取得roleAssignment
  257. List roleWorkEfforts = null;
  258. if (userLogin != null && userLogin.get("partyId") != null)
  259. {
  260. try {
  261. List constraints = new LinkedList();
  262. constraints.add(new EntityExpr("partyId", EntityOperator.EQUALS, userLogin.get("partyId")));
  263. constraints.add(new EntityExpr("roleTypeId", EntityOperator.NOT_EQUAL, "_NA_"));
  264. constraints.add(new EntityExpr("workEffortTypeId", EntityOperator.EQUALS, "ACTIVITY"));
  265. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DECLINED"));
  266. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DELEGATED"));
  267. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_ACCEPTED"));
  268. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_COMPLETED"));
  269. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED"));
  270. constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_COMPLETED"));
  271. constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_TERMINATED"));
  272. constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_ABORTED"));
  273. roleWorkEfforts = delegator.findByAnd("WorkEffortPartyAssignByRole", constraints, UtilMisc.toList("priority"));
  274. }
  275. catch (GenericEntityException e)
  276. {
  277. Debug.logWarning(e);
  278. return "error";
  279. }
  280. }
  281. if (roleWorkEfforts == null) roleWorkEfforts = new LinkedList();
  282. request.setAttribute("roleAssignment",roleWorkEfforts);
  283. return "success";
  284. }
  285. public static String accept(HttpServletRequest request, HttpServletResponse response)
  286. {
  287. GenericDelegator delegator=(GenericDelegator)request.getAttribute("delegator");
  288. LocalDispatcher dispatcher=(LocalDispatcher)request.getAttribute("dispatcher");
  289. String workEffortId = request.getParameter("workEffortId");
  290. String partyId = request.getParameter("partyId");
  291. String roleTypeId=request.getParameter("roleTypeId");
  292. String fromDateS=request.getParameter("fromDate");
  293. int year=Integer.parseInt(fromDateS.substring(0,4))-1900;
  294. int month=Integer.parseInt(fromDateS.substring(5,7))-1;
  295. int day=Integer.parseInt(fromDateS.substring(8,10));
  296. int hour=Integer.parseInt(fromDateS.substring(11,13));
  297. int minute=Integer.parseInt(fromDateS.substring(14,16));
  298. int second=Integer.parseInt(fromDateS.substring(17,19));
  299. Timestamp fromDate=new Timestamp(year,month,day,hour,minute,second,0);
  300. try
  301. {
  302. WorkflowClient client=new WorkflowClient(delegator,dispatcher);
  303. client.delegateAndAccept(workEffortId,"_NA_",roleTypeId,fromDate,partyId,roleTypeId,fromDate,true);
  304. }
  305. catch (WfException we)
  306. {
  307. Debug.log(we);
  308. request.setAttribute("borrow.error","该任务已经被其他人接受,不能再接受!");
  309. return "error";
  310. }
  311. return "success";
  312. }
  313. public static String dispatch(HttpServletRequest request, HttpServletResponse response)
  314. {
  315. GenericDelegator delegator=(GenericDelegator)request.getAttribute("delegator");
  316. LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
  317. String workEffortId=request.getParameter("workEffortId");
  318. try
  319. {
  320. GenericValue workEffortDetail=delegator.findByPrimaryKey("WorkEffort",UtilMisc.toMap("workEffortId",workEffortId));
  321. String packageId=workEffortDetail.getString("workflowPackageId");
  322. String processId=workEffortDetail.getString("workflowProcessId");
  323. String activityId=workEffortDetail.getString("workflowActivityId");
  324. //取得活动对应的borrowId
  325. WorkflowClient wfc=new WorkflowClient(delegator,dispatcher);
  326. Map ctx=wfc.getContext(workEffortId);
  327. String borrowId=(String)ctx.get("borrowId");
  328. //取得borrowId对应的借款单数据
  329. GenericValue borrow=delegator.findByPrimaryKey("Borrow",UtilMisc.toMap("borrowId",borrowId));
  330. //判断是哪个活动,并根据活动转发。
  331. //此处为硬编码,将来在项目中应根据配置文件进行动态转发。
  332. if(packageId.equals("com.jat.test"))
  333. {
  334. if(processId.equals("Borrow"))
  335. {
  336. if(activityId.equals("deptManAudit"))//部门负责人审核
  337. {
  338. request.setAttribute("borrow",borrow);
  339. return "dman";
  340. }
  341. else if(activityId.equals("generalManAudit"))//总经理审核
  342. {
  343. request.setAttribute("borrow",borrow);
  344. return "gman";
  345. }
  346. else if(activityId.equals("finDeptAudit"))//财务审核
  347. {
  348. request.setAttribute("borrow",borrow);
  349. return "financial";
  350. }
  351. else
  352. {
  353. Debug.log("未知的任务!");
  354. return "error";
  355. }
  356. }
  357. else
  358. {
  359. Debug.log("未知的过程!");
  360. return "error";
  361. }
  362. }
  363. else
  364. {
  365. Debug.log("未知的包名!");
  366. return "error";
  367. }
  368. }
  369. catch(Exception e)
  370. {
  371. Debug.log(e);
  372. return "error";
  373. }
  374. }
  375. public static Map dealWithPay(DispatchContext ctx, Map context)
  376. {
  377. GenericDelegator delegator = ctx.getDelegator();
  378. Map result = new HashMap();
  379. String borrowId=(String)context.get("borrowId");
  380. try
  381. {
  382. GenericValue borrow=delegator.findByPrimaryKey("Borrow",UtilMisc.toMap("borrowId",borrowId));
  383. borrow.set("actsum",borrow.getDouble("reqsum"));
  384. borrow.store();
  385. result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
  386. }
  387. catch(Exception we)
  388. {
  389. Debug.log(we);
  390. result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
  391.         }
  392. return result;
  393. }
  394. public static boolean hasPermission(Security sec, String workEffortId, GenericValue userLogin)
  395. {
  396. if(userLogin == null || workEffortId == null)
  397. {
  398. Debug.logWarning("No UserLogin object or no Workeffort ID was passed.");
  399. return false;
  400. }
  401. if(sec.hasPermission("WORKFLOW_MAINT", userLogin))
  402. {
  403. return true;
  404. }
  405. else
  406. {
  407. String partyId = userLogin.getString("partyId");
  408. List expr = new ArrayList();
  409. expr.add(new EntityExpr("partyId", EntityOperator.EQUALS, partyId));
  410. expr.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DECLINED"));
  411. expr.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DELEGATED"));
  412. expr.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_COMPLETED"));
  413. expr.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED"));
  414. expr.add(new EntityExpr("workEffortId", EntityOperator.EQUALS, workEffortId));
  415. expr.add(new EntityExpr("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, UtilDateTime.nowTimestamp()));
  416. Collection c = null;
  417. try
  418. {
  419. c = userLogin.getDelegator().findByAnd("WorkEffortAndPartyAssign", expr);
  420. }
  421. catch(GenericEntityException e)
  422. {
  423. Debug.logWarning(e);
  424. return false;
  425. }
  426. if (c.size() == 0)
  427. {
  428. expr = new ArrayList();
  429. expr.add(new EntityExpr("partyId", EntityOperator.EQUALS, partyId));
  430. expr.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DECLINED"));
  431. expr.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DELEGATED"));
  432. expr.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_COMPLETED"));
  433. expr.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED"));
  434. expr.add(new EntityExpr("workEffortParentId", EntityOperator.EQUALS, workEffortId));
  435. expr.add(new EntityExpr("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, UtilDateTime.nowTimestamp()));
  436. try
  437. {
  438. c = userLogin.getDelegator().findByAnd("WorkEffortAndPartyAssign", expr);
  439. if (Debug.infoOn()) Debug.logInfo("Found " + c.size() + " records.");
  440. }
  441. catch(GenericEntityException e)
  442. {
  443. Debug.logWarning(e);
  444. return false;
  445. }
  446. }
  447. if(c.size() > 0)
  448. {
  449. return true;
  450. }
  451. }
  452. return false;
  453. }
  454. public static String borrowlist(HttpServletRequest request, HttpServletResponse response)
  455. {
  456. GenericDelegator delegator=(GenericDelegator)request.getAttribute("delegator");
  457. List borrows=null;
  458. try
  459. {
  460. borrows=delegator.findAll("Borrow",UtilMisc.toList("borrowId"));
  461. }
  462. catch (GenericEntityException e)
  463. {
  464. Debug.logWarning(e);
  465. return "error";
  466. }
  467. if (borrows == null) borrows = new LinkedList();
  468. request.setAttribute("borrowList",borrows);
  469. return "success";
  470. }
  471. /*演示访问修改相关数据
  472. public static String resume(HttpServletRequest request, HttpServletResponse response)
  473. {
  474. try
  475. {
  476. GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
  477. LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
  478. String workEffortId=request.getParameter("workEffortId");
  479. Debug.log("!!!!!"+workEffortId);
  480. Map map=UtilMisc.toMap("orderStatusId","ORDER_APPROVED");
  481. WorkflowClient wfc=new WorkflowClient(delegator,dispatcher);
  482. wfc.appendContext(workEffortId,map);
  483. wfc.resume(workEffortId);
  484. }
  485. catch(Exception e)
  486. {
  487. Debug.logError(e, "jiaotw error", module);
  488. return "error";
  489. }
  490. return "success";
  491. }
  492. public static Map getWorkEffortAssignedActivities(DispatchContext ctx, Map context)
  493. {
  494. GenericDelegator delegator = ctx.getDelegator();
  495. GenericValue userLogin = (GenericValue) context.get("userLogin");
  496. List validWorkEfforts = null;
  497. if (userLogin != null && userLogin.get("partyId") != null)
  498. {
  499. try
  500. {
  501. List constraints = new LinkedList();
  502. constraints.add(new EntityExpr("partyId", EntityOperator.EQUALS, userLogin.get("partyId")));
  503. constraints.add(new EntityExpr("workEffortTypeId", EntityOperator.EQUALS, "ACTIVITY"));
  504. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DECLINED"));
  505. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DELEGATED"));
  506. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_COMPLETED"));
  507. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED"));
  508. constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_COMPLETED"));
  509. constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_TERMINATED"));
  510. constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_ABORTED"));
  511. validWorkEfforts = delegator.findByAnd("WorkEffortAndPartyAssign", constraints, UtilMisc.toList("priority"));
  512. }
  513. catch (GenericEntityException e)
  514. {
  515. Debug.logWarning(e);
  516. return ServiceUtil.returnError("Error finding desired WorkEffort records: " + e.toString());
  517. }
  518. }
  519. Map result = new HashMap();
  520. if (validWorkEfforts == null) validWorkEfforts = new LinkedList();
  521. result.put("activities", validWorkEfforts);
  522. return result;
  523. }
  524. public static Map getWorkEffortAssignedActivitiesByRole(DispatchContext ctx, Map context) {
  525. GenericDelegator delegator = ctx.getDelegator();
  526. GenericValue userLogin = (GenericValue) context.get("userLogin");
  527. List roleWorkEfforts = null;
  528. if (userLogin != null && userLogin.get("partyId") != null) {
  529. try {
  530. List constraints = new LinkedList();
  531. constraints.add(new EntityExpr("partyId", EntityOperator.EQUALS, userLogin.get("partyId")));
  532. constraints.add(new EntityExpr("workEffortTypeId", EntityOperator.EQUALS, "ACTIVITY"));
  533. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DECLINED"));
  534. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_DELEGATED"));
  535. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_COMPLETED"));
  536. constraints.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED"));
  537. constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_COMPLETED"));
  538. constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_TERMINATED"));
  539. constraints.add(new EntityExpr("currentStatusId", EntityOperator.NOT_EQUAL, "WF_ABORTED"));
  540. roleWorkEfforts = delegator.findByAnd("WorkEffortPartyAssignByRole", constraints, UtilMisc.toList("priority"));
  541. }
  542. catch (GenericEntityException e)
  543. {
  544. Debug.logWarning(e);
  545. return ServiceUtil.returnError("Error finding desired WorkEffort records: " + e.toString());
  546. }
  547. }
  548. Map result = new HashMap();
  549. if (roleWorkEfforts == null) roleWorkEfforts = new LinkedList();
  550. result.put("roleActivities", roleWorkEfforts);
  551. return result;
  552. }
  553. */
  554. }