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