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