package eu.dnetlib.client.managers;

import java.util.ArrayList;

import eu.dnetlib.client.notification.NotificationEvent;

/**
 * Manager handling Notification ( Server Push) features. +Sends messages to
 * notificaton server on create-update-delete of components by the current user
 * +Receives notifications and handles created-updated-deleted components by
 * other users
 * 
 * 
 */
public interface NotificationManager {
	/**
	 * Starts up listeners and services for the given user
	 * 
	 * @param userId
	 */
	public void InitCometServices(String userId);

	/**
	 * Registers a user with @userId to the notification server so that he can
	 * receive updates
	 * 
	 * @param userId
	 */

	public void registerUser(String userId);

	public void unregisterUser(String userId, ArrayList<String> userLockedComponents);

	/***********************************************
	 * 
	 * Perform updates based on received notifications
	 * 
	 * 
	 * 
	 * *********************************************/

	/**
	 * Handles new items that have been sent by the Notification Server and
	 * caught by the Notification Listener.
	 * 
	 * Components cache and layout are updated
	 * 
	 * If among the received components are items that have been created locally
	 * by the current user, they are ignored, in order to avoid duplicate
	 * updates.
	 * 
	 * @param thenewEvent
	 */
	public void addNewItems(NotificationEvent thenewEvent);

	/**
	 * Handles updated items that have been sent by the Notification Server and
	 * caught by the Notification Listener.
	 * 
	 * * Components cache and layout are updated
	 * 
	 * If among the received components are items that have been updated locally
	 * by the current user, they are ignored, in order to avoid duplicate
	 * updates.
	 * 
	 * 
	 * @param thenewEvent
	 */
	public void updateItems(NotificationEvent thenewEvent);

	/**
	 * Handles deleted items that have been sent by the Notification Server and
	 * caught by the Notification Listener.
	 * 
	 * Components cache and layout are updated
	 * 
	 * If among the received components are items that have been deleted locally
	 * by the current user, they are ignored, in order to avoid duplicate
	 * updates.
	 * 
	 * @param thenewEvent
	 */
	public void deleteItems(NotificationEvent thenewEvent);

	/**
	 * 
	 * Handles new frames that have been sent by the Notification Server and
	 * caught by the Notification Listener.
	 * 
	 * Components cache and layout are updated
	 * 
	 * If among the received components are items that have been created locally
	 * by the current user, they are ignored, in order to avoid duplicate
	 * updates.
	 * 
	 * @param thenewEvent
	 */
	public void addNewFrames(NotificationEvent thenewEvent);

	/**
	 * Handles updated frames that have been sent by the Notification Server and
	 * caught by the Notification Listener.
	 * 
	 * Components cache and layout are updated
	 * 
	 * If among the received components are frames that have been updated
	 * locally by the current user, they are ignored, in order to avoid
	 * duplicate updates.
	 * 
	 * @param thenewEvent
	 */
	public void updateFrames(NotificationEvent thenewEvent);

	/****
	 * Handles deleted frames that have been sent by the Notification Server and
	 * caught by the Notification Listener.
	 * 
	 * Components cache and layout are updated
	 * 
	 * If among the received components are frames that have been deleted
	 * locally by the current user, they are ignored, in order to avoid
	 * duplicate updates.
	 * 
	 * @param thenewEvent
	 */
	public void deleteFrames(NotificationEvent thenewEvent);

	/**
	 * Handles new Topics that have been sent by the Notification Server and
	 * caught by the Notification Listener.
	 * 
	 * Components cache and layout are updated
	 * 
	 * If among the received components are topics that have been created
	 * locally by the current user, they are ignored, in order to avoid
	 * duplicate updates.
	 * 
	 * @param thenewEvent
	 */
	public void addNewTopics(NotificationEvent thenewEvent);

	/**
	 * Handles updated Topics that have been sent by the Notification Server and
	 * caught by the Notification Listener.
	 * 
	 * Components cache and layout are updated
	 * 
	 * If among the received components are topics that have been updated
	 * locally by the current user, they are ignored, in order to avoid
	 * duplicate updates. *
	 * 
	 * @param thenewEvent
	 */
	public void updateTopics(NotificationEvent thenewEvent);

	/**
	 * * Handles deleted Themes that have been sent by the Notification Server
	 * and caught by the Notification Listener.
	 * 
	 * Components cache and layout are updated
	 * 
	 * If among the received components are topics that have been deleted
	 * locally by the current user, they are ignored, in order to avoid
	 * duplicate updates.
	 * 
	 * @param thenewEvent
	 */
	public void deleteTopics(NotificationEvent thenewEvent);

	public void addNewThemes(NotificationEvent thenewEvent);

	public void updateThemes(NotificationEvent thenewEvent);

	public void deleteThemes(NotificationEvent thenewEvent);

	public void addNewUsers(NotificationEvent thenewEvent);

	public void updateUsers(NotificationEvent thenewEvent);

	public void deleteUsers(NotificationEvent thenewEvent);

	public void updateEfgProps(NotificationEvent thenewEvent);

	void destroyCometServices();

 

}
