View Javadoc
1   /**
2    * Copyright 2005-2014 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.impl.peopleflow;
17  
18  import org.kuali.rice.core.api.mo.common.Versioned;
19  import org.kuali.rice.kew.api.repository.type.KewAttributeDefinition;
20  import org.kuali.rice.kew.impl.type.KewAttributeDefinitionBo;
21  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
22  
23  import javax.persistence.Column;
24  import javax.persistence.Entity;
25  import javax.persistence.GeneratedValue;
26  import javax.persistence.Id;
27  import javax.persistence.JoinColumn;
28  import javax.persistence.ManyToOne;
29  import javax.persistence.Table;
30  import javax.persistence.Version;
31  import java.io.Serializable;
32  
33  @Entity
34  @Table(name = "KREW_PPL_FLW_ATTR_T")
35  public class PeopleFlowAttributeBo implements Serializable, Versioned {
36  
37      @Id
38      @GeneratedValue(generator = "KREW_PPL_FLW_ATTR_S")
39      @PortableSequenceGenerator(name = "KREW_PPL_FLW_ATTR_S")
40      @Column(name="PPL_FLW_ATTR_ID", nullable = false)
41      private String id;
42  
43      @Column(name="ATTR_VAL")
44      private String value;
45  
46      @Version
47      @Column(name="VER_NBR", nullable = false)
48      private Long versionNumber;
49  
50      @ManyToOne
51      @JoinColumn(name = "PPL_FLW_ID", nullable = false)
52      private PeopleFlowBo peopleFlow;
53  
54      @ManyToOne
55      @JoinColumn(name="ATTR_DEFN_ID", nullable = false)
56      private KewAttributeDefinitionBo attributeDefinition;
57  
58      public static PeopleFlowAttributeBo from(KewAttributeDefinition attributeDefinition, String id, PeopleFlowBo peopleFlow,
59              String value) {
60  
61          if (null == attributeDefinition) {
62              return null;
63          }
64  
65          PeopleFlowAttributeBo peopleFlowAttributeBo = new PeopleFlowAttributeBo();
66          peopleFlowAttributeBo.setId(id);
67          peopleFlowAttributeBo.setPeopleFlow(peopleFlow);
68          peopleFlowAttributeBo.setValue(value);
69          peopleFlowAttributeBo.setAttributeDefinition(KewAttributeDefinitionBo.from(attributeDefinition));
70  
71          return peopleFlowAttributeBo;
72      }
73  
74      /**
75       * Default constructor.
76       */
77      public PeopleFlowAttributeBo() { }
78  
79      /**
80       * Returns the people flow attribute id.
81       * @return the people flow attribute id
82       */
83      public String getId() {
84          return id;
85      }
86  
87      /**
88       * @see #getId()
89       */
90      public void setId(String id) {
91          this.id = id;
92      }
93  
94      public PeopleFlowBo getPeopleFlow() {
95          return peopleFlow;
96      }
97  
98      public void setPeopleFlow(PeopleFlowBo peopleFlow) {
99          this.peopleFlow = peopleFlow;
100     }
101 
102     /**
103      * Returns the attribute value.
104      * @return the attribute value
105      */
106     public String getValue() {
107         return value;
108     }
109 
110     /**
111      * @see #getValue()
112      */
113     public void setValue(String value) {
114         this.value = value;
115     }
116 
117     /**
118      * Returns the version number.
119      * @return the version number
120      */
121     public Long getVersionNumber() {
122         return versionNumber;
123     }
124 
125     /**
126      * @see #getVersionNumber()
127      */
128     public void setVersionNumber(Long versionNumber) {
129         this.versionNumber = versionNumber;
130     }
131 
132     /**
133      * Returns a {@link KewAttributeDefinitionBo}
134      * @return {@link KewAttributeDefinitionBo}
135      */
136     public KewAttributeDefinitionBo getAttributeDefinition() {
137         return attributeDefinition;
138     }
139 
140     /**
141      * @see #getAttributeDefinitionId()
142      */
143     public void setAttributeDefinition(KewAttributeDefinitionBo attributeDefinition) {
144         this.attributeDefinition = attributeDefinition;
145     }
146 
147     /**
148      * Returns the @{link KewAttributeDefinitionBo} id
149      * @return the @{link KewAttributeDefinitonBo} id
150      */
151     public String getAttributeDefinitionId() {
152         if (null != this.attributeDefinition) {
153             return this.attributeDefinition.getId();
154         } else {
155             return null;
156         }
157     }
158 }