org.mmbase.module.corebuilders
Class TypeRel

java.lang.Object
  |
  +--org.mmbase.module.core.MMTable
        |
        +--org.mmbase.module.core.MMObjectBuilder
              |
              +--org.mmbase.module.corebuilders.TypeRel
All Implemented Interfaces:
MMBaseObserver

public class TypeRel
extends MMObjectBuilder
implements MMBaseObserver

TypeRel defines the allowed relations between two object types.

Version:
$Id: TypeRel.java,v 1.24 2002/01/24 15:22:45 vpro Exp $
Author:
Daniel Ockeloen, Pierre van Rooden

Fields inherited from class org.mmbase.module.core.MMObjectBuilder
broadcastChanges, className, database, debug, description, descriptions, fields, NODE_MAX_SIZE, nodeCache, obj2type, OBJ2TYPE_MAX_SIZE, oType, replaceCache, searchAge, sortedDBLayout, TEMPNODE_DEFAULT_SIZE, TemporaryNodes, virtual
 
Fields inherited from class org.mmbase.module.core.MMTable
mmb, tableName
 
Constructor Summary
TypeRel()
          Constructor for the TypeRel builder
 
Method Summary
 java.util.Enumeration getAllowedRelations(int number)
          Retrieves all relations which are 'allowed' for a specified node, that is, where the node is either allowed to be the source, or to be the destination (but where the corresponding relation definition is bidirectional).
 java.util.Enumeration getAllowedRelations(int snum, int dnum)
          Retrieves all relations which are 'allowed' between two specified nodes.
 java.util.Enumeration getAllowedRelations(MMObjectNode mmnode)
          Retrieves all relations which are 'allowed' for a specified node, that is, where the node is either allowed to be the source, or to be the destination (but where the corresponing relation definition is bidirectional).
 java.util.Enumeration getAllowedRelations(MMObjectNode n1, MMObjectNode n2)
          Retrieves all relations which are 'allowed' between two specified nodes.
 java.util.Vector getAllowedRelationsNames(int number1, int number2)
          Retrieves all relations which are 'allowed' between two specified nodes.
 java.util.Enumeration getAllowedRelationsTable(int number)
          Memory version of getAllowedRelations
 java.util.Enumeration getAllowedRelationsTable(int snum, int dnum)
          Memory version of getAllowedRelations
 java.util.Vector getAllowedRelationsTypes(int snum, int dnum)
          For use with MultiRelations Retrieves all reldef nodes for relations which are 'allowed' between two specified nodes.
 int getAllowedRelationType(int snum, int dnum)
          Retrieves the identifying number of the relation definition that is 'allowed' between two specified node types.
 java.util.Vector getAllowedRelationTypes(int snum, int dnum)
          Retrieves all reldef node numbers for relations which are 'allowed' between two specified nodes.
 java.lang.String getGUIIndicator(MMObjectNode node)
          Returns the display string for this node It returns a commbination of objecttypes and rolename : "source->destination (role)".
 java.lang.String getGUIIndicator(java.lang.String field, MMObjectNode node)
          Returns the display string for a specified field.
 java.util.Vector getList(scanpage sp, StringTagger tagger, java.util.StringTokenizer tok)
          Processes the BUILDER-typerel-ALLOWEDRELATIONSNAMES in the LIST command, and (possibly) returns a Vector containing requested data (based on the content of TYPE and NODE, which can be retrieved through tagger).
 boolean init()
          Initialize this builder and load the caches
 int insert(java.lang.String owner, MMObjectNode node)
          Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided).
 boolean nodeChanged(java.lang.String machine, java.lang.String number, java.lang.String builder, java.lang.String ctype)
          Watch for changes on relation types and adjust our memory table accordingly
 boolean nodeLocalChanged(java.lang.String machine, java.lang.String number, java.lang.String builder, java.lang.String ctype)
          Called when a local node is changed.
 boolean nodeRemoteChanged(java.lang.String machine, java.lang.String number, java.lang.String builder, java.lang.String ctype)
          Called when a remote node is changed.
 boolean reldefCorrect(int n1, int n2, int r)
          Checks whether a specific relation exists.
 void removeNode(MMObjectNode node)
          Remove a node from the cloud.
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addField, addLocalObserver, addRemoteObserver, buildSet, checkAddTmpField, commit, convertMMNode2SQL, count, create, createAlias, created, debug, deleteNodeCache, executeFunction, fieldLocalChanged, getAge, getAliasedNode, getCacheNumbers, getCacheSize, getCacheSize, getClassName, getDBByte, getDBKey, getDBState, getDBText, getDBType, getDefaultTeaser, getDefaultUrl, getDescription, getDescriptions, getDutchSName, getEditFields, getField, getFieldNames, getFields, getFullTableName, getFunctionParameters, getHardNode, getHardNode, getHTML, getInitParameter, getInitParameters, getMachineName, getMaintainer, getNewNode, getNewTmpNode, getNextField, getNode, getNode, getNode, getNode, getNodeType, getNumberFromName, getPluralName, getPluralName, getPluralNames, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getSortedFields, getSortedListFields, getTableName, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, getXMLSetup, hostname_function, init_obj2type, insert, insertDone, isNodeCached, isVirtual, isXMLConfig, preCommit, preEdit, process, putTmpNode, readSearchResults, removeField, removeRelations, removeTmpNode, replace, safeCache, safeCommit, safeInsert, search, search, search, searchIn, searchIn, searchIn, searchNumbers, searchVector, searchVector, searchVector, searchVector, searchVectorIn, searchVectorIn, searchVectorIn, searchVectorIn, searchWithWhere, sendFieldChangeSignal, setClassName, setDBLayout_xml, setDBLayout, setDebug, setDefaults, setDescription, setDescriptions, setDutchSName, setInitParameter, setMaintainer, setMMBase, setPluralNames, setSearchAge, setSingularNames, setTableName, setValue, setValue, setVersion, setXmlConfig, setXMLPath, setXMLValues, signalNewObject, testValidData, toXML, waitUntilNodeChanged, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeRel

public TypeRel()
Constructor for the TypeRel builder
Method Detail

init

public boolean init()
Initialize this builder and load the caches
Overrides:
init in class MMObjectBuilder
Following copied from class: org.mmbase.module.core.MMObjectBuilder
Returns:
Always true.
See Also:
MMObjectBuilder.create()

insert

public int insert(java.lang.String owner,
                  MMObjectNode node)
Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided). This method indirectly calls MMObjectBuilder.preCommit(org.mmbase.module.core.MMObjectNode).
Overrides:
insert in class MMObjectBuilder
Parameters:
owner - The administrator creating the node
node - The object to insert. The object need be of the same type as the current builder.
Returns:
An int value which is the new object's unique number, -1 if the insert failed.

removeNode

public void removeNode(MMObjectNode node)
Remove a node from the cloud.
Overrides:
removeNode in class MMObjectBuilder
Parameters:
node - The node to remove.

getAllowedRelations

public java.util.Enumeration getAllowedRelations(MMObjectNode mmnode)
Retrieves all relations which are 'allowed' for a specified node, that is, where the node is either allowed to be the source, or to be the destination (but where the corresponing relation definition is bidirectional). The allowed relations are determined by the type of the node
Parameters:
mmnode - The node to retrieve the allowed relations of.
Returns:
An Enumeration of nodes containing the typerel relation data

getAllowedRelations

public java.util.Enumeration getAllowedRelations(int number)
Retrieves all relations which are 'allowed' for a specified node, that is, where the node is either allowed to be the source, or to be the destination (but where the corresponding relation definition is bidirectional). The allowed relations are determined by the type of the node
Parameters:
number - The number of the node to retrieve the allowed relations of.
Returns:
An Enumeration of nodes containing the typerel relation data

getAllowedRelationsTable

public java.util.Enumeration getAllowedRelationsTable(int number)
Memory version of getAllowedRelations

getAllowedRelations

public java.util.Enumeration getAllowedRelations(int snum,
                                                 int dnum)
Retrieves all relations which are 'allowed' between two specified nodes.
Parameters:
n1 - The first objectnode (the source)
n2 - The second objectnode (the destination)
Returns:
An Enumeration of nodes containing the typerel relation data

getAllowedRelationsTable

public java.util.Enumeration getAllowedRelationsTable(int snum,
                                                      int dnum)
Memory version of getAllowedRelations

getAllowedRelationType

public int getAllowedRelationType(int snum,
                                  int dnum)
Retrieves the identifying number of the relation definition that is 'allowed' between two specified node types. The results are dependent on there being only one type of relation between two node types (not enforced, thus unpredictable). Makes use of a cache.
Parameters:
snum - The first objectnode type (the source)
dnum - The second objectnode type (the destination)
Returns:
the number of the found relation, or -1 if either no relation was found, or more than one was found.

getAllowedRelationTypes

public java.util.Vector getAllowedRelationTypes(int snum,
                                                int dnum)
Retrieves all reldef node numbers for relations which are 'allowed' between two specified nodes.
Parameters:
n1 - The number of the first objectnode (the source)
n2 - The number of the second objectnode (the destination)
Returns:
A Vector of Integers containing the reldef object node numbers

getAllowedRelationsTypes

public java.util.Vector getAllowedRelationsTypes(int snum,
                                                 int dnum)
For use with MultiRelations Retrieves all reldef nodes for relations which are 'allowed' between two specified nodes.
Parameters:
n1 - The number of the first objectnode (the source)
n2 - The number of the second objectnode (the destination)
Returns:
A Vector of Integers containing the reldef object node numbers

getAllowedRelations

public java.util.Enumeration getAllowedRelations(MMObjectNode n1,
                                                 MMObjectNode n2)
Retrieves all relations which are 'allowed' between two specified nodes.
Parameters:
n1 - The first objectnode (the source)
n2 - The second objectnode (the destination)
Returns:
An Enumeration of nodes containing the typerel relation data

getGUIIndicator

public java.lang.String getGUIIndicator(MMObjectNode node)
Returns the display string for this node It returns a commbination of objecttypes and rolename : "source->destination (role)".
Overrides:
getGUIIndicator in class MMObjectBuilder
Parameters:
node - Node from which to retrieve the data
Returns:
A String describing the content of the node

getGUIIndicator

public java.lang.String getGUIIndicator(java.lang.String field,
                                        MMObjectNode node)
Returns the display string for a specified field. Returns, for snumber and dnumber, the name of the objecttype they represent, and for rnumber the display (GUI) string for the indicated relation definition.
Overrides:
getGUIIndicator in class MMObjectBuilder
Parameters:
field - The name of the field to retrieve
node - Node from which to retrieve the data
Returns:
A String describing the content of the field

getList

public java.util.Vector getList(scanpage sp,
                                StringTagger tagger,
                                java.util.StringTokenizer tok)
Processes the BUILDER-typerel-ALLOWEDRELATIONSNAMES in the LIST command, and (possibly) returns a Vector containing requested data (based on the content of TYPE and NODE, which can be retrieved through tagger).
Overrides:
getList in class MMObjectBuilder
Following copied from class: org.mmbase.module.core.MMObjectBuilder
Parameters:
sp - The scanpage (containing http and user info) that calls the function
tagger - a Hashtable of parameters (name-value pairs) for the command
tok - a list of strings that describe the (sub)command to execute
Returns:
a Vector containing the result values as a String

reldefCorrect

public boolean reldefCorrect(int n1,
                             int n2,
                             int r)
Checks whether a specific relation exists. Maintains a cache containing the last checked relations Note that this routine returns false both when a snumber/dnumber are swapped, and when a typecombo does not exist - it is not possible to derive whether one or the other has occurred.
Parameters:
n1 - Number of the source node
n2 - Number of the destination node
r - Number of the relation definition
Returns:
A boolean indicating success when the relation exists, failure if it does not.

getAllowedRelationsNames

public java.util.Vector getAllowedRelationsNames(int number1,
                                                 int number2)
Retrieves all relations which are 'allowed' between two specified nodes.
Parameters:
snum - The first objectnode type (the source)
dnum - The second objectnode type (the destination)
Returns:
An Enumeration of nodes containing the reldef (not typerel!) sname field

nodeRemoteChanged

public boolean nodeRemoteChanged(java.lang.String machine,
                                 java.lang.String number,
                                 java.lang.String builder,
                                 java.lang.String ctype)
Description copied from class: MMObjectBuilder
Called when a remote node is changed. Should be called by subclasses if they override it.
Specified by:
nodeRemoteChanged in interface MMBaseObserver
Overrides:
nodeRemoteChanged in class MMObjectBuilder
Following copied from class: org.mmbase.module.core.MMObjectBuilder
Parameters:
machine - Name of the machine that changed the node.
number - Number of the changed node as a String
builder - type of the changed node
ctype - command type, 'c'=changed, 'd'=deleted', 'r'=relations changed, 'n'=new
Returns:
always true

nodeLocalChanged

public boolean nodeLocalChanged(java.lang.String machine,
                                java.lang.String number,
                                java.lang.String builder,
                                java.lang.String ctype)
Description copied from class: MMObjectBuilder
Called when a local node is changed. Should be called by subclasses if they override it.
Specified by:
nodeLocalChanged in interface MMBaseObserver
Overrides:
nodeLocalChanged in class MMObjectBuilder
Following copied from class: org.mmbase.module.core.MMObjectBuilder
Parameters:
machine - Name of the machine that changed the node.
number - Number of the changed node as a String
builder - type of the changed node
ctype - command type, 'c'=changed, 'd'=deleted', 'r'=relations changed, 'n'=new
Returns:
always true

nodeChanged

public boolean nodeChanged(java.lang.String machine,
                           java.lang.String number,
                           java.lang.String builder,
                           java.lang.String ctype)
Watch for changes on relation types and adjust our memory table accordingly


MMBase 2002