001/** 002 * Copyright 2005-2016 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.kim.impl.identity.residency; 017 018import javax.persistence.Column; 019import javax.persistence.Entity; 020import javax.persistence.GeneratedValue; 021import javax.persistence.Id; 022import javax.persistence.Table; 023 024import org.joda.time.DateTime; 025import org.kuali.rice.kim.api.identity.CodedAttributeContract; 026import org.kuali.rice.kim.api.identity.residency.EntityResidency; 027import org.kuali.rice.kim.api.identity.residency.EntityResidencyContract; 028import org.kuali.rice.krad.bo.DataObjectBase; 029import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 030 031@Entity 032@Table(name = "KRIM_ENTITY_RESIDENCY_T") 033public class EntityResidencyBo extends DataObjectBase implements EntityResidencyContract { 034 035 private static final long serialVersionUID = 1L; 036 037 @PortableSequenceGenerator(name = "KRIM_ENTITY_RESIDENCY_ID_S") 038 @GeneratedValue(generator = "KRIM_ENTITY_RESIDENCY_ID_S") 039 @Id 040 @Column(name = "ID") 041 private String id; 042 043 @Column(name = "ENTITY_ID") 044 private String entityId; 045 046 @Column(name = "DETERMINATION_METHOD") 047 private String determinationMethod; 048 049 @Column(name = "IN_STATE") 050 private String inState; 051 052 public static EntityResidency to(EntityResidencyBo bo) { 053 if (bo == null) { 054 return null; 055 } 056 return EntityResidency.Builder.create(bo).build(); 057 } 058 059 /** 060 * Creates a EntityResidencyBo business object from an immutable representation of a EntityResidency. 061 * 062 * @param immutable an immutable EntityResidency 063 * @return a EntityResidencyBo 064 */ 065 public static EntityResidencyBo from(EntityResidency immutable) { 066 if (immutable == null) { 067 return null; 068 } 069 EntityResidencyBo bo = new EntityResidencyBo(); 070 bo.entityId = immutable.getEntityId(); 071 bo.id = immutable.getId(); 072 bo.determinationMethod = immutable.getDeterminationMethod(); 073 bo.inState = immutable.getInState(); 074 bo.setVersionNumber(immutable.getVersionNumber()); 075 bo.setObjectId(immutable.getObjectId()); 076 return bo; 077 } 078 079 @Override 080 public String getId() { 081 return id; 082 } 083 084 public void setId(String id) { 085 this.id = id; 086 } 087 088 @Override 089 public String getEntityId() { 090 return entityId; 091 } 092 093 public void setEntityId(String entityId) { 094 this.entityId = entityId; 095 } 096 097 @Override 098 public String getDeterminationMethod() { 099 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}