Coverage Report - org.kuali.rice.kew.api.doctype.RouteNode
 
Classes in this File Line Coverage Branch Coverage Complexity
RouteNode
100%
57/57
75%
3/4
1.278
RouteNode$1
N/A
N/A
1.278
RouteNode$Builder
94%
86/91
64%
9/14
1.278
RouteNode$Constants
0%
0/1
N/A
1.278
RouteNode$Elements
0%
0/1
N/A
1.278
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.kew.api.doctype;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.core.api.CoreConstants;
 20  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 21  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 22  
 import org.kuali.rice.core.api.util.collect.CollectionUtils;
 23  
 import org.w3c.dom.Element;
 24  
 
 25  
 import javax.xml.bind.annotation.XmlAccessType;
 26  
 import javax.xml.bind.annotation.XmlAccessorType;
 27  
 import javax.xml.bind.annotation.XmlAnyElement;
 28  
 import javax.xml.bind.annotation.XmlElement;
 29  
 import javax.xml.bind.annotation.XmlElementWrapper;
 30  
 import javax.xml.bind.annotation.XmlRootElement;
 31  
 import javax.xml.bind.annotation.XmlType;
 32  
 import java.io.Serializable;
 33  
 import java.util.ArrayList;
 34  
 import java.util.Collection;
 35  
 import java.util.List;
 36  
 
 37  
 @XmlRootElement(name = RouteNode.Constants.ROOT_ELEMENT_NAME)
 38  
 @XmlAccessorType(XmlAccessType.NONE)
 39  
 @XmlType(name = RouteNode.Constants.TYPE_NAME, propOrder = {
 40  
         RouteNode.Elements.ID,
 41  
         RouteNode.Elements.DOCUMENT_TYPE_ID,
 42  
         RouteNode.Elements.NAME,
 43  
         RouteNode.Elements.ROUTE_METHOD_NAME,
 44  
         RouteNode.Elements.ROUTE_METHOD_CODE,
 45  
         RouteNode.Elements.FINAL_APPROVAL,
 46  
         RouteNode.Elements.MANDATORY,
 47  
         RouteNode.Elements.ACTIVATION_TYPE,
 48  
         RouteNode.Elements.EXCEPTION_GROUP_ID,
 49  
         RouteNode.Elements.TYPE,
 50  
         RouteNode.Elements.BRANCH_NAME,
 51  
         RouteNode.Elements.NEXT_DOCUMENT_STATUS,
 52  
         RouteNode.Elements.CONFIGURATION_PARAMETERS,
 53  
         RouteNode.Elements.PREVIOUS_NODE_IDS,
 54  
         RouteNode.Elements.NEXT_NODE_IDS,
 55  
         CoreConstants.CommonElements.VERSION_NUMBER,
 56  
         CoreConstants.CommonElements.FUTURE_ELEMENTS
 57  
 })
 58  3
 public final class RouteNode extends AbstractDataTransferObject implements RouteNodeContract {
 59  
 
 60  
     private static final long serialVersionUID = -1756380702013287285L;
 61  
 
 62  
     @XmlElement(name = Elements.ID, required = false)
 63  
     private final String id;
 64  
 
 65  
     @XmlElement(name = Elements.DOCUMENT_TYPE_ID, required = false)
 66  
     private final String documentTypeId;
 67  
 
 68  
     @XmlElement(name = Elements.NAME, required = true)
 69  
     private final String name;
 70  
 
 71  
     @XmlElement(name = Elements.ROUTE_METHOD_NAME, required = false)
 72  
     private final String routeMethodName;
 73  
 
 74  
     @XmlElement(name = Elements.ROUTE_METHOD_CODE, required = false)
 75  
     private final String routeMethodCode;
 76  
 
 77  
     @XmlElement(name = Elements.FINAL_APPROVAL, required = false)
 78  
     private final boolean finalApproval;
 79  
 
 80  
     @XmlElement(name = Elements.MANDATORY, required = false)
 81  
     private final boolean mandatory;
 82  
 
 83  
     @XmlElement(name = Elements.ACTIVATION_TYPE, required = false)
 84  
     private final String activationType;
 85  
 
 86  
     @XmlElement(name = Elements.EXCEPTION_GROUP_ID, required = false)
 87  
     private final String exceptionGroupId;
 88  
 
 89  
     @XmlElement(name = Elements.TYPE, required = true)
 90  
     private final String type;
 91  
 
 92  
     @XmlElement(name = Elements.BRANCH_NAME, required = false)
 93  
     private final String branchName;
 94  
     
 95  
     @XmlElement(name = Elements.NEXT_DOCUMENT_STATUS, required = false)
 96  
     private final String nextDocumentStatus;
 97  
     
 98  
     @XmlElementWrapper(name = Elements.CONFIGURATION_PARAMETERS, required = false)
 99  
     @XmlElement(name = Elements.CONFIGURATION_PARAMETER, required = false)
 100  
     private final List<RouteNodeConfigurationParameter> configurationParameters;
 101  
 
 102  
     @XmlElementWrapper(name = Elements.PREVIOUS_NODE_IDS, required = false)
 103  
     @XmlElement(name = Elements.PREVIOUS_NODE_ID, required = false)
 104  
     private final List<String> previousNodeIds;
 105  
 
 106  
     @XmlElementWrapper(name = Elements.NEXT_NODE_IDS, required = false)
 107  
     @XmlElement(name = Elements.NEXT_NODE_ID, required = false)
 108  
     private final List<String> nextNodeIds;
 109  
     
 110  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 111  
     private final Long versionNumber;
 112  
 
 113  5
     @SuppressWarnings("unused")
 114  
     @XmlAnyElement
 115  
     private final Collection<Element> _futureElements = null;
 116  
 
 117  
     /**
 118  
      * Private constructor used only by JAXB.
 119  
      */
 120  2
     private RouteNode() {
 121  2
         this.id = null;
 122  2
         this.documentTypeId = null;
 123  2
         this.name = null;
 124  2
         this.routeMethodName = null;
 125  2
         this.routeMethodCode = null;
 126  2
         this.finalApproval = false;
 127  2
         this.mandatory = false;
 128  2
         this.activationType = null;
 129  2
         this.exceptionGroupId = null;
 130  2
         this.type = null;
 131  2
         this.branchName = null;
 132  2
         this.nextDocumentStatus = null;
 133  2
         this.configurationParameters = null;
 134  2
         this.previousNodeIds = null;
 135  2
         this.nextNodeIds = null;
 136  2
         this.versionNumber = null;
 137  2
     }
 138  
 
 139  3
     private RouteNode(Builder builder) {
 140  3
         this.id = builder.getId();
 141  3
         this.documentTypeId = builder.getDocumentTypeId();
 142  3
         this.name = builder.getName();
 143  3
         this.routeMethodName = builder.getRouteMethodName();
 144  3
         this.routeMethodCode = builder.getRouteMethodCode();
 145  3
         this.finalApproval = builder.isFinalApproval();
 146  3
         this.mandatory = builder.isMandatory();
 147  3
         this.activationType = builder.getActivationType();
 148  3
         this.exceptionGroupId = builder.getExceptionGroupId();
 149  3
         this.type = builder.getType();
 150  3
         this.branchName = builder.getBranchName();
 151  3
         this.nextDocumentStatus = builder.getNextDocumentStatus();
 152  3
         this.configurationParameters = new ArrayList<RouteNodeConfigurationParameter>();
 153  3
         if (builder.getConfigurationParameters() != null) {
 154  3
             for (RouteNodeConfigurationParameter.Builder configurationParameter : builder.getConfigurationParameters()) {
 155  5
                 this.configurationParameters.add(configurationParameter.build());
 156  
             }
 157  
         }
 158  3
         this.previousNodeIds = new ArrayList<String>(builder.getPreviousNodeIds());
 159  3
         this.nextNodeIds = new ArrayList<String>(builder.getNextNodeIds());
 160  3
         this.versionNumber = builder.getVersionNumber();
 161  3
     }
 162  
 
 163  
     @Override
 164  
     public String getId() {
 165  1
         return this.id;
 166  
     }
 167  
 
 168  
     @Override
 169  
     public String getName() {
 170  2
         return this.name;
 171  
     }
 172  
 
 173  
     @Override
 174  
     public String getDocumentTypeId() {
 175  1
         return this.documentTypeId;
 176  
     }
 177  
 
 178  
     @Override
 179  
     public String getRouteMethodName() {
 180  1
         return this.routeMethodName;
 181  
     }
 182  
 
 183  
     @Override
 184  
     public String getRouteMethodCode() {
 185  1
         return this.routeMethodCode;
 186  
     }
 187  
 
 188  
     @Override
 189  
     public boolean isFinalApproval() {
 190  1
         return this.finalApproval;
 191  
     }
 192  
 
 193  
     @Override
 194  
     public boolean isMandatory() {
 195  1
         return this.mandatory;
 196  
     }
 197  
 
 198  
     @Override
 199  
     public String getActivationType() {
 200  1
         return this.activationType;
 201  
     }
 202  
 
 203  
     @Override
 204  
     public String getExceptionGroupId() {
 205  1
         return this.exceptionGroupId;
 206  
     }
 207  
 
 208  
     @Override
 209  
     public String getType() {
 210  2
         return this.type;
 211  
     }
 212  
 
 213  
     @Override
 214  
     public String getBranchName() {
 215  1
         return this.branchName;
 216  
     }
 217  
 
 218  
     @Override
 219  
     public String getNextDocumentStatus() {
 220  1
         return this.nextDocumentStatus;
 221  
     }
 222  
 
 223  
     @Override
 224  
     public List<RouteNodeConfigurationParameter> getConfigurationParameters() {
 225  1
         return CollectionUtils.unmodifiableListNullSafe(this.configurationParameters);
 226  
     }
 227  
 
 228  
     @Override
 229  
     public List<String> getPreviousNodeIds() {
 230  1
         return CollectionUtils.unmodifiableListNullSafe(this.previousNodeIds);
 231  
     }
 232  
 
 233  
     @Override
 234  
     public List<String> getNextNodeIds() {
 235  1
         return CollectionUtils.unmodifiableListNullSafe(this.nextNodeIds);
 236  
     }
 237  
 
 238  
     @Override
 239  
     public Long getVersionNumber() {
 240  1
         return this.versionNumber;
 241  
     }
 242  
 
 243  
     /**
 244  
      * A builder which can be used to construct {@link RouteNode} instances. Enforces the
 245  
      * constraints of the {@link RouteNodeContract}.
 246  
      */
 247  3
     public final static class Builder implements Serializable, ModelBuilder, RouteNodeContract {
 248  
 
 249  
         private static final long serialVersionUID = 7076065049417371344L;
 250  
         private String id;
 251  
         private String documentTypeId;
 252  
         private String name;
 253  
         private String routeMethodName;
 254  
         private String routeMethodCode;
 255  
         private boolean finalApproval;
 256  
         private boolean mandatory;
 257  
         private String activationType;
 258  
         private String exceptionGroupId;
 259  
         private String type;
 260  
         private String branchName;
 261  
         private String nextDocumentStatus;
 262  
         private List<RouteNodeConfigurationParameter.Builder> configurationParameters;
 263  
         private List<String> previousNodeIds;
 264  
         private List<String> nextNodeIds;
 265  
         private Long versionNumber;
 266  
 
 267  4
         private Builder(String name, String type) {
 268  4
             setName(name);
 269  4
             setType(type);
 270  4
             setConfigurationParameters(new ArrayList<RouteNodeConfigurationParameter.Builder>());
 271  4
             setPreviousNodeIds(new ArrayList<String>());
 272  4
             setNextNodeIds(new ArrayList<String>());
 273  4
         }
 274  
 
 275  
         public static Builder create(String name, String type) {
 276  4
             return new Builder(name, type);
 277  
         }
 278  
 
 279  
         public static Builder create(RouteNodeContract contract) {
 280  3
             if (contract == null) {
 281  1
                 throw new IllegalArgumentException("contract was null");
 282  
             }
 283  2
             Builder builder = create(contract.getName(), contract.getType());
 284  2
             builder.setId(contract.getId());
 285  2
             builder.setDocumentTypeId(contract.getDocumentTypeId());
 286  2
             builder.setName(contract.getName());
 287  2
             builder.setRouteMethodName(contract.getRouteMethodName());
 288  2
             builder.setRouteMethodCode(contract.getRouteMethodCode());
 289  2
             builder.setFinalApproval(contract.isFinalApproval());
 290  2
             builder.setMandatory(contract.isMandatory());
 291  2
             builder.setActivationType(contract.getActivationType());
 292  2
             builder.setExceptionGroupId(contract.getExceptionGroupId());
 293  2
             builder.setType(contract.getType());
 294  2
             builder.setBranchName(contract.getBranchName());
 295  2
             builder.setNextDocumentStatus(contract.getNextDocumentStatus());
 296  2
             List<RouteNodeConfigurationParameter.Builder> parameterBuilders = new ArrayList<RouteNodeConfigurationParameter.Builder>();
 297  2
             for (RouteNodeConfigurationParameterContract configurationParameter : contract.getConfigurationParameters()) {
 298  5
                 parameterBuilders.add(RouteNodeConfigurationParameter.Builder.create(configurationParameter));
 299  
             }
 300  2
             builder.setConfigurationParameters(parameterBuilders);
 301  2
             builder.setPreviousNodeIds(contract.getPreviousNodeIds());
 302  2
             builder.setNextNodeIds(contract.getNextNodeIds());
 303  2
             builder.setVersionNumber(contract.getVersionNumber());
 304  
             
 305  2
             return builder;
 306  
         }
 307  
 
 308  
         public RouteNode build() {
 309  3
             return new RouteNode(this);
 310  
         }
 311  
         
 312  
         @Override
 313  
         public String getId() {
 314  3
             return this.id;
 315  
         }
 316  
 
 317  
         @Override
 318  
         public String getDocumentTypeId() {
 319  3
             return this.documentTypeId;
 320  
         }
 321  
 
 322  
         @Override
 323  
         public String getName() {
 324  3
             return this.name;
 325  
         }
 326  
 
 327  
         @Override
 328  
         public String getRouteMethodName() {
 329  3
             return this.routeMethodName;
 330  
         }
 331  
 
 332  
         @Override
 333  
         public String getRouteMethodCode() {
 334  3
             return this.routeMethodCode;
 335  
         }
 336  
 
 337  
         @Override
 338  
         public boolean isFinalApproval() {
 339  3
             return this.finalApproval;
 340  
         }
 341  
 
 342  
         @Override
 343  
         public boolean isMandatory() {
 344  3
             return this.mandatory;
 345  
         }
 346  
 
 347  
         @Override
 348  
         public String getActivationType() {
 349  3
             return this.activationType;
 350  
         }
 351  
 
 352  
         @Override
 353  
         public String getExceptionGroupId() {
 354  3
             return this.exceptionGroupId;
 355  
         }
 356  
 
 357  
         @Override
 358  
         public String getType() {
 359  3
             return this.type;
 360  
         }
 361  
 
 362  
         @Override
 363  
         public String getBranchName() {
 364  3
             return this.branchName;
 365  
         }
 366  
 
 367  
         @Override
 368  
         public String getNextDocumentStatus() {
 369  3
             return this.nextDocumentStatus;
 370  
         }
 371  
 
 372  
         @Override
 373  
         public List<RouteNodeConfigurationParameter.Builder> getConfigurationParameters() {
 374  6
             return this.configurationParameters;
 375  
         }
 376  
 
 377  
         @Override
 378  
         public List<String> getPreviousNodeIds() {
 379  3
             return this.previousNodeIds;
 380  
         }
 381  
 
 382  
         @Override
 383  
         public List<String> getNextNodeIds() {
 384  3
             return this.nextNodeIds;
 385  
         }
 386  
         
 387  
         @Override
 388  
         public Long getVersionNumber() {
 389  3
             return this.versionNumber;
 390  
         }
 391  
         
 392  
         public void setId(String id) {
 393  2
             this.id = id;
 394  2
         }
 395  
 
 396  
         public void setDocumentTypeId(String documentTypeId) {
 397  2
             this.documentTypeId = documentTypeId;
 398  2
         }
 399  
         
 400  
         public void setName(String name) {
 401  6
             if (StringUtils.isBlank(name)) {
 402  0
                 throw new IllegalArgumentException("name was null or blank");
 403  
             }
 404  6
             this.name = name;
 405  6
         }
 406  
 
 407  
         public void setRouteMethodName(String routeMethodName) {
 408  2
             this.routeMethodName = routeMethodName;
 409  2
         }
 410  
 
 411  
         public void setRouteMethodCode(String routeMethodCode) {
 412  2
             this.routeMethodCode = routeMethodCode;
 413  2
         }
 414  
 
 415  
         public void setFinalApproval(boolean finalApproval) {
 416  2
             this.finalApproval = finalApproval;
 417  2
         }
 418  
 
 419  
         public void setMandatory(boolean mandatory) {
 420  2
             this.mandatory = mandatory;
 421  2
         }
 422  
 
 423  
         public void setActivationType(String activationType) {
 424  2
             this.activationType = activationType;
 425  2
         }
 426  
 
 427  
         public void setExceptionGroupId(String exceptionGroupId) {
 428  2
             this.exceptionGroupId = exceptionGroupId;
 429  2
         }
 430  
         
 431  
         public void setType(String type) {
 432  6
             if (StringUtils.isBlank(type)) {
 433  0
                 throw new IllegalArgumentException("type was null or blank");
 434  
             }
 435  6
             this.type = type;
 436  6
         }
 437  
 
 438  
         public void setBranchName(String branchName) {
 439  2
             this.branchName = branchName;
 440  2
         }
 441  
         
 442  
         public void setNextDocumentStatus(String nextDocumentStatus) {
 443  2
             this.nextDocumentStatus = nextDocumentStatus;
 444  2
         }
 445  
         
 446  
         public void setConfigurationParameters(List<RouteNodeConfigurationParameter.Builder> configurationParameters) {
 447  6
             if (configurationParameters == null) {
 448  0
                 throw new IllegalArgumentException("configurationParameters was null");
 449  
             }
 450  6
             this.configurationParameters = configurationParameters;
 451  6
         }
 452  
 
 453  
         public void setPreviousNodeIds(List<String> previousNodeIds) {
 454  6
             if (previousNodeIds == null) {
 455  0
                 throw new IllegalArgumentException("previousNodeIds was null");
 456  
             }
 457  6
             this.previousNodeIds = previousNodeIds;
 458  6
         }
 459  
 
 460  
         public void setNextNodeIds(List<String> nextNodeIds) {
 461  6
             if (nextNodeIds == null) {
 462  0
                 throw new IllegalArgumentException("nextNodeIds was null");
 463  
             }
 464  6
             this.nextNodeIds = nextNodeIds;
 465  6
         }
 466  
         
 467  
         public void setVersionNumber(Long versionNumber) {
 468  2
             this.versionNumber = versionNumber;
 469  2
         }
 470  
 
 471  
     }
 472  
 
 473  
     /**
 474  
      * Defines some internal constants used on this class.
 475  
      */
 476  0
     static class Constants {
 477  
         final static String ROOT_ELEMENT_NAME = "routeNode";
 478  
         final static String TYPE_NAME = "RouteNodeType";
 479  
     }
 480  
 
 481  
     /**
 482  
      * A private class which exposes constants which define the XML element names to use when this
 483  
      * object is marshalled to XML.
 484  
      */
 485  0
     static class Elements {
 486  
         final static String ID = "id";
 487  
         final static String DOCUMENT_TYPE_ID = "documentTypeId";
 488  
         final static String NAME = "name";
 489  
         final static String ROUTE_METHOD_NAME = "routeMethodName";
 490  
         final static String ROUTE_METHOD_CODE = "routeMethodCode";
 491  
         final static String FINAL_APPROVAL = "finalApproval";
 492  
         final static String MANDATORY = "mandatory";
 493  
         final static String ACTIVATION_TYPE = "activationType";
 494  
         final static String EXCEPTION_GROUP_ID = "exceptionGroupId";
 495  
         final static String TYPE = "type";
 496  
         final static String BRANCH_NAME = "branchName";
 497  
         final static String NEXT_DOCUMENT_STATUS = "nextDocumentStatus";
 498  
         final static String CONFIGURATION_PARAMETERS = "configurationParameters";
 499  
         final static String CONFIGURATION_PARAMETER = "configurationParameter";
 500  
         final static String PREVIOUS_NODE_IDS = "previousNodeIds";
 501  
         final static String PREVIOUS_NODE_ID = "previousNodeId";
 502  
         final static String NEXT_NODE_IDS = "nextNodeIds";
 503  
         final static String NEXT_NODE_ID = "nextNodeId";
 504  
     }
 505  
 
 506  
 }