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