View Javadoc

1   package org.kuali.rice.kew.api.rule;
2   
3   import org.kuali.rice.core.api.CoreConstants;
4   import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
5   import org.kuali.rice.core.api.mo.ModelBuilder;
6   import org.kuali.rice.core.api.util.jaxb.MapStringStringAdapter;
7   import org.w3c.dom.Element;
8   
9   import javax.xml.bind.annotation.XmlAccessType;
10  import javax.xml.bind.annotation.XmlAccessorType;
11  import javax.xml.bind.annotation.XmlAnyElement;
12  import javax.xml.bind.annotation.XmlElement;
13  import javax.xml.bind.annotation.XmlElementWrapper;
14  import javax.xml.bind.annotation.XmlRootElement;
15  import javax.xml.bind.annotation.XmlType;
16  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
17  import java.io.Serializable;
18  import java.util.Collection;
19  import java.util.Collections;
20  import java.util.List;
21  import java.util.Map;
22  
23  @XmlRootElement(name = RuleReportCriteria.Constants.ROOT_ELEMENT_NAME)
24  @XmlAccessorType(XmlAccessType.NONE)
25  @XmlType(name = RuleReportCriteria.Constants.TYPE_NAME, propOrder = {
26      RuleReportCriteria.Elements.RULE_DESCRIPTION,
27      RuleReportCriteria.Elements.DOCUMENT_TYPE_NAME,
28      RuleReportCriteria.Elements.RULE_TEMPLATE_NAME,
29      RuleReportCriteria.Elements.ACTION_REQUEST_CODES,
30      RuleReportCriteria.Elements.RESPONSIBLE_PRINCIPAL_ID,
31      RuleReportCriteria.Elements.RESPONSIBLE_GROUP_ID,
32      RuleReportCriteria.Elements.RESPONSIBLE_ROLE_NAME,
33      RuleReportCriteria.Elements.RULE_EXTENSIONS,
34      RuleReportCriteria.Elements.ACTIVE,
35      RuleReportCriteria.Elements.CONSIDER_GROUP_MEMBERSHIP,
36      RuleReportCriteria.Elements.INCLUDE_DELEGATIONS,
37      CoreConstants.CommonElements.FUTURE_ELEMENTS
38  })
39  public final class RuleReportCriteria
40      extends AbstractDataTransferObject
41      implements RuleReportCriteriaContract
42  {
43  
44      @XmlElement(name = Elements.RULE_DESCRIPTION, required = false)
45      private final String ruleDescription;
46      @XmlElement(name = Elements.DOCUMENT_TYPE_NAME, required = false)
47      private final String documentTypeName;
48      @XmlElement(name = Elements.RULE_TEMPLATE_NAME, required = false)
49      private final String ruleTemplateName;
50      @XmlElementWrapper(name = Elements.ACTION_REQUEST_CODES, required = false)
51      @XmlElement(name = Elements.ACTION_REQUEST_CODE, required = false)
52      private final List<String> actionRequestCodes;
53      @XmlElement(name = Elements.RESPONSIBLE_PRINCIPAL_ID, required = false)
54      private final String responsiblePrincipalId;
55      @XmlElement(name = Elements.RESPONSIBLE_GROUP_ID, required = false)
56      private final String responsibleGroupId;
57      @XmlElement(name = Elements.RESPONSIBLE_ROLE_NAME, required = false)
58      private final String responsibleRoleName;
59      @XmlElement(name = Elements.RULE_EXTENSIONS, required = false)
60      @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
61      private final Map<String, String> ruleExtensions;
62      @XmlElement(name = Elements.ACTIVE, required = false)
63      private final boolean active;
64      @XmlElement(name = Elements.CONSIDER_GROUP_MEMBERSHIP, required = false)
65      private final boolean considerGroupMembership;
66      @XmlElement(name = Elements.INCLUDE_DELEGATIONS, required = false)
67      private final boolean includeDelegations;
68      @SuppressWarnings("unused")
69      @XmlAnyElement
70      private final Collection<Element> _futureElements = null;
71  
72      /**
73       * Private constructor used only by JAXB.
74       *
75       */
76      private RuleReportCriteria() {
77          this.ruleDescription = null;
78          this.documentTypeName = null;
79          this.ruleTemplateName = null;
80          this.actionRequestCodes = null;
81          this.responsiblePrincipalId = null;
82          this.responsibleGroupId = null;
83          this.responsibleRoleName = null;
84          this.ruleExtensions = null;
85          this.active = false;
86          this.considerGroupMembership = false;
87          this.includeDelegations = false;
88      }
89  
90      private RuleReportCriteria(Builder builder) {
91          this.ruleDescription = builder.getRuleDescription();
92          this.documentTypeName = builder.getDocumentTypeName();
93          this.ruleTemplateName = builder.getRuleTemplateName();
94          this.actionRequestCodes = builder.getActionRequestCodes();
95          this.responsiblePrincipalId = builder.getResponsiblePrincipalId();
96          this.responsibleGroupId = builder.getResponsibleGroupId();
97          this.responsibleRoleName = builder.getResponsibleRoleName();
98          this.ruleExtensions = builder.getRuleExtensions();
99          this.active = builder.isActive();
100         this.considerGroupMembership = builder.isConsiderGroupMembership();
101         this.includeDelegations = builder.isIncludeDelegations();
102     }
103 
104     @Override
105     public String getRuleDescription() {
106         return this.ruleDescription;
107     }
108 
109     @Override
110     public String getDocumentTypeName() {
111         return this.documentTypeName;
112     }
113 
114     @Override
115     public String getRuleTemplateName() {
116         return this.ruleTemplateName;
117     }
118 
119     @Override
120     public List<String> getActionRequestCodes() {
121         return this.actionRequestCodes;
122     }
123 
124     @Override
125     public String getResponsiblePrincipalId() {
126         return this.responsiblePrincipalId;
127     }
128 
129     @Override
130     public String getResponsibleGroupId() {
131         return this.responsibleGroupId;
132     }
133 
134     @Override
135     public String getResponsibleRoleName() {
136         return this.responsibleRoleName;
137     }
138 
139     @Override
140     public Map<String, String> getRuleExtensions() {
141         return this.ruleExtensions;
142     }
143 
144     @Override
145     public boolean isActive() {
146         return this.active;
147     }
148 
149     @Override
150     public boolean isConsiderGroupMembership() {
151         return this.considerGroupMembership;
152     }
153 
154     @Override
155     public boolean isIncludeDelegations() {
156         return this.includeDelegations;
157     }
158 
159 
160     /**
161      * A builder which can be used to construct {@link RuleReportCriteria} instances.  Enforces the constraints of the {@link RuleReportCriteriaContract}.
162      *
163      */
164     public final static class Builder
165         implements Serializable, ModelBuilder, RuleReportCriteriaContract
166     {
167 
168         private String ruleDescription;
169         private String documentTypeName;
170         private String ruleTemplateName;
171         private List<String> actionRequestCodes;
172         private String responsiblePrincipalId;
173         private String responsibleGroupId;
174         private String responsibleRoleName;
175         private Map<String, String> ruleExtensions;
176         private boolean active;
177         private boolean considerGroupMembership;
178         private boolean includeDelegations;
179 
180         private Builder() {
181             setActive(true);
182             setConsiderGroupMembership(true);
183         }
184 
185         public static Builder create() {
186             return new Builder();
187         }
188 
189         public static Builder create(RuleReportCriteriaContract contract) {
190             if (contract == null) {
191                 throw new IllegalArgumentException("contract was null");
192             }
193             Builder builder = create();
194             builder.setRuleDescription(contract.getRuleDescription());
195             builder.setDocumentTypeName(contract.getDocumentTypeName());
196             builder.setRuleTemplateName(contract.getRuleTemplateName());
197             builder.setActionRequestCodes(contract.getActionRequestCodes());
198             builder.setResponsiblePrincipalId(contract.getResponsiblePrincipalId());
199             builder.setResponsibleGroupId(contract.getResponsibleGroupId());
200             builder.setResponsibleRoleName(contract.getResponsibleRoleName());
201             builder.setRuleExtensions(contract.getRuleExtensions());
202             builder.setActive(contract.isActive());
203             builder.setConsiderGroupMembership(contract.isConsiderGroupMembership());
204             builder.setIncludeDelegations(contract.isIncludeDelegations());
205             return builder;
206         }
207 
208         public RuleReportCriteria build() {
209             return new RuleReportCriteria(this);
210         }
211 
212         @Override
213         public String getRuleDescription() {
214             return this.ruleDescription;
215         }
216 
217         @Override
218         public String getDocumentTypeName() {
219             return this.documentTypeName;
220         }
221 
222         @Override
223         public String getRuleTemplateName() {
224             return this.ruleTemplateName;
225         }
226 
227         @Override
228         public List<String> getActionRequestCodes() {
229             return this.actionRequestCodes;
230         }
231 
232         @Override
233         public String getResponsiblePrincipalId() {
234             return this.responsiblePrincipalId;
235         }
236 
237         @Override
238         public String getResponsibleGroupId() {
239             return this.responsibleGroupId;
240         }
241 
242         @Override
243         public String getResponsibleRoleName() {
244             return this.responsibleRoleName;
245         }
246 
247         @Override
248         public Map<String, String> getRuleExtensions() {
249             return this.ruleExtensions;
250         }
251 
252         @Override
253         public boolean isActive() {
254             return this.active;
255         }
256 
257         @Override
258         public boolean isConsiderGroupMembership() {
259             return this.considerGroupMembership;
260         }
261 
262         @Override
263         public boolean isIncludeDelegations() {
264             return this.includeDelegations;
265         }
266 
267         public void setRuleDescription(String ruleDescription) {
268 
269             this.ruleDescription = ruleDescription;
270         }
271 
272         public void setDocumentTypeName(String documentTypeName) {
273 
274             this.documentTypeName = documentTypeName;
275         }
276 
277         public void setRuleTemplateName(String ruleTemplateName) {
278 
279             this.ruleTemplateName = ruleTemplateName;
280         }
281 
282         public void setActionRequestCodes(List<String> actionRequestCodes) {
283 
284             this.actionRequestCodes = actionRequestCodes;
285         }
286 
287         public void setResponsiblePrincipalId(String responsiblePrincipalId) {
288 
289             this.responsiblePrincipalId = responsiblePrincipalId;
290         }
291 
292         public void setResponsibleGroupId(String responsibleGroupId) {
293 
294             this.responsibleGroupId = responsibleGroupId;
295         }
296 
297         public void setResponsibleRoleName(String responsibleRoleName) {
298 
299             this.responsibleRoleName = responsibleRoleName;
300         }
301 
302         public void setRuleExtensions(Map<String, String> ruleExtensions) {
303 
304             this.ruleExtensions = Collections.unmodifiableMap(ruleExtensions);
305         }
306 
307         public void setActive(boolean active) {
308 
309             this.active = active;
310         }
311 
312         public void setConsiderGroupMembership(boolean considerGroupMembership) {
313 
314             this.considerGroupMembership = considerGroupMembership;
315         }
316 
317         public void setIncludeDelegations(boolean includeDelegations) {
318 
319             this.includeDelegations = includeDelegations;
320         }
321 
322     }
323 
324 
325     /**
326      * Defines some internal constants used on this class.
327      *
328      */
329     static class Constants {
330 
331         final static String ROOT_ELEMENT_NAME = "ruleReportCriteria";
332         final static String TYPE_NAME = "RuleReportCriteriaType";
333 
334     }
335 
336 
337     /**
338      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
339      *
340      */
341     static class Elements {
342 
343         final static String RULE_DESCRIPTION = "ruleDescription";
344         final static String DOCUMENT_TYPE_NAME = "documentTypeName";
345         final static String RULE_TEMPLATE_NAME = "ruleTemplateName";
346         final static String ACTION_REQUEST_CODES = "actionRequestCodes";
347         final static String ACTION_REQUEST_CODE = "actionRequestCode";
348         final static String RESPONSIBLE_PRINCIPAL_ID = "responsiblePrincipalId";
349         final static String RESPONSIBLE_GROUP_ID = "responsibleGroupId";
350         final static String RESPONSIBLE_ROLE_NAME = "responsibleRoleName";
351         final static String RULE_EXTENSIONS = "ruleExtensions";
352         final static String ACTIVE = "active";
353         final static String CONSIDER_GROUP_MEMBERSHIP = "considerGroupMembership";
354         final static String INCLUDE_DELEGATIONS = "includeDelegations";
355 
356     }
357 
358 }