View Javadoc
1   /**
2    * Copyright 2005-2015 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.GeneratedValue;
21  import javax.persistence.Id;
22  import javax.persistence.Table;
23  import org.kuali.rice.kim.api.common.template.Template;
24  import org.kuali.rice.kim.api.common.template.TemplateContract;
25  import org.kuali.rice.kim.impl.common.template.TemplateBo;
26  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
27  
28  @Entity
29  @Table(name = "KRIM_PERM_TMPL_T")
30  public class PermissionTemplateBo extends TemplateBo implements TemplateContract {
31  
32      private static final long serialVersionUID = 1L;
33  
34      @PortableSequenceGenerator(name = "KRIM_PERM_TMPL_ID_S")
35      @GeneratedValue(generator = "KRIM_PERM_TMPL_ID_S")
36      @Id
37      @Column(name = "PERM_TMPL_ID")
38      protected String id;
39  
40      /**
41       * Converts a mutable bo to its immutable counterpart
42       * @param bo the mutable business object
43       * @return the immutable object
44       */
45      public static Template to(PermissionTemplateBo bo) {
46          if (bo == null) {
47              return null;
48          }
49          return Template.Builder.create(bo).build();
50      }
51  
52      /**
53       * Converts a immutable object to its mutable counterpart
54       * @param im immutable object
55       * @return the mutable bo
56       */
57      public static PermissionTemplateBo from(Template im) {
58          if (im == null) {
59              return null;
60          }
61          PermissionTemplateBo bo = new PermissionTemplateBo();
62          bo.setId(im.getId());
63          bo.setNamespaceCode(im.getNamespaceCode());
64          bo.setName(im.getName());
65          bo.setDescription(im.getDescription());
66          bo.setActive(im.isActive());
67          bo.setKimTypeId(im.getKimTypeId());
68          bo.setVersionNumber(im.getVersionNumber());
69          bo.setObjectId(im.getObjectId());
70          return bo;
71      }
72  
73      @Override
74      public String getId() {
75          return id;
76      }
77  
78      public void setId(String id) {
79          this.id = id;
80      }
81  }