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.kim.impl.identity.residency;
17  
18  import javax.persistence.Column;
19  import javax.persistence.Entity;
20  import javax.persistence.GeneratedValue;
21  import javax.persistence.Id;
22  import javax.persistence.Table;
23  
24  import org.joda.time.DateTime;
25  import org.kuali.rice.kim.api.identity.CodedAttributeContract;
26  import org.kuali.rice.kim.api.identity.residency.EntityResidency;
27  import org.kuali.rice.kim.api.identity.residency.EntityResidencyContract;
28  import org.kuali.rice.krad.bo.DataObjectBase;
29  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
30  
31  @Entity
32  @Table(name = "KRIM_ENTITY_RESIDENCY_T")
33  public class EntityResidencyBo extends DataObjectBase implements EntityResidencyContract {
34  
35      private static final long serialVersionUID = 1L;
36  
37      @PortableSequenceGenerator(name = "KRIM_ENTITY_RESIDENCY_ID_S")
38      @GeneratedValue(generator = "KRIM_ENTITY_RESIDENCY_ID_S")
39      @Id
40      @Column(name = "ID")
41      private String id;
42  
43      @Column(name = "ENTITY_ID")
44      private String entityId;
45  
46      @Column(name = "DETERMINATION_METHOD")
47      private String determinationMethod;
48  
49      @Column(name = "IN_STATE")
50      private String inState;
51  
52      public static EntityResidency to(EntityResidencyBo bo) {
53          if (bo == null) {
54              return null;
55          }
56          return EntityResidency.Builder.create(bo).build();
57      }
58  
59      /**
60       * Creates a EntityResidencyBo business object from an immutable representation of a EntityResidency.
61       *
62       * @param immutable an immutable EntityResidency
63       * @return a EntityResidencyBo
64       */
65      public static EntityResidencyBo from(EntityResidency immutable) {
66          if (immutable == null) {
67              return null;
68          }
69          EntityResidencyBo bo = new EntityResidencyBo();
70          bo.entityId = immutable.getEntityId();
71          bo.id = immutable.getId();
72          bo.determinationMethod = immutable.getDeterminationMethod();
73          bo.inState = immutable.getInState();
74          bo.setVersionNumber(immutable.getVersionNumber());
75          bo.setObjectId(immutable.getObjectId());
76          return bo;
77      }
78  
79      @Override
80      public String getId() {
81          return id;
82      }
83  
84      public void setId(String id) {
85          this.id = id;
86      }
87  
88      @Override
89      public String getEntityId() {
90          return entityId;
91      }
92  
93      public void setEntityId(String entityId) {
94          this.entityId = entityId;
95      }
96  
97      @Override
98      public String getDeterminationMethod() {
99          return determinationMethod;
100     }
101 
102     public void setDeterminationMethod(String determinationMethod) {
103         this.determinationMethod = determinationMethod;
104     }
105 
106     @Override
107     public String getInState() {
108         return inState;
109     }
110 
111     public void setInState(String inState) {
112         this.inState = inState;
113     }
114 }