View Javadoc

1   /**
2    * Copyright 2005-2015 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  
62      @XmlElement(name = Elements.DOCUMENT_TYPE_NAME, required = false)
63      private final String documentTypeName;
64  
65      @XmlElement(name = Elements.RULE_TEMPLATE_NAME, required = false)
66      private final String ruleTemplateName;
67  
68      @XmlElementWrapper(name = Elements.ACTION_REQUEST_CODES, required = false)
69      @XmlElement(name = Elements.ACTION_REQUEST_CODE, required = false)
70      private final List<String> actionRequestCodes;
71  
72      @XmlElement(name = Elements.RESPONSIBLE_PRINCIPAL_ID, required = false)
73      private final String responsiblePrincipalId;
74  
75      @XmlElement(name = Elements.RESPONSIBLE_GROUP_ID, required = false)
76      private final String responsibleGroupId;
77  
78      @XmlElement(name = Elements.RESPONSIBLE_ROLE_NAME, required = false)
79      private final String responsibleRoleName;
80  
81      @XmlElement(name = Elements.RULE_EXTENSIONS, required = false)
82      @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
83      private final Map<String, String> ruleExtensions;
84  
85      @XmlElement(name = Elements.ACTIVE, required = false)
86      private final boolean active;
87  
88      @XmlElement(name = Elements.CONSIDER_GROUP_MEMBERSHIP, required = false)
89      private final boolean considerGroupMembership;
90  
91      @XmlElement(name = Elements.INCLUDE_DELEGATIONS, required = false)
92      private final boolean includeDelegations;
93  
94      @SuppressWarnings("unused")
95      @XmlAnyElement
96      private final Collection<Element> _futureElements = null;
97  
98      /**
99       * Private constructor used only by JAXB.
100      *
101      */
102     private RuleReportCriteria() {
103         this.ruleDescription = null;
104         this.documentTypeName = null;
105         this.ruleTemplateName = null;
106         this.actionRequestCodes = null;
107         this.responsiblePrincipalId = null;
108         this.responsibleGroupId = null;
109         this.responsibleRoleName = null;
110         this.ruleExtensions = null;
111         this.active = false;
112         this.considerGroupMembership = false;
113         this.includeDelegations = false;
114     }
115 
116     private RuleReportCriteria(Builder builder) {
117         this.ruleDescription = builder.getRuleDescription();
118         this.documentTypeName = builder.getDocumentTypeName();
119         this.ruleTemplateName = builder.getRuleTemplateName();
120         this.actionRequestCodes = builder.getActionRequestCodes();
121         this.responsiblePrincipalId = builder.getResponsiblePrincipalId();
122         this.responsibleGroupId = builder.getResponsibleGroupId();
123         this.responsibleRoleName = builder.getResponsibleRoleName();
124         this.ruleExtensions = builder.getRuleExtensions();
125         this.active = builder.isActive();
126         this.considerGroupMembership = builder.isConsiderGroupMembership();
127         this.includeDelegations = builder.isIncludeDelegations();
128     }
129 
130     @Override
131     public String getRuleDescription() {
132         return this.ruleDescription;
133     }
134 
135     @Override
136     public String getDocumentTypeName() {
137         return this.documentTypeName;
138     }
139 
140     @Override
141     public String getRuleTemplateName() {
142         return this.ruleTemplateName;
143     }
144 
145     @Override
146     public List<String> getActionRequestCodes() {
147         return this.actionRequestCodes;
148     }
149 
150     @Override
151     public String getResponsiblePrincipalId() {
152         return this.responsiblePrincipalId;
153     }
154 
155     @Override
156     public String getResponsibleGroupId() {
157         return this.responsibleGroupId;
158     }
159 
160     @Override
161     public String getResponsibleRoleName() {
162         return this.responsibleRoleName;
163     }
164 
165     @Override
166     public Map<String, String> getRuleExtensions() {
167         return this.ruleExtensions;
168     }
169 
170     @Override
171     public boolean isActive() {
172         return this.active;
173     }
174 
175     @Override
176     public boolean isConsiderGroupMembership() {
177         return this.considerGroupMembership;
178     }
179 
180     @Override
181     public boolean isIncludeDelegations() {
182         return this.includeDelegations;
183     }
184 
185 
186     /**
187      * A builder which can be used to construct {@link RuleReportCriteria} instances.  Enforces the constraints of the {@link RuleReportCriteriaContract}.
188      *
189      */
190     public final static class Builder
191         implements Serializable, ModelBuilder, RuleReportCriteriaContract
192     {
193 
194         private String ruleDescription;
195         private String documentTypeName;
196         private String ruleTemplateName;
197         private List<String> actionRequestCodes;
198         private String responsiblePrincipalId;
199         private String responsibleGroupId;
200         private String responsibleRoleName;
201         private Map<String, String> ruleExtensions;
202         private boolean active;
203         private boolean considerGroupMembership;
204         private boolean includeDelegations;
205 
206         private Builder() {
207             setActive(true);
208             setConsiderGroupMembership(true);
209         }
210 
211         public static Builder create() {
212             return new Builder();
213         }
214 
215         public static Builder create(RuleReportCriteriaContract contract) {
216             if (contract == null) {
217                 throw new IllegalArgumentException("contract was null");
218             }
219             Builder builder = create();
220             builder.setRuleDescription(contract.getRuleDescription());
221             builder.setDocumentTypeName(contract.getDocumentTypeName());
222             builder.setRuleTemplateName(contract.getRuleTemplateName());
223             builder.setActionRequestCodes(contract.getActionRequestCodes());
224             builder.setResponsiblePrincipalId(contract.getResponsiblePrincipalId());
225             builder.setResponsibleGroupId(contract.getResponsibleGroupId());
226             builder.setResponsibleRoleName(contract.getResponsibleRoleName());
227             builder.setRuleExtensions(contract.getRuleExtensions());
228             builder.setActive(contract.isActive());
229             builder.setConsiderGroupMembership(contract.isConsiderGroupMembership());
230             builder.setIncludeDelegations(contract.isIncludeDelegations());
231             return builder;
232         }
233 
234         public RuleReportCriteria build() {
235             return new RuleReportCriteria(this);
236         }
237 
238         @Override
239         public String getRuleDescription() {
240             return this.ruleDescription;
241         }
242 
243         @Override
244         public String getDocumentTypeName() {
245             return this.documentTypeName;
246         }
247 
248         @Override
249         public String getRuleTemplateName() {
250             return this.ruleTemplateName;
251         }
252 
253         @Override
254         public List<String> getActionRequestCodes() {
255             return this.actionRequestCodes;
256         }
257 
258         @Override
259         public String getResponsiblePrincipalId() {
260             return this.responsiblePrincipalId;
261         }
262 
263         @Override
264         public String getResponsibleGroupId() {
265             return this.responsibleGroupId;
266         }
267 
268         @Override
269         public String getResponsibleRoleName() {
270             return this.responsibleRoleName;
271         }
272 
273         @Override
274         public Map<String, String> getRuleExtensions() {
275             return this.ruleExtensions;
276         }
277 
278         @Override
279         public boolean isActive() {
280             return this.active;
281         }
282 
283         @Override
284         public boolean isConsiderGroupMembership() {
285             return this.considerGroupMembership;
286         }
287 
288         @Override
289         public boolean isIncludeDelegations() {
290             return this.includeDelegations;
291         }
292 
293         public void setRuleDescription(String ruleDescription) {
294 
295             this.ruleDescription = ruleDescription;
296         }
297 
298         public void setDocumentTypeName(String documentTypeName) {
299 
300             this.documentTypeName = documentTypeName;
301         }
302 
303         public void setRuleTemplateName(String ruleTemplateName) {
304 
305             this.ruleTemplateName = ruleTemplateName;
306         }
307 
308         public void setActionRequestCodes(List<String> actionRequestCodes) {
309 
310             this.actionRequestCodes = actionRequestCodes;
311         }
312 
313         public void setResponsiblePrincipalId(String responsiblePrincipalId) {
314 
315             this.responsiblePrincipalId = responsiblePrincipalId;
316         }
317 
318         public void setResponsibleGroupId(String responsibleGroupId) {
319 
320             this.responsibleGroupId = responsibleGroupId;
321         }
322 
323         public void setResponsibleRoleName(String responsibleRoleName) {
324 
325             this.responsibleRoleName = responsibleRoleName;
326         }
327 
328         public void setRuleExtensions(Map<String, String> ruleExtensions) {
329 
330             this.ruleExtensions = Collections.unmodifiableMap(ruleExtensions);
331         }
332 
333         public void setActive(boolean active) {
334 
335             this.active = active;
336         }
337 
338         public void setConsiderGroupMembership(boolean considerGroupMembership) {
339 
340             this.considerGroupMembership = considerGroupMembership;
341         }
342 
343         public void setIncludeDelegations(boolean includeDelegations) {
344 
345             this.includeDelegations = includeDelegations;
346         }
347 
348     }
349 
350 
351     /**
352      * Defines some internal constants used on this class.
353      *
354      */
355     static class Constants {
356 
357         final static String ROOT_ELEMENT_NAME = "ruleReportCriteria";
358         final static String TYPE_NAME = "RuleReportCriteriaType";
359 
360     }
361 
362 
363     /**
364      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
365      *
366      */
367     static class Elements {
368 
369         final static String RULE_DESCRIPTION = "ruleDescription";
370         final static String DOCUMENT_TYPE_NAME = "documentTypeName";
371         final static String RULE_TEMPLATE_NAME = "ruleTemplateName";
372         final static String ACTION_REQUEST_CODES = "actionRequestCodes";
373         final static String ACTION_REQUEST_CODE = "actionRequestCode";
374         final static String RESPONSIBLE_PRINCIPAL_ID = "responsiblePrincipalId";
375         final static String RESPONSIBLE_GROUP_ID = "responsibleGroupId";
376         final static String RESPONSIBLE_ROLE_NAME = "responsibleRoleName";
377         final static String RULE_EXTENSIONS = "ruleExtensions";
378         final static String ACTIVE = "active";
379         final static String CONSIDER_GROUP_MEMBERSHIP = "considerGroupMembership";
380         final static String INCLUDE_DELEGATIONS = "includeDelegations";
381 
382     }
383 
384 }