org.mmbase.bridge.implementation
Class BasicNodeManager

java.lang.Object
  extended byorg.mmbase.bridge.implementation.BasicNode
      extended byorg.mmbase.bridge.implementation.BasicNodeManager
All Implemented Interfaces:
java.lang.Comparable, Node, NodeManager, SizeMeasurable
Direct Known Subclasses:
BasicRelationManager, VirtualNodeManager

public class BasicNodeManager
extends BasicNode
implements NodeManager, java.lang.Comparable

This class represents a node's type information object - what used to be the 'builder'. It contains all the field and attribuut information, as well as GUI data for editors and some information on deribed and deriving types. It also contains some maintenance code - code to create new nodes, en code to query objects belonging to the same manager. Since node types are normally maintained through use of config files (and not in the database), as wel as for security issues, the data of a nodetype cannot be changed except through the use of an administration module (which is why we do not include setXXX methods here).

Version:
$Id: BasicNodeManager.java,v 1.77 2004/03/03 14:34:30 michiel Exp $
Author:
Rob Vermeulen, Pierre van Rooden, Michiel Meeuwissen

Field Summary
protected  MMObjectBuilder builder
           
protected  java.util.Map fieldTypes
           
protected  java.util.Set queryFields
           
 
Fields inherited from class org.mmbase.bridge.implementation.BasicNode
account, ACTION_COMMIT, ACTION_CREATE, ACTION_DELETE, ACTION_EDIT, cloud, isnew, mmb, nodeManager, noderef, temporaryNodeId
 
Fields inherited from interface org.mmbase.bridge.NodeManager
GUI_PLURAL, GUI_SINGULAR, ORDER_CREATE, ORDER_EDIT, ORDER_LIST, ORDER_NONE, ORDER_SEARCH
 
Method Summary
 void commit()
          Commit the node to the database.
 Node createNode()
          Creates a new node.
 NodeQuery createQuery()
          Creates a query for this NodeNanager.
 void delete(boolean deleteRelations)
          Removes the Node.
 RelationManagerList getAllowedRelations()
          Based on NodeSearchQuery (but it is wrapped in a BasicNodeQuery, because of security contraints).
 RelationManagerList getAllowedRelations(NodeManager nodeManager, java.lang.String role, java.lang.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(java.lang.String nodeManager, java.lang.String role, java.lang.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.
 NodeManagerList getDescendants()
          Retrieve a list of descendant nodemanagers (the Nodemanager that - posisbly indirectly - extend from this nodemanager)
 java.lang.String getDescription()
          Returns the description of this node manager.
 java.lang.String getDescription(java.util.Locale locale)
          Returns the description of this node manager in a specified language.
 Field getField(java.lang.String fieldName)
          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.
 java.lang.String getGUIName()
          Returns the descriptive name of this node manager.
 java.lang.String getGUIName(int plurality)
          Returns the descriptive name of this node manager.
 java.lang.String getGUIName(int plurality, java.util.Locale locale)
          Returns the descriptive name of this node manager ina a specified language.
 java.lang.String getInfo(java.lang.String command)
          Retrieve info from a node manager based on a command string.
 java.lang.String getInfo(java.lang.String command, javax.servlet.ServletRequest req, javax.servlet.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(java.lang.String command, java.util.Map parameters)
          Retrieve info (as a list of virtual nodes) from a node manager based on a command string.
 NodeList getList(java.lang.String command, java.util.Map parameters, javax.servlet.ServletRequest req, javax.servlet.ServletResponse resp)
          Retrieve info from a node manager based on a command string Similar to the LIST command in SCAN.
 NodeList getList(java.lang.String constraints, java.lang.String sorted, java.lang.String directions)
          Returns a list of nodes belonging to this node manager.
 java.lang.String getName()
          Returns the name of this node manager.
 NodeManager getParent()
          Retrieve the parent of this NodeManager (the Nodemanager that this nodemanager extends from)
 java.util.Map getProperties()
          Retrieve a copy of the node manager's properties
 java.lang.String getProperty(java.lang.String name)
          Retrieve a property of the node manager.
protected  java.util.Set getQueryFields()
           
 boolean hasField(java.lang.String fieldName)
          Tests whether the field with the specified name exists in this nodemanager.
protected  void initManager()
          Initializes the NodeManager: determines the MMObjectBuilder if it was not already known, and fills the fields list.
 boolean mayCreateNode()
          Check if the current user may create a new node of this type.
 
Methods inherited from class org.mmbase.bridge.implementation.BasicNode
cancel, compareTo, countRelatedNodes, countRelatedNodes, countRelations, countRelations, createAlias, createRelation, delete, deleteAlias, deleteRelations, deleteRelations, edit, equals, finalize, getAliases, getBooleanValue, getByteSize, getByteSize, getByteValue, getCloud, getContext, getDoubleValue, getFieldValue, getFieldValue, getFloatValue, getFunctionValue, getIntValue, getLongValue, getNode, getNodeManager, getNodeValue, getNumber, getObjectValue, getPossibleContexts, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelations, getRelations, getRelations, getRelations, getRelations, getStringValue, getValue, getXMLValue, getXMLValue, hashCode, hasRelations, init, invalidateNode, isNodeManager, isRelation, isRelationManager, mayChangeContext, mayDelete, mayWrite, setBooleanValue, setByteValue, setContext, setDoubleValue, setFloatValue, setIntValue, setLongValue, setNode, setNodeValue, setObjectValue, setStringValue, setValue, setValueWithoutChecks, setValueWithoutProcess, setXMLValue, toNodeManager, toRelation, toRelationManager, toString
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mmbase.bridge.NodeManager
getCloud
 
Methods inherited from interface org.mmbase.bridge.Node
cancel, countRelatedNodes, countRelatedNodes, countRelations, countRelations, createAlias, createRelation, delete, deleteAlias, deleteRelations, deleteRelations, getAliases, getBooleanValue, getByteValue, getContext, getDoubleValue, getFieldValue, getFieldValue, getFloatValue, getFunctionValue, getIntValue, getLongValue, getNodeManager, getNodeValue, getNumber, getObjectValue, getPossibleContexts, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelations, getRelations, getRelations, getRelations, getRelations, getStringValue, getValue, getXMLValue, getXMLValue, hasRelations, isNodeManager, isRelation, isRelationManager, mayChangeContext, mayDelete, mayWrite, setBooleanValue, setByteValue, setContext, setDoubleValue, setFloatValue, setIntValue, setLongValue, setNodeValue, setObjectValue, setStringValue, setValue, setXMLValue, toNodeManager, toRelation, toRelationManager, toString
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

builder

protected MMObjectBuilder builder

fieldTypes

protected java.util.Map fieldTypes

queryFields

protected java.util.Set queryFields
Since:
MMBase-1.7
Method Detail

initManager

protected void initManager()
Initializes the NodeManager: determines the MMObjectBuilder if it was not already known, and fills the fields list.


getQueryFields

protected java.util.Set getQueryFields()

createNode

public Node createNode()
Description copied from interface: NodeManager
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.

Specified by:
createNode in interface NodeManager
Returns:
the new Node

getParent

public NodeManager getParent()
                      throws NotFoundException
Description copied from interface: NodeManager
Retrieve the parent of this NodeManager (the Nodemanager that this nodemanager extends from)

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

getDescendants

public NodeManagerList getDescendants()
Description copied from interface: NodeManager
Retrieve a list of descendant nodemanagers (the Nodemanager that - posisbly indirectly - extend from this nodemanager)

Specified by:
getDescendants in interface NodeManager
Returns:
a list of NodeManagers

getName

public java.lang.String getName()
Description copied from interface: NodeManager
Returns the name of this node manager. This name is a unique name.

Specified by:
getName in interface NodeManager
Returns:
the name of this node manager.

getProperty

public java.lang.String getProperty(java.lang.String name)
Description copied from interface: NodeManager
Retrieve a property of the node manager.

Specified by:
getProperty in interface NodeManager
Parameters:
name - the name of the property
Returns:
the property value (null if not given)

getProperties

public java.util.Map getProperties()
Description copied from interface: NodeManager
Retrieve a copy of the node manager's properties

Specified by:
getProperties in interface NodeManager
Returns:
a map of node manager properties

getGUIName

public java.lang.String getGUIName()
Description copied from interface: NodeManager
Returns the descriptive name of this node manager. This name will be in the language of the current cloud (defined in cloud.getLocale()).

Specified by:
getGUIName in interface NodeManager
Returns:
the descriptive name of this node manager

getGUIName

public java.lang.String getGUIName(int plurality)
Description copied from interface: NodeManager
Returns the descriptive name of this node manager. This name will be in the language of the current cloud (defined in cloud.getLocale()).

Specified by:
getGUIName in interface NodeManager
Parameters:
plurality - the plurality (number of objects) for which to return a description (NodeManager.GUI_SINGULAR or NodeManager.GUI_PLURAL)
Returns:
the descriptive name of this node manager

getGUIName

public java.lang.String getGUIName(int plurality,
                                   java.util.Locale locale)
Description copied from interface: NodeManager
Returns the descriptive name of this node manager ina a specified language.

Specified by:
getGUIName in interface NodeManager
Parameters:
plurality - the plurality (number of objects) for which to return a description (NodeManager.GUI_SINGULAR or NodeManager.GUI_PLURAL)
locale - the locale that determines the language for the GUI name
Returns:
the descriptive name of this node manager

getDescription

public java.lang.String getDescription()
Description copied from interface: NodeManager
Returns the description of this node manager.

Specified by:
getDescription in interface NodeManager
Returns:
the description of this node manager

getDescription

public java.lang.String getDescription(java.util.Locale locale)
Description copied from interface: NodeManager
Returns the description of this node manager in a specified language.

Specified by:
getDescription in interface NodeManager
Parameters:
locale - the locale that determines the language for the description
Returns:
the description of this node manager

getFields

public FieldList getFields()
Description copied from interface: NodeManager
Returns a list of all fields defined for this node manager.

Specified by:
getFields in interface NodeManager
Returns:
a list of all fields defined for this node manager

getFields

public FieldList getFields(int order)
Description copied from interface: NodeManager
Retrieve a subset of field types of this NodeManager, depending on a given order.

Specified by:
getFields in interface NodeManager
Parameters:
order - the order in which to list the fields
Returns:
a List of FieldType objects

getField

public Field getField(java.lang.String fieldName)
               throws NotFoundException
Description copied from interface: NodeManager
Returns the field with the specified name.

Specified by:
getField in interface NodeManager
Parameters:
fieldName - the name of the field to be returned
Returns:
the field with the requested name
Throws:
NotFoundException - is the field does not exist

hasField

public boolean hasField(java.lang.String fieldName)
Description copied from interface: NodeManager
Tests whether the field with the specified name exists in this nodemanager.

Specified by:
hasField in interface NodeManager
Returns:
true if the field with the requested name exists

createQuery

public NodeQuery createQuery()
Description copied from interface: NodeManager
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.

Specified by:
createQuery in interface NodeManager
See Also:
NodeManager.getList(java.lang.String, java.lang.String, java.lang.String), Cloud.createNodeQuery()

getList

public NodeList getList(NodeQuery query)
Description copied from interface: NodeManager
Executes a query and returns the result as nodes of this NodeManager (or of extensions)

Specified by:
getList in interface NodeManager

getList

public NodeList getList(java.lang.String constraints,
                        java.lang.String sorted,
                        java.lang.String directions)
Description copied from interface: NodeManager
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.

Specified by:
getList in interface NodeManager
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 .
sorted - 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

getAllowedRelations

public RelationManagerList getAllowedRelations()
Based on NodeSearchQuery (but it is wrapped in a BasicNodeQuery, because of security contraints).

Specified by:
getAllowedRelations in interface NodeManager
Returns:
the relation manager list
Since:
MMBase-1.7

getAllowedRelations

public RelationManagerList getAllowedRelations(java.lang.String nodeManager,
                                               java.lang.String role,
                                               java.lang.String direction)
Description copied from interface: NodeManager
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.

Specified by:
getAllowedRelations in interface NodeManager
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

getAllowedRelations

public RelationManagerList getAllowedRelations(NodeManager nodeManager,
                                               java.lang.String role,
                                               java.lang.String direction)
Description copied from interface: NodeManager
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.

Specified by:
getAllowedRelations in interface NodeManager
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

getInfo

public java.lang.String getInfo(java.lang.String command)
Description copied from interface: NodeManager
Retrieve info from a node manager based on a command string. Similar to the $MOD command in SCAN.

Specified by:
getInfo in interface NodeManager
Parameters:
command - the info to obtain, i.e. "USER-OS".

getInfo

public java.lang.String getInfo(java.lang.String command,
                                javax.servlet.ServletRequest req,
                                javax.servlet.ServletResponse resp)
Description copied from interface: NodeManager
Retrieve info from a node manager based on a command string Similar to the $MOD command in SCAN.

Specified by:
getInfo in interface NodeManager
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.

getList

public NodeList getList(java.lang.String command,
                        java.util.Map parameters)
Description copied from interface: NodeManager
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..

Specified by:
getList in interface NodeManager
Parameters:
command - the info to obtain, i.e. "USER-OS".
parameters - a hashtable containing the named parameters of the list.

getList

public NodeList getList(java.lang.String command,
                        java.util.Map parameters,
                        javax.servlet.ServletRequest req,
                        javax.servlet.ServletResponse resp)
Description copied from interface: NodeManager
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..

Specified by:
getList in interface NodeManager
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.

mayCreateNode

public boolean mayCreateNode()
Description copied from interface: NodeManager
Check if the current user may create a new node of this type.

Specified by:
mayCreateNode in interface NodeManager
Returns:
Check if the current user may create a new node of this type.

commit

public void commit()
Description copied from interface: Node
Commit the node to the database. Makes this node and/or the changes made to this node visible to the cloud. If this method is called for the first time on this node it will make this node visible to the cloud, otherwise the modifications made to this node using the set methods will be made visible to the cloud. This action fails if the current node is not in edit mode. If the node is in a transaction, nothing happens - actual committing occurs through the transaction.

Specified by:
commit in interface Node
Overrides:
commit in class BasicNode

delete

public void delete(boolean deleteRelations)
Description copied from interface: Node
Removes the Node.

Specified by:
delete in interface Node
Overrides:
delete in class BasicNode


MMBase build 1.7.1.20041002