org.mmbase.module.gui.html
Class StateManager

java.lang.Object
  extended by org.mmbase.module.gui.html.StateManager
All Implemented Interfaces:
CommandHandlerInterface

public class StateManager
extends Object
implements CommandHandlerInterface

The StateManager class maintains a list of EditStates for users logged on to MMBase through SCAN. It provides the states so a user can browse the SCAN editors and edit objects, letting the server remember the change history. Changes to the state are made either by calling a replace ($MOD) command, or by processing parameters passed to a SCAN page. State info (such as the current editnode number) can be retrieved using $MOD.

Version:
$Id: StateManager.java 35335 2009-05-21 08:14:41Z michiel $
Author:
Daniel Ockeloen, Hans Speijer, Pierre van Rooden
Application:
SCAN

Field Summary
(package private)  Hashtable<String,EditState> editStates
          Username to EditState mappings.
 MMBase mmBase
          Reference to the MMBase module.
 
Constructor Summary
StateManager(MMBase mmBase)
          Initialises the StateManager, by creating a new (empty) map of editstates.
 
Method Summary
(package private)  String createSelectionQuery(Hashtable<String,Object> skeys, MMObjectBuilder bul)
           
 EditState getEditState(String user)
          Retrieves the EditState for a user, or creates a new one if the user did not yet have an EditState assigned.
 List<String> getList(PageInfo sp, StringTagger args, StringTokenizer command)
          List commands
 Vector getOpenBuilders(EditState state, StringTagger args)
           
 EditState getState(String user)
          Retrieves the EditState for a user, or creates a new one if the user did not yet have an EditState assigned.
(package private)  void initLink(String user, String objectType)
          a new relation has been initiated and the EditState for the specific user is updated.
 void initUserStates()
          Loads all previously persistified editstates from the database.
(package private)  boolean newInsNode(EditState ed, String userName, StringTokenizer tok)
          Creates a new Node, depending on the builder name (or relation name) specified in the StringTokenizer.
 boolean process(PageInfo sp, StringTokenizer command, Hashtable cmds, Hashtable vars)
          The hook that passes all form related pages to the correct handler
 String replace(PageInfo sp, StringTokenizer commands)
          Handle a $MOD command.
(package private)  boolean setSearchValues(EditState ed, Hashtable vars)
          setSearchVals
(package private)  void updateEditField(String user, String fieldName)
          A field has been selected to edit and the EditState for the specific user is updated.
(package private)  void updateSelectedObject(String user, String objectID)
          An object has been selected and the EditState of the specific user is updated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mmBase

public MMBase mmBase
Reference to the MMBase module.


editStates

Hashtable<String,EditState> editStates
Username to EditState mappings. Each user has an editstate, stored in the statemanager.

Scope:
private
Constructor Detail

StateManager

public StateManager(MMBase mmBase)
Initialises the StateManager, by creating a new (empty) map of editstates.

Parameters:
mmBase - reference to the MMBase module
Method Detail

initUserStates

public void initUserStates()
Loads all previously persistified editstates from the database.

Deprecated-now:
removed per 1.7, does not do anything, and is never called

getEditState

public EditState getEditState(String user)
Retrieves the EditState for a user, or creates a new one if the user did not yet have an EditState assigned. The EditState contains status information for a specific user (which node is being edited, for instance). EditStates are associated by username. They are kept in memory as long as teh StateManager is.

Parameters:
user - the user for which to retrieve an EditState object
Returns:
the EditState objevt associated with this user

replace

public String replace(PageInfo sp,
                      StringTokenizer commands)
Handle a $MOD command. This generally replaces the command in the SCAN page with the value returned by the command.
Commands include:

Specified by:
replace in interface CommandHandlerInterface

newInsNode

boolean newInsNode(EditState ed,
                   String userName,
                   StringTokenizer tok)
Creates a new Node, depending on the builder name (or relation name) specified in the StringTokenizer. This method is used to create relation nodes

Parameters:
ed - Editstate in which to add the new node.
userName - User who becomes owner of the new node
tok - Tokens used to configure the node. The next three tokens should be:
  • The number of the node to link FROM
  • The number of the node to link TO
  • The name of the builder to use or relation to add (determines type of node and/or relation)
Returns:
Always true. If the addition was successful, a new node has been added to the EditState object.

setSearchValues

boolean setSearchValues(EditState ed,
                        Hashtable vars)
setSearchVals

Javadoc:

createSelectionQuery

String createSelectionQuery(Hashtable<String,Object> skeys,
                            MMObjectBuilder bul)
Javadoc:

updateSelectedObject

void updateSelectedObject(String user,
                          String objectID)
An object has been selected and the EditState of the specific user is updated.

Deprecated-now:
removed per 1.7, does not do anything, and is never called

updateEditField

void updateEditField(String user,
                     String fieldName)
A field has been selected to edit and the EditState for the specific user is updated.

Deprecated-now:
removed per 1.7, does not do anything, and is never called

initLink

void initLink(String user,
              String objectType)
a new relation has been initiated and the EditState for the specific user is updated.

Deprecated-now:
removed per 1.7, does not do anything, and is never called

getList

public List<String> getList(PageInfo sp,
                            StringTagger args,
                            StringTokenizer command)
                     throws ParseException
List commands

Specified by:
getList in interface CommandHandlerInterface
Throws:
ParseException
Javadoc:

process

public boolean process(PageInfo sp,
                       StringTokenizer command,
                       Hashtable cmds,
                       Hashtable vars)
The hook that passes all form related pages to the correct handler

Specified by:
process in interface CommandHandlerInterface
Javadoc:

getOpenBuilders

public Vector getOpenBuilders(EditState state,
                              StringTagger args)
Javadoc:

getState

public EditState getState(String user)
Retrieves the EditState for a user, or creates a new one if the user did not yet have an EditState assigned.

Parameters:
user - the user for which to retrieve an EditState object
Returns:
the EditState objevt associated with this user
Deprecated-now:
removed per 1.7, use getEditState() instead.


MMBase 2.0-SNAPSHOT - null