View Javadoc

1   /**
2    * Copyright 2005-2012 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.NotificationResponse;
19  import org.kuali.rice.ken.api.notification.NotificationResponseContract;
20  import org.kuali.rice.ken.util.NotificationConstants;
21  import org.kuali.rice.kim.api.permission.Permission;
22  import org.kuali.rice.kim.impl.permission.PermissionTemplateBo;
23  
24  /**
25   * This class represents the data structure that will house information for
26   * a Notification Response
27   *
28   * TODO: Really this class should just be replaced by NotificationResponse...
29   *
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public class NotificationResponseBo implements NotificationResponseContract {
33      
34      private String status;
35      
36      private String message;
37  
38      private Long notificationId;
39      
40      /**
41       * Constructs a NotificationResponse.java instance.
42       */
43      public NotificationResponseBo() {
44  	status = NotificationConstants.RESPONSE_STATUSES.SUCCESS;
45      }
46      
47      /**
48       * Gets the status attribute. 
49       * @return Returns the response status.
50       */
51      public String getStatus() {
52  	return status;
53      }
54  
55      /**
56       * Sets the status attribute value.
57       * @param status The status to set.
58       */
59      public void setStatus(String status) {
60  	this.status = status;
61      }
62      
63      /**
64       * Gets the message attribute. 
65       * @return Returns the response message.
66       */
67      
68      public String getMessage() {
69  	return message;
70      }
71  
72      /**
73       * Sets the message attribute value.
74       * @param message The message to set.
75       */
76      public void setMessage(String message) {
77  	this.message = message;
78      }
79  
80      /**
81       * Gets the id of the sent notification
82       * @return the id of the sent notification
83       */
84      public Long getNotificationId() {
85          return notificationId;
86      }
87  
88      /**
89       * Sets the id of the sent notification
90       * @param notificationId the id of the sent notification
91       */
92      public void setNotificationId(Long notificationId) {
93          this.notificationId = notificationId;
94      }
95  
96      /**
97       * Converts a mutable bo to its immutable counterpart
98       * @param bo the mutable business object
99       * @return the immutable object
100      */
101     public static NotificationResponse to(NotificationResponseBo bo) {
102         if (bo == null) {
103             return null;
104         }
105 
106         return NotificationResponse.Builder.create(bo).build();
107     }
108 
109     /**
110      * Converts a immutable object to its mutable counterpart
111      * @param im immutable object
112      * @return the mutable bo
113      */
114     public static NotificationResponseBo from(NotificationResponse im) {
115         if (im == null) {
116             return null;
117         }
118 
119         NotificationResponseBo bo = new NotificationResponseBo();
120         bo.setMessage(im.getMessage());
121         bo.setNotificationId(im.getNotificationId());
122         bo.setStatus(im.getStatus());
123 
124         return bo;
125     }
126 }