001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.ken.bo; 017 018import org.hibernate.annotations.GenericGenerator; 019import org.hibernate.annotations.Parameter; 020import org.kuali.rice.ken.api.notification.NotificationChannelReviewer; 021import org.kuali.rice.ken.api.notification.NotificationChannelReviewerContract; 022import org.kuali.rice.ken.api.notification.UserChannelSubscription; 023import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; 024 025import javax.persistence.*; 026 027/** 028 * A reviewer for a notification publications to a NotificationChannel 029 * @author Kuali Rice Team (rice.collab@kuali.org) 030 */ 031@Entity 032@Table(name="KREN_RVWER_T") 033public class NotificationChannelReviewerBo extends PersistableBusinessObjectBase implements NotificationChannelReviewerContract { 034 @Id 035 @GeneratedValue(generator="KREN_RVWER_S") 036 @GenericGenerator(name="KREN_RVWER_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={ 037 @Parameter(name="sequence_name",value="KREN_RVWER_S"), 038 @Parameter(name="value_column",value="id") 039 }) 040 @Column(name="RVWER_ID") 041 private Long id; 042 @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH, CascadeType.DETACH }) 043 @JoinColumn(name="CHNL_ID") 044 private NotificationChannelBo channel; 045 @Column(name="TYP", nullable=false) 046 private String reviewerType; 047 @Column(name="PRNCPL_ID", nullable=false) 048 private String reviewerId; 049 050 /** 051 * Returns the primary key value 052 * @return the primary key value 053 */ 054 public Long getId() { 055 return id; 056 } 057 058 /** 059 * Sets the primary key value 060 * @param id the primary key value 061 */ 062 public void setId(Long id) { 063 this.id = id; 064 } 065 066 /** 067 * Returns the channel with which this reviewer is associated 068 * @return the channel with which this reviewer is associated 069 */ 070 public NotificationChannelBo getChannel() { 071 return channel; 072 } 073 074 /** 075 * Sets the channel with which this reviewer is associated 076 * @param channel the channel with which this reviewer is associated 077 */ 078 public void setChannel(NotificationChannelBo channel) { 079 this.channel = channel; 080 } 081 082 /** 083 * Returns the user id of the reviewer. This is abstract but ultimately 084 * will need to be resolved to a KEW user/group 085 * @return the user id of the reviewer 086 */ 087 public String getReviewerId() { 088 return reviewerId; 089 } 090 091 /** 092 * Sets the user id of the reviewer 093 * @param reviewerId the user id of the reviewer 094 */ 095 public void setReviewerId(String reviewerId) { 096 this.reviewerId = reviewerId; 097 } 098 099 /** 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}