001/**
002 * Copyright 2005-2015 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.NotificationResponse;
019import org.kuali.rice.ken.api.notification.NotificationResponseContract;
020import org.kuali.rice.ken.util.NotificationConstants;
021import org.kuali.rice.kim.api.permission.Permission;
022import org.kuali.rice.kim.impl.permission.PermissionTemplateBo;
023
024/**
025 * This class represents the data structure that will house information for
026 * a Notification Response
027 *
028 * TODO: Really this class should just be replaced by NotificationResponse...
029 *
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032public class NotificationResponseBo implements NotificationResponseContract {
033    
034    private String status;
035    
036    private String message;
037
038    private Long notificationId;
039    
040    /**
041     * Constructs a NotificationResponse.java instance.
042     */
043    public NotificationResponseBo() {
044        status = NotificationConstants.RESPONSE_STATUSES.SUCCESS;
045    }
046    
047    /**
048     * Gets the status attribute. 
049     * @return Returns the response status.
050     */
051    public String getStatus() {
052        return status;
053    }
054
055    /**
056     * Sets the status attribute value.
057     * @param status The status to set.
058     */
059    public void setStatus(String status) {
060        this.status = status;
061    }
062    
063    /**
064     * Gets the message attribute. 
065     * @return Returns the response message.
066     */
067    
068    public String getMessage() {
069        return message;
070    }
071
072    /**
073     * Sets the message attribute value.
074     * @param message The message to set.
075     */
076    public void setMessage(String message) {
077        this.message = message;
078    }
079
080    /**
081     * Gets the id of the sent notification
082     * @return the id of the sent notification
083     */
084    public Long getNotificationId() {
085        return notificationId;
086    }
087
088    /**
089     * Sets the id of the sent notification
090     * @param notificationId the id of the sent notification
091     */
092    public void setNotificationId(Long notificationId) {
093        this.notificationId = notificationId;
094    }
095
096    /**
097     * Converts a mutable bo to its immutable counterpart
098     * @param bo the mutable business object
099     * @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}