001 /** 002 * Copyright 2005-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.kim.api.role; 017 018 import org.apache.commons.lang.StringUtils; 019 import org.apache.commons.lang.builder.EqualsBuilder; 020 import org.apache.commons.lang.builder.HashCodeBuilder; 021 import org.apache.commons.lang.builder.ToStringBuilder; 022 import org.kuali.rice.core.api.CoreConstants; 023 import org.kuali.rice.core.api.mo.AbstractDataTransferObject; 024 import org.kuali.rice.core.api.mo.ModelBuilder; 025 import org.kuali.rice.core.api.mo.ModelObjectComplete; 026 import org.kuali.rice.kim.api.KimConstants; 027 import org.w3c.dom.Element; 028 029 import javax.xml.bind.annotation.XmlAccessType; 030 import javax.xml.bind.annotation.XmlAccessorType; 031 import javax.xml.bind.annotation.XmlAnyElement; 032 import javax.xml.bind.annotation.XmlElement; 033 import javax.xml.bind.annotation.XmlRootElement; 034 import javax.xml.bind.annotation.XmlType; 035 import java.util.Collection; 036 037 /** 038 * @author Kuali Rice Team (rice.collab@kuali.org) 039 */ 040 @XmlRootElement(name = RoleResponsibilityAction.Constants.ROOT_ELEMENT_NAME) 041 @XmlAccessorType(XmlAccessType.NONE) 042 @XmlType(name = RoleResponsibilityAction.Constants.TYPE_NAME, propOrder = { 043 RoleResponsibilityAction.Elements.ID, 044 RoleResponsibilityAction.Elements.ROLE_RESPONSIBILITY_ID, 045 RoleResponsibilityAction.Elements.ROLE_MEMBER_ID, 046 RoleResponsibilityAction.Elements.ACTION_TYPE_CODE, 047 RoleResponsibilityAction.Elements.ACTION_POLICY_CODE, 048 RoleResponsibilityAction.Elements.FORCE_ACTION, 049 RoleResponsibilityAction.Elements.PRIORITY_NUMBER, 050 RoleResponsibilityAction.Elements.ROLE_RESPONSIBILITY, 051 CoreConstants.CommonElements.VERSION_NUMBER, 052 CoreConstants.CommonElements.FUTURE_ELEMENTS 053 }) 054 public class RoleResponsibilityAction extends AbstractDataTransferObject implements RoleResponsibilityActionContract { 055 056 @XmlElement(name = RoleResponsibilityAction.Elements.ID, required = true) 057 private final String id; 058 059 @XmlElement(name = RoleResponsibilityAction.Elements.ROLE_RESPONSIBILITY_ID) 060 private final String roleResponsibilityId; 061 062 @XmlElement(name = RoleResponsibilityAction.Elements.ROLE_MEMBER_ID) 063 private final String roleMemberId; 064 065 @XmlElement(name = RoleResponsibilityAction.Elements.ACTION_TYPE_CODE) 066 private final String actionTypeCode; 067 068 @XmlElement(name = RoleResponsibilityAction.Elements.ACTION_POLICY_CODE) 069 private final String actionPolicyCode; 070 071 @XmlElement(name = RoleResponsibilityAction.Elements.FORCE_ACTION) 072 private final boolean forceAction; 073 074 @XmlElement(name = RoleResponsibilityAction.Elements.PRIORITY_NUMBER) 075 private final Integer priorityNumber; 076 077 @XmlElement(name = RoleResponsibilityAction.Elements.ROLE_RESPONSIBILITY) 078 private final RoleResponsibility roleResponsibility; 079 080 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER) 081 private final Long versionNumber; 082 083 @SuppressWarnings("unused") 084 @XmlAnyElement 085 private final Collection<Element> _futureElements = null; 086 087 /** 088 * Private default constructor should only be called by JAXB 089 */ 090 @SuppressWarnings("unused") 091 private RoleResponsibilityAction() { 092 id = null; 093 roleResponsibilityId = null; 094 roleMemberId = null; 095 actionTypeCode = null; 096 actionPolicyCode = null; 097 forceAction = false; 098 priorityNumber = null; 099 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 if (versionNumber == null || Id == null) { 198 throw new IllegalStateException("versionNumber and id must be non-null and " + 199 "not empty for RoleResponsibilityAction"); 200 } 201 return new RoleResponsibilityAction(this); 202 } 203 204 @Override 205 public String getId() { 206 return Id; 207 } 208 209 public void setId(String id) { 210 if (StringUtils.isBlank(id)) { 211 throw new IllegalArgumentException("id must be non-null and not empty"); 212 } 213 this.Id = id; 214 } 215 216 @Override 217 public String getRoleResponsibilityId() { 218 return roleResponsibilityId; 219 } 220 221 public void setRoleResponsibilityId(String roleResponsibilityId) { 222 this.roleResponsibilityId = roleResponsibilityId; 223 } 224 225 @Override 226 public String getActionTypeCode() { 227 return actionTypeCode; 228 } 229 230 public void setActionTypeCode(String actionTypeCode) { 231 this.actionTypeCode = actionTypeCode; 232 } 233 234 @Override 235 public Integer getPriorityNumber() { 236 return priorityNumber; 237 } 238 239 public void setPriorityNumber(Integer priorityNumber) { 240 this.priorityNumber = priorityNumber; 241 } 242 243 @Override 244 public String getActionPolicyCode() { 245 return actionPolicyCode; 246 } 247 248 public void setActionPolicyCode(String actionPolicyCode) { 249 this.actionPolicyCode = actionPolicyCode; 250 } 251 252 @Override 253 public String getRoleMemberId() { 254 return roleMemberId; 255 } 256 257 public void setRoleMemberId(String roleMemberId) { 258 this.roleMemberId = roleMemberId; 259 } 260 261 @Override 262 public RoleResponsibility getRoleResponsibility() { 263 return roleResponsibility; 264 } 265 266 public void setRoleResponsibility(RoleResponsibility roleResponsibility) { 267 this.roleResponsibility = roleResponsibility; 268 } 269 270 @Override 271 public boolean isForceAction() { 272 return forceAction; 273 } 274 275 public void setForceAction(boolean forceAction) { 276 this.forceAction = forceAction; 277 } 278 279 @Override 280 public Long getVersionNumber() { 281 return versionNumber; 282 } 283 284 public void setVersionNumber(Long versionNumber) { 285 if (versionNumber == null) { 286 throw new IllegalArgumentException("versionNumber must be non-null"); 287 } 288 this.versionNumber = versionNumber; 289 } 290 291 @Override 292 public int hashCode() { 293 return HashCodeBuilder.reflectionHashCode(this); 294 } 295 296 @Override 297 public boolean equals(Object obj) { 298 return EqualsBuilder.reflectionEquals(obj, this); 299 } 300 301 @Override 302 public String toString() { 303 return ToStringBuilder.reflectionToString(this); 304 } 305 } 306 307 308 /** 309 * A private class which exposes constants which define the XML element names to use 310 * when this object is marshalled to XML. 311 */ 312 static class Elements { 313 final static String ID = "id"; 314 final static String ROLE_RESPONSIBILITY_ID = "roleResponsibilityId"; 315 final static String ROLE_MEMBER_ID = "roleMemberId"; 316 final static String ACTION_TYPE_CODE = "actionTypeCode"; 317 final static String ACTION_POLICY_CODE = "actionPolicyCode"; 318 final static String FORCE_ACTION = "forceAction"; 319 final static String PRIORITY_NUMBER = "priorityNumber"; 320 final static String ROLE_RESPONSIBILITY = "roleResponsibility"; 321 } 322 323 /** 324 * Defines some internal constants used on this class. 325 */ 326 static class Constants { 327 final static String ROOT_ELEMENT_NAME = "roleResponsibilityAction"; 328 final static String TYPE_NAME = "RoleResponsibilityActionType"; 329 } 330 331 public static class Cache { 332 public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + RoleResponsibilityAction.Constants.TYPE_NAME; 333 } 334 }