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.permission; 017 018import javax.persistence.Column; 019import javax.persistence.Entity; 020import javax.persistence.GeneratedValue; 021import javax.persistence.Id; 022import javax.persistence.Table; 023 024import org.kuali.rice.kim.api.common.attribute.KimAttributeData; 025import org.kuali.rice.kim.api.common.attribute.KimAttributeDataContract; 026import org.kuali.rice.kim.impl.common.attribute.KimAttributeBo; 027import org.kuali.rice.kim.impl.common.attribute.KimAttributeDataBo; 028import org.kuali.rice.krad.bo.BusinessObject; 029import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 030 031/** 032 * @author Kuali Rice Team (rice.collab@kuali.org) 033 */ 034@Entity 035@Table(name = "KRIM_PERM_ATTR_DATA_T") 036public class PermissionAttributeBo extends KimAttributeDataBo implements KimAttributeDataContract, BusinessObject { 037 private static final long serialVersionUID = 1L; 038 039 @PortableSequenceGenerator(name = "KRIM_ATTR_DATA_ID_S") 040 @GeneratedValue(generator = "KRIM_ATTR_DATA_ID_S") 041 @Id 042 @Column(name = "ATTR_DATA_ID") 043 private String id; 044 045 @Column(name = "PERM_ID") 046 private String assignedToId; 047 048 @Override 049 public String getId() { 050 return id; 051 } 052 053 @Override 054 public void setId(String id) { 055 this.id = id; 056 } 057 058 @Override 059 public String getAssignedToId() { 060 return assignedToId; 061 } 062 063 @Override 064 public void setAssignedToId(String assignedToId) { 065 this.assignedToId = assignedToId; 066 } 067 068 /** 069 * Converts a mutable bo to its immutable counterpart 070 * @param bo the mutable business object 071 * @return the immutable object 072 */ 073 public static KimAttributeData to(PermissionAttributeBo bo) { 074 if (bo == null) { 075 return null; 076 } 077 return KimAttributeData.Builder.create(bo).build(); 078 } 079 080 /** 081 * Converts a immutable object to its mutable counterpart 082 * @param im immutable object 083 * @return the mutable bo 084 */ 085 public static PermissionAttributeBo from(KimAttributeData im) { 086 if (im == null) { 087 return null; 088 } 089 PermissionAttributeBo bo = new PermissionAttributeBo(); 090 bo.setId(im.getId()); 091 bo.setAssignedToId(im.getAssignedToId()); 092 bo.setKimAttribute(KimAttributeBo.from(im.getKimAttribute())); 093 bo.setKimAttributeId(im.getKimAttribute() != null ? im.getKimAttribute().getId() : null); 094 bo.setAttributeValue(bo.getAttributeValue()); 095 bo.setKimTypeId(im.getKimTypeId()); 096 bo.setVersionNumber(im.getVersionNumber()); 097 bo.setObjectId(im.getObjectId()); 098 return bo; 099 } 100 101 @Override 102 public void refresh() { 103 } 104}