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.ken.bo;
17  
18  import org.kuali.rice.ken.api.notification.NotificationChannelReviewer;
19  import org.kuali.rice.ken.api.notification.NotificationChannelReviewerContract;
20  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
21  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
22  
23  import javax.persistence.CascadeType;
24  import javax.persistence.Column;
25  import javax.persistence.Entity;
26  import javax.persistence.FetchType;
27  import javax.persistence.GeneratedValue;
28  import javax.persistence.Id;
29  import javax.persistence.JoinColumn;
30  import javax.persistence.OneToOne;
31  import javax.persistence.Table;
32  
33  /**
34   * A reviewer for a notification publications to a NotificationChannel
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   */
37  @Entity
38  @Table(name="KREN_RVWER_T")
39  public class NotificationChannelReviewerBo extends PersistableBusinessObjectBase implements NotificationChannelReviewerContract {
40      @Id
41      @GeneratedValue(generator="KREN_RVWER_S")
42      @PortableSequenceGenerator(name="KREN_RVWER_S")
43  	@Column(name="RVWER_ID")
44  	private Long id;
45      @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH, CascadeType.DETACH })
46  	@JoinColumn(name="CHNL_ID")
47  	private NotificationChannelBo channel;
48      @Column(name="TYP", nullable=false)
49  	private String reviewerType;
50      @Column(name="PRNCPL_ID", nullable=false)
51  	private String reviewerId;
52  
53      /**
54       * Returns the primary key value
55       * @return the primary key value
56       */
57      public Long getId() {
58          return id;
59      }
60  
61      /**
62       * Sets the primary key value
63       * @param id the primary key value
64       */
65      public void setId(Long id) {
66          this.id = id;
67      }
68      
69      /**
70       * Returns the channel with which this reviewer is associated
71       * @return the channel with which this reviewer is associated
72       */
73      public NotificationChannelBo getChannel() {
74          return channel;
75      }
76  
77      /**
78       * Sets the channel with which this reviewer is associated
79       * @param channel the channel with which this reviewer is associated
80       */
81      public void setChannel(NotificationChannelBo channel) {
82          this.channel = channel;
83      }
84  
85      /**
86       * Returns the user id of the reviewer.  This is abstract but ultimately
87       * will need to be resolved to a KEW user/group
88       * @return the user id of the reviewer
89       */
90      public String getReviewerId() {
91          return reviewerId;
92      }
93      
94      /**
95       * Sets the user id of the reviewer
96       * @param reviewerId the user id of the reviewer
97       */
98      public void setReviewerId(String reviewerId) {
99          this.reviewerId = reviewerId;
100     }
101     
102     /**
103      * Returns the type of reviewer, USER or GROUP
104      * @return the type of reviewer, USER or GROUP
105      */
106     public String getReviewerType() {
107         return reviewerType;
108     }
109 
110     /**
111      * Sets the type of reviewer, USER or GROUP
112      * @param reviewerType the type of reviewer, USER or GROUP
113      */
114     public void setReviewerType(String reviewerType) {
115         this.reviewerType = reviewerType;
116     }
117 
118     /**
119      * Converts a mutable bo to its immutable counterpart
120      * @param bo the mutable business object
121      * @return the immutable object
122      */
123     public static NotificationChannelReviewer to(NotificationChannelReviewerBo bo) {
124         if (bo == null) {
125             return null;
126         }
127 
128         return NotificationChannelReviewer.Builder.create(bo).build();
129     }
130 
131     /**
132      * Converts a immutable object to its mutable counterpart
133      * @param im immutable object
134      * @return the mutable bo
135      */
136     public static NotificationChannelReviewerBo from(NotificationChannelReviewer im) {
137         if (im == null) {
138             return null;
139         }
140 
141         NotificationChannelReviewerBo bo = new NotificationChannelReviewerBo();
142         bo.setId(im.getId());
143         bo.setVersionNumber(im.getVersionNumber());
144         bo.setObjectId(im.getObjectId());
145 
146         bo.setReviewerType(im.getReviewerType());
147         bo.setReviewerId(im.getReviewerId());
148         bo.setChannel(im.getChannel() == null ? null : NotificationChannelBo.from(im.getChannel()));
149 
150         return bo;
151     }
152 }