001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kew.engine.node;
017
018import org.kuali.rice.kew.api.doctype.ProcessDefinitionContract;
019import org.kuali.rice.kew.doctype.bo.DocumentType;
020
021import javax.persistence.CascadeType;
022import javax.persistence.Column;
023import javax.persistence.Entity;
024import javax.persistence.FetchType;
025import javax.persistence.GeneratedValue;
026import javax.persistence.Id;
027import javax.persistence.JoinColumn;
028import javax.persistence.ManyToOne;
029import javax.persistence.OneToOne;
030import javax.persistence.Table;
031import javax.persistence.Version;
032import java.io.Serializable;
033
034
035/**
036 * Represents a route path defined on a {@link DocumentType}.  A ProcessDefinition is a named entity which
037 * simply points to an initial {@link RouteNode} which represents the beginning of the ProcessDefinition.
038 * The path of the process can then be followed using the next nodes defined on the route nodes. 
039 *
040 * @author Kuali Rice Team (rice.collab@kuali.org)
041 */
042@Entity
043@Table(name="KREW_DOC_TYP_PROC_T")
044//@Sequence(name="KREW_RTE_NODE_S",property="processId")
045public class ProcessDefinitionBo implements Serializable, ProcessDefinitionContract {
046
047        private static final long serialVersionUID = -6338857095673479752L;
048    
049    @Id
050    @GeneratedValue(generator="KREW_RTE_NODE_S")
051        @Column(name="DOC_TYP_PROC_ID")
052        private String processId;
053        @Column(name="NM")
054        private String name;
055        @ManyToOne(fetch=FetchType.EAGER)
056        @JoinColumn(name="DOC_TYP_ID")
057        private DocumentType documentType;
058        @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST, CascadeType.MERGE})
059        @JoinColumn(name="INIT_RTE_NODE_ID")
060        private RouteNode initialRouteNode;
061    @Column(name="INIT_IND")
062        private boolean initial = false;
063        @Version
064        @Column(name="VER_NBR")
065        private Integer lockVerNbr;
066        
067        public String getProcessId() {
068                return processId;
069        }
070        public void setProcessId(String processId) {
071                this.processId = processId;
072        }
073        public DocumentType getDocumentType() {
074                return documentType;
075        }
076        public void setDocumentType(DocumentType documentType) {
077                this.documentType = documentType;
078        }
079        public RouteNode getInitialRouteNode() {
080                return initialRouteNode;
081        }
082        public void setInitialRouteNode(RouteNode initialRouteNode) {
083                this.initialRouteNode = initialRouteNode;
084        }
085        public String getName() {
086                return name;
087        }
088        public void setName(String name) {
089                this.name = name;
090        }
091        public boolean isInitial() {
092                return initial;
093        }
094        public void setInitial(boolean initial) {
095                this.initial = initial;
096        }
097        public Integer getLockVerNbr() {
098                return lockVerNbr;
099        }
100        public void setLockVerNbr(Integer lockVerNbr) {
101                this.lockVerNbr = lockVerNbr;
102        }
103
104        @Override
105    public String getId() {
106        if (processId == null) {
107            return null;
108        }
109        return processId.toString();
110    }
111
112    @Override
113    public Long getVersionNumber() {
114        if (lockVerNbr == null) {
115            return null;
116        }
117        return new Long(lockVerNbr.longValue());
118    }
119
120    @Override
121    public String getDocumentTypeId() {
122        if (documentType == null) {
123            return null;
124        }
125        return documentType.getId();
126    }
127
128}