View Javadoc
1   /**
2    * Copyright 2005-2014 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.responsibility;
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  /**
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  @Entity
32  @Table(name = "KRIM_RSP_TMPL_T")
33  public class ResponsibilityTemplateBo extends TemplateBo implements TemplateContract {
34  
35      private static final long serialVersionUID = 1L;
36  
37      @PortableSequenceGenerator(name = "KRIM_RSP_TMPL_ID_S")
38      @GeneratedValue(generator = "KRIM_RSP_TMPL_ID_S")
39      @Id
40      @Column(name = "RSP_TMPL_ID")
41      private String id;
42  
43      /**
44       * Converts a mutable bo to its immutable counterpart
45       *
46       * @param bo the mutable business object
47       * @return the immutable object
48       */
49      public static Template to(TemplateContract bo) {
50          if (bo == null) {
51              return null;
52          }
53          return Template.Builder.create(bo).build();
54      }
55  
56      /**
57       * Converts a immutable object to its mutable counterpart
58       *
59       * @param im immutable object
60       * @return the mutable bo
61       */
62      public static ResponsibilityTemplateBo from(TemplateContract im) {
63          if (im == null) {
64              return null;
65          }
66          ResponsibilityTemplateBo bo = new ResponsibilityTemplateBo();
67          bo.id = im.getId();
68          bo.setNamespaceCode(im.getNamespaceCode());
69          bo.setName(im.getName());
70          bo.setDescription(im.getDescription());
71          bo.setActive(im.isActive());
72          bo.setKimTypeId(im.getKimTypeId());
73          bo.setVersionNumber(im.getVersionNumber());
74          bo.setObjectId(im.getObjectId());
75          return bo;
76      }
77  
78      @Override
79      public String getId() {
80          return id;
81      }
82  
83      public void setId(String id) {
84          this.id = id;
85      }
86  }