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; 023import org.kuali.rice.kim.api.common.template.Template; 024import org.kuali.rice.kim.api.common.template.TemplateContract; 025import org.kuali.rice.kim.impl.common.template.TemplateBo; 026import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 027 028@Entity 029@Table(name = "KRIM_PERM_TMPL_T") 030public class PermissionTemplateBo extends TemplateBo implements TemplateContract { 031 032 private static final long serialVersionUID = 1L; 033 034 @PortableSequenceGenerator(name = "KRIM_PERM_TMPL_ID_S") 035 @GeneratedValue(generator = "KRIM_PERM_TMPL_ID_S") 036 @Id 037 @Column(name = "PERM_TMPL_ID") 038 protected String id; 039 040 /** 041 * Converts a mutable bo to its immutable counterpart 042 * @param bo the mutable business object 043 * @return the immutable object 044 */ 045 public static Template to(PermissionTemplateBo bo) { 046 if (bo == null) { 047 return null; 048 } 049 return Template.Builder.create(bo).build(); 050 } 051 052 /** 053 * Converts a immutable object to its mutable counterpart 054 * @param im immutable object 055 * @return the mutable bo 056 */ 057 public static PermissionTemplateBo from(Template im) { 058 if (im == null) { 059 return null; 060 } 061 PermissionTemplateBo bo = new PermissionTemplateBo(); 062 bo.setId(im.getId()); 063 bo.setNamespaceCode(im.getNamespaceCode()); 064 bo.setName(im.getName()); 065 bo.setDescription(im.getDescription()); 066 bo.setActive(im.isActive()); 067 bo.setKimTypeId(im.getKimTypeId()); 068 bo.setVersionNumber(im.getVersionNumber()); 069 bo.setObjectId(im.getObjectId()); 070 return bo; 071 } 072 073 @Override 074 public String getId() { 075 return id; 076 } 077 078 public void setId(String id) { 079 this.id = id; 080 } 081}