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.Table; 021import org.kuali.rice.kim.api.common.attribute.KimAttributeData; 022import org.kuali.rice.kim.api.common.attribute.KimAttributeDataContract; 023import org.kuali.rice.kim.impl.common.attribute.KimAttributeBo; 024import org.kuali.rice.kim.impl.common.attribute.KimAttributeDataBo; 025 026/** 027 * @author Kuali Rice Team (rice.collab@kuali.org) 028 */ 029@Entity 030@Table(name="KRIM_PERM_ATTR_DATA_T") 031public class PermissionAttributeBo extends KimAttributeDataBo implements KimAttributeDataContract { 032 033 @Column(name="PERM_ID") 034 private String assignedToId; 035 036 /** 037 * Converts a mutable bo to its immutable counterpart 038 * @param bo the mutable business object 039 * @return the immutable object 040 */ 041 public static KimAttributeData to(PermissionAttributeBo bo) { 042 if (bo == null) { 043 return null; 044 } 045 046 return KimAttributeData.Builder.create(bo).build(); 047 } 048 049 /** 050 * Converts a immutable object to its mutable counterpart 051 * @param im immutable object 052 * @return the mutable bo 053 */ 054 public static PermissionAttributeBo from(KimAttributeData im) { 055 if (im == null) { 056 return null; 057 } 058 059 PermissionAttributeBo bo = new PermissionAttributeBo(); 060 bo.setId(im.getId()); 061 bo.setAssignedToId(im.getAssignedToId()); 062 bo.setKimAttribute(KimAttributeBo.from(im.getKimAttribute())); 063 bo.setKimAttributeId(im.getKimAttribute() != null ? im.getKimAttribute().getId() : null); 064 bo.setAttributeValue(bo.getAttributeValue()); 065 bo.setKimTypeId(im.getKimTypeId()); 066 bo.setVersionNumber(im.getVersionNumber()); 067 bo.setObjectId(im.getObjectId()); 068 069 return bo; 070 } 071 072 @Override 073 public String getAssignedToId() { 074 return assignedToId; 075 } 076 077 @Override 078 public void setAssignedToId(String assignedToId) { 079 this.assignedToId = assignedToId; 080 } 081}