View Javadoc

1   /**
2    * Copyright 2005-2012 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.kim.api.role;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.apache.commons.lang.builder.EqualsBuilder;
20  import org.apache.commons.lang.builder.HashCodeBuilder;
21  import org.apache.commons.lang.builder.ToStringBuilder;
22  import org.kuali.rice.core.api.CoreConstants;
23  import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
24  import org.kuali.rice.core.api.mo.ModelBuilder;
25  import org.kuali.rice.core.api.mo.ModelObjectComplete;
26  import org.kuali.rice.kim.api.KimConstants;
27  import org.w3c.dom.Element;
28  
29  import javax.xml.bind.annotation.XmlAccessType;
30  import javax.xml.bind.annotation.XmlAccessorType;
31  import javax.xml.bind.annotation.XmlAnyElement;
32  import javax.xml.bind.annotation.XmlElement;
33  import javax.xml.bind.annotation.XmlRootElement;
34  import javax.xml.bind.annotation.XmlType;
35  import java.util.Collection;
36  
37  /**
38   * @author Kuali Rice Team (rice.collab@kuali.org)
39   */
40  @XmlRootElement(name = RoleResponsibilityAction.Constants.ROOT_ELEMENT_NAME)
41  @XmlAccessorType(XmlAccessType.NONE)
42  @XmlType(name = RoleResponsibilityAction.Constants.TYPE_NAME, propOrder = {
43          RoleResponsibilityAction.Elements.ID,
44          RoleResponsibilityAction.Elements.ROLE_RESPONSIBILITY_ID,
45          RoleResponsibilityAction.Elements.ROLE_MEMBER_ID,
46          RoleResponsibilityAction.Elements.ACTION_TYPE_CODE,
47          RoleResponsibilityAction.Elements.ACTION_POLICY_CODE,
48          RoleResponsibilityAction.Elements.FORCE_ACTION,
49          RoleResponsibilityAction.Elements.PRIORITY_NUMBER,
50          RoleResponsibilityAction.Elements.ROLE_RESPONSIBILITY,
51          CoreConstants.CommonElements.VERSION_NUMBER,
52          CoreConstants.CommonElements.FUTURE_ELEMENTS
53  })
54  public class RoleResponsibilityAction extends AbstractDataTransferObject implements RoleResponsibilityActionContract {
55  
56      @XmlElement(name = RoleResponsibilityAction.Elements.ID, required = false)
57      private final String id;
58  
59      @XmlElement(name = RoleResponsibilityAction.Elements.ROLE_RESPONSIBILITY_ID)
60      private final String roleResponsibilityId;
61  
62      @XmlElement(name = RoleResponsibilityAction.Elements.ROLE_MEMBER_ID)
63      private final String roleMemberId;
64  
65      @XmlElement(name = RoleResponsibilityAction.Elements.ACTION_TYPE_CODE)
66      private final String actionTypeCode;
67  
68      @XmlElement(name = RoleResponsibilityAction.Elements.ACTION_POLICY_CODE)
69      private final String actionPolicyCode;
70  
71      @XmlElement(name = RoleResponsibilityAction.Elements.FORCE_ACTION)
72      private final boolean forceAction;
73  
74      @XmlElement(name = RoleResponsibilityAction.Elements.PRIORITY_NUMBER)
75      private final Integer priorityNumber;
76  
77      @XmlElement(name = RoleResponsibilityAction.Elements.ROLE_RESPONSIBILITY)
78      private final RoleResponsibility roleResponsibility;
79  
80      @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER)
81      private final Long versionNumber;
82  
83      @SuppressWarnings("unused")
84      @XmlAnyElement
85      private final Collection<Element> _futureElements = null;
86  
87      /**
88       * Private default constructor should only be called by JAXB
89       */
90      @SuppressWarnings("unused")
91      private RoleResponsibilityAction() {
92          id = null;
93          roleResponsibilityId = null;
94          roleMemberId = null;
95          actionTypeCode = null;
96          actionPolicyCode = null;
97          forceAction = false;
98          priorityNumber = null;
99          roleResponsibility = null;
100         versionNumber = null;
101     }
102 
103     private RoleResponsibilityAction(Builder b) {
104         id = b.getId();
105         roleResponsibilityId = b.getRoleResponsibilityId();
106         roleMemberId = b.getRoleMemberId();
107         actionTypeCode = b.getActionTypeCode();
108         actionPolicyCode = b.getActionPolicyCode();
109         forceAction = b.isForceAction();
110         priorityNumber = b.getPriorityNumber();
111         roleResponsibility = b.getRoleResponsibility();
112         versionNumber = b.getVersionNumber();
113     }
114 
115     @Override
116     public String getId() {
117         return this.id;
118     }
119 
120     @Override
121     public String getRoleResponsibilityId() {
122         return this.roleResponsibilityId;
123     }
124 
125     @Override
126     public String getActionTypeCode() {
127         return this.actionTypeCode;
128     }
129 
130     @Override
131     public Integer getPriorityNumber() {
132         return this.priorityNumber;
133     }
134 
135     @Override
136     public String getActionPolicyCode() {
137         return this.actionPolicyCode;
138     }
139 
140     @Override
141     public String getRoleMemberId() {
142         return this.roleMemberId;
143     }
144 
145     @Override
146     public RoleResponsibility getRoleResponsibility() {
147         return this.roleResponsibility;
148     }
149 
150     @Override
151     public boolean isForceAction() {
152         return this.forceAction;
153     }
154 
155     @Override
156     public Long getVersionNumber() {
157         return this.versionNumber;
158     }
159 
160     public static class Builder implements RoleResponsibilityActionContract, ModelBuilder, ModelObjectComplete {
161 
162         private String id;
163         private String roleResponsibilityId;
164         private String roleMemberId;
165         private String actionTypeCode;
166         private String actionPolicyCode;
167         private boolean forceAction;
168         private Integer priorityNumber;
169         private RoleResponsibility roleResponsibility;
170         private Long versionNumber;
171 
172         private Builder() {
173         }
174 
175         public static Builder create() {
176             return new Builder();
177         }
178 
179         public static Builder create(RoleResponsibilityActionContract rra) {
180             Builder b = new Builder();
181             b.setForceAction(rra.isForceAction());
182             b.setActionPolicyCode(rra.getActionPolicyCode());
183             b.setActionTypeCode(rra.getActionTypeCode());
184             b.setPriorityNumber(rra.getPriorityNumber());
185             b.setRoleMemberId(rra.getRoleMemberId());
186             if (rra.getRoleResponsibility() != null) {
187                 b.setRoleResponsibility(RoleResponsibility.Builder.create(rra.getRoleResponsibility()).build());
188             }
189             b.setId(rra.getId());
190             b.setRoleResponsibilityId(rra.getRoleResponsibilityId());
191             b.setVersionNumber(rra.getVersionNumber());
192             return b;
193         }
194 
195         @Override
196         public RoleResponsibilityAction build() {
197             return new RoleResponsibilityAction(this);
198         }
199 
200         @Override
201         public String getId() {
202             return id;
203         }
204 
205         public void setId(String id) {
206             if (StringUtils.isWhitespace(id)) {
207                 throw new IllegalArgumentException("id must be not be whitespace");
208             }
209             this.id = id;
210         }
211 
212         @Override
213         public String getRoleResponsibilityId() {
214             return roleResponsibilityId;
215         }
216 
217         public void setRoleResponsibilityId(String roleResponsibilityId) {
218             this.roleResponsibilityId = roleResponsibilityId;
219         }
220 
221         @Override
222         public String getActionTypeCode() {
223             return actionTypeCode;
224         }
225 
226         public void setActionTypeCode(String actionTypeCode) {
227             this.actionTypeCode = actionTypeCode;
228         }
229 
230         @Override
231         public Integer getPriorityNumber() {
232             return priorityNumber;
233         }
234 
235         public void setPriorityNumber(Integer priorityNumber) {
236             this.priorityNumber = priorityNumber;
237         }
238 
239         @Override
240         public String getActionPolicyCode() {
241             return actionPolicyCode;
242         }
243 
244         public void setActionPolicyCode(String actionPolicyCode) {
245             this.actionPolicyCode = actionPolicyCode;
246         }
247 
248         @Override
249         public String getRoleMemberId() {
250             return roleMemberId;
251         }
252 
253         public void setRoleMemberId(String roleMemberId) {
254             this.roleMemberId = roleMemberId;
255         }
256 
257         @Override
258         public RoleResponsibility getRoleResponsibility() {
259             return roleResponsibility;
260         }
261 
262         public void setRoleResponsibility(RoleResponsibility roleResponsibility) {
263             this.roleResponsibility = roleResponsibility;
264         }
265 
266         @Override
267         public boolean isForceAction() {
268             return forceAction;
269         }
270 
271         public void setForceAction(boolean forceAction) {
272             this.forceAction = forceAction;
273         }
274 
275         @Override
276         public Long getVersionNumber() {
277             return versionNumber;
278         }
279 
280         public void setVersionNumber(Long versionNumber) {
281             this.versionNumber = versionNumber;
282         }
283 
284         @Override
285         public int hashCode() {
286             return HashCodeBuilder.reflectionHashCode(this);
287         }
288 
289         @Override
290         public boolean equals(Object obj) {
291             return EqualsBuilder.reflectionEquals(obj, this);
292         }
293 
294         @Override
295         public String toString() {
296             return ToStringBuilder.reflectionToString(this);
297         }
298     }
299 
300 
301     /**
302      * A private class which exposes constants which define the XML element names to use
303      * when this object is marshalled to XML.
304      */
305     static class Elements {
306         final static String ID = "id";
307         final static String ROLE_RESPONSIBILITY_ID = "roleResponsibilityId";
308         final static String ROLE_MEMBER_ID = "roleMemberId";
309         final static String ACTION_TYPE_CODE = "actionTypeCode";
310         final static String ACTION_POLICY_CODE = "actionPolicyCode";
311         final static String FORCE_ACTION = "forceAction";
312         final static String PRIORITY_NUMBER = "priorityNumber";
313         final static String ROLE_RESPONSIBILITY = "roleResponsibility";
314     }
315 
316     /**
317      * Defines some internal constants used on this class.
318      */
319     static class Constants {
320         final static String ROOT_ELEMENT_NAME = "roleResponsibilityAction";
321         final static String TYPE_NAME = "RoleResponsibilityActionType";
322     }
323 
324     public static class Cache {
325         public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + RoleResponsibilityAction.Constants.TYPE_NAME;
326     }
327 }