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.responsibility; 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/** 029 * @author Kuali Rice Team (rice.collab@kuali.org) 030 */ 031@Entity 032@Table(name = "KRIM_RSP_TMPL_T") 033public class ResponsibilityTemplateBo extends TemplateBo implements TemplateContract { 034 035 private static final long serialVersionUID = 1L; 036 037 @PortableSequenceGenerator(name = "KRIM_RSP_TMPL_ID_S") 038 @GeneratedValue(generator = "KRIM_RSP_TMPL_ID_S") 039 @Id 040 @Column(name = "RSP_TMPL_ID") 041 private String id; 042 043 /** 044 * Converts a mutable bo to its immutable counterpart 045 * 046 * @param bo the mutable business object 047 * @return the immutable object 048 */ 049 public static Template to(TemplateContract bo) { 050 if (bo == null) { 051 return null; 052 } 053 return Template.Builder.create(bo).build(); 054 } 055 056 /** 057 * Converts a immutable object to its mutable counterpart 058 * 059 * @param im immutable object 060 * @return the mutable bo 061 */ 062 public static ResponsibilityTemplateBo from(TemplateContract im) { 063 if (im == null) { 064 return null; 065 } 066 ResponsibilityTemplateBo bo = new ResponsibilityTemplateBo(); 067 bo.id = im.getId(); 068 bo.setNamespaceCode(im.getNamespaceCode()); 069 bo.setName(im.getName()); 070 bo.setDescription(im.getDescription()); 071 bo.setActive(im.isActive()); 072 bo.setKimTypeId(im.getKimTypeId()); 073 bo.setVersionNumber(im.getVersionNumber()); 074 bo.setObjectId(im.getObjectId()); 075 return bo; 076 } 077 078 @Override 079 public String getId() { 080 return id; 081 } 082 083 public void setId(String id) { 084 this.id = id; 085 } 086}