| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.rice.kew.engine.node; |
| 18 | |
|
| 19 | |
import java.io.Serializable; |
| 20 | |
import java.util.ArrayList; |
| 21 | |
import java.util.Iterator; |
| 22 | |
import java.util.List; |
| 23 | |
|
| 24 | |
import javax.persistence.CascadeType; |
| 25 | |
import javax.persistence.Column; |
| 26 | |
import javax.persistence.Entity; |
| 27 | |
import javax.persistence.FetchType; |
| 28 | |
import javax.persistence.GeneratedValue; |
| 29 | |
import javax.persistence.Id; |
| 30 | |
import javax.persistence.JoinColumn; |
| 31 | |
import javax.persistence.ManyToOne; |
| 32 | |
import javax.persistence.OneToMany; |
| 33 | |
import javax.persistence.OneToOne; |
| 34 | |
import javax.persistence.Table; |
| 35 | |
import javax.persistence.Version; |
| 36 | |
|
| 37 | |
import org.hibernate.annotations.Fetch; |
| 38 | |
import org.hibernate.annotations.FetchMode; |
| 39 | |
import org.hibernate.annotations.GenericGenerator; |
| 40 | |
import org.hibernate.annotations.Parameter; |
| 41 | |
import org.kuali.rice.core.framework.persistence.jpa.OrmUtils; |
| 42 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
@Entity |
| 50 | |
|
| 51 | |
@Table(name="KREW_RTE_BRCH_T") |
| 52 | 0 | public class Branch implements Serializable { |
| 53 | |
|
| 54 | |
private static final long serialVersionUID = 7164561979112939112L; |
| 55 | |
|
| 56 | |
@Id |
| 57 | |
@GeneratedValue(generator="KREW_RTE_NODE_S") |
| 58 | |
@GenericGenerator(name="KREW_RTE_NODE_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={ |
| 59 | |
@Parameter(name="sequence_name",value="KREW_RTE_NODE_S"), |
| 60 | |
@Parameter(name="value_column",value="id") |
| 61 | |
}) |
| 62 | |
@Column(name="RTE_BRCH_ID") |
| 63 | |
private Long branchId; |
| 64 | |
@ManyToOne(fetch=FetchType.EAGER,cascade=CascadeType.PERSIST) |
| 65 | |
@JoinColumn(name="PARNT_ID") |
| 66 | |
private Branch parentBranch; |
| 67 | |
@Column(name="NM") |
| 68 | |
private String name; |
| 69 | 0 | @OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.PERSIST,CascadeType.MERGE}, mappedBy="branch", orphanRemoval=true) |
| 70 | |
@Fetch(value=FetchMode.SELECT) |
| 71 | |
private List<BranchState> branchState = new ArrayList<BranchState>(); |
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
@OneToOne(fetch=FetchType.EAGER,cascade={CascadeType.PERSIST}) |
| 80 | |
@JoinColumn(name="INIT_RTE_NODE_INSTN_ID") |
| 81 | |
private RouteNodeInstance initialNode; |
| 82 | |
@ManyToOne(fetch=FetchType.EAGER,cascade=CascadeType.PERSIST) |
| 83 | |
@JoinColumn(name="SPLT_RTE_NODE_INSTN_ID") |
| 84 | |
private RouteNodeInstance splitNode; |
| 85 | |
@ManyToOne(fetch=FetchType.EAGER,cascade={CascadeType.PERSIST,CascadeType.MERGE}) |
| 86 | |
@JoinColumn(name="JOIN_RTE_NODE_INSTN_ID") |
| 87 | |
private RouteNodeInstance joinNode; |
| 88 | |
|
| 89 | |
@Version |
| 90 | |
@Column(name="VER_NBR") |
| 91 | |
private Integer lockVerNbr; |
| 92 | |
|
| 93 | |
public String getName() { |
| 94 | 0 | return name; |
| 95 | |
} |
| 96 | |
|
| 97 | |
public void setName(String name) { |
| 98 | 0 | this.name = name; |
| 99 | 0 | } |
| 100 | |
|
| 101 | |
public RouteNodeInstance getSplitNode() { |
| 102 | 0 | return splitNode; |
| 103 | |
} |
| 104 | |
public void setSplitNode(RouteNodeInstance splitNode) { |
| 105 | 0 | this.splitNode = splitNode; |
| 106 | 0 | } |
| 107 | |
public RouteNodeInstance getInitialNode() { |
| 108 | 0 | return initialNode; |
| 109 | |
} |
| 110 | |
public void setInitialNode(RouteNodeInstance activeNode) { |
| 111 | 0 | this.initialNode = activeNode; |
| 112 | 0 | } |
| 113 | |
public Long getBranchId() { |
| 114 | 0 | return branchId; |
| 115 | |
} |
| 116 | |
public void setBranchId(Long branchId) { |
| 117 | 0 | this.branchId = branchId; |
| 118 | 0 | } |
| 119 | |
public RouteNodeInstance getJoinNode() { |
| 120 | 0 | return joinNode; |
| 121 | |
} |
| 122 | |
public void setJoinNode(RouteNodeInstance joinNode) { |
| 123 | 0 | this.joinNode = joinNode; |
| 124 | 0 | } |
| 125 | |
public Branch getParentBranch() { |
| 126 | 0 | return parentBranch; |
| 127 | |
} |
| 128 | |
public void setParentBranch(Branch parentBranch) { |
| 129 | 0 | this.parentBranch = parentBranch; |
| 130 | 0 | } |
| 131 | |
public BranchState getBranchState(String key) { |
| 132 | 0 | for (Iterator iter = branchState.iterator(); iter.hasNext();) { |
| 133 | 0 | BranchState branchState = (BranchState) iter.next(); |
| 134 | 0 | if (branchState.getKey().equals(key)) { |
| 135 | 0 | return branchState; |
| 136 | |
} |
| 137 | 0 | } |
| 138 | 0 | return null; |
| 139 | |
} |
| 140 | |
public void addBranchState(BranchState state) { |
| 141 | 0 | branchState.add(state); |
| 142 | 0 | state.setBranch(this); |
| 143 | 0 | } |
| 144 | |
public List<BranchState> getBranchState() { |
| 145 | 0 | return branchState; |
| 146 | |
} |
| 147 | |
public void setBranchState(List<BranchState> branchState) { |
| 148 | 0 | this.branchState.clear(); |
| 149 | 0 | this.branchState.addAll(branchState); |
| 150 | |
|
| 151 | 0 | } |
| 152 | |
|
| 153 | |
public BranchState getDocBranchState(int index){ |
| 154 | 0 | while (branchState.size() <= index) { |
| 155 | 0 | branchState.add(new BranchState()); |
| 156 | |
} |
| 157 | 0 | return (BranchState) branchState.get(index); |
| 158 | |
|
| 159 | |
} |
| 160 | |
|
| 161 | |
public Integer getLockVerNbr() { |
| 162 | 0 | return lockVerNbr; |
| 163 | |
} |
| 164 | |
public void setLockVerNbr(Integer lockVerNbr) { |
| 165 | 0 | this.lockVerNbr = lockVerNbr; |
| 166 | 0 | } |
| 167 | |
|
| 168 | |
public String toString() { |
| 169 | 0 | return "[Branch: branchId=" + branchId + |
| 170 | |
", parentBranch=" + (parentBranch == null ? "null" : parentBranch.getBranchId()) + |
| 171 | |
"]"; |
| 172 | |
} |
| 173 | |
|
| 174 | |
|
| 175 | |
public void beforeInsert(){ |
| 176 | 0 | OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager()); |
| 177 | 0 | } |
| 178 | |
} |
| 179 | |
|