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.group; 017 018import javax.persistence.Column; 019import javax.persistence.Entity; 020import javax.persistence.GeneratedValue; 021import javax.persistence.Id; 022import javax.persistence.Table; 023import org.kuali.rice.kim.api.common.attribute.KimAttribute; 024import org.kuali.rice.kim.api.common.attribute.KimAttributeData; 025import org.kuali.rice.kim.impl.common.attribute.KimAttributeBo; 026import org.kuali.rice.kim.impl.common.attribute.KimAttributeDataBo; 027import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 028 029@Entity 030@Table(name = "KRIM_GRP_ATTR_DATA_T") 031public class GroupAttributeBo extends KimAttributeDataBo { 032 033 private static final long serialVersionUID = 6380313567330578976L; 034 035 @PortableSequenceGenerator(name = "KRIM_GRP_ATTR_DATA_ID_S") 036 @GeneratedValue(generator = "KRIM_GRP_ATTR_DATA_ID_S") 037 @Id 038 @Column(name = "ATTR_DATA_ID") 039 private String id; 040 041 @Column(name = "GRP_ID") 042 private String assignedToId; 043 044 @Override 045 public String getId() { 046 return id; 047 } 048 049 @Override 050 public void setId(String id) { 051 this.id = id; 052 } 053 054 @Override 055 public String getAssignedToId() { 056 return assignedToId; 057 } 058 059 @Override 060 public void setAssignedToId(String assignedToId) { 061 this.assignedToId = assignedToId; 062 } 063 064 public static KimAttributeData to(GroupAttributeBo bo) { 065 if (bo == null) { 066 return null; 067 } 068 return KimAttributeData.Builder.create(bo).build(); 069 } 070 071 public static GroupAttributeBo from(KimAttributeData im) { 072 if (im == null) { 073 return null; 074 } 075 GroupAttributeBo bo = new GroupAttributeBo(); 076 bo.setId(im.getId()); 077 bo.setAssignedToId(im.getAssignedToId()); 078 bo.setKimAttribute(KimAttributeBo.from(im.getKimAttribute())); 079 final KimAttribute attribute = im.getKimAttribute(); 080 bo.setKimAttributeId((attribute == null ? null : attribute.getId())); 081 bo.setAttributeValue(bo.getAttributeValue()); 082 bo.setKimTypeId(im.getKimTypeId()); 083 bo.setVersionNumber(im.getVersionNumber()); 084 bo.setObjectId(im.getObjectId()); 085 return bo; 086 } 087}