1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.engine.simulation;
17
18 import java.io.Serializable;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.kuali.rice.kew.api.action.RoutingReportActionToTake;
22 import org.kuali.rice.kew.service.KEWServiceLocator;
23 import org.kuali.rice.kim.api.identity.Person;
24 import org.kuali.rice.kim.api.identity.principal.Principal;
25 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
26
27
28
29
30
31
32 public class SimulationActionToTake implements Serializable {
33 private static final long serialVersionUID = 5212455086079117671L;
34
35 private String actionToPerform;
36 private Person user;
37 private String nodeName;
38
39 public SimulationActionToTake() {
40 }
41
42 public String getActionToPerform() {
43 return actionToPerform;
44 }
45
46 public void setActionToPerform(String actionToPerform) {
47 this.actionToPerform = actionToPerform;
48 }
49
50 public String getNodeName() {
51 return nodeName;
52 }
53
54 public void setNodeName(String nodeName) {
55 this.nodeName = nodeName;
56 }
57
58 public Person getUser() {
59 return user;
60 }
61
62 public void setUser(Person user) {
63 this.user = user;
64 }
65
66 public static SimulationActionToTake from(RoutingReportActionToTake actionToTake) {
67 if (actionToTake == null) {
68 return null;
69 }
70 SimulationActionToTake simActionToTake = new SimulationActionToTake();
71 simActionToTake.setNodeName(actionToTake.getNodeName());
72 if (StringUtils.isBlank(actionToTake.getActionToPerform())) {
73 throw new IllegalArgumentException("ReportActionToTakeVO must contain an action taken code and does not");
74 }
75 simActionToTake.setActionToPerform(actionToTake.getActionToPerform());
76 if (actionToTake.getPrincipalId() == null) {
77 throw new IllegalArgumentException("ReportActionToTakeVO must contain a principalId and does not");
78 }
79 Principal kPrinc = KEWServiceLocator.getIdentityHelperService().getPrincipal(actionToTake.getPrincipalId());
80 Person user = KimApiServiceLocator.getPersonService().getPerson(kPrinc.getPrincipalId());
81 if (user == null) {
82 throw new IllegalStateException("Could not locate Person for the given id: " + actionToTake.getPrincipalId());
83 }
84 simActionToTake.setUser(user);
85 return simActionToTake;
86 }
87
88 }