View Javadoc

1   /**
2    * Copyright 2005-2013 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.group;
17  
18  import org.kuali.rice.kim.api.common.attribute.KimAttribute;
19  import org.kuali.rice.kim.api.common.attribute.KimAttributeData;
20  import org.kuali.rice.kim.api.common.attribute.KimAttributeDataContract;
21  import org.kuali.rice.kim.api.common.attribute.KimAttributeDataHistory;
22  import org.kuali.rice.kim.impl.common.attribute.KimAttributeBo;
23  import org.kuali.rice.kim.impl.common.attribute.KimAttributeDataBo;
24  import org.kuali.rice.krad.data.jpa.eclipselink.PortableSequenceGenerator;
25  
26  import javax.persistence.Column;
27  import javax.persistence.Entity;
28  import javax.persistence.GeneratedValue;
29  import javax.persistence.Id;
30  import javax.persistence.Table;
31  
32  @Entity
33  @Table(name = "KRIM_HIST_GRP_ATTR_DATA_T")
34  public class GroupAttributeHistoryBo extends KimAttributeDataBo implements KimAttributeDataContract
35  {
36      private static final long serialVersionUID = -1358263879165065051L;
37  
38      @Id
39      @GeneratedValue(generator = "KRIM_HIST_GRP_ATTR_DATA_ID_S")
40      @PortableSequenceGenerator(name = "KRIM_HIST_GRP_ATTR_DATA_ID_S")
41      @Column(name="ATTR_DATA_ID")
42      private String id;
43  
44      @Column(name = "GRP_HIST_ID")
45      private String assignedToId;
46  
47      @Override
48      public String getId() {
49          return id;
50      }
51  
52      @Override
53      public void setId(String id) {
54          this.id = id;
55      }
56  
57      @Override
58      public String getAssignedToId() {
59          return assignedToId;
60      }
61  
62      @Override
63      public void setAssignedToId(String assignedToId) {
64          this.assignedToId = assignedToId;
65      }
66  
67      /**
68       * Converts a mutable bo to its immutable counterpart
69       * @param bo the mutable business object
70       * @return the immutable object
71       */
72      public static KimAttributeData to(GroupAttributeHistoryBo bo) {
73          if (bo == null) {
74              return null;
75          }
76  
77          return KimAttributeData.Builder.create(bo).build();
78      }
79  
80      /*public static GroupAttributeHistoryBo from(KimAttributeData im, Timestamp fromDate, Timestamp toDate) {
81          if (im == null) {
82              return null;
83          }
84  
85          GroupAttributeHistoryBo bo = new GroupAttributeHistoryBo();
86          bo.setId(im.getId());
87          bo.setAssignedToId(im.getAssignedToId());
88          bo.setKimAttribute(KimAttributeBo.from(im.getKimAttribute()));
89          final KimAttribute attribute = im.getKimAttribute();
90          bo.setKimAttributeId((attribute == null ? null : attribute.getId()));
91          bo.setAttributeValue(bo.getAttributeValue());
92          bo.setKimTypeId(im.getKimTypeId());
93          bo.setVersionNumber(im.getVersionNumber());
94          bo.setObjectId(im.getObjectId());
95  
96          return bo;
97      }*/
98  
99      public static GroupAttributeHistoryBo from(KimAttributeData im) {
100         if (im == null) {
101             return null;
102         }
103 
104         GroupAttributeHistoryBo bo = new GroupAttributeHistoryBo();
105         bo.setId(im.getId());
106         //bo.setHistoryId(im.getHistoryId());
107         bo.setAssignedToId(im.getAssignedToId());
108         //bo.setAssignedToHistoryId(im.getAssignedToHistoryId());
109         bo.setKimAttribute(KimAttributeBo.from(im.getKimAttribute()));
110         final KimAttribute attribute = im.getKimAttribute();
111         bo.setKimAttributeId((attribute == null ? null : attribute.getId()));
112         bo.setAttributeValue(bo.getAttributeValue());
113         bo.setKimTypeId(im.getKimTypeId());
114         bo.setVersionNumber(im.getVersionNumber());
115         bo.setObjectId(im.getObjectId());
116 
117         return bo;
118     }
119 
120 }