001/** 002 * Copyright 2005-2017 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.krms.impl.repository; 017 018import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 019import org.kuali.rice.krms.api.repository.BaseAttributeContract; 020import org.kuali.rice.krms.api.repository.type.KrmsAttributeDefinitionContract; 021 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.Table; 030import java.io.Serializable; 031 032@Entity 033@Table(name = "KRMS_CNTXT_ATTR_T") 034public class ContextAttributeBo extends BaseAttributeBo implements BaseAttributeContract, Serializable { 035 036 private static final long serialVersionUID = 1l; 037 038 @PortableSequenceGenerator(name = "KRMS_CNTXT_ATTR_S") 039 @GeneratedValue(generator = "KRMS_CNTXT_ATTR_S") 040 @Id 041 @Column(name = "CNTXT_ATTR_ID") 042 private String id; 043 044 @ManyToOne() 045 @JoinColumn(name = "CNTXT_ID", referencedColumnName = "CNTXT_ID") 046 private ContextBo context; 047 048 @ManyToOne(fetch= FetchType.EAGER) 049 @JoinColumn(name = "ATTR_DEFN_ID", referencedColumnName = "ATTR_DEFN_ID") 050 private KrmsAttributeDefinitionBo attributeDefinition; 051 052 @Override 053 public String getId() { 054 return id; 055 } 056 057 public void setId(String id) { 058 this.id = id; 059 } 060 061 public String getContextId() { 062 if (context != null) { 063 return context.getId(); 064 } 065 066 return null; 067 } 068 069 public ContextBo getContext() { 070 return context; 071 } 072 073 public void setContext(ContextBo context) { 074 this.context = context; 075 } 076 077 @Override 078 public KrmsAttributeDefinitionContract getAttributeDefinition() { 079 return attributeDefinition; 080 } 081 082 public void setAttributeDefinition(KrmsAttributeDefinitionBo attributeDefinition) { 083 this.attributeDefinition = attributeDefinition; 084 } 085 086}