View Javadoc
1   /**
2    * Copyright 2005-2015 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 java.sql.Timestamp;
19  import javax.persistence.Column;
20  import javax.persistence.Entity;
21  import javax.persistence.GeneratedValue;
22  import javax.persistence.Id;
23  import javax.persistence.Table;
24  import org.kuali.rice.kim.api.group.GroupMember;
25  import org.kuali.rice.kim.api.group.GroupMemberContract;
26  import org.kuali.rice.kim.impl.membership.AbstractMemberBo;
27  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
28  import javax.persistence.Cacheable;
29  
30  @Entity
31  @Cacheable(false)
32  @Table(name = "KRIM_GRP_MBR_T")
33  public class GroupMemberBo extends AbstractMemberBo implements GroupMemberContract {
34  
35      private static final long serialVersionUID = 6773749266062306217L;
36  
37      @PortableSequenceGenerator(name = "KRIM_GRP_MBR_ID_S")
38      @GeneratedValue(generator = "KRIM_GRP_MBR_ID_S")
39      @Id
40      @Column(name = "GRP_MBR_ID")
41      private String id;
42  
43      @Column(name = "GRP_ID")
44      private String groupId;
45  
46      public static GroupMember to(GroupMemberBo bo) {
47          if (bo == null) {
48              return null;
49          }
50          return GroupMember.Builder.create(bo).build();
51      }
52  
53      public static GroupMemberBo from(GroupMember im) {
54          if (im == null) {
55              return null;
56          }
57          GroupMemberBo bo = new GroupMemberBo();
58          bo.setId(im.getId());
59          bo.setGroupId(im.getGroupId());
60          bo.setMemberId(im.getMemberId());
61          bo.setTypeCode(im.getType().getCode());
62          bo.setActiveFromDateValue(im.getActiveFromDate() == null ? null : new Timestamp(im.getActiveFromDate().getMillis()));
63          bo.setActiveToDateValue(im.getActiveToDate() == null ? null : new Timestamp(im.getActiveToDate().getMillis()));
64          bo.setVersionNumber(im.getVersionNumber());
65          bo.setObjectId(im.getObjectId());
66          return bo;
67      }
68  
69      @Override
70      public String getId() {
71          return id;
72      }
73  
74      public void setId(String id) {
75          this.id = id;
76      }
77  
78      @Override
79      public String getGroupId() {
80          return groupId;
81      }
82  
83      public void setGroupId(String groupId) {
84          this.groupId = groupId;
85      }
86  }