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.krms.impl.repository;
17  
18  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
19  import org.kuali.rice.krms.api.repository.BaseAttributeContract;
20  import org.kuali.rice.krms.api.repository.type.KrmsAttributeDefinitionContract;
21  
22  import javax.persistence.Column;
23  import javax.persistence.Entity;
24  import javax.persistence.FetchType;
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 java.io.Serializable;
31  
32  @Entity
33  @Table(name = "KRMS_CNTXT_ATTR_T")
34  public class ContextAttributeBo extends BaseAttributeBo implements BaseAttributeContract, Serializable {
35  
36      private static final long serialVersionUID = 1l;
37  
38      @PortableSequenceGenerator(name = "KRMS_CNTXT_ATTR_S")
39      @GeneratedValue(generator = "KRMS_CNTXT_ATTR_S")
40      @Id
41      @Column(name = "CNTXT_ATTR_ID")
42      private String id;
43  
44      @ManyToOne()
45      @JoinColumn(name = "CNTXT_ID", referencedColumnName = "CNTXT_ID")
46      private ContextBo context;
47  
48      @ManyToOne(fetch= FetchType.EAGER)
49      @JoinColumn(name = "ATTR_DEFN_ID", referencedColumnName = "ATTR_DEFN_ID")
50      private KrmsAttributeDefinitionBo attributeDefinition;
51  
52      @Override
53      public String getId() {
54          return id;
55      }
56  
57      public void setId(String id) {
58          this.id = id;
59      }
60  
61      public String getContextId() {
62          if (context != null) {
63              return context.getId();
64          }
65  
66          return null;
67      }
68  
69      public ContextBo getContext() {
70          return context;
71      }
72  
73      public void setContext(ContextBo context) {
74          this.context = context;
75      }
76  
77      @Override
78      public KrmsAttributeDefinitionContract getAttributeDefinition() {
79          return attributeDefinition;
80      }
81  
82      public void setAttributeDefinition(KrmsAttributeDefinitionBo attributeDefinition) {
83          this.attributeDefinition = attributeDefinition;
84      }
85  
86  }