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