View Javadoc

1   /**
2    * Copyright 2005-2012 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.Table;
21  import org.kuali.rice.kim.api.common.attribute.KimAttributeData;
22  import org.kuali.rice.kim.api.common.attribute.KimAttributeDataContract;
23  import org.kuali.rice.kim.impl.common.attribute.KimAttributeBo;
24  import org.kuali.rice.kim.impl.common.attribute.KimAttributeDataBo;
25  
26  /**
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  @Entity
30  @Table(name="KRIM_PERM_ATTR_DATA_T")
31  public class PermissionAttributeBo extends KimAttributeDataBo implements KimAttributeDataContract {
32  
33      @Column(name="PERM_ID")
34      private String assignedToId;
35  
36      /**
37       * Converts a mutable bo to its immutable counterpart
38       * @param bo the mutable business object
39       * @return the immutable object
40       */
41      public static KimAttributeData to(PermissionAttributeBo bo) {
42          if (bo == null) {
43              return null;
44          }
45  
46          return KimAttributeData.Builder.create(bo).build();
47      }
48  
49      /**
50       * Converts a immutable object to its mutable counterpart
51       * @param im immutable object
52       * @return the mutable bo
53       */
54      public static PermissionAttributeBo from(KimAttributeData im) {
55          if (im == null) {
56              return null;
57          }
58  
59          PermissionAttributeBo bo = new PermissionAttributeBo();
60          bo.setId(im.getId());
61          bo.setAssignedToId(im.getAssignedToId());
62          bo.setKimAttribute(KimAttributeBo.from(im.getKimAttribute()));
63          bo.setKimAttributeId(im.getKimAttribute() != null ? im.getKimAttribute().getId() : null);
64          bo.setAttributeValue(bo.getAttributeValue());
65          bo.setKimTypeId(im.getKimTypeId());
66          bo.setVersionNumber(im.getVersionNumber());
67          bo.setObjectId(im.getObjectId());
68  
69          return bo;
70      }
71  
72      @Override
73      public String getAssignedToId() {
74          return assignedToId;
75      }
76  
77      @Override
78      public void setAssignedToId(String assignedToId) {
79          this.assignedToId = assignedToId;
80      }
81  }