View Javadoc
1   /**
2    * Copyright 2005-2015 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.engine.node;
17  
18  import org.hibernate.annotations.GenericGenerator;
19  import org.hibernate.annotations.Parameter;
20  import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
21  import org.kuali.rice.kew.api.doctype.ProcessDefinitionContract;
22  import org.kuali.rice.kew.doctype.bo.DocumentType;
23  import org.kuali.rice.kew.service.KEWServiceLocator;
24  
25  import javax.persistence.CascadeType;
26  import javax.persistence.Column;
27  import javax.persistence.Entity;
28  import javax.persistence.FetchType;
29  import javax.persistence.GeneratedValue;
30  import javax.persistence.Id;
31  import javax.persistence.JoinColumn;
32  import javax.persistence.ManyToOne;
33  import javax.persistence.OneToOne;
34  import javax.persistence.Table;
35  import javax.persistence.Version;
36  import java.io.Serializable;
37  
38  
39  /**
40   * Represents a route path defined on a {@link DocumentType}.  A ProcessDefinition is a named entity which
41   * simply points to an initial {@link RouteNode} which represents the beginning of the ProcessDefinition.
42   * The path of the process can then be followed using the next nodes defined on the route nodes. 
43   *
44   * @author Kuali Rice Team (rice.collab@kuali.org)
45   */
46  @Entity
47  @Table(name="KREW_DOC_TYP_PROC_T")
48  //@Sequence(name="KREW_RTE_NODE_S",property="processId")
49  public class ProcessDefinitionBo implements Serializable, ProcessDefinitionContract {
50  
51  	private static final long serialVersionUID = -6338857095673479752L;
52      
53      @Id
54      @GeneratedValue(generator="KREW_RTE_NODE_S")
55  	@GenericGenerator(name="KREW_RTE_NODE_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
56  			@Parameter(name="sequence_name",value="KREW_RTE_NODE_S"),
57  			@Parameter(name="value_column",value="id")
58  	})
59  	@Column(name="DOC_TYP_PROC_ID")
60  	private String processId;
61  	@Column(name="NM")
62  	private String name;
63  	@ManyToOne(fetch=FetchType.EAGER)
64  	@JoinColumn(name="DOC_TYP_ID")
65  	private DocumentType documentType;
66  	@OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST, CascadeType.MERGE})
67  	@JoinColumn(name="INIT_RTE_NODE_ID")
68  	private RouteNode initialRouteNode;
69      @Column(name="INIT_IND")
70  	private boolean initial = false;
71  	@Version
72  	@Column(name="VER_NBR")
73  	private Integer lockVerNbr;
74  	
75  	public String getProcessId() {
76  		return processId;
77  	}
78  	public void setProcessId(String processId) {
79  		this.processId = processId;
80  	}
81  	public DocumentType getDocumentType() {
82  		return documentType;
83  	}
84  	public void setDocumentType(DocumentType documentType) {
85  		this.documentType = documentType;
86  	}
87  	public RouteNode getInitialRouteNode() {
88  		return initialRouteNode;
89  	}
90  	public void setInitialRouteNode(RouteNode initialRouteNode) {
91  		this.initialRouteNode = initialRouteNode;
92  	}
93  	public String getName() {
94  		return name;
95  	}
96  	public void setName(String name) {
97  		this.name = name;
98  	}
99  	public boolean isInitial() {
100 		return initial;
101 	}
102 	public void setInitial(boolean initial) {
103 		this.initial = initial;
104 	}
105 	public Integer getLockVerNbr() {
106 		return lockVerNbr;
107 	}
108 	public void setLockVerNbr(Integer lockVerNbr) {
109 		this.lockVerNbr = lockVerNbr;
110 	}
111 
112 	//@PrePersist
113 	public void beforeInsert(){
114 		OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager());
115 	}
116 
117 	@Override
118     public String getId() {
119         if (processId == null) {
120             return null;
121         }
122         return processId.toString();
123     }
124 
125     @Override
126     public Long getVersionNumber() {
127         if (lockVerNbr == null) {
128             return null;
129         }
130         return new Long(lockVerNbr.longValue());
131     }
132 
133     @Override
134     public String getDocumentTypeId() {
135         if (documentType == null) {
136             return null;
137         }
138         return documentType.getId();
139     }
140 
141 }