yawda.data.model.application
Class CModule

java.lang.Object
  extended byyawda.data.model.application.CModule

public final class CModule
extends Object

This class represent a module of an application. A module is an element like a page, a frameset, a frame, a form, a button, a link and it can also represent an Action handler.

Author:
Quentin Anciaux

Field Summary
static String A_HREF
          Comment for A_HREF This module represent an html link (a)
static String ACTION
          Comment for ACTION This module represent a struts action handler
static String APPLICATION
          Comment for APPLICATION This module represent an Application, the root module is of this type.
static String BLOCK
          Comment for BLOCK This module represent an html block (div, span, ...)
static String BUTTON
          Comment for BUTTON This module represent an html button (input type="submit,button")
static String CHECKBOX
          Comment for CHECKBOX This module represent an html check box (input type=checkbox)
static String COMBOBOX
          Comment for COMBOBOX This module represent an html combo/list box(tag select)
static String ERR_MSG
          Comment for ERR_MSG This module represent an error message
static String FILE
          Comment for FILE This module represent a file
static String FORM
          Comment for FORM This module represent an html form
static String FRAME
          Comment for FRAME This module represent an html frame
static String FRAMESET
          Comment for FRAMESET This module represent an html frameset
static String IMAGE
          Comment for IMAGE This module represent an html image tag
static String LABEL
          Comment for LABEL This module represent a multilanguage resource
static String PAGE
          Comment for PAGE This module represent an html page/any file type
static String PORTLET
          Comment for PORTLET This module represent a portlet
static String RADIOBUTTON
          Comment for RADIOBUTTON This module represent an html radio button (input type=radio)
static String REF_PORTLET
          Comment for REF_PORTLET This module represent a reference to a portlet
static String SCRIPT
          Comment for SCRIPT This module represent a java script file or a java script tag in a PAGE
static String TABLE
          Comment for TABLE This module represent an html table
static String TABLE_COLUMN
          Comment for TABLE_COLUMN This module represent an html table column (td)
static String TABLE_HEADER
          Comment for TABLE_HEADER This module represent an html table row th
static String TABLE_ROW
          Comment for TABLE_ROW This module represent an html table row tr
static String TEXTAREA
          Comment for TEXTAREA This module represent an html textarea
static String TEXTFIELD
          Comment for TEXTFIELD This module represent an html input field (input type=text)
static String TREE
          Comment for TREE This module represent a tree view
static String TREE_ITEM
          Comment for TREE_ITEM This module represent a tree view node
 
Constructor Summary
CModule(String name, String type, boolean isPublic)
          Create a new module
CModule(String name, String type, boolean isPublic, CModule parent)
          Create a new module
 
Method Summary
 void addCSSFile(String href, String rel, String title)
           
 CGroup addGroup(CGroup group)
          Add a group to this module
 String[] addJSCall(String event, String call)
          add a javascript call on event on this module
 String addJSFile(String src)
           
 CNavigationItem addSourceNavigationItems(CNavigationItem navItem)
           
 String[] addSysparam(String name, String value)
          Add a system parameter to this module.
 String addValue(String key, String value)
          Add a custom attribute to the module
 CModule appendChild(CModule module)
           
static boolean checkEvent(String event)
           
static boolean checkSecurity(CModule module, javax.servlet.http.HttpServletRequest request)
           
static boolean checkType(String type)
           
 String get(String key)
          Get a custom attribute of the module
 CAction getAction()
           
 CModule getChildModule(String name)
           
 Iterator getChildModules()
           
 String[] getCSSFile(String href)
           
 Iterator getCSSFiles()
           
 Iterator getDestinationNavigationItems()
           
 Iterator getGroups()
           
 String getId()
           
 String getJSCall(String event)
           
 Iterator getJSCalls()
           
 Iterator getJSFiles()
           
static CModule getModuleForId(CModule module, String id)
           
 CModule getModuleForId(String id)
           
static CModule getModuleForPath(CModule module, String path)
           
 CModule getModuleForPath(String path)
           
 String getName()
           
 CModule getParent()
           
 String getPath()
           
 CModule getRoot()
           
 CNavigationItem getSourceNavigationItem(String name)
           
 Iterator getSourceNavigationItems()
           
 String getSysparam(String name)
           
 Iterator getSysparams()
           
 String getTranslation(javax.servlet.http.HttpServletRequest request)
           
 String getType()
           
 String getURL()
           
 String getValue(String key)
          Get a custom attribute of the module
 Iterator getValues()
          A Map.Entry based iterator on the custom attribute
 boolean hasGroups()
           
 boolean isAllConnected()
           
 boolean isLinkedToGroup(String name)
           
 boolean isProtected()
           
 boolean isPublic()
           
 boolean isPublicOnly()
           
 CAction setAction(CAction action)
          Set an action to this module.
 void setPublicOnly(boolean isPublicOnly)
           
 String toString()
           
 String toString(String tabs)
           
static CModule unmarshall(Node node, CModule parentModule)
          Unmarshall a module from a DOM node.
protected  void validate()
           
protected  void validateCSS()
           
protected  void validateSysparam()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

APPLICATION

public static final String APPLICATION
Comment for APPLICATION This module represent an Application, the root module is of this type.

See Also:
Constant Field Values

PAGE

public static final String PAGE
Comment for PAGE This module represent an html page/any file type

See Also:
Constant Field Values

PORTLET

public static final String PORTLET
Comment for PORTLET This module represent a portlet

See Also:
Constant Field Values

REF_PORTLET

public static final String REF_PORTLET
Comment for REF_PORTLET This module represent a reference to a portlet

See Also:
Constant Field Values

FRAMESET

public static final String FRAMESET
Comment for FRAMESET This module represent an html frameset

See Also:
Constant Field Values

FRAME

public static final String FRAME
Comment for FRAME This module represent an html frame

See Also:
Constant Field Values

BLOCK

public static final String BLOCK
Comment for BLOCK This module represent an html block (div, span, ...)

See Also:
Constant Field Values

A_HREF

public static final String A_HREF
Comment for A_HREF This module represent an html link (a)

See Also:
Constant Field Values

ERR_MSG

public static final String ERR_MSG
Comment for ERR_MSG This module represent an error message

See Also:
Constant Field Values

BUTTON

public static final String BUTTON
Comment for BUTTON This module represent an html button (input type="submit,button")

See Also:
Constant Field Values

IMAGE

public static final String IMAGE
Comment for IMAGE This module represent an html image tag

See Also:
Constant Field Values

LABEL

public static final String LABEL
Comment for LABEL This module represent a multilanguage resource

See Also:
Constant Field Values

FORM

public static final String FORM
Comment for FORM This module represent an html form

See Also:
Constant Field Values

ACTION

public static final String ACTION
Comment for ACTION This module represent a struts action handler

See Also:
Constant Field Values

TABLE

public static final String TABLE
Comment for TABLE This module represent an html table

See Also:
Constant Field Values

TABLE_COLUMN

public static final String TABLE_COLUMN
Comment for TABLE_COLUMN This module represent an html table column (td)

See Also:
Constant Field Values

TABLE_ROW

public static final String TABLE_ROW
Comment for TABLE_ROW This module represent an html table row tr

See Also:
Constant Field Values

TABLE_HEADER

public static final String TABLE_HEADER
Comment for TABLE_HEADER This module represent an html table row th

See Also:
Constant Field Values

TEXTFIELD

public static final String TEXTFIELD
Comment for TEXTFIELD This module represent an html input field (input type=text)

See Also:
Constant Field Values

TEXTAREA

public static final String TEXTAREA
Comment for TEXTAREA This module represent an html textarea

See Also:
Constant Field Values

TREE

public static final String TREE
Comment for TREE This module represent a tree view

See Also:
Constant Field Values

TREE_ITEM

public static final String TREE_ITEM
Comment for TREE_ITEM This module represent a tree view node

See Also:
Constant Field Values

SCRIPT

public static final String SCRIPT
Comment for SCRIPT This module represent a java script file or a java script tag in a PAGE

See Also:
Constant Field Values

FILE

public static final String FILE
Comment for FILE This module represent a file

See Also:
Constant Field Values

COMBOBOX

public static final String COMBOBOX
Comment for COMBOBOX This module represent an html combo/list box(tag select)

See Also:
Constant Field Values

RADIOBUTTON

public static final String RADIOBUTTON
Comment for RADIOBUTTON This module represent an html radio button (input type=radio)

See Also:
Constant Field Values

CHECKBOX

public static final String CHECKBOX
Comment for CHECKBOX This module represent an html check box (input type=checkbox)

See Also:
Constant Field Values
Constructor Detail

CModule

public CModule(String name,
               String type,
               boolean isPublic)
Create a new module

Parameters:
name - the name
type - the type (PAGE,FRAMESET,FRAME,HREF,FORM, ACTION,BUTTON,COMBOBOX,RADIOBUTTON,CHECKBOX,BLOCK)
isPublic - true if the module is available as anonymous

CModule

public CModule(String name,
               String type,
               boolean isPublic,
               CModule parent)
Create a new module

Parameters:
name - the name
type - the type (PAGE,FRAMESET,FRAME,HREF,FORM, ACTION,BUTTON,COMBOBOX,RADIOBUTTON,CHECKBOX,BLOCK)
isPublic - true if the module is available as anonymous
parent - the parent module
Method Detail

checkType

public static final boolean checkType(String type)
Parameters:
type - the module type
Returns:
true if type is a valid module type

addValue

public final String addValue(String key,
                             String value)
Add a custom attribute to the module

Parameters:
key - the name of the attribute
value - the value of the attribute
Returns:
the value of the added attribute or null if the attribute is a general module attribute

getValue

public final String getValue(String key)
Get a custom attribute of the module

Parameters:
key - the name of the attribute
Returns:
the value or null if not found

get

public final String get(String key)
Get a custom attribute of the module

Parameters:
key - the name of the attribute
Returns:
the value or null if not found

getValues

public final Iterator getValues()
A Map.Entry based iterator on the custom attribute

Returns:

setAction

public final CAction setAction(CAction action)
Set an action to this module. Work only for module of type : * PAGE * FRAMESET * ACTION

Parameters:
action - the action handler to associate to this module
Returns:
the action handler or null if not set

getAction

public final CAction getAction()
Returns:
the action handler or null if not set

getId

public final String getId()
Returns:
the unique identifier

appendChild

public final CModule appendChild(CModule module)
Parameters:
module - the child to append
Returns:
the appended child

getChildModule

public final CModule getChildModule(String name)
Parameters:
name - the name of the child module to find
Returns:
the child module with given name or null if not found

getChildModules

public final Iterator getChildModules()
Returns:
A Map.Entry iterator on the child modules

getName

public final String getName()
Returns:
the name of the module

getType

public final String getType()
Returns:
the type of the module

getParent

public final CModule getParent()
Returns:
the parent module or null if the root module

getPath

public final String getPath()
Returns:
the path of the module (ex: /module1/module2/.../)

getRoot

public final CModule getRoot()
Returns:
the root module (the <application> tag)

getModuleForPath

public final CModule getModuleForPath(String path)
Parameters:
path - the path of the module (ex: /module1/module2/.../)
Returns:
the module which match the given path or null if no match

getModuleForPath

public static final CModule getModuleForPath(CModule module,
                                             String path)
Parameters:
module - a module to start
path - the path of the module (ex: /module1/module2/.../)
Returns:
the module which match the given path or null if no match

getModuleForId

public final CModule getModuleForId(String id)
Parameters:
id - the unique id to search for
Returns:
the module which have this id or null if no match

getModuleForId

public static final CModule getModuleForId(CModule module,
                                           String id)
Parameters:
module - a module to start
id - the unique id to search for
Returns:
the module which have this id or null if no match

getSourceNavigationItems

public final Iterator getSourceNavigationItems()
Returns:
the Navigation items that go from this module to another module

getDestinationNavigationItems

public final Iterator getDestinationNavigationItems()
Returns:
the Navigation items that go from this module to another module

checkSecurity

public static boolean checkSecurity(CModule module,
                                    javax.servlet.http.HttpServletRequest request)
Parameters:
module -
request -
Returns:

getURL

public final String getURL()

addSourceNavigationItems

public final CNavigationItem addSourceNavigationItems(CNavigationItem navItem)
Parameters:
navItem - The navigation item to add
Returns:
the added navigation item.

getSourceNavigationItem

public final CNavigationItem getSourceNavigationItem(String name)
Parameters:
name - the name of the navigation item to find
Returns:
the navigation item that match the name or null if not found

addGroup

public final CGroup addGroup(CGroup group)
Add a group to this module

Parameters:
group - the group to add
Returns:
the added group or null if the module type is APPLICATION

isLinkedToGroup

public final boolean isLinkedToGroup(String name)
Parameters:
name - the name of the group to check
Returns:
true if this module is linked to the group with the given name

isPublic

public final boolean isPublic()
Returns:
true if the module is available as anonymous

isPublicOnly

public final boolean isPublicOnly()
Returns:
true if the module is available as anonymous

setPublicOnly

public final void setPublicOnly(boolean isPublicOnly)
Parameters:
isPublicOnly -

isProtected

public final boolean isProtected()
Returns:
true if the module is not available as anonymous

isAllConnected

public final boolean isAllConnected()
Returns:
true if the module is available as an authenticated user

hasGroups

public final boolean hasGroups()
Returns:
true if the module has at least one group attached

getGroups

public final Iterator getGroups()
Returns:
an CGroup based iterator

getTranslation

public final String getTranslation(javax.servlet.http.HttpServletRequest request)
Parameters:
request - the current http request
Returns:
the translation for this module for the current user language

getJSCalls

public final Iterator getJSCalls()
Returns:
a Map.Entry based iterator on the javascript calls made on thus module. The key is the event name, the value is the script.

checkEvent

public static final boolean checkEvent(String event)
Parameters:
event - the event name
Returns:
true if the event is a valid html event

addJSCall

public final String[] addJSCall(String event,
                                String call)
add a javascript call on event on this module

Parameters:
event - the event name
call - the script
Returns:
a String array(2) : (0): event name (1): script

getJSCall

public final String getJSCall(String event)
Parameters:
event - the event name
Returns:
the script

addJSFile

public final String addJSFile(String src)
Parameters:
src - the source url of the script
Returns:
the source url of the script

addCSSFile

public final void addCSSFile(String href,
                             String rel,
                             String title)
Returns:
the source url of the script

validate

protected final void validate()

validateCSS

protected final void validateCSS()

validateSysparam

protected final void validateSysparam()

getJSFiles

public final Iterator getJSFiles()
Returns:
a String based iterator on all the javascript files linked to this module

getCSSFiles

public final Iterator getCSSFiles()
Returns:
a String based iterator on all the javascript files linked to this module

getCSSFile

public final String[] getCSSFile(String href)

addSysparam

public final String[] addSysparam(String name,
                                  String value)
Add a system parameter to this module. System parameter are inherited by child module when they are added. Frame module does not have sysparam but forward to the child modules

Parameters:
name - the name of the parameter
value - the value of the parameter
Returns:
a String array(2) (0): the name of the parameter (1): the value of the parameter

getSysparam

public final String getSysparam(String name)
Parameters:
name - the name of the parameter
Returns:
the value if found or null

getSysparams

public final Iterator getSysparams()
Returns:
a Map.Entry iterator on the sysparam list key = the name of the parameter value = the value of the parameter

unmarshall

public static CModule unmarshall(Node node,
                                 CModule parentModule)
Unmarshall a module from a DOM node.

Parameters:
node - a Node of a <module> tag
parentModule -
Returns:
the unmarshalled module

toString

public final String toString()
See Also:
Object.toString()

toString

public final String toString(String tabs)
Parameters:
tabs - a String containing tab (\t)
Returns:
the xml representation of the module