View Javadoc

1   /**
2    * Copyright 2005-2013 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.kim.impl.identity.affiliation;
17  
18  import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliation;
19  import org.kuali.rice.krad.data.jpa.eclipselink.PortableSequenceGenerator;
20  
21  import javax.persistence.Column;
22  import javax.persistence.Entity;
23  import javax.persistence.FetchType;
24  import javax.persistence.GeneratedValue;
25  import javax.persistence.Id;
26  import javax.persistence.JoinColumn;
27  import javax.persistence.ManyToOne;
28  import javax.persistence.Table;
29  
30  @Entity
31  @Table(name = "KRIM_ENTITY_AFLTN_T")
32  public class EntityAffiliationBo extends EntityAffiliationBase {
33      private static final long serialVersionUID = 0L;
34      @Id
35      @GeneratedValue(generator = "KRIM_ENTITY_AFLTN_ID_S")
36      @PortableSequenceGenerator(name = "KRIM_ENTITY_AFLTN_ID_S")
37      @Column(name = "ENTITY_AFLTN_ID")
38      private String id;
39  
40      @ManyToOne(targetEntity = EntityAffiliationTypeBo.class, fetch = FetchType.EAGER, cascade = {})
41      @JoinColumn(
42              name = "AFLTN_TYP_CD", insertable = false, updatable = false)
43      private EntityAffiliationTypeBo affiliationType;
44  
45      public static EntityAffiliation to(EntityAffiliationBo bo) {
46          if (bo == null) {
47              return null;
48          }
49  
50          return EntityAffiliation.Builder.create(bo)
51                  .build();
52      }
53  
54      /**
55       * Creates a EntityAffiliationBo business object from an immutable representation of a EntityAffiliation.
56       *
57       * @param immutable an immutable EntityAffiliation
58       * @return a EntityAffiliationBo
59       */
60      public static EntityAffiliationBo from(EntityAffiliation immutable) {
61          if (immutable == null) {
62              return null;
63          }
64  
65          EntityAffiliationBo bo = new EntityAffiliationBo();
66          bo.setActive(immutable.isActive());
67          if (immutable.getAffiliationType() != null) {
68              bo.setAffiliationTypeCode(immutable.getAffiliationType().getCode());
69              bo.setAffiliationType(EntityAffiliationTypeBo.from(immutable.getAffiliationType()));
70          }
71  
72          bo.setId(immutable.getId());
73          bo.setCampusCode(immutable.getCampusCode());
74          bo.setEntityId(immutable.getEntityId());
75          bo.setActive(immutable.isActive());
76          bo.setDefaultValue(immutable.isDefaultValue());
77          bo.setVersionNumber(immutable.getVersionNumber());
78  
79          return bo;
80      }
81  
82      @Override
83      public EntityAffiliationTypeBo getAffiliationType() {
84          return this.affiliationType;
85      }
86  
87      public void setAffiliationType(EntityAffiliationTypeBo affiliationType) {
88          this.affiliationType = affiliationType;
89      }
90  
91      @Override
92      public String getId() {
93          return id;
94      }
95  
96      public void setId(String id) {
97          this.id = id;
98      }
99  }