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.GeneratedValue;
21  import javax.persistence.Id;
22  import javax.persistence.Table;
23  
24  import org.kuali.rice.kim.api.common.attribute.KimAttributeData;
25  import org.kuali.rice.kim.api.common.attribute.KimAttributeDataContract;
26  import org.kuali.rice.kim.impl.common.attribute.KimAttributeBo;
27  import org.kuali.rice.kim.impl.common.attribute.KimAttributeDataBo;
28  import org.kuali.rice.krad.bo.BusinessObject;
29  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
30  
31  /**
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  @Entity
35  @Table(name = "KRIM_PERM_ATTR_DATA_T")
36  public class PermissionAttributeBo extends KimAttributeDataBo implements KimAttributeDataContract, BusinessObject {
37      private static final long serialVersionUID = 1L;
38  
39      @PortableSequenceGenerator(name = "KRIM_ATTR_DATA_ID_S")
40      @GeneratedValue(generator = "KRIM_ATTR_DATA_ID_S")
41      @Id
42      @Column(name = "ATTR_DATA_ID")
43      private String id;
44  
45      @Column(name = "PERM_ID")
46      private String assignedToId;
47  
48      @Override
49      public String getId() {
50          return id;
51      }
52  
53      @Override
54      public void setId(String id) {
55          this.id = id;
56      }
57  
58      @Override
59      public String getAssignedToId() {
60          return assignedToId;
61      }
62  
63      @Override
64      public void setAssignedToId(String assignedToId) {
65          this.assignedToId = assignedToId;
66      }
67  
68      /**
69       * Converts a mutable bo to its immutable counterpart
70       * @param bo the mutable business object
71       * @return the immutable object
72       */
73      public static KimAttributeData to(PermissionAttributeBo bo) {
74          if (bo == null) {
75              return null;
76          }
77          return KimAttributeData.Builder.create(bo).build();
78      }
79  
80      /**
81       * Converts a immutable object to its mutable counterpart
82       * @param im immutable object
83       * @return the mutable bo
84       */
85      public static PermissionAttributeBo from(KimAttributeData im) {
86          if (im == null) {
87              return null;
88          }
89          PermissionAttributeBo bo = new PermissionAttributeBo();
90          bo.setId(im.getId());
91          bo.setAssignedToId(im.getAssignedToId());
92          bo.setKimAttribute(KimAttributeBo.from(im.getKimAttribute()));
93          bo.setKimAttributeId(im.getKimAttribute() != null ? im.getKimAttribute().getId() : null);
94          bo.setAttributeValue(bo.getAttributeValue());
95          bo.setKimTypeId(im.getKimTypeId());
96          bo.setVersionNumber(im.getVersionNumber());
97          bo.setObjectId(im.getObjectId());
98          return bo;
99      }
100 
101     @Override
102     public void refresh() {
103     }
104 }