Coverage Report - org.kuali.rice.kim.api.responsibility.ResponsibilityAction
 
Classes in this File Line Coverage Branch Coverage Complexity
ResponsibilityAction
0%
0/58
0%
0/4
1.574
ResponsibilityAction$1
N/A
N/A
1.574
ResponsibilityAction$Builder
0%
0/92
0%
0/44
1.574
ResponsibilityAction$Constants
0%
0/2
N/A
1.574
ResponsibilityAction$Elements
0%
0/1
N/A
1.574
 
 1  
 package org.kuali.rice.kim.api.responsibility;
 2  
 
 3  
 import org.apache.commons.lang.StringUtils;
 4  
 import org.apache.commons.lang.builder.EqualsBuilder;
 5  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 6  
 import org.apache.commons.lang.builder.ToStringBuilder;
 7  
 import org.kuali.rice.core.api.CoreConstants;
 8  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 9  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 10  
 import org.kuali.rice.core.api.mo.common.Attributes;
 11  
 import org.kuali.rice.kim.api.common.delegate.Delegate;
 12  
 import org.kuali.rice.kim.api.common.delegate.DelegateContract;
 13  
 import org.w3c.dom.Element;
 14  
 
 15  
 import javax.xml.bind.annotation.XmlAccessType;
 16  
 import javax.xml.bind.annotation.XmlAccessorType;
 17  
 import javax.xml.bind.annotation.XmlAnyElement;
 18  
 import javax.xml.bind.annotation.XmlElement;
 19  
 import javax.xml.bind.annotation.XmlRootElement;
 20  
 import javax.xml.bind.annotation.XmlType;
 21  
 import java.io.Serializable;
 22  
 import java.util.ArrayList;
 23  
 import java.util.Collection;
 24  
 import java.util.Collections;
 25  
 import java.util.List;
 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  0
 public final class ResponsibilityAction
 48  
         implements ModelObjectComplete, 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  
     private final Attributes qualifier;
 76  
     @XmlElement(name = Elements.DELEGATES, required = true)
 77  
     private final List<Delegate> delegates;
 78  
     @XmlElement(name = Elements.ROLE_ID, required = true)
 79  
     private final String roleId;
 80  0
     @SuppressWarnings("unused")
 81  
     @XmlAnyElement
 82  
     private final Collection<Element> _futureElements = null;
 83  
 
 84  
     /**
 85  
      * Private constructor used only by JAXB.
 86  
      */
 87  0
     private ResponsibilityAction() {
 88  0
         this.principalId = null;
 89  0
         this.roleResponsibilityActionId = null;
 90  0
         this.parallelRoutingGroupingCode = null;
 91  0
         this.actionTypeCode = null;
 92  0
         this.actionPolicyCode = null;
 93  0
         this.priorityNumber = null;
 94  0
         this.groupId = null;
 95  0
         this.memberRoleId = null;
 96  0
         this.responsibilityName = null;
 97  0
         this.responsibilityId = null;
 98  0
         this.responsibilityNamespaceCode = null;
 99  0
         this.forceAction = false;
 100  0
         this.qualifier = null;
 101  0
         this.delegates = null;
 102  0
         this.roleId = null;
 103  0
     }
 104  
 
 105  0
     private ResponsibilityAction(Builder builder) {
 106  0
         this.principalId = builder.getPrincipalId();
 107  0
         this.roleResponsibilityActionId = builder.getRoleResponsibilityActionId();
 108  0
         this.parallelRoutingGroupingCode = builder.getParallelRoutingGroupingCode();
 109  0
         this.actionTypeCode = builder.getActionTypeCode();
 110  0
         this.actionPolicyCode = builder.getActionPolicyCode();
 111  0
         this.priorityNumber = builder.getPriorityNumber();
 112  0
         this.groupId = builder.getGroupId();
 113  0
         this.memberRoleId = builder.getMemberRoleId();
 114  0
         this.responsibilityName = builder.getResponsibilityName();
 115  0
         this.responsibilityId = builder.getResponsibilityId();
 116  0
         this.responsibilityNamespaceCode = builder.getResponsibilityNamespaceCode();
 117  0
         this.forceAction = builder.isForceAction();
 118  0
         this.qualifier = builder.getQualifier();
 119  0
         final List<Delegate> ds = new ArrayList<Delegate>();
 120  0
         for (Delegate.Builder d : builder.getDelegates()) {
 121  0
             if (d != null) {
 122  0
                 ds.add(d.build());
 123  
             }
 124  
         }
 125  0
         this.delegates = ds;
 126  0
         this.roleId = builder.getRoleId();
 127  0
     }
 128  
 
 129  
     @Override
 130  
     public String getPrincipalId() {
 131  0
         return this.principalId;
 132  
     }
 133  
 
 134  
     @Override
 135  
     public String getRoleResponsibilityActionId() {
 136  0
         return this.roleResponsibilityActionId;
 137  
     }
 138  
 
 139  
     @Override
 140  
     public String getParallelRoutingGroupingCode() {
 141  0
         return this.parallelRoutingGroupingCode;
 142  
     }
 143  
 
 144  
     @Override
 145  
     public String getActionTypeCode() {
 146  0
         return this.actionTypeCode;
 147  
     }
 148  
 
 149  
     @Override
 150  
     public String getActionPolicyCode() {
 151  0
         return this.actionPolicyCode;
 152  
     }
 153  
 
 154  
     @Override
 155  
     public Integer getPriorityNumber() {
 156  0
         return this.priorityNumber;
 157  
     }
 158  
 
 159  
     @Override
 160  
     public String getGroupId() {
 161  0
         return this.groupId;
 162  
     }
 163  
 
 164  
     @Override
 165  
     public String getMemberRoleId() {
 166  0
         return this.memberRoleId;
 167  
     }
 168  
 
 169  
     @Override
 170  
     public String getResponsibilityName() {
 171  0
         return this.responsibilityName;
 172  
     }
 173  
 
 174  
     @Override
 175  
     public String getResponsibilityId() {
 176  0
         return this.responsibilityId;
 177  
     }
 178  
 
 179  
     @Override
 180  
     public String getResponsibilityNamespaceCode() {
 181  0
         return this.responsibilityNamespaceCode;
 182  
     }
 183  
 
 184  
     @Override
 185  
     public boolean isForceAction() {
 186  0
         return this.forceAction;
 187  
     }
 188  
 
 189  
     @Override
 190  
     public Attributes getQualifier() {
 191  0
         return this.qualifier;
 192  
     }
 193  
 
 194  
     @Override
 195  
     public List<Delegate> getDelegates() {
 196  0
         return Collections.unmodifiableList(this.delegates);
 197  
     }
 198  
 
 199  
     @Override
 200  
     public String getRoleId() {
 201  0
         return this.roleId;
 202  
     }
 203  
 
 204  
     @Override
 205  
     public int hashCode() {
 206  0
         return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 207  
     }
 208  
 
 209  
     @Override
 210  
     public boolean equals(Object object) {
 211  0
         return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 212  
     }
 213  
 
 214  
     @Override
 215  
     public String toString() {
 216  0
         return ToStringBuilder.reflectionToString(this);
 217  
     }
 218  
 
 219  
 
 220  
     /**
 221  
      * A builder which can be used to construct {@link ResponsibilityAction} instances.  Enforces the constraints of the {@link ResponsibilityActionContract}.
 222  
      */
 223  0
     public final static class Builder
 224  
             implements Serializable, ModelBuilder, ResponsibilityActionContract {
 225  
 
 226  
         private String principalId;
 227  
         private String roleResponsibilityActionId;
 228  
         private String parallelRoutingGroupingCode;
 229  
         private String actionTypeCode;
 230  
         private String actionPolicyCode;
 231  
         private Integer priorityNumber;
 232  
         private String groupId;
 233  
         private String memberRoleId;
 234  
         private String responsibilityName;
 235  
         private String responsibilityId;
 236  
         private String responsibilityNamespaceCode;
 237  
         private boolean forceAction;
 238  
         private Attributes qualifier;
 239  
         private List<Delegate.Builder> delegates;
 240  
         private String roleId;
 241  
 
 242  0
         private Builder() {
 243  0
         }
 244  
 
 245  
         /**
 246  
          * All required fields are enforced in the {@link org.kuali.rice.kim.api.responsibility.ResponsibilityAction.Builder#build()}
 247  
          * method.  Please see {@link ResponsibilityActionContract} to see what fields are required.
 248  
          *
 249  
          * @return a new builder, not yet in a valid state
 250  
          */
 251  
         public static Builder create() {
 252  
             //there is a lot of required fields - require fields are enforced at build time
 253  0
             return new Builder();
 254  
         }
 255  
 
 256  
         public static Builder create(ResponsibilityActionContract contract) {
 257  0
             if (contract == null) {
 258  0
                 throw new IllegalArgumentException("contract was null");
 259  
             }
 260  0
             Builder builder = create();
 261  0
             builder.setPrincipalId(contract.getPrincipalId());
 262  0
             builder.setRoleResponsibilityActionId(contract.getRoleResponsibilityActionId());
 263  0
             builder.setParallelRoutingGroupingCode(contract.getParallelRoutingGroupingCode());
 264  0
             builder.setActionTypeCode(contract.getActionTypeCode());
 265  0
             builder.setActionPolicyCode(contract.getActionPolicyCode());
 266  0
             builder.setPriorityNumber(contract.getPriorityNumber());
 267  0
             builder.setGroupId(contract.getGroupId());
 268  0
             builder.setMemberRoleId(contract.getMemberRoleId());
 269  0
             builder.setResponsibilityName(contract.getResponsibilityName());
 270  0
             builder.setResponsibilityId(contract.getResponsibilityId());
 271  0
             builder.setResponsibilityNamespaceCode(contract.getResponsibilityNamespaceCode());
 272  0
             builder.setForceAction(contract.isForceAction());
 273  0
             builder.setQualifier(contract.getQualifier());
 274  0
             final List<Delegate.Builder> dbs = new ArrayList<Delegate.Builder>();
 275  0
             for (DelegateContract d : contract.getDelegates()) {
 276  0
                 if (d != null) {
 277  0
                     dbs.add(Delegate.Builder.create(d));
 278  
                 }
 279  
             }
 280  0
             builder.setDelegates(dbs);
 281  0
             builder.setRoleId(contract.getRoleId());
 282  0
             return builder;
 283  
         }
 284  
 
 285  
         public ResponsibilityAction build() {
 286  
             //validate required fields
 287  0
             final boolean requiredSet = (groupId != null ^ principalId != null) &&
 288  
                             memberRoleId != null &&
 289  
                             responsibilityName != null &&
 290  
                             responsibilityId != null &&
 291  
                             responsibilityNamespaceCode != null &&
 292  
                             qualifier != null &&
 293  
                             delegates != null &&
 294  
                             roleId != null;
 295  
 
 296  0
             if (!requiredSet) {
 297  0
                 throw new IllegalStateException("all the required fields are not set");
 298  
             }
 299  0
             return new ResponsibilityAction(this);
 300  
         }
 301  
 
 302  
         @Override
 303  
         public String getPrincipalId() {
 304  0
             return this.principalId;
 305  
         }
 306  
 
 307  
         @Override
 308  
         public String getRoleResponsibilityActionId() {
 309  0
             return this.roleResponsibilityActionId;
 310  
         }
 311  
 
 312  
         @Override
 313  
         public String getParallelRoutingGroupingCode() {
 314  0
             return this.parallelRoutingGroupingCode;
 315  
         }
 316  
 
 317  
         @Override
 318  
         public String getActionTypeCode() {
 319  0
             return this.actionTypeCode;
 320  
         }
 321  
 
 322  
         @Override
 323  
         public String getActionPolicyCode() {
 324  0
             return this.actionPolicyCode;
 325  
         }
 326  
 
 327  
         @Override
 328  
         public Integer getPriorityNumber() {
 329  0
             return this.priorityNumber;
 330  
         }
 331  
 
 332  
         @Override
 333  
         public String getGroupId() {
 334  0
             return this.groupId;
 335  
         }
 336  
 
 337  
         @Override
 338  
         public String getMemberRoleId() {
 339  0
             return this.memberRoleId;
 340  
         }
 341  
 
 342  
         @Override
 343  
         public String getResponsibilityName() {
 344  0
             return this.responsibilityName;
 345  
         }
 346  
 
 347  
         @Override
 348  
         public String getResponsibilityId() {
 349  0
             return this.responsibilityId;
 350  
         }
 351  
 
 352  
         @Override
 353  
         public String getResponsibilityNamespaceCode() {
 354  0
             return this.responsibilityNamespaceCode;
 355  
         }
 356  
 
 357  
         @Override
 358  
         public boolean isForceAction() {
 359  0
             return this.forceAction;
 360  
         }
 361  
 
 362  
         @Override
 363  
         public Attributes getQualifier() {
 364  0
             return this.qualifier;
 365  
         }
 366  
 
 367  
         @Override
 368  
         public List<Delegate.Builder> getDelegates() {
 369  0
             return Collections.unmodifiableList(this.delegates);
 370  
         }
 371  
 
 372  
         @Override
 373  
         public String getRoleId() {
 374  0
             return this.roleId;
 375  
         }
 376  
 
 377  
         public void setPrincipalId(String principalId) {
 378  0
             this.principalId = principalId;
 379  0
         }
 380  
 
 381  
         public void setRoleResponsibilityActionId(String roleResponsibilityActionId) {
 382  0
             this.roleResponsibilityActionId = roleResponsibilityActionId;
 383  0
         }
 384  
 
 385  
         public void setParallelRoutingGroupingCode(String parallelRoutingGroupingCode) {
 386  0
             this.parallelRoutingGroupingCode = parallelRoutingGroupingCode;
 387  0
         }
 388  
 
 389  
         public void setActionTypeCode(String actionTypeCode) {
 390  0
             this.actionTypeCode = actionTypeCode;
 391  0
         }
 392  
 
 393  
         public void setActionPolicyCode(String actionPolicyCode) {
 394  0
             this.actionPolicyCode = actionPolicyCode;
 395  0
         }
 396  
 
 397  
         public void setPriorityNumber(Integer priorityNumber) {
 398  0
             this.priorityNumber = priorityNumber;
 399  0
         }
 400  
 
 401  
         public void setGroupId(String groupId) {
 402  0
             if (StringUtils.isBlank(groupId)) {
 403  0
                 throw new IllegalArgumentException("groupId is blank");
 404  
             }
 405  
 
 406  0
             this.groupId = groupId;
 407  0
         }
 408  
 
 409  
         public void setMemberRoleId(String memberRoleId) {
 410  0
             if (StringUtils.isBlank(memberRoleId)) {
 411  0
                 throw new IllegalArgumentException("memberRoleId is blank");
 412  
             }
 413  
 
 414  0
             this.memberRoleId = memberRoleId;
 415  0
         }
 416  
 
 417  
         public void setResponsibilityName(String responsibilityName) {
 418  0
             if (StringUtils.isBlank(responsibilityName)) {
 419  0
                 throw new IllegalArgumentException("responsibilityName is blank");
 420  
             }
 421  
 
 422  0
             this.responsibilityName = responsibilityName;
 423  0
         }
 424  
 
 425  
         public void setResponsibilityId(String responsibilityId) {
 426  0
             if (StringUtils.isBlank(responsibilityId)) {
 427  0
                 throw new IllegalArgumentException("responsibilityId is blank");
 428  
             }
 429  
 
 430  0
             this.responsibilityId = responsibilityId;
 431  0
         }
 432  
 
 433  
         public void setResponsibilityNamespaceCode(String responsibilityNamespaceCode) {
 434  0
             if (StringUtils.isBlank(responsibilityNamespaceCode)) {
 435  0
                 throw new IllegalArgumentException("responsibilityNamespaceCode is blank");
 436  
             }
 437  0
             this.responsibilityNamespaceCode = responsibilityNamespaceCode;
 438  0
         }
 439  
 
 440  
         public void setForceAction(boolean forceAction) {
 441  0
             this.forceAction = forceAction;
 442  0
         }
 443  
 
 444  
         public void setQualifier(Attributes qualifier) {
 445  0
             if (qualifier == null) {
 446  0
                 throw new IllegalArgumentException("qualifier is null");
 447  
             }
 448  0
             this.qualifier = qualifier;
 449  0
         }
 450  
 
 451  
         public void setDelegates(List<Delegate.Builder> delegates) {
 452  0
             if (delegates == null) {
 453  0
                 throw new IllegalArgumentException("delegates is null");
 454  
             }
 455  0
             this.delegates = new ArrayList<Delegate.Builder>(delegates);
 456  0
         }
 457  
 
 458  
         public void setRoleId(String roleId) {
 459  0
             if (StringUtils.isBlank(roleId)) {
 460  0
                 throw new IllegalArgumentException("roleId is blank");
 461  
             }
 462  0
             this.roleId = roleId;
 463  0
         }
 464  
 
 465  
     }
 466  
 
 467  
 
 468  
     /**
 469  
      * Defines some internal constants used on this class.
 470  
      */
 471  0
     static class Constants {
 472  
 
 473  
         final static String ROOT_ELEMENT_NAME = "responsibilityAction";
 474  
         final static String TYPE_NAME = "ResponsibilityActionType";
 475  0
         final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[]{CoreConstants.CommonElements.FUTURE_ELEMENTS};
 476  
 
 477  
     }
 478  
 
 479  
 
 480  
     /**
 481  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 482  
      */
 483  0
     static class Elements {
 484  
 
 485  
         final static String PRINCIPAL_ID = "principalId";
 486  
         final static String ROLE_RESPONSIBILITY_ACTION_ID = "roleResponsibilityActionId";
 487  
         final static String PARALLEL_ROUTING_GROUPING_CODE = "parallelRoutingGroupingCode";
 488  
         final static String ACTION_TYPE_CODE = "actionTypeCode";
 489  
         final static String ACTION_POLICY_CODE = "actionPolicyCode";
 490  
         final static String PRIORITY_NUMBER = "priorityNumber";
 491  
         final static String GROUP_ID = "groupId";
 492  
         final static String MEMBER_ROLE_ID = "memberRoleId";
 493  
         final static String RESPONSIBILITY_NAME = "responsibilityName";
 494  
         final static String RESPONSIBILITY_ID = "responsibilityId";
 495  
         final static String RESPONSIBILITY_NAMESPACE_CODE = "responsibilityNamespaceCode";
 496  
         final static String FORCE_ACTION = "forceAction";
 497  
         final static String QUALIFIER = "qualifier";
 498  
         final static String DELEGATES = "delegates";
 499  
         final static String ROLE_ID = "roleId";
 500  
 
 501  
     }
 502  
 
 503  
 }