Coverage Report - org.kuali.rice.kew.api.doctype.ProcessDefinition
 
Classes in this File Line Coverage Branch Coverage Complexity
ProcessDefinition
0%
0/26
0%
0/2
1.292
ProcessDefinition$1
N/A
N/A
1.292
ProcessDefinition$Builder
0%
0/36
0%
0/6
1.292
ProcessDefinition$Constants
0%
0/1
N/A
1.292
ProcessDefinition$Elements
0%
0/1
N/A
1.292
 
 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.w3c.dom.Element;
 23  
 
 24  
 import javax.xml.bind.annotation.XmlAccessType;
 25  
 import javax.xml.bind.annotation.XmlAccessorType;
 26  
 import javax.xml.bind.annotation.XmlAnyElement;
 27  
 import javax.xml.bind.annotation.XmlElement;
 28  
 import javax.xml.bind.annotation.XmlRootElement;
 29  
 import javax.xml.bind.annotation.XmlType;
 30  
 import java.io.Serializable;
 31  
 import java.util.Collection;
 32  
 
 33  
 @XmlRootElement(name = ProcessDefinition.Constants.ROOT_ELEMENT_NAME)
 34  
 @XmlAccessorType(XmlAccessType.NONE)
 35  
 @XmlType(name = ProcessDefinition.Constants.TYPE_NAME, propOrder = {
 36  
         ProcessDefinition.Elements.ID,
 37  
         ProcessDefinition.Elements.NAME,
 38  
         ProcessDefinition.Elements.DOCUMENT_TYPE_ID,
 39  
         ProcessDefinition.Elements.INITIAL_ROUTE_NODE,
 40  
         ProcessDefinition.Elements.INITIAL,
 41  
         CoreConstants.CommonElements.VERSION_NUMBER,
 42  
         CoreConstants.CommonElements.FUTURE_ELEMENTS
 43  
 })
 44  0
 public final class ProcessDefinition extends AbstractDataTransferObject implements ProcessDefinitionContract {
 45  
 
 46  
     private static final long serialVersionUID = 1076976038764944504L;
 47  
 
 48  
     @XmlElement(name = Elements.ID, required = false)
 49  
     private final String id;
 50  
 
 51  
     @XmlElement(name = Elements.NAME, required = true)
 52  
     private final String name;
 53  
 
 54  
     @XmlElement(name = Elements.DOCUMENT_TYPE_ID, required = false)
 55  
     private final String documentTypeId;
 56  
 
 57  
     @XmlElement(name = Elements.INITIAL_ROUTE_NODE, required = true)
 58  
     private final RouteNode initialRouteNode;
 59  
 
 60  
     @XmlElement(name = Elements.INITIAL, required = true)
 61  
     private final boolean initial;
 62  
 
 63  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 64  
     private final Long versionNumber;
 65  
 
 66  0
     @SuppressWarnings("unused")
 67  
     @XmlAnyElement
 68  
     private final Collection<Element> _futureElements = null;
 69  
 
 70  
     /**
 71  
      * Private constructor used only by JAXB.
 72  
      */
 73  0
     private ProcessDefinition() {
 74  0
         this.id = null;
 75  0
         this.name = null;
 76  0
         this.documentTypeId = null;
 77  0
         this.initialRouteNode = null;
 78  0
         this.initial = false;
 79  0
         this.versionNumber = null;
 80  0
     }
 81  
 
 82  0
     private ProcessDefinition(Builder builder) {
 83  0
         this.id = builder.getId();
 84  0
         this.name = builder.getName();
 85  0
         this.documentTypeId = builder.getDocumentTypeId();
 86  0
         if (builder.getInitialRouteNode() != null) {
 87  0
             this.initialRouteNode = builder.getInitialRouteNode().build();
 88  
         } else {
 89  0
             this.initialRouteNode = null;
 90  
         }
 91  0
         this.initial = builder.isInitial();
 92  0
         this.versionNumber = builder.getVersionNumber();
 93  0
     }
 94  
 
 95  
     @Override
 96  
     public String getId() {
 97  0
         return this.id;
 98  
     }
 99  
 
 100  
     @Override
 101  
     public String getName() {
 102  0
         return this.name;
 103  
     }
 104  
 
 105  
     @Override
 106  
     public String getDocumentTypeId() {
 107  0
         return this.documentTypeId;
 108  
     }
 109  
 
 110  
     @Override
 111  
     public RouteNodeContract getInitialRouteNode() {
 112  0
         return this.initialRouteNode;
 113  
     }
 114  
 
 115  
     @Override
 116  
     public boolean isInitial() {
 117  0
         return this.initial;
 118  
     }
 119  
 
 120  
     @Override
 121  
     public Long getVersionNumber() {
 122  0
         return this.versionNumber;
 123  
     }
 124  
 
 125  
     /**
 126  
      * A builder which can be used to construct {@link ProcessDefinition} instances. Enforces the constraints
 127  
      * of the {@link ProcessDefinitionContract}.
 128  
      */
 129  0
     public final static class Builder implements Serializable, ModelBuilder, ProcessDefinitionContract {
 130  
 
 131  
         private static final long serialVersionUID = 5897271312287857808L;
 132  
 
 133  
         private String id;
 134  
         private String name;
 135  
         private String documentTypeId;
 136  
         private RouteNode.Builder initialRouteNode;
 137  
         private boolean initial;
 138  
         private Long versionNumber;
 139  
 
 140  0
         private Builder(String name, RouteNode.Builder initialRouteNode, boolean initial) {
 141  0
             setName(name);
 142  0
             setInitialRouteNode(initialRouteNode);
 143  0
             setInitial(initial);
 144  0
         }
 145  
 
 146  
         public static Builder create(String name, RouteNode.Builder initialRouteNode, boolean initial) {
 147  0
             return new Builder(name, initialRouteNode, initial);
 148  
         }
 149  
 
 150  
         public static Builder create(ProcessDefinitionContract contract) {
 151  0
             if (contract == null) {
 152  0
                 throw new IllegalArgumentException("contract was null");
 153  
             }
 154  0
             Builder builder = create(contract.getName(), RouteNode.Builder.create(contract.getInitialRouteNode()),
 155  
                     contract.isInitial());
 156  0
             builder.setDocumentTypeId(contract.getDocumentTypeId());
 157  0
             builder.setId(contract.getId());
 158  0
             return builder;
 159  
         }
 160  
 
 161  
         public ProcessDefinition build() {
 162  0
             return new ProcessDefinition(this);
 163  
         }
 164  
 
 165  
         @Override
 166  
         public String getId() {
 167  0
             return this.id;
 168  
         }
 169  
 
 170  
         @Override
 171  
         public String getName() {
 172  0
             return this.name;
 173  
         }
 174  
 
 175  
         @Override
 176  
         public String getDocumentTypeId() {
 177  0
             return this.documentTypeId;
 178  
         }
 179  
 
 180  
         @Override
 181  
         public RouteNode.Builder getInitialRouteNode() {
 182  0
             return this.initialRouteNode;
 183  
         }
 184  
 
 185  
         @Override
 186  
         public boolean isInitial() {
 187  0
             return this.initial;
 188  
         }
 189  
 
 190  
         @Override
 191  
         public Long getVersionNumber() {
 192  0
             return this.versionNumber;
 193  
         }
 194  
 
 195  
         public void setId(String id) {
 196  0
             this.id = id;
 197  0
         }
 198  
 
 199  
         public void setName(String name) {
 200  0
             if (StringUtils.isBlank(name)) {
 201  0
                 throw new IllegalArgumentException("name was null or blank");
 202  
             }
 203  0
             this.name = name;
 204  0
         }
 205  
 
 206  
         public void setDocumentTypeId(String documentTypeId) {
 207  0
             this.documentTypeId = documentTypeId;
 208  0
         }
 209  
 
 210  
         public void setInitialRouteNode(RouteNode.Builder initialRouteNode) {
 211  0
             if (initialRouteNode == null) {
 212  0
                 throw new IllegalArgumentException("initialRouteNode was null");
 213  
             }
 214  0
             this.initialRouteNode = initialRouteNode;
 215  0
         }
 216  
 
 217  
         public void setInitial(boolean initial) {
 218  0
             this.initial = initial;
 219  0
         }
 220  
 
 221  
         public void setVersionNumber(Long versionNumber) {
 222  0
             this.versionNumber = versionNumber;
 223  0
         }
 224  
 
 225  
     }
 226  
 
 227  
     /**
 228  
      * Defines some internal constants used on this class.
 229  
      */
 230  0
     static class Constants {
 231  
         final static String ROOT_ELEMENT_NAME = "process";
 232  
         final static String TYPE_NAME = "ProcessType";
 233  
     }
 234  
 
 235  
     /**
 236  
      * A private class which exposes constants which define the XML element names to use when this
 237  
      * object is marshalled to XML.
 238  
      */
 239  0
     static class Elements {
 240  
         final static String ID = "id";
 241  
         final static String NAME = "name";
 242  
         final static String DOCUMENT_TYPE_ID = "documentTypeId";
 243  
         final static String INITIAL_ROUTE_NODE = "initialRouteNode";
 244  
         final static String INITIAL = "initial";
 245  
     }
 246  
 
 247  
 }