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