| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 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 | 0 | 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 | 0 | @SuppressWarnings("unused") |
| 114 | |
@XmlAnyElement |
| 115 | |
private final Collection<Element> _futureElements = null; |
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | 0 | private RouteNode() { |
| 121 | 0 | this.id = null; |
| 122 | 0 | this.documentTypeId = null; |
| 123 | 0 | this.name = null; |
| 124 | 0 | this.routeMethodName = null; |
| 125 | 0 | this.routeMethodCode = null; |
| 126 | 0 | this.finalApproval = false; |
| 127 | 0 | this.mandatory = false; |
| 128 | 0 | this.activationType = null; |
| 129 | 0 | this.exceptionGroupId = null; |
| 130 | 0 | this.type = null; |
| 131 | 0 | this.branchName = null; |
| 132 | 0 | this.nextDocumentStatus = null; |
| 133 | 0 | this.configurationParameters = null; |
| 134 | 0 | this.previousNodeIds = null; |
| 135 | 0 | this.nextNodeIds = null; |
| 136 | 0 | this.versionNumber = null; |
| 137 | 0 | } |
| 138 | |
|
| 139 | 0 | private RouteNode(Builder builder) { |
| 140 | 0 | this.id = builder.getId(); |
| 141 | 0 | this.documentTypeId = builder.getDocumentTypeId(); |
| 142 | 0 | this.name = builder.getName(); |
| 143 | 0 | this.routeMethodName = builder.getRouteMethodName(); |
| 144 | 0 | this.routeMethodCode = builder.getRouteMethodCode(); |
| 145 | 0 | this.finalApproval = builder.isFinalApproval(); |
| 146 | 0 | this.mandatory = builder.isMandatory(); |
| 147 | 0 | this.activationType = builder.getActivationType(); |
| 148 | 0 | this.exceptionGroupId = builder.getExceptionGroupId(); |
| 149 | 0 | this.type = builder.getType(); |
| 150 | 0 | this.branchName = builder.getBranchName(); |
| 151 | 0 | this.nextDocumentStatus = builder.getNextDocumentStatus(); |
| 152 | 0 | this.configurationParameters = new ArrayList<RouteNodeConfigurationParameter>(); |
| 153 | 0 | if (builder.getConfigurationParameters() != null) { |
| 154 | 0 | for (RouteNodeConfigurationParameter.Builder configurationParameter : builder.getConfigurationParameters()) { |
| 155 | 0 | this.configurationParameters.add(configurationParameter.build()); |
| 156 | |
} |
| 157 | |
} |
| 158 | 0 | this.previousNodeIds = new ArrayList<String>(builder.getPreviousNodeIds()); |
| 159 | 0 | this.nextNodeIds = new ArrayList<String>(builder.getNextNodeIds()); |
| 160 | 0 | this.versionNumber = builder.getVersionNumber(); |
| 161 | 0 | } |
| 162 | |
|
| 163 | |
@Override |
| 164 | |
public String getId() { |
| 165 | 0 | return this.id; |
| 166 | |
} |
| 167 | |
|
| 168 | |
@Override |
| 169 | |
public String getName() { |
| 170 | 0 | return this.name; |
| 171 | |
} |
| 172 | |
|
| 173 | |
@Override |
| 174 | |
public String getDocumentTypeId() { |
| 175 | 0 | return this.documentTypeId; |
| 176 | |
} |
| 177 | |
|
| 178 | |
@Override |
| 179 | |
public String getRouteMethodName() { |
| 180 | 0 | return this.routeMethodName; |
| 181 | |
} |
| 182 | |
|
| 183 | |
@Override |
| 184 | |
public String getRouteMethodCode() { |
| 185 | 0 | return this.routeMethodCode; |
| 186 | |
} |
| 187 | |
|
| 188 | |
@Override |
| 189 | |
public boolean isFinalApproval() { |
| 190 | 0 | return this.finalApproval; |
| 191 | |
} |
| 192 | |
|
| 193 | |
@Override |
| 194 | |
public boolean isMandatory() { |
| 195 | 0 | return this.mandatory; |
| 196 | |
} |
| 197 | |
|
| 198 | |
@Override |
| 199 | |
public String getActivationType() { |
| 200 | 0 | return this.activationType; |
| 201 | |
} |
| 202 | |
|
| 203 | |
@Override |
| 204 | |
public String getExceptionGroupId() { |
| 205 | 0 | return this.exceptionGroupId; |
| 206 | |
} |
| 207 | |
|
| 208 | |
@Override |
| 209 | |
public String getType() { |
| 210 | 0 | return this.type; |
| 211 | |
} |
| 212 | |
|
| 213 | |
@Override |
| 214 | |
public String getBranchName() { |
| 215 | 0 | return this.branchName; |
| 216 | |
} |
| 217 | |
|
| 218 | |
@Override |
| 219 | |
public String getNextDocumentStatus() { |
| 220 | 0 | return this.nextDocumentStatus; |
| 221 | |
} |
| 222 | |
|
| 223 | |
@Override |
| 224 | |
public List<RouteNodeConfigurationParameter> getConfigurationParameters() { |
| 225 | 0 | return CollectionUtils.unmodifiableListNullSafe(this.configurationParameters); |
| 226 | |
} |
| 227 | |
|
| 228 | |
@Override |
| 229 | |
public List<String> getPreviousNodeIds() { |
| 230 | 0 | return CollectionUtils.unmodifiableListNullSafe(this.previousNodeIds); |
| 231 | |
} |
| 232 | |
|
| 233 | |
@Override |
| 234 | |
public List<String> getNextNodeIds() { |
| 235 | 0 | return CollectionUtils.unmodifiableListNullSafe(this.nextNodeIds); |
| 236 | |
} |
| 237 | |
|
| 238 | |
@Override |
| 239 | |
public Long getVersionNumber() { |
| 240 | 0 | return this.versionNumber; |
| 241 | |
} |
| 242 | |
|
| 243 | |
|
| 244 | |
|
| 245 | |
|
| 246 | |
|
| 247 | 0 | 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 | 0 | private Builder(String name, String type) { |
| 268 | 0 | setName(name); |
| 269 | 0 | setType(type); |
| 270 | 0 | setConfigurationParameters(new ArrayList<RouteNodeConfigurationParameter.Builder>()); |
| 271 | 0 | setPreviousNodeIds(new ArrayList<String>()); |
| 272 | 0 | setNextNodeIds(new ArrayList<String>()); |
| 273 | 0 | } |
| 274 | |
|
| 275 | |
public static Builder create(String name, String type) { |
| 276 | 0 | return new Builder(name, type); |
| 277 | |
} |
| 278 | |
|
| 279 | |
public static Builder create(RouteNodeContract contract) { |
| 280 | 0 | if (contract == null) { |
| 281 | 0 | throw new IllegalArgumentException("contract was null"); |
| 282 | |
} |
| 283 | 0 | Builder builder = create(contract.getName(), contract.getType()); |
| 284 | 0 | builder.setId(contract.getId()); |
| 285 | 0 | builder.setDocumentTypeId(contract.getDocumentTypeId()); |
| 286 | 0 | builder.setName(contract.getName()); |
| 287 | 0 | builder.setRouteMethodName(contract.getRouteMethodName()); |
| 288 | 0 | builder.setRouteMethodCode(contract.getRouteMethodCode()); |
| 289 | 0 | builder.setFinalApproval(contract.isFinalApproval()); |
| 290 | 0 | builder.setMandatory(contract.isMandatory()); |
| 291 | 0 | builder.setActivationType(contract.getActivationType()); |
| 292 | 0 | builder.setExceptionGroupId(contract.getExceptionGroupId()); |
| 293 | 0 | builder.setType(contract.getType()); |
| 294 | 0 | builder.setBranchName(contract.getBranchName()); |
| 295 | 0 | builder.setNextDocumentStatus(contract.getNextDocumentStatus()); |
| 296 | 0 | List<RouteNodeConfigurationParameter.Builder> parameterBuilders = new ArrayList<RouteNodeConfigurationParameter.Builder>(); |
| 297 | 0 | for (RouteNodeConfigurationParameterContract configurationParameter : contract.getConfigurationParameters()) { |
| 298 | 0 | parameterBuilders.add(RouteNodeConfigurationParameter.Builder.create(configurationParameter)); |
| 299 | |
} |
| 300 | 0 | builder.setConfigurationParameters(parameterBuilders); |
| 301 | 0 | builder.setPreviousNodeIds(contract.getPreviousNodeIds()); |
| 302 | 0 | builder.setNextNodeIds(contract.getNextNodeIds()); |
| 303 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
| 304 | |
|
| 305 | 0 | return builder; |
| 306 | |
} |
| 307 | |
|
| 308 | |
public RouteNode build() { |
| 309 | 0 | return new RouteNode(this); |
| 310 | |
} |
| 311 | |
|
| 312 | |
@Override |
| 313 | |
public String getId() { |
| 314 | 0 | return this.id; |
| 315 | |
} |
| 316 | |
|
| 317 | |
@Override |
| 318 | |
public String getDocumentTypeId() { |
| 319 | 0 | return this.documentTypeId; |
| 320 | |
} |
| 321 | |
|
| 322 | |
@Override |
| 323 | |
public String getName() { |
| 324 | 0 | return this.name; |
| 325 | |
} |
| 326 | |
|
| 327 | |
@Override |
| 328 | |
public String getRouteMethodName() { |
| 329 | 0 | return this.routeMethodName; |
| 330 | |
} |
| 331 | |
|
| 332 | |
@Override |
| 333 | |
public String getRouteMethodCode() { |
| 334 | 0 | return this.routeMethodCode; |
| 335 | |
} |
| 336 | |
|
| 337 | |
@Override |
| 338 | |
public boolean isFinalApproval() { |
| 339 | 0 | return this.finalApproval; |
| 340 | |
} |
| 341 | |
|
| 342 | |
@Override |
| 343 | |
public boolean isMandatory() { |
| 344 | 0 | return this.mandatory; |
| 345 | |
} |
| 346 | |
|
| 347 | |
@Override |
| 348 | |
public String getActivationType() { |
| 349 | 0 | return this.activationType; |
| 350 | |
} |
| 351 | |
|
| 352 | |
@Override |
| 353 | |
public String getExceptionGroupId() { |
| 354 | 0 | return this.exceptionGroupId; |
| 355 | |
} |
| 356 | |
|
| 357 | |
@Override |
| 358 | |
public String getType() { |
| 359 | 0 | return this.type; |
| 360 | |
} |
| 361 | |
|
| 362 | |
@Override |
| 363 | |
public String getBranchName() { |
| 364 | 0 | return this.branchName; |
| 365 | |
} |
| 366 | |
|
| 367 | |
@Override |
| 368 | |
public String getNextDocumentStatus() { |
| 369 | 0 | return this.nextDocumentStatus; |
| 370 | |
} |
| 371 | |
|
| 372 | |
@Override |
| 373 | |
public List<RouteNodeConfigurationParameter.Builder> getConfigurationParameters() { |
| 374 | 0 | return this.configurationParameters; |
| 375 | |
} |
| 376 | |
|
| 377 | |
@Override |
| 378 | |
public List<String> getPreviousNodeIds() { |
| 379 | 0 | return this.previousNodeIds; |
| 380 | |
} |
| 381 | |
|
| 382 | |
@Override |
| 383 | |
public List<String> getNextNodeIds() { |
| 384 | 0 | return this.nextNodeIds; |
| 385 | |
} |
| 386 | |
|
| 387 | |
@Override |
| 388 | |
public Long getVersionNumber() { |
| 389 | 0 | return this.versionNumber; |
| 390 | |
} |
| 391 | |
|
| 392 | |
public void setId(String id) { |
| 393 | 0 | this.id = id; |
| 394 | 0 | } |
| 395 | |
|
| 396 | |
public void setDocumentTypeId(String documentTypeId) { |
| 397 | 0 | this.documentTypeId = documentTypeId; |
| 398 | 0 | } |
| 399 | |
|
| 400 | |
public void setName(String name) { |
| 401 | 0 | if (StringUtils.isBlank(name)) { |
| 402 | 0 | throw new IllegalArgumentException("name was null or blank"); |
| 403 | |
} |
| 404 | 0 | this.name = name; |
| 405 | 0 | } |
| 406 | |
|
| 407 | |
public void setRouteMethodName(String routeMethodName) { |
| 408 | 0 | this.routeMethodName = routeMethodName; |
| 409 | 0 | } |
| 410 | |
|
| 411 | |
public void setRouteMethodCode(String routeMethodCode) { |
| 412 | 0 | this.routeMethodCode = routeMethodCode; |
| 413 | 0 | } |
| 414 | |
|
| 415 | |
public void setFinalApproval(boolean finalApproval) { |
| 416 | 0 | this.finalApproval = finalApproval; |
| 417 | 0 | } |
| 418 | |
|
| 419 | |
public void setMandatory(boolean mandatory) { |
| 420 | 0 | this.mandatory = mandatory; |
| 421 | 0 | } |
| 422 | |
|
| 423 | |
public void setActivationType(String activationType) { |
| 424 | 0 | this.activationType = activationType; |
| 425 | 0 | } |
| 426 | |
|
| 427 | |
public void setExceptionGroupId(String exceptionGroupId) { |
| 428 | 0 | this.exceptionGroupId = exceptionGroupId; |
| 429 | 0 | } |
| 430 | |
|
| 431 | |
public void setType(String type) { |
| 432 | 0 | if (StringUtils.isBlank(type)) { |
| 433 | 0 | throw new IllegalArgumentException("type was null or blank"); |
| 434 | |
} |
| 435 | 0 | this.type = type; |
| 436 | 0 | } |
| 437 | |
|
| 438 | |
public void setBranchName(String branchName) { |
| 439 | 0 | this.branchName = branchName; |
| 440 | 0 | } |
| 441 | |
|
| 442 | |
public void setNextDocumentStatus(String nextDocumentStatus) { |
| 443 | 0 | this.nextDocumentStatus = nextDocumentStatus; |
| 444 | 0 | } |
| 445 | |
|
| 446 | |
public void setConfigurationParameters(List<RouteNodeConfigurationParameter.Builder> configurationParameters) { |
| 447 | 0 | if (configurationParameters == null) { |
| 448 | 0 | throw new IllegalArgumentException("configurationParameters was null"); |
| 449 | |
} |
| 450 | 0 | this.configurationParameters = configurationParameters; |
| 451 | 0 | } |
| 452 | |
|
| 453 | |
public void setPreviousNodeIds(List<String> previousNodeIds) { |
| 454 | 0 | if (previousNodeIds == null) { |
| 455 | 0 | throw new IllegalArgumentException("previousNodeIds was null"); |
| 456 | |
} |
| 457 | 0 | this.previousNodeIds = previousNodeIds; |
| 458 | 0 | } |
| 459 | |
|
| 460 | |
public void setNextNodeIds(List<String> nextNodeIds) { |
| 461 | 0 | if (nextNodeIds == null) { |
| 462 | 0 | throw new IllegalArgumentException("nextNodeIds was null"); |
| 463 | |
} |
| 464 | 0 | this.nextNodeIds = nextNodeIds; |
| 465 | 0 | } |
| 466 | |
|
| 467 | |
public void setVersionNumber(Long versionNumber) { |
| 468 | 0 | this.versionNumber = versionNumber; |
| 469 | 0 | } |
| 470 | |
|
| 471 | |
} |
| 472 | |
|
| 473 | |
|
| 474 | |
|
| 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 | |
|
| 483 | |
|
| 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 | |
} |