001: /*
002: * Copyright 2005-2006 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.engine.node;
018:
019: import java.io.Serializable;
020: import java.util.ArrayList;
021: import java.util.Iterator;
022: import java.util.List;
023:
024: /**
025: * Represents a branch in the routing path of the document.
026: *
027: * @author ewestfal
028: */
029: public class Branch implements Serializable {
030:
031: private static final long serialVersionUID = 7164561979112939112L;
032:
033: private Long branchId;
034: private Branch parentBranch;
035: private String name;
036: private List<BranchState> branchState = new ArrayList<BranchState>();
037: // apache lazy list commented out due to not being serializable
038: // private List branchState = ListUtils.lazyList(new ArrayList(),
039: // new Factory() {
040: // public Object create() {
041: // return new BranchState();
042: // }
043: // });
044: private RouteNodeInstance initialNode;
045: private RouteNodeInstance splitNode;
046: private RouteNodeInstance joinNode;
047:
048: private Long initialNodeId;
049:
050: private Integer lockVerNbr;
051:
052: public String getName() {
053: return name;
054: }
055:
056: public void setName(String name) {
057: this .name = name;
058: }
059:
060: public RouteNodeInstance getSplitNode() {
061: return splitNode;
062: }
063:
064: public void setSplitNode(RouteNodeInstance splitNode) {
065: this .splitNode = splitNode;
066: }
067:
068: public RouteNodeInstance getInitialNode() {
069: return initialNode;
070: }
071:
072: public void setInitialNode(RouteNodeInstance activeNode) {
073: this .initialNode = activeNode;
074: }
075:
076: public Long getBranchId() {
077: return branchId;
078: }
079:
080: public void setBranchId(Long branchId) {
081: this .branchId = branchId;
082: }
083:
084: public RouteNodeInstance getJoinNode() {
085: return joinNode;
086: }
087:
088: public void setJoinNode(RouteNodeInstance joinNode) {
089: this .joinNode = joinNode;
090: }
091:
092: public Branch getParentBranch() {
093: return parentBranch;
094: }
095:
096: public void setParentBranch(Branch parentBranch) {
097: this .parentBranch = parentBranch;
098: }
099:
100: public BranchState getBranchState(String key) {
101: for (Iterator iter = branchState.iterator(); iter.hasNext();) {
102: BranchState branchState = (BranchState) iter.next();
103: if (branchState.getKey().equals(key)) {
104: return branchState;
105: }
106: }
107: return null;
108: }
109:
110: public void addBranchState(BranchState state) {
111: branchState.add(state);
112: state.setBranch(this );
113: }
114:
115: public List<BranchState> getBranchState() {
116: return branchState;
117: }
118:
119: public void setBranchState(List<BranchState> branchState) {
120: this .branchState = branchState;
121: }
122:
123: public BranchState getDocBranchState(int index) {
124: while (branchState.size() <= index) {
125: branchState.add(new BranchState());
126: }
127: return (BranchState) branchState.get(index);
128:
129: }
130:
131: public Integer getLockVerNbr() {
132: return lockVerNbr;
133: }
134:
135: public void setLockVerNbr(Integer lockVerNbr) {
136: this .lockVerNbr = lockVerNbr;
137: }
138:
139: public String toString() {
140: return "[Branch: branchId="
141: + branchId
142: + ", parentBranch="
143: + (parentBranch == null ? "null" : parentBranch
144: .getBranchId()) + "]";
145: }
146: }
|