View Javadoc

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