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