| 1 | |
package org.kuali.rice.kim.api.responsibility; |
| 2 | |
|
| 3 | |
import com.google.common.collect.Maps; |
| 4 | |
import org.apache.commons.lang.StringUtils; |
| 5 | |
import org.kuali.rice.core.api.CoreConstants; |
| 6 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
| 7 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
| 8 | |
import org.kuali.rice.core.api.util.jaxb.MapStringStringAdapter; |
| 9 | |
import org.kuali.rice.kim.api.common.delegate.DelegateType; |
| 10 | |
import org.kuali.rice.kim.api.common.delegate.DelegateTypeContract; |
| 11 | |
import org.w3c.dom.Element; |
| 12 | |
|
| 13 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 14 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 15 | |
import javax.xml.bind.annotation.XmlAnyElement; |
| 16 | |
import javax.xml.bind.annotation.XmlElement; |
| 17 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 18 | |
import javax.xml.bind.annotation.XmlType; |
| 19 | |
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
| 20 | |
import java.io.Serializable; |
| 21 | |
import java.util.ArrayList; |
| 22 | |
import java.util.Collection; |
| 23 | |
import java.util.Collections; |
| 24 | |
import java.util.List; |
| 25 | |
import java.util.Map; |
| 26 | |
|
| 27 | |
@XmlRootElement(name = ResponsibilityAction.Constants.ROOT_ELEMENT_NAME) |
| 28 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 29 | |
@XmlType(name = ResponsibilityAction.Constants.TYPE_NAME, propOrder = { |
| 30 | |
ResponsibilityAction.Elements.PRINCIPAL_ID, |
| 31 | |
ResponsibilityAction.Elements.ROLE_RESPONSIBILITY_ACTION_ID, |
| 32 | |
ResponsibilityAction.Elements.PARALLEL_ROUTING_GROUPING_CODE, |
| 33 | |
ResponsibilityAction.Elements.ACTION_TYPE_CODE, |
| 34 | |
ResponsibilityAction.Elements.ACTION_POLICY_CODE, |
| 35 | |
ResponsibilityAction.Elements.PRIORITY_NUMBER, |
| 36 | |
ResponsibilityAction.Elements.GROUP_ID, |
| 37 | |
ResponsibilityAction.Elements.MEMBER_ROLE_ID, |
| 38 | |
ResponsibilityAction.Elements.RESPONSIBILITY_NAME, |
| 39 | |
ResponsibilityAction.Elements.RESPONSIBILITY_ID, |
| 40 | |
ResponsibilityAction.Elements.RESPONSIBILITY_NAMESPACE_CODE, |
| 41 | |
ResponsibilityAction.Elements.FORCE_ACTION, |
| 42 | |
ResponsibilityAction.Elements.QUALIFIER, |
| 43 | |
ResponsibilityAction.Elements.DELEGATES, |
| 44 | |
ResponsibilityAction.Elements.ROLE_ID, |
| 45 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 46 | |
}) |
| 47 | 6 | public final class ResponsibilityAction extends AbstractDataTransferObject |
| 48 | |
implements ResponsibilityActionContract { |
| 49 | |
|
| 50 | |
@XmlElement(name = Elements.PRINCIPAL_ID, required = false) |
| 51 | |
private final String principalId; |
| 52 | |
@XmlElement(name = Elements.ROLE_RESPONSIBILITY_ACTION_ID, required = false) |
| 53 | |
private final String roleResponsibilityActionId; |
| 54 | |
@XmlElement(name = Elements.PARALLEL_ROUTING_GROUPING_CODE, required = false) |
| 55 | |
private final String parallelRoutingGroupingCode; |
| 56 | |
@XmlElement(name = Elements.ACTION_TYPE_CODE, required = false) |
| 57 | |
private final String actionTypeCode; |
| 58 | |
@XmlElement(name = Elements.ACTION_POLICY_CODE, required = false) |
| 59 | |
private final String actionPolicyCode; |
| 60 | |
@XmlElement(name = Elements.PRIORITY_NUMBER, required = false) |
| 61 | |
private final Integer priorityNumber; |
| 62 | |
@XmlElement(name = Elements.GROUP_ID, required = true) |
| 63 | |
private final String groupId; |
| 64 | |
@XmlElement(name = Elements.MEMBER_ROLE_ID, required = true) |
| 65 | |
private final String memberRoleId; |
| 66 | |
@XmlElement(name = Elements.RESPONSIBILITY_NAME, required = true) |
| 67 | |
private final String responsibilityName; |
| 68 | |
@XmlElement(name = Elements.RESPONSIBILITY_ID, required = true) |
| 69 | |
private final String responsibilityId; |
| 70 | |
@XmlElement(name = Elements.RESPONSIBILITY_NAMESPACE_CODE, required = true) |
| 71 | |
private final String responsibilityNamespaceCode; |
| 72 | |
@XmlElement(name = Elements.FORCE_ACTION, required = true) |
| 73 | |
private final boolean forceAction; |
| 74 | |
@XmlElement(name = Elements.QUALIFIER, required = true) |
| 75 | |
@XmlJavaTypeAdapter(value = MapStringStringAdapter.class) |
| 76 | |
private final Map<String, String> qualifier; |
| 77 | |
@XmlElement(name = Elements.DELEGATES, required = true) |
| 78 | |
private final List<DelegateType> delegates; |
| 79 | |
@XmlElement(name = Elements.ROLE_ID, required = true) |
| 80 | |
private final String roleId; |
| 81 | 8 | @SuppressWarnings("unused") |
| 82 | |
@XmlAnyElement |
| 83 | |
private final Collection<Element> _futureElements = null; |
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | 2 | private ResponsibilityAction() { |
| 89 | 2 | this.principalId = null; |
| 90 | 2 | this.roleResponsibilityActionId = null; |
| 91 | 2 | this.parallelRoutingGroupingCode = null; |
| 92 | 2 | this.actionTypeCode = null; |
| 93 | 2 | this.actionPolicyCode = null; |
| 94 | 2 | this.priorityNumber = null; |
| 95 | 2 | this.groupId = null; |
| 96 | 2 | this.memberRoleId = null; |
| 97 | 2 | this.responsibilityName = null; |
| 98 | 2 | this.responsibilityId = null; |
| 99 | 2 | this.responsibilityNamespaceCode = null; |
| 100 | 2 | this.forceAction = false; |
| 101 | 2 | this.qualifier = null; |
| 102 | 2 | this.delegates = null; |
| 103 | 2 | this.roleId = null; |
| 104 | 2 | } |
| 105 | |
|
| 106 | 6 | private ResponsibilityAction(Builder builder) { |
| 107 | 6 | this.principalId = builder.getPrincipalId(); |
| 108 | 6 | this.roleResponsibilityActionId = builder.getRoleResponsibilityActionId(); |
| 109 | 6 | this.parallelRoutingGroupingCode = builder.getParallelRoutingGroupingCode(); |
| 110 | 6 | this.actionTypeCode = builder.getActionTypeCode(); |
| 111 | 6 | this.actionPolicyCode = builder.getActionPolicyCode(); |
| 112 | 6 | this.priorityNumber = builder.getPriorityNumber(); |
| 113 | 6 | this.groupId = builder.getGroupId(); |
| 114 | 6 | this.memberRoleId = builder.getMemberRoleId(); |
| 115 | 6 | this.responsibilityName = builder.getResponsibilityName(); |
| 116 | 6 | this.responsibilityId = builder.getResponsibilityId(); |
| 117 | 6 | this.responsibilityNamespaceCode = builder.getResponsibilityNamespaceCode(); |
| 118 | 6 | this.forceAction = builder.isForceAction(); |
| 119 | 6 | this.qualifier = builder.getQualifier(); |
| 120 | 6 | final List<DelegateType> ds = new ArrayList<DelegateType>(); |
| 121 | 6 | for (DelegateType.Builder d : builder.getDelegates()) { |
| 122 | 0 | if (d != null) { |
| 123 | 0 | ds.add(d.build()); |
| 124 | |
} |
| 125 | |
} |
| 126 | 6 | this.delegates = ds; |
| 127 | 6 | this.roleId = builder.getRoleId(); |
| 128 | 6 | } |
| 129 | |
|
| 130 | |
@Override |
| 131 | |
public String getPrincipalId() { |
| 132 | 1 | return this.principalId; |
| 133 | |
} |
| 134 | |
|
| 135 | |
@Override |
| 136 | |
public String getRoleResponsibilityActionId() { |
| 137 | 1 | return this.roleResponsibilityActionId; |
| 138 | |
} |
| 139 | |
|
| 140 | |
@Override |
| 141 | |
public String getParallelRoutingGroupingCode() { |
| 142 | 1 | return this.parallelRoutingGroupingCode; |
| 143 | |
} |
| 144 | |
|
| 145 | |
@Override |
| 146 | |
public String getActionTypeCode() { |
| 147 | 1 | return this.actionTypeCode; |
| 148 | |
} |
| 149 | |
|
| 150 | |
@Override |
| 151 | |
public String getActionPolicyCode() { |
| 152 | 1 | return this.actionPolicyCode; |
| 153 | |
} |
| 154 | |
|
| 155 | |
@Override |
| 156 | |
public Integer getPriorityNumber() { |
| 157 | 1 | return this.priorityNumber; |
| 158 | |
} |
| 159 | |
|
| 160 | |
@Override |
| 161 | |
public String getGroupId() { |
| 162 | 1 | return this.groupId; |
| 163 | |
} |
| 164 | |
|
| 165 | |
@Override |
| 166 | |
public String getMemberRoleId() { |
| 167 | 1 | return this.memberRoleId; |
| 168 | |
} |
| 169 | |
|
| 170 | |
@Override |
| 171 | |
public String getResponsibilityName() { |
| 172 | 1 | return this.responsibilityName; |
| 173 | |
} |
| 174 | |
|
| 175 | |
@Override |
| 176 | |
public String getResponsibilityId() { |
| 177 | 1 | return this.responsibilityId; |
| 178 | |
} |
| 179 | |
|
| 180 | |
@Override |
| 181 | |
public String getResponsibilityNamespaceCode() { |
| 182 | 1 | return this.responsibilityNamespaceCode; |
| 183 | |
} |
| 184 | |
|
| 185 | |
@Override |
| 186 | |
public boolean isForceAction() { |
| 187 | 1 | return this.forceAction; |
| 188 | |
} |
| 189 | |
|
| 190 | |
@Override |
| 191 | |
public Map<String, String> getQualifier() { |
| 192 | 1 | return this.qualifier; |
| 193 | |
} |
| 194 | |
|
| 195 | |
@Override |
| 196 | |
public List<DelegateType> getDelegates() { |
| 197 | 1 | return Collections.unmodifiableList(this.delegates); |
| 198 | |
} |
| 199 | |
|
| 200 | |
@Override |
| 201 | |
public String getRoleId() { |
| 202 | 1 | return this.roleId; |
| 203 | |
} |
| 204 | |
|
| 205 | |
|
| 206 | |
|
| 207 | |
|
| 208 | |
|
| 209 | 7 | public final static class Builder |
| 210 | |
implements Serializable, ModelBuilder, ResponsibilityActionContract { |
| 211 | |
|
| 212 | |
private String principalId; |
| 213 | |
private String roleResponsibilityActionId; |
| 214 | |
private String parallelRoutingGroupingCode; |
| 215 | |
private String actionTypeCode; |
| 216 | |
private String actionPolicyCode; |
| 217 | |
private Integer priorityNumber; |
| 218 | |
private String groupId; |
| 219 | |
private String memberRoleId; |
| 220 | |
private String responsibilityName; |
| 221 | |
private String responsibilityId; |
| 222 | |
private String responsibilityNamespaceCode; |
| 223 | |
private boolean forceAction; |
| 224 | |
private Map<String, String> qualifier; |
| 225 | |
private List<DelegateType.Builder> delegates; |
| 226 | |
private String roleId; |
| 227 | |
|
| 228 | 24 | private Builder() { |
| 229 | 24 | } |
| 230 | |
|
| 231 | |
|
| 232 | |
|
| 233 | |
|
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | |
public static Builder create() { |
| 238 | |
|
| 239 | 24 | return new Builder(); |
| 240 | |
} |
| 241 | |
|
| 242 | |
public static Builder create(ResponsibilityActionContract contract) { |
| 243 | 1 | if (contract == null) { |
| 244 | 0 | throw new IllegalArgumentException("contract was null"); |
| 245 | |
} |
| 246 | 1 | Builder builder = create(); |
| 247 | 1 | builder.setPrincipalId(contract.getPrincipalId()); |
| 248 | 1 | builder.setRoleResponsibilityActionId(contract.getRoleResponsibilityActionId()); |
| 249 | 1 | builder.setParallelRoutingGroupingCode(contract.getParallelRoutingGroupingCode()); |
| 250 | 1 | builder.setActionTypeCode(contract.getActionTypeCode()); |
| 251 | 1 | builder.setActionPolicyCode(contract.getActionPolicyCode()); |
| 252 | 1 | builder.setPriorityNumber(contract.getPriorityNumber()); |
| 253 | 1 | builder.setGroupId(contract.getGroupId()); |
| 254 | 1 | builder.setMemberRoleId(contract.getMemberRoleId()); |
| 255 | 1 | builder.setResponsibilityName(contract.getResponsibilityName()); |
| 256 | 1 | builder.setResponsibilityId(contract.getResponsibilityId()); |
| 257 | 1 | builder.setResponsibilityNamespaceCode(contract.getResponsibilityNamespaceCode()); |
| 258 | 1 | builder.setForceAction(contract.isForceAction()); |
| 259 | 1 | builder.setQualifier(contract.getQualifier()); |
| 260 | 1 | final List<DelegateType.Builder> dbs = new ArrayList<DelegateType.Builder>(); |
| 261 | 1 | for (DelegateTypeContract d : contract.getDelegates()) { |
| 262 | 0 | if (d != null) { |
| 263 | 0 | dbs.add(DelegateType.Builder.create(d)); |
| 264 | |
} |
| 265 | |
} |
| 266 | 1 | builder.setDelegates(dbs); |
| 267 | 1 | builder.setRoleId(contract.getRoleId()); |
| 268 | 1 | return builder; |
| 269 | |
} |
| 270 | |
|
| 271 | |
public ResponsibilityAction build() { |
| 272 | |
|
| 273 | 7 | final boolean requiredSet = (groupId != null ^ principalId != null) && |
| 274 | |
memberRoleId != null && |
| 275 | |
responsibilityName != null && |
| 276 | |
responsibilityId != null && |
| 277 | |
responsibilityNamespaceCode != null && |
| 278 | |
qualifier != null && |
| 279 | |
delegates != null && |
| 280 | |
roleId != null; |
| 281 | |
|
| 282 | 7 | if (!requiredSet) { |
| 283 | 1 | throw new IllegalStateException("all the required fields are not set"); |
| 284 | |
} |
| 285 | 6 | return new ResponsibilityAction(this); |
| 286 | |
} |
| 287 | |
|
| 288 | |
@Override |
| 289 | |
public String getPrincipalId() { |
| 290 | 6 | return this.principalId; |
| 291 | |
} |
| 292 | |
|
| 293 | |
@Override |
| 294 | |
public String getRoleResponsibilityActionId() { |
| 295 | 6 | return this.roleResponsibilityActionId; |
| 296 | |
} |
| 297 | |
|
| 298 | |
@Override |
| 299 | |
public String getParallelRoutingGroupingCode() { |
| 300 | 6 | return this.parallelRoutingGroupingCode; |
| 301 | |
} |
| 302 | |
|
| 303 | |
@Override |
| 304 | |
public String getActionTypeCode() { |
| 305 | 6 | return this.actionTypeCode; |
| 306 | |
} |
| 307 | |
|
| 308 | |
@Override |
| 309 | |
public String getActionPolicyCode() { |
| 310 | 6 | return this.actionPolicyCode; |
| 311 | |
} |
| 312 | |
|
| 313 | |
@Override |
| 314 | |
public Integer getPriorityNumber() { |
| 315 | 6 | return this.priorityNumber; |
| 316 | |
} |
| 317 | |
|
| 318 | |
@Override |
| 319 | |
public String getGroupId() { |
| 320 | 6 | return this.groupId; |
| 321 | |
} |
| 322 | |
|
| 323 | |
@Override |
| 324 | |
public String getMemberRoleId() { |
| 325 | 6 | return this.memberRoleId; |
| 326 | |
} |
| 327 | |
|
| 328 | |
@Override |
| 329 | |
public String getResponsibilityName() { |
| 330 | 6 | return this.responsibilityName; |
| 331 | |
} |
| 332 | |
|
| 333 | |
@Override |
| 334 | |
public String getResponsibilityId() { |
| 335 | 6 | return this.responsibilityId; |
| 336 | |
} |
| 337 | |
|
| 338 | |
@Override |
| 339 | |
public String getResponsibilityNamespaceCode() { |
| 340 | 6 | return this.responsibilityNamespaceCode; |
| 341 | |
} |
| 342 | |
|
| 343 | |
@Override |
| 344 | |
public boolean isForceAction() { |
| 345 | 6 | return this.forceAction; |
| 346 | |
} |
| 347 | |
|
| 348 | |
@Override |
| 349 | |
public Map<String, String> getQualifier() { |
| 350 | 6 | return this.qualifier; |
| 351 | |
} |
| 352 | |
|
| 353 | |
@Override |
| 354 | |
public List<DelegateType.Builder> getDelegates() { |
| 355 | 6 | return Collections.unmodifiableList(this.delegates); |
| 356 | |
} |
| 357 | |
|
| 358 | |
@Override |
| 359 | |
public String getRoleId() { |
| 360 | 6 | return this.roleId; |
| 361 | |
} |
| 362 | |
|
| 363 | |
public void setPrincipalId(String principalId) { |
| 364 | 4 | this.principalId = principalId; |
| 365 | 4 | } |
| 366 | |
|
| 367 | |
public void setRoleResponsibilityActionId(String roleResponsibilityActionId) { |
| 368 | 1 | this.roleResponsibilityActionId = roleResponsibilityActionId; |
| 369 | 1 | } |
| 370 | |
|
| 371 | |
public void setParallelRoutingGroupingCode(String parallelRoutingGroupingCode) { |
| 372 | 1 | this.parallelRoutingGroupingCode = parallelRoutingGroupingCode; |
| 373 | 1 | } |
| 374 | |
|
| 375 | |
public void setActionTypeCode(String actionTypeCode) { |
| 376 | 1 | this.actionTypeCode = actionTypeCode; |
| 377 | 1 | } |
| 378 | |
|
| 379 | |
public void setActionPolicyCode(String actionPolicyCode) { |
| 380 | 1 | this.actionPolicyCode = actionPolicyCode; |
| 381 | 1 | } |
| 382 | |
|
| 383 | |
public void setPriorityNumber(Integer priorityNumber) { |
| 384 | 1 | this.priorityNumber = priorityNumber; |
| 385 | 1 | } |
| 386 | |
|
| 387 | |
public void setGroupId(String groupId) { |
| 388 | 27 | this.groupId = groupId; |
| 389 | 27 | } |
| 390 | |
|
| 391 | |
public void setMemberRoleId(String memberRoleId) { |
| 392 | 27 | if (StringUtils.isBlank(memberRoleId)) { |
| 393 | 3 | throw new IllegalArgumentException("memberRoleId is blank"); |
| 394 | |
} |
| 395 | |
|
| 396 | 24 | this.memberRoleId = memberRoleId; |
| 397 | 24 | } |
| 398 | |
|
| 399 | |
public void setResponsibilityName(String responsibilityName) { |
| 400 | 27 | if (StringUtils.isBlank(responsibilityName)) { |
| 401 | 3 | throw new IllegalArgumentException("responsibilityName is blank"); |
| 402 | |
} |
| 403 | |
|
| 404 | 24 | this.responsibilityName = responsibilityName; |
| 405 | 24 | } |
| 406 | |
|
| 407 | |
public void setResponsibilityId(String responsibilityId) { |
| 408 | 27 | if (StringUtils.isBlank(responsibilityId)) { |
| 409 | 3 | throw new IllegalArgumentException("responsibilityId is blank"); |
| 410 | |
} |
| 411 | |
|
| 412 | 24 | this.responsibilityId = responsibilityId; |
| 413 | 24 | } |
| 414 | |
|
| 415 | |
public void setResponsibilityNamespaceCode(String responsibilityNamespaceCode) { |
| 416 | 27 | if (StringUtils.isBlank(responsibilityNamespaceCode)) { |
| 417 | 3 | throw new IllegalArgumentException("responsibilityNamespaceCode is blank"); |
| 418 | |
} |
| 419 | 24 | this.responsibilityNamespaceCode = responsibilityNamespaceCode; |
| 420 | 24 | } |
| 421 | |
|
| 422 | |
public void setForceAction(boolean forceAction) { |
| 423 | 1 | this.forceAction = forceAction; |
| 424 | 1 | } |
| 425 | |
|
| 426 | |
public void setQualifier(Map<String, String> qualifier) { |
| 427 | 25 | if (qualifier == null) { |
| 428 | 1 | throw new IllegalArgumentException("qualifier is null"); |
| 429 | |
} |
| 430 | 24 | this.qualifier = Collections.unmodifiableMap(Maps.newHashMap(qualifier)); |
| 431 | 24 | } |
| 432 | |
|
| 433 | |
public void setDelegates(List<DelegateType.Builder> delegates) { |
| 434 | 25 | if (delegates == null) { |
| 435 | 1 | throw new IllegalArgumentException("delegates is null"); |
| 436 | |
} |
| 437 | 24 | this.delegates = new ArrayList<DelegateType.Builder>(delegates); |
| 438 | 24 | } |
| 439 | |
|
| 440 | |
public void setRoleId(String roleId) { |
| 441 | 27 | if (StringUtils.isBlank(roleId)) { |
| 442 | 3 | throw new IllegalArgumentException("roleId is blank"); |
| 443 | |
} |
| 444 | 24 | this.roleId = roleId; |
| 445 | 24 | } |
| 446 | |
|
| 447 | |
} |
| 448 | |
|
| 449 | |
|
| 450 | |
|
| 451 | |
|
| 452 | |
|
| 453 | 0 | static class Constants { |
| 454 | |
|
| 455 | |
final static String ROOT_ELEMENT_NAME = "responsibilityAction"; |
| 456 | |
final static String TYPE_NAME = "ResponsibilityActionType"; |
| 457 | |
} |
| 458 | |
|
| 459 | |
|
| 460 | |
|
| 461 | |
|
| 462 | |
|
| 463 | 0 | static class Elements { |
| 464 | |
|
| 465 | |
final static String PRINCIPAL_ID = "principalId"; |
| 466 | |
final static String ROLE_RESPONSIBILITY_ACTION_ID = "roleResponsibilityActionId"; |
| 467 | |
final static String PARALLEL_ROUTING_GROUPING_CODE = "parallelRoutingGroupingCode"; |
| 468 | |
final static String ACTION_TYPE_CODE = "actionTypeCode"; |
| 469 | |
final static String ACTION_POLICY_CODE = "actionPolicyCode"; |
| 470 | |
final static String PRIORITY_NUMBER = "priorityNumber"; |
| 471 | |
final static String GROUP_ID = "groupId"; |
| 472 | |
final static String MEMBER_ROLE_ID = "memberRoleId"; |
| 473 | |
final static String RESPONSIBILITY_NAME = "responsibilityName"; |
| 474 | |
final static String RESPONSIBILITY_ID = "responsibilityId"; |
| 475 | |
final static String RESPONSIBILITY_NAMESPACE_CODE = "responsibilityNamespaceCode"; |
| 476 | |
final static String FORCE_ACTION = "forceAction"; |
| 477 | |
final static String QUALIFIER = "qualifier"; |
| 478 | |
final static String DELEGATES = "delegates"; |
| 479 | |
final static String ROLE_ID = "roleId"; |
| 480 | |
|
| 481 | |
} |
| 482 | |
|
| 483 | |
} |