1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.api.action;
17
18 import java.util.Collection;
19 import java.util.Collections;
20 import java.util.EnumSet;
21 import java.util.Set;
22
23 import javax.xml.bind.annotation.XmlAccessType;
24 import javax.xml.bind.annotation.XmlAccessorType;
25 import javax.xml.bind.annotation.XmlAnyElement;
26 import javax.xml.bind.annotation.XmlElement;
27 import javax.xml.bind.annotation.XmlRootElement;
28 import javax.xml.bind.annotation.XmlType;
29
30 import org.kuali.rice.core.api.CoreConstants;
31 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
32 import org.w3c.dom.Element;
33
34 @XmlRootElement(name = RequestedActions.Constants.ROOT_ELEMENT_NAME)
35 @XmlAccessorType(XmlAccessType.NONE)
36 @XmlType(name = RequestedActions.Constants.TYPE_NAME, propOrder = {
37 RequestedActions.Elements.COMPLETE_REQUESTED,
38 RequestedActions.Elements.APPROVE_REQUESTED,
39 RequestedActions.Elements.ACKNOWLEDGE_REQUESTED,
40 RequestedActions.Elements.FYI_REQUESTED,
41 CoreConstants.CommonElements.FUTURE_ELEMENTS
42 })
43 public final class RequestedActions extends AbstractDataTransferObject {
44
45 private static final long serialVersionUID = -6600754341497697330L;
46
47 @XmlElement(name = Elements.COMPLETE_REQUESTED, required = true)
48 private final boolean completeRequested;
49
50 @XmlElement(name = Elements.APPROVE_REQUESTED, required = true)
51 private final boolean approveRequested;
52
53 @XmlElement(name = Elements.ACKNOWLEDGE_REQUESTED, required = true)
54 private final boolean acknowledgeRequested;
55
56 @XmlElement(name = Elements.FYI_REQUESTED, required = true)
57 private final boolean fyiRequested;
58
59 @SuppressWarnings("unused")
60 @XmlAnyElement
61 private final Collection<Element> _futureElements = null;
62
63 private RequestedActions() {
64 this.completeRequested = false;
65 this.approveRequested = false;
66 this.acknowledgeRequested = false;
67 this.fyiRequested = false;
68 }
69
70 private RequestedActions(boolean completeRequested, boolean approveRequested, boolean acknowledgeRequested, boolean fyiRequested) {
71 this.completeRequested = completeRequested;
72 this.approveRequested = approveRequested;
73 this.acknowledgeRequested = acknowledgeRequested;
74 this.fyiRequested = fyiRequested;
75 }
76
77 public static RequestedActions create(boolean completeRequested, boolean approveRequested, boolean acknowledgeRequested, boolean fyiRequested) {
78 return new RequestedActions(completeRequested, approveRequested, acknowledgeRequested, fyiRequested);
79 }
80
81 public boolean isCompleteRequested() {
82 return completeRequested;
83 }
84
85 public boolean isApproveRequested() {
86 return approveRequested;
87 }
88
89 public boolean isAcknowledgeRequested() {
90 return acknowledgeRequested;
91 }
92
93 public boolean isFyiRequested() {
94 return fyiRequested;
95 }
96
97
98
99
100
101
102
103
104
105 public Set<ActionRequestType> getRequestedActions() {
106 EnumSet<ActionRequestType> requestedActions = EnumSet.noneOf(ActionRequestType.class);
107 if (isCompleteRequested()) {
108 requestedActions.add(ActionRequestType.COMPLETE);
109 }
110 if (isApproveRequested()) {
111 requestedActions.add(ActionRequestType.APPROVE);
112 }
113 if (isAcknowledgeRequested()) {
114 requestedActions.add(ActionRequestType.ACKNOWLEDGE);
115 }
116 if (isFyiRequested()) {
117 requestedActions.add(ActionRequestType.FYI);
118 }
119 return Collections.unmodifiableSet(requestedActions);
120 }
121
122
123
124
125
126
127
128
129
130
131 public boolean contains(ActionRequestType actionRequestType) {
132 if (actionRequestType == null) {
133 throw new IllegalArgumentException("actionRequestType was null");
134 }
135 return getRequestedActions().contains(actionRequestType);
136 }
137
138
139
140
141 static class Constants {
142 final static String ROOT_ELEMENT_NAME = "requestedActions";
143 final static String TYPE_NAME = "RequestedActionsType";
144 }
145
146
147
148
149 static class Elements {
150 final static String COMPLETE_REQUESTED = "completeRequested";
151 final static String APPROVE_REQUESTED = "approveRequested";
152 final static String ACKNOWLEDGE_REQUESTED = "acknowledgeRequested";
153 final static String FYI_REQUESTED = "fyiRequested";
154 }
155
156 }