001/** 002 * Copyright 2005-2017 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.kuali.rice.ken.api.notification.NotificationChannelReviewer; 019import org.kuali.rice.ken.api.notification.NotificationChannelReviewerContract; 020import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; 021import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 022 023import javax.persistence.CascadeType; 024import javax.persistence.Column; 025import javax.persistence.Entity; 026import javax.persistence.FetchType; 027import javax.persistence.GeneratedValue; 028import javax.persistence.Id; 029import javax.persistence.JoinColumn; 030import javax.persistence.OneToOne; 031import javax.persistence.Table; 032 033/** 034 * A reviewer for a notification publications to a NotificationChannel 035 * @author Kuali Rice Team (rice.collab@kuali.org) 036 */ 037@Entity 038@Table(name="KREN_RVWER_T") 039public class NotificationChannelReviewerBo extends PersistableBusinessObjectBase implements NotificationChannelReviewerContract { 040 @Id 041 @GeneratedValue(generator="KREN_RVWER_S") 042 @PortableSequenceGenerator(name="KREN_RVWER_S") 043 @Column(name="RVWER_ID") 044 private Long id; 045 @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH, CascadeType.DETACH }) 046 @JoinColumn(name="CHNL_ID") 047 private NotificationChannelBo channel; 048 @Column(name="TYP", nullable=false) 049 private String reviewerType; 050 @Column(name="PRNCPL_ID", nullable=false) 051 private String reviewerId; 052 053 /** 054 * Returns the primary key value 055 * @return the primary key value 056 */ 057 public Long getId() { 058 return id; 059 } 060 061 /** 062 * Sets the primary key value 063 * @param id the primary key value 064 */ 065 public void setId(Long id) { 066 this.id = id; 067 } 068 069 /** 070 * Returns the channel with which this reviewer is associated 071 * @return the channel with which this reviewer is associated 072 */ 073 public NotificationChannelBo getChannel() { 074 return channel; 075 } 076 077 /** 078 * Sets the channel with which this reviewer is associated 079 * @param channel the channel with which this reviewer is associated 080 */ 081 public void setChannel(NotificationChannelBo channel) { 082 this.channel = channel; 083 } 084 085 /** 086 * Returns the user id of the reviewer. This is abstract but ultimately 087 * will need to be resolved to a KEW user/group 088 * @return the user id of the reviewer 089 */ 090 public String getReviewerId() { 091 return reviewerId; 092 } 093 094 /** 095 * Sets the user id of the reviewer 096 * @param reviewerId the user id of the reviewer 097 */ 098 public void setReviewerId(String reviewerId) { 099 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}