001/*
002 * JGrapes Event Driven Framework
003 * Copyright (C) 2017-2018 Michael N. Lipp
004 * 
005 * This program is free software; you can redistribute it and/or modify it 
006 * under the terms of the GNU Affero General Public License as published by 
007 * the Free Software Foundation; either version 3 of the License, or 
008 * (at your option) any later version.
009 * 
010 * This program is distributed in the hope that it will be useful, but 
011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License 
013 * for more details.
014 * 
015 * You should have received a copy of the GNU Affero General Public License along 
016 * with this program; if not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.jgrapes.portal.base.events;
020
021import org.jdrupes.json.JsonArray;
022import org.jgrapes.core.Event;
023import org.jgrapes.portal.base.RenderSupport;
024
025/**
026 * A decoded notification (as defined by the JSON RPC specification) that
027 * invokes a method on a portlet model. Usually, though not necessarily,
028 * the portlet component responds by sending a
029 * {@link NotifyPortletView} to update the portlet representation.
030 * 
031 * ![Event Sequence](NotifyPortletModelSeq.svg)
032 * 
033 * @startuml NotifyPortletModelSeq.svg
034 * hide footbox
035 * 
036 * Browser -> Portal: "notifyPortletModel"
037 * activate Portal
038 * Portal -> Portlet: NotifyPortletModel
039 * deactivate Portal
040 * activate Portlet
041 * Portlet -> Portal: NotifyPortletView
042 * deactivate Portlet
043 * activate Portal
044 * Portal -> Browser: "notifyPortletView"
045 * deactivate Portal
046 * 
047 * @enduml
048 */
049@SuppressWarnings("PMD.DataClass")
050public class NotifyPortletModel extends Event<Void> {
051
052    private final RenderSupport renderSupport;
053    private final String portletId;
054    private final String method;
055    private final JsonArray params;
056
057    /**
058     * Creates a new event.
059     * 
060     * @param renderSupport the render support from the portal in case
061     * the response requires it
062     * @param portletId the portlet model that the notification is 
063     * directed at 
064     * @param method the method to be executed
065     * @param params parameters
066     */
067    public NotifyPortletModel(RenderSupport renderSupport,
068            String portletId, String method, JsonArray params) {
069        this.renderSupport = renderSupport;
070        this.portletId = portletId;
071        this.method = method;
072        this.params = params;
073    }
074
075    /**
076     * Returns the render support.
077     * 
078     * @return the render support
079     */
080    public RenderSupport renderSupport() {
081        return renderSupport;
082    }
083
084    /**
085     * Returns the portlet id.
086     * 
087     * @return the portlet id
088     */
089    public String portletId() {
090        return portletId;
091    }
092
093    /**
094     * Returns the method.
095     * 
096     * @return the method
097     */
098    public String method() {
099        return method;
100    }
101
102    /**
103     * Returns the parameters.
104     * 
105     * @return the parameters
106     */
107    public JsonArray params() {
108        return params;
109    }
110}