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.io.Serializable; |
19 | |
import java.util.Collection; |
20 | |
|
21 | |
import javax.xml.bind.annotation.XmlAccessType; |
22 | |
import javax.xml.bind.annotation.XmlAccessorType; |
23 | |
import javax.xml.bind.annotation.XmlAnyElement; |
24 | |
import javax.xml.bind.annotation.XmlElement; |
25 | |
import javax.xml.bind.annotation.XmlRootElement; |
26 | |
import javax.xml.bind.annotation.XmlType; |
27 | |
|
28 | |
import org.apache.commons.lang.StringUtils; |
29 | |
import org.kuali.rice.core.api.CoreConstants; |
30 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
31 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
32 | |
import org.kuali.rice.kew.api.action.ActionItem.Elements; |
33 | |
import org.kuali.rice.kew.api.actionlist.DisplayParameters; |
34 | |
import org.w3c.dom.Element; |
35 | |
|
36 | |
@XmlRootElement(name = ActionItemCustomization.Constants.ROOT_ELEMENT_NAME) |
37 | |
@XmlAccessorType(XmlAccessType.NONE) |
38 | |
@XmlType(name = ActionItemCustomization.Constants.TYPE_NAME, propOrder = { |
39 | |
ActionItemCustomization.Elements.ID, |
40 | |
ActionItemCustomization.Elements.ACTION_SET, |
41 | |
ActionItemCustomization.Elements.DISPLAY_PARAMETERS, |
42 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
43 | |
}) |
44 | 0 | public class ActionItemCustomization extends AbstractDataTransferObject implements ActionItemCustomizationContract { |
45 | |
|
46 | |
@XmlElement(name = Elements.ID, required = false) |
47 | |
private final String id; |
48 | |
@XmlElement(name = Elements.ACTION_SET, required = true) |
49 | |
private final ActionSet actionSet; |
50 | |
@XmlElement(name = Elements.DISPLAY_PARAMETERS, required = true) |
51 | |
private final DisplayParameters displayParameters; |
52 | 0 | @SuppressWarnings("unused") |
53 | |
@XmlAnyElement |
54 | |
private final Collection<Element> _futureElements = null; |
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | 0 | private ActionItemCustomization() { |
61 | 0 | this.id = null; |
62 | 0 | this.actionSet = null; |
63 | 0 | this.displayParameters = null; |
64 | 0 | } |
65 | |
|
66 | 0 | private ActionItemCustomization(Builder builder) { |
67 | 0 | this.id = builder.getId(); |
68 | 0 | this.actionSet = builder.getActionSet(); |
69 | 0 | this.displayParameters = builder.getDisplayParameters(); |
70 | 0 | } |
71 | |
|
72 | |
@Override |
73 | |
public String getId() { |
74 | 0 | return this.id; |
75 | |
} |
76 | |
|
77 | |
@Override |
78 | |
public ActionSet getActionSet() { |
79 | 0 | return this.actionSet; |
80 | |
} |
81 | |
|
82 | |
@Override |
83 | |
public DisplayParameters getDisplayParameters() { |
84 | 0 | return this.displayParameters; |
85 | |
} |
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | 0 | public final static class Builder |
92 | |
implements Serializable, ModelBuilder, ActionItemCustomizationContract |
93 | |
{ |
94 | |
|
95 | |
private String id; |
96 | |
private ActionSet actionSet; |
97 | |
private DisplayParameters displayParameters; |
98 | |
|
99 | 0 | private Builder(ActionSet actionSet, DisplayParameters displayParameters) { |
100 | 0 | setActionSet(actionSet); |
101 | 0 | setDisplayParameters(displayParameters); |
102 | 0 | } |
103 | |
|
104 | |
public static Builder create(ActionSet actionSet, DisplayParameters displayParameters) { |
105 | 0 | return new Builder(actionSet, displayParameters); |
106 | |
} |
107 | |
|
108 | |
public static Builder create(ActionItemCustomizationContract contract) { |
109 | 0 | if (contract == null) { |
110 | 0 | throw new IllegalArgumentException("contract is null"); |
111 | |
} |
112 | 0 | Builder builder = create(contract.getActionSet(), contract.getDisplayParameters()); |
113 | 0 | builder.setId(contract.getId()); |
114 | 0 | return builder; |
115 | |
} |
116 | |
|
117 | |
@Override |
118 | |
public ActionItemCustomization build() { |
119 | 0 | return new ActionItemCustomization(this); |
120 | |
} |
121 | |
|
122 | |
@Override |
123 | |
public ActionSet getActionSet() { |
124 | 0 | return this.actionSet; |
125 | |
} |
126 | |
|
127 | |
public DisplayParameters getDisplayParameters() { |
128 | 0 | return this.displayParameters; |
129 | |
} |
130 | |
|
131 | |
public String getId() { |
132 | 0 | return this.id; |
133 | |
} |
134 | |
|
135 | |
public void setId(String id) { |
136 | 0 | if (StringUtils.isWhitespace(id)) { |
137 | 0 | throw new IllegalArgumentException("id is blank"); |
138 | |
} |
139 | 0 | this.id = id; |
140 | 0 | } |
141 | |
|
142 | |
public void setActionSet(ActionSet actionSet) { |
143 | 0 | if (actionSet == null) { |
144 | 0 | throw new IllegalArgumentException("actionSet is null"); |
145 | |
} |
146 | 0 | this.actionSet = actionSet; |
147 | 0 | } |
148 | |
|
149 | |
public void setDisplayParameters(DisplayParameters displayParameters) { |
150 | 0 | if (displayParameters == null) { |
151 | 0 | throw new IllegalArgumentException("displayParameters is null"); |
152 | |
} |
153 | 0 | this.displayParameters = displayParameters; |
154 | 0 | } |
155 | |
} |
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | 0 | static class Constants { |
162 | |
final static String ROOT_ELEMENT_NAME = "actionItemCustomization"; |
163 | |
final static String TYPE_NAME = "ActionItemCustomizationType"; |
164 | |
} |
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | 0 | static class Elements { |
171 | |
final static String ID = "id"; |
172 | |
final static String ACTION_SET = "actionSet"; |
173 | |
final static String DISPLAY_PARAMETERS = "displayParameters"; |
174 | |
} |
175 | |
} |