org.mmbase.bridge
Interface NodeManager

All Superinterfaces:
Comparable<Node>, Node
All Known Subinterfaces:
RelationManager
All Known Implementing Classes:
AbstractNodeManager, BasicNodeManager, BasicRelationManager, MapNodeManager, MockNodeManager, MockRelationManager, VirtualNodeManager

public interface NodeManager
extends Node

This interface represents a node's type information object. This is also commonly - because of legacy - referred to as 'builder'.

It contains all the field and attribute information, as well as GUI data for editors and some information on derived and deriving types. It also contains some maintenance code - code to create new nodes, and code to query objects belonging to the same manager.

Node types are normally maintained using config files (and not in the database), in so called 'builder xmls'.

A NodeManager does however extend Node, because an entry for each node manager is stored in the 'typedef' NodeManager. The number Node.getNumber() of the NodeManager is the 'otype' field of the Nodes of that type.

Version:
$Id: NodeManager.java 41943 2010-04-16 17:18:19Z michiel $
Author:
Rob Vermeulen, Pierre van Rooden

Field Summary
static int GUI_PLURAL
           
static int GUI_SINGULAR
           
static int ORDER_CREATE
          A constant for use with getFields(int), meaning `all fields, in storage order (so which are in storage'.
static int ORDER_EDIT
          A constant for use with getFields(int), meaning all fields which a user may want to fill when creating or editing this node.
static int ORDER_LIST
          A constant for use with getFields(int).
static int ORDER_NONE
          A constant for use with getFields(int), meaning `all fields, even those which are not stored.
static int ORDER_SEARCH
          A constant for use with getFields(int) On some fields, like binary fields (e.g.
 
Fields inherited from interface org.mmbase.bridge.Node
CLOUD_COMMITNODE_KEY
 
Method Summary
 FieldList createFieldList()
          Returns a new, empty field list for this nodemanager
 Node createNode()
          Creates a new node.
 NodeList createNodeList()
          Returns a new, empty node list for this nodemanager
 NodeQuery createQuery()
          Creates a query for this NodeNanager.
 RelationList createRelationList()
          Returns a new, empty relation list for this nodemanager
 RelationManagerList getAllowedRelations()
          Retrieve all relation managers that can be used to create relations for objects of this nodemanager.
 RelationManagerList getAllowedRelations(NodeManager nodeManager, String role, String direction)
          Retrieve all relation managers that can be used to create relations for objects from this nodemanager, to the specified manager, using the specified role and direction.
 RelationManagerList getAllowedRelations(String nodeManager, String role, String direction)
          Retrieve all relation managers that can be used to create relations for objects from this nodemanager, to the specified manager, using the specified role and direction.
 Cloud getCloud()
          Returns the cloud to which this manager belongs.
 NodeManagerList getDescendants()
          Retrieve a list of descendant nodemanagers (the nodemanagers that - possibly indirectly - extend from this nodemanager)
 String getDescription()
          Returns the description of this node manager.
 String getDescription(Locale locale)
          Returns the description of this node manager in a specified language.
 Field getField(String name)
          Returns the field with the specified name.
 FieldList getFields()
          Returns a list of all fields defined for this node manager.
 FieldList getFields(int order)
          Retrieve a subset of field types of this NodeManager, depending on a given order.
 String getGUIName()
          Returns the descriptive name of this node manager.
 String getGUIName(int plurality)
          Returns the descriptive name of this node manager.
 String getGUIName(int plurality, Locale locale)
          Returns the descriptive name of this node manager ina a specified language.
 String getInfo(String command)
          Retrieve info from a node manager based on a command string.
 String getInfo(String command, ServletRequest req, ServletResponse resp)
          Retrieve info from a node manager based on a command string Similar to the $MOD command in SCAN.
 NodeList getList(NodeQuery query)
          Executes a query and returns the result as nodes of this NodeManager (or of extensions)
 NodeList getList(String command, Map parameters)
          Retrieve info (as a list of virtual nodes) from a node manager based on a command string.
 NodeList getList(String command, Map parameters, ServletRequest req, ServletResponse resp)
          Retrieve info from a node manager based on a command string Similar to the LIST command in SCAN.
 NodeList getList(String constraints, String orderby, String directions)
          Returns a list of nodes belonging to this node manager.
 String getName()
          Returns the name of this node manager.
 NodeManager getParent()
          Retrieve the parent of this NodeManager (the Nodemanager that this nodemanager extends from)
 Map<String,String> getProperties()
          Retrieve a copy of the node manager's properties
 String getProperty(String name)
          Retrieve a property of the node manager.
 boolean hasField(String fieldName)
          Tests whether the field with the specified name exists in this nodemanager.
 boolean mayCreateNode()
          Check if the current user may create a new node of this type.
 
Methods inherited from interface org.mmbase.bridge.Node
cancel, commit, countRelatedNodes, countRelatedNodes, countRelations, countRelations, createAlias, createParameters, createRelation, delete, delete, deleteAlias, deleteRelations, deleteRelations, getAliases, getBooleanValue, getByteValue, getChanged, getContext, getDateValue, getDecimalValue, getDoubleValue, getFieldValue, getFieldValue, getFloatValue, getFunction, getFunctions, getFunctionValue, getInputStreamValue, getIntValue, getListValue, getLongValue, getNodeManager, getNodeValue, getNumber, getObjectValue, getPossibleContexts, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelations, getRelations, getRelations, getRelations, getRelations, getSize, getStringValue, getValue, getValueWithoutProcess, getXMLValue, getXMLValue, hasRelations, isChanged, isChanged, isNew, isNodeManager, isNull, isRelation, isRelationManager, mayChangeContext, mayDelete, mayWrite, setBooleanValue, setByteValue, setContext, setDateValue, setDecimalValue, setDoubleValue, setFloatValue, setInputStreamValue, setIntValue, setListValue, setLongValue, setNodeManager, setNodeValue, setObjectValue, setStringValue, setValue, setValueWithoutProcess, setXMLValue, toNodeManager, toRelation, toRelationManager, toString, validate
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

ORDER_NONE

static final int ORDER_NONE
A constant for use with getFields(int), meaning `all fields, even those which are not stored.

See Also:
Constant Field Values

ORDER_CREATE

static final int ORDER_CREATE
A constant for use with getFields(int), meaning `all fields, in storage order (so which are in storage'.

See Also:
Constant Field Values

ORDER_EDIT

static final int ORDER_EDIT
A constant for use with getFields(int), meaning all fields which a user may want to fill when creating or editing this node. That are normally all nodes without the `automatic' ones like `number' and `otype'.

See Also:
Constant Field Values

ORDER_LIST

static final int ORDER_LIST
A constant for use with getFields(int). When presenting a Node in some list overview then less essential fields can be left out, to get a more concise presentation of the node.

See Also:
Constant Field Values

ORDER_SEARCH

static final int ORDER_SEARCH
A constant for use with getFields(int) On some fields, like binary fields (e.g. images) it makes no sense searching. These are left out among the `search' fields.

See Also:
Constant Field Values

GUI_SINGULAR

static final int GUI_SINGULAR
See Also:
Constant Field Values

GUI_PLURAL

static final int GUI_PLURAL
See Also:
Constant Field Values
Method Detail

createNode

Node createNode()
Creates a new node. The returned node will not be visible in the cloud until the commit() method is called on this node. Until then it will have a temporary node number.

Returns:
the new Node

getCloud

Cloud getCloud()
Returns the cloud to which this manager belongs.

Specified by:
getCloud in interface Node
Returns:
the cloud to which this manager belongs

getParent

NodeManager getParent()
                      throws NotFoundException
Retrieve the parent of this NodeManager (the Nodemanager that this nodemanager extends from)

Returns:
the NodeManager's parent
Throws:
NotFoundException - if no parent exists (i.e. this nodeManager is "object")

getDescendants

NodeManagerList getDescendants()
Retrieve a list of descendant nodemanagers (the nodemanagers that - possibly indirectly - extend from this nodemanager)

Returns:
a list of NodeManagers
Since:
MMBase-1.7

getName

String getName()
Returns the name of this node manager. This name is a unique name.

Returns:
the name of this node manager.

getProperty

String getProperty(String name)
Retrieve a property of the node manager.

Parameters:
name - the name of the property
Returns:
the property value (null if not given)
Since:
MMBase-1.7

getProperties

Map<String,String> getProperties()
Retrieve a copy of the node manager's properties

Returns:
a map of node manager properties
Since:
MMBase-1.7

getGUIName

String getGUIName()
Returns the descriptive name of this node manager. This name will be in the language of the current cloud (defined in cloud.getLocale()).

Returns:
the descriptive name of this node manager

getGUIName

String getGUIName(int plurality)
Returns the descriptive name of this node manager. This name will be in the language of the current cloud (defined in cloud.getLocale()).

Parameters:
plurality - the plurality (number of objects) for which to return a description (GUI_SINGULAR or GUI_PLURAL)
Returns:
the descriptive name of this node manager
Since:
MMBase-1.6

getGUIName

String getGUIName(int plurality,
                  Locale locale)
Returns the descriptive name of this node manager ina a specified language.

Parameters:
plurality - the plurality (number of objects) for which to return a description (GUI_SINGULAR or GUI_PLURAL)
locale - the locale that determines the language for the GUI name
Returns:
the descriptive name of this node manager
Since:
MMBase-1.6

getDescription

String getDescription()
Returns the description of this node manager.

Returns:
the description of this node manager

getDescription

String getDescription(Locale locale)
Returns the description of this node manager in a specified language.

Parameters:
locale - the locale that determines the language for the description
Returns:
the description of this node manager
Since:
MMBase-1.7

getFields

FieldList getFields()
Returns a list of all fields defined for this node manager.

Returns:
a list of all fields defined for this node manager

getFields

FieldList getFields(int order)
Retrieve a subset of field types of this NodeManager, depending on a given order. The order is a integer constant which symbolizes `none', `create', `edit', `list' or `search'. These last three one may recognize from builder XML's. `none' means `all fields'. The actual integer contants are present as the ORDER contants in this interface.

Parameters:
order - the order in which to list the fields
Returns:
a FieldList object, which is a specialized List of Field objects.
See Also:
ORDER_NONE, ORDER_CREATE, ORDER_EDIT, ORDER_LIST, ORDER_SEARCH

getField

Field getField(String name)
               throws NotFoundException
Returns the field with the specified name.

Parameters:
name - the name of the field to be returned
Returns:
the field with the requested name
Throws:
NotFoundException - is the field does not exist

hasField

boolean hasField(String fieldName)
Tests whether the field with the specified name exists in this nodemanager.

Parameters:
fieldName - the name of the field to be returned
Returns:
true if the field with the requested name exists
Since:
MMBase-1.6

getList

NodeList getList(String constraints,
                 String orderby,
                 String directions)
Returns a list of nodes belonging to this node manager. Constraints can be given to exclude nodes from the returned list. These constraints follow the syntax of the SQL where clause. It's a good practice to use uppercase letters for the operators and lowercase letters for the fieldnames. Example constraints are:
 "number = 100" (!=, <, >, <= and >= can also be used)
 "name = 'admin'",
 "email IS NULL" (indicating the email field is empty)
 "email LIKE '%.org'" (indication the email should end with .org)
 "number BETWEEN 99 AND 101"
 "name IN ('admin', 'anonymous')"
 
The NOT operator can be used to get the opposite result like:
 "NOT (number = 100)"
 "NOT (name = 'admin')",
 "email IS NOT NULL"
 "email NOT LIKE '%.org'" (indication the email should not end with .org)
 "number NOT BETWEEN 99 AND 101"
 "name NOT IN ('admin', 'anonymous')"
 
Some special functions (not part of standard SQL, but most databases support them) can be used like:
 "LOWER(name) = 'admin'" (to also allow 'Admin' to be selected)
 "LENGTH(name) > 5" (to only select names longer then 5 characters)
 
Constraints can be linked together using AND and OR:
 "((number=100) OR (name='admin') AND email LIKE '%.org')"
 
The single quote can be escaped using it twice for every single occurence:
 "name='aaa''bbb'" (if we want to find the string aaa'bbb)
 
For more info consult a SQL tutorial like Jim Hoffman's introduction to Structured Query Language.

Parameters:
constraints - Constraints to prevent nodes from being included in the resulting list which would normally by included or null if no constraints should be applied .
orderby - A comma separated list of field names on which the returned list should be sorted or null if the order of the returned virtual nodes doesn't matter.
directions - A comma separated list of values indicating wether to sort up (ascending) or down (descending) on the corresponding field in the orderby parameter or null if sorting on all fields should be up. The value DOWN (case insensitive) indicates that sorting on the corresponding field should be down, all other values (including the empty value) indicate that sorting on the corresponding field should be up. If the number of values found in this parameter are less than the number of fields in the orderby parameter, all fields that don't have a corresponding direction value are sorted according to the last specified direction value.
Returns:
a list of nodes belonging to this node manager

createQuery

NodeQuery createQuery()
Creates a query for this NodeNanager. The nodemanager is added as a step, and also all (non byte array) fields are added. The query can be used by getList of Cloud. You can not add steps to this NodeQuery.

Returns:
query for this NodeNanager
Since:
MMBase-1.7
See Also:
getList(NodeQuery), Cloud.createNodeQuery()

getList

NodeList getList(NodeQuery query)
Executes a query and returns the result as nodes of this NodeManager (or of extensions)

Parameters:
query - query to execute
Returns:
list of nodes
Since:
MMBase-1.7

getInfo

String getInfo(String command)
Retrieve info from a node manager based on a command string. Similar to the $MOD command in SCAN.

Parameters:
command - the info to obtain, i.e. "USER-OS".
Returns:
info from a node manager

getInfo

String getInfo(String command,
               ServletRequest req,
               ServletResponse resp)
Retrieve info from a node manager based on a command string Similar to the $MOD command in SCAN.

Parameters:
command - the info to obtain, i.e. "USER-OS".
req - the Request item to use for obtaining user information. For backward compatibility.
resp - the Response item to use for redirecting users. For backward compatibility.
Returns:
info from a node manager

getAllowedRelations

RelationManagerList getAllowedRelations()
Retrieve all relation managers that can be used to create relations for objects of this nodemanager.

Returns:
the relation manager list
Since:
MMBase-1.6

getAllowedRelations

RelationManagerList getAllowedRelations(String nodeManager,
                                        String role,
                                        String direction)
Retrieve all relation managers that can be used to create relations for objects from this nodemanager, to the specified manager, using the specified role and direction.

Parameters:
nodeManager - the name of the nodemanger with which to make a relation, can be null
role - the role with which to make a relation, can be null
direction - the search direction ("source", "destination", "both"), can be null
Returns:
the relation manager list
Since:
MMBase-1.6

getAllowedRelations

RelationManagerList getAllowedRelations(NodeManager nodeManager,
                                        String role,
                                        String direction)
Retrieve all relation managers that can be used to create relations for objects from this nodemanager, to the specified manager, using the specified role and direction.

Parameters:
nodeManager - the nodemanger with which to make a relation, can be null
role - the role with which to make a relation, can be null
direction - the search direction ("source", "destination", "both"), can be null
Returns:
the relation manager list
Since:
MMBase-1.6

getList

NodeList getList(String command,
                 Map parameters)
Retrieve info (as a list of virtual nodes) from a node manager based on a command string. Similar to the LIST command in SCAN. The values retrieved are represented as fields of a virtual node, named following the fieldnames listed in the fields paramaters..

Parameters:
command - the info to obtain, i.e. "USER-OS".
parameters - a hashtable containing the named parameters of the list.
Returns:
info from a node manager (as a list of virtual nodes)

getList

NodeList getList(String command,
                 Map parameters,
                 ServletRequest req,
                 ServletResponse resp)
Retrieve info from a node manager based on a command string Similar to the LIST command in SCAN. The values retrieved are represented as fields of a virtual node, named following the fieldnames listed in the fields paramaters..

Parameters:
command - the info to obtain, i.e. "USER-OS".
parameters - a hashtable containing the named parameters of the list.
req - the Request item to use for obtaining user information. For backward compatibility.
resp - the Response item to use for redirecting users. For backward compatibility.
Returns:
info from a node manager (as a list of virtual nodes)

mayCreateNode

boolean mayCreateNode()
Check if the current user may create a new node of this type.

Returns:
Check if the current user may create a new node of this type.

createFieldList

FieldList createFieldList()
Returns a new, empty field list for this nodemanager

Returns:
The empty list
Since:
MMBase-1.8

createNodeList

NodeList createNodeList()
Returns a new, empty node list for this nodemanager

Returns:
The empty list
Since:
MMBase-1.8

createRelationList

RelationList createRelationList()
Returns a new, empty relation list for this nodemanager

Returns:
The empty list
Since:
MMBase-1.8


MMBase 2.0-SNAPSHOT - null