View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.impl.permission;
17  
18  import javax.persistence.Column;
19  import javax.persistence.Entity;
20  import javax.persistence.Id;
21  import javax.persistence.Table;
22  import org.kuali.rice.kim.api.common.template.Template;
23  import org.kuali.rice.kim.api.common.template.TemplateContract;
24  import org.kuali.rice.kim.impl.common.template.TemplateBo;
25  
26  @Entity
27  @Table(name="KRIM_PERM_TMPL_T")
28  public class PermissionTemplateBo extends TemplateBo implements TemplateContract {
29      private static final long serialVersionUID = 1L;
30  
31      @Id
32      @Column(name="PERM_TMPL_ID")
33      private String id;
34  
35      /**
36       * Converts a mutable bo to its immutable counterpart
37       * @param bo the mutable business object
38       * @return the immutable object
39       */
40      public static Template to(PermissionTemplateBo bo) {
41          if (bo == null) {
42              return null;
43          }
44  
45          return Template.Builder.create(bo).build();
46      }
47  
48      /**
49       * Converts a immutable object to its mutable counterpart
50       * @param im immutable object
51       * @return the mutable bo
52       */
53      public static PermissionTemplateBo from(Template im) {
54          if (im == null) {
55              return null;
56          }
57  
58          PermissionTemplateBo bo = new PermissionTemplateBo();
59          bo.setId(im.getId());
60          bo.setNamespaceCode(im.getNamespaceCode());
61          bo.setName(im.getName());
62          bo.setDescription(im.getDescription());
63          bo.setActive(im.isActive());
64          bo.setKimTypeId(im.getKimTypeId());
65          bo.setVersionNumber(im.getVersionNumber());
66          bo.setObjectId(im.getObjectId());
67  
68          return bo;
69      }
70  
71      @Override
72      public String getId() {
73          return id;
74      }
75  
76      public void setId(String id) {
77          this.id = id;
78      }
79  
80  }