org.mmbase.module.builders
Class MultiRelations

java.lang.Object
  extended byorg.mmbase.module.core.MMTable
      extended byorg.mmbase.module.core.MMObjectBuilder
          extended byorg.mmbase.module.builders.MultiRelations

Deprecated. Use ClusterBuilder instead.

public class MultiRelations
extends MMObjectBuilder

MultiRelations is a builder which creates 'virtual' nodes. The nodes are build out of a set of fields from different nodes, combined through a complex query, which is in turn based on the relations that exist between nodes.
The builder supplies a method to retrieve these virtual nodes: searchMultiLevelVector(). Other public methods in this builder function to handle the requests for data obtained from this particular node.

Version:
$Id: MultiRelations.java,v 1.36.2.1 2004/06/15 21:09:56 robmaris Exp $
Author:
Rico Jansen, Pierre van Rooden

Field Summary
static int SEARCH_ALL
          Deprecated. Use RelationStep.DIRECTIONS_ALL instead.
static int SEARCH_BOTH
          Deprecated. Use RelationStep.DIRECTIONS_BOTH instead.
static int SEARCH_DESTINATION
          Deprecated. Use RelationStep.DIRECTIONS_DESTINATION instead.
static int SEARCH_EITHER
          Deprecated. Use RelationStep.DIRECTIONS_EITHER instead.
static int SEARCH_SOURCE
          Deprecated. Use RelationStep.DIRECTIONS_SOURCE instead.
 
Fields inherited from class org.mmbase.module.core.MMObjectBuilder
AGE_PARAMETERS, broadcastChanges, database, DEFAULT_ALINEA, DEFAULT_EOL, description, descriptions, fields, GUI_PARAMETERS, listCache, nodeCache, OBJ2TYPE_MAX_SIZE, oType, REPLACE_CACHE, searchAge, sortedDBLayout, TEMPNODE_DEFAULT_SIZE, TemporaryNodes, virtual
 
Fields inherited from class org.mmbase.module.core.MMTable
mmb, tableName
 
Constructor Summary
MultiRelations(MMBase m)
          Deprecated. Creates an instance of the MultiRelations builder.
 
Method Summary
 boolean create()
          Deprecated. Creates a new builder table in the current database.
 int getDBType(java.lang.String fieldName)
          Deprecated. Return a field's database type.
 java.lang.String getGUIIndicator(MMObjectNode node)
          Deprecated. What should a GUI display for this node.
 java.lang.String getGUIIndicator(java.lang.String field, MMObjectNode node)
          Deprecated. What should a GUI display for this node/field combo.
protected  java.lang.String getRelationString(java.util.Vector alltables)
          Deprecated. Creates a condition string which checks the relations between nodes.
protected  java.lang.String getRelationString(java.util.Vector alltables, int searchdir)
          Deprecated. Creates a condition string which checks the relations between nodes.
protected  java.lang.String getSelectString(java.util.Vector alltables, java.util.Vector rfields)
          Deprecated. Creates a select string for the Multi level query.
 byte[] getShortedByte(java.lang.String fieldname, int number)
          Deprecated. Get binary data of a database blob field.
 java.lang.String getShortedText(java.lang.String fieldname, int number)
          Deprecated. Get text from a blob field.
protected  java.lang.String getTableString(java.util.Vector alltables)
          Deprecated. This method defines what is 'allowed' in tablenames.
 java.lang.Object getValue(MMObjectNode node, java.lang.String fieldName)
          Deprecated. Provides additional functionality when obtaining field values.
protected  java.lang.String idx2char(int idx)
          Deprecated. Converts an index to a one-character string.
 int insert(java.lang.String owner, MMObjectNode node)
          Deprecated. Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided).
 java.util.Vector searchMultiLevelVector(int snode, java.util.Vector fields, java.lang.String pdistinct, java.util.Vector tables, java.lang.String where, java.util.Vector orderVec, java.util.Vector direction)
          Deprecated. Return all the objects that match the searchkeys.
 java.util.Vector searchMultiLevelVector(java.util.Vector snodes, java.util.Vector fields, java.lang.String pdistinct, java.util.Vector tables, java.lang.String where, java.util.Vector orderVec, java.util.Vector direction)
          Deprecated. Return all the objects that match the searchkeys.
 java.util.Vector searchMultiLevelVector(java.util.Vector snodes, java.util.Vector fields, java.lang.String pdistinct, java.util.Vector tables, java.lang.String where, java.util.Vector orderVec, java.util.Vector direction, int searchdir)
          Deprecated. Return all the objects that match the searchkeys.
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addField, addLocalObserver, addRemoteObserver, buildSet, checkAddTmpField, commit, convertMMNode2SQL, count, count, createAlias, delete, deleteNodeCache, drop, equals, equals, executeFunction, executeFunction, fieldLocalChanged, getAge, getAliasedNode, getAncestors, getCacheNumbers, getCacheSize, getCacheSize, getClassName, getConfigFile, getDBByte, getDBKey, getDBState, getDBText, getDefaultTeaser, getDefaultUrl, getDescendants, getDescription, getDescription, getDescriptions, getEditFields, getField, getFieldNames, getFields, getFields, getFunctionParameters, getHardNode, getHardNode, getHTML, getInitParameter, getInitParameters, getList, getLocaleGUIIndicator, getLocaleGUIIndicator, getMachineName, getMaintainer, getMMBase, getNewNode, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNode, getNodes, getNodes, getNodeType, getNumberFromName, getObjectType, getObjectValue, getParameterDefinition, getParentBuilder, getPluralName, getPluralName, getPluralNames, getQuery, getQuery, getQuery, getRawNodes, getRelations_main, getSearchAge, getShort, getSingularName, getSingularName, getSingularNames, getSmartPath, getSortedFields, getSortedListFields, getTmpNode, getURLEncode, getVersion, getWAP, getXMLPath, hashCode, hostname_function, init, insert, insertDone, isExtensionOf, isNodeCached, isVirtual, nodeLocalChanged, nodeRemoteChanged, preCommit, preEdit, process, processSearchResults, putTmpNode, readSearchResults, removeField, removeNode, removeRelations, removeSyncNodes, removeTmpNode, replace, safeCache, safeCommit, safeInsert, search, search, search, searchIn, searchIn, searchIn, searchList, searchList, searchNumbers, searchVector, searchVector, searchVector, searchVector, searchVectorIn, searchVectorIn, searchVectorIn, searchVectorIn, searchWithWhere, sendFieldChangeSignal, setDBLayout_xml, setDefaults, setDescription, setDescriptions, setInitParameter, setMaintainer, setMMBase, setParentBuilder, setPluralNames, setSearchAge, setSingularNames, setTableName, setUniqueValue, setUniqueValue, setValue, setValue, setVersion, setXMLPath, setXMLValues, signalNewObject, testValidData, toString, toString, toXML, updateFields, waitUntilNodeChanged, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
created, getFullTableName, getTableName, size
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SEARCH_BOTH

public static final int SEARCH_BOTH
Deprecated. Use RelationStep.DIRECTIONS_BOTH instead.

Search for all valid relations. When searching relations, return both relations from source to deastination and from destination to source, provided directionality allows

See Also:
Constant Field Values

SEARCH_DESTINATION

public static final int SEARCH_DESTINATION
Deprecated. Use RelationStep.DIRECTIONS_DESTINATION instead.

Search for destinations, When searching relations, return only relations from source to deastination.

See Also:
Constant Field Values

SEARCH_SOURCE

public static final int SEARCH_SOURCE
Deprecated. Use RelationStep.DIRECTIONS_SOURCE instead.

Seach for sources. When searching a multilevel, return only relations from destination to source, provided directionality allows

See Also:
Constant Field Values

SEARCH_ALL

public static final int SEARCH_ALL
Deprecated. Use RelationStep.DIRECTIONS_ALL instead.

Search for all relations. When searching a multilevel, return both relations from source to deastination and from destination to source. Directionality is not checked - ALL relations are used.

See Also:
Constant Field Values

SEARCH_EITHER

public static final int SEARCH_EITHER
Deprecated. Use RelationStep.DIRECTIONS_EITHER instead.

Search for either destination or source. When searching a multilevel, return either relations from source to destination OR from destination to source. The returned set is decided through the typerel tabel. However, if both directiosn ARE somehow supported, the system onyl returns source to destination relations. This is the default value (for compatibility purposes).

See Also:
Constant Field Values
Constructor Detail

MultiRelations

public MultiRelations(MMBase m)
Deprecated. 
Creates an instance of the MultiRelations builder. Called from the MMBase class.

Parameters:
m - the MMbase cloud creating the node
Method Detail

create

public boolean create()
Deprecated. 
Creates a new builder table in the current database. This method does not perform any action in MultiRelations, as there is no actual table associated with this builder.

Overrides:
create in class MMObjectBuilder

insert

public int insert(java.lang.String owner,
                  MMObjectNode node)
Deprecated. 
Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided). This method does not perform any action in MultiRelations.

Overrides:
insert in class MMObjectBuilder
Parameters:
owner - The administrator creating the node
node - The object to insert
Returns:
-1 (the insert failed)

getGUIIndicator

public java.lang.String getGUIIndicator(MMObjectNode node)
Deprecated. 
What should a GUI display for this node. This version displays the contents of the 'name' field.

Overrides:
getGUIIndicator in class MMObjectBuilder
Parameters:
node - The node to display
Returns:
the display of the node as a String

getGUIIndicator

public java.lang.String getGUIIndicator(java.lang.String field,
                                        MMObjectNode node)
Deprecated. 
What should a GUI display for this node/field combo. Default is null (indicating to display the field as is) Override this to display your own choice.

Overrides:
getGUIIndicator in class MMObjectBuilder
Parameters:
node - The node to display
field - the name field of the field to display
Returns:
the display of the node's field as a String, null if not specified

getDBType

public int getDBType(java.lang.String fieldName)
Deprecated. 
Return a field's database type. The returned value is one of the following values declared in FieldDefs: TYPE_STRING, TYPE_INTEGER, TYPE_BYTE, TYPE_FLOAT, TYPE_DOUBLE, TYPE_LONG, TYPE_NODE TYPE_UNKNOWN (returned if the original builder of the field cannot be determined)

Overrides:
getDBType in class MMObjectBuilder
Returns:
the field's type.

getValue

public java.lang.Object getValue(MMObjectNode node,
                                 java.lang.String fieldName)
Deprecated. 
Provides additional functionality when obtaining field values. This method is called whenever a Node of the builder's type fails at evaluating a getValue() request (generally when a fieldname is supplied that doesn't exist). This method does some ugly things with teh fieldname prefix (as in 'people.lastname').

Overrides:
getValue in class MMObjectBuilder
Parameters:
node - the node whos efields are queries
fieldName - the fieldname that is requested
Returns:
the result of the 'function', or null if no valid functions could be determined.

searchMultiLevelVector

public java.util.Vector searchMultiLevelVector(int snode,
                                               java.util.Vector fields,
                                               java.lang.String pdistinct,
                                               java.util.Vector tables,
                                               java.lang.String where,
                                               java.util.Vector orderVec,
                                               java.util.Vector direction)
Deprecated. 
Return all the objects that match the searchkeys.

Parameters:
snode - The number of the node to start the search with. The node has to be present in the first table listed in the tables parameter.
fields - The fieldnames to return. This should include the name of the builder. Fieldnames without a builder prefix are ignored. Fieldnames are accessible in the nodes returned in the same format (i.e. with manager indication) as they are specified in this parameter. Examples: 'people.lastname'
pdistinct - 'YES' indicates the records returned need to be distinct. Any other value indicates double values can be returned.
tables - The builder chain. A list containing builder names. The search is formed by following the relations between successive builders in the list. It is possible to explicitly supply a relation builder by placing the name of the builder between two builders to search. Example: company,people or typedef,authrel,people.
where - The constraint. this is in essence a SQL where clause, using the NodeManager names from the nodes as tablenames. The syntax is either sql (if preceded by "WHERE') or Examples: "WHERE people.email IS NOT NULL", "(authrel.creat=1) and (people.lastname='admin')"
orderVec - the fieldnames on which you want to sort.
direction - A list of values containing, for each field in the order parameter, a value indicating whether the sort is ascending (UP) or descending (DOWN). If less values are syupplied then there are fields in order, the first value in the list is used for the remaining fields. Default value is 'UP'.
Returns:
a Vector containing all matching nodes

searchMultiLevelVector

public java.util.Vector searchMultiLevelVector(java.util.Vector snodes,
                                               java.util.Vector fields,
                                               java.lang.String pdistinct,
                                               java.util.Vector tables,
                                               java.lang.String where,
                                               java.util.Vector orderVec,
                                               java.util.Vector direction)
Deprecated. 
Return all the objects that match the searchkeys.

Parameters:
snodes - The numbers of the nodes to start the search with. These have to be present in the first table listed in the tables parameter.
fields - The fieldnames to return. This should include the name of the builder. Fieldnames without a builder prefix are ignored. Fieldnames are accessible in the nodes returned in the same format (i.e. with manager indication) as they are specified in this parameter. Examples: 'people.lastname'
pdistinct - 'YES' indicates the records returned need to be distinct. Any other value indicates double values can be returned.
tables - The builder chain. A list containing builder names. The search is formed by following the relations between successive builders in the list. It is possible to explicitly supply a relation builder by placing the name of the builder between two builders to search. Example: company,people or typedef,authrel,people.
where - The constraint. this is in essence a SQL where clause, using the NodeManager names from the nodes as tablenames. The syntax is either sql (if preceded by "WHERE') or Examples: "WHERE people.email IS NOT NULL", "(authrel.creat=1) and (people.lastname='admin')"
orderVec - the fieldnames on which you want to sort.
direction - A list of values containing, for each field in the order parameter, a value indicating whether the sort is ascending (UP) or descending (DOWN). If less values are syupplied then there are fields in order, the first value in the list is used for the remaining fields. Default value is 'UP'.
Returns:
a Vector containing all matching nodes

searchMultiLevelVector

public java.util.Vector searchMultiLevelVector(java.util.Vector snodes,
                                               java.util.Vector fields,
                                               java.lang.String pdistinct,
                                               java.util.Vector tables,
                                               java.lang.String where,
                                               java.util.Vector orderVec,
                                               java.util.Vector direction,
                                               int searchdir)
Deprecated. 
Return all the objects that match the searchkeys.

Parameters:
snodes - The numbers of the nodes to start the search with. These have to be present in the first table listed in the tables parameter.
fields - The fieldnames to return. This should include the name of the builder. Fieldnames without a builder prefix are ignored. Fieldnames are accessible in the nodes returned in the same format (i.e. with manager indication) as they are specified in this parameter. Examples: 'people.lastname'
pdistinct - 'YES' indicates the records returned need to be distinct. Any other value indicates double values can be returned.
tables - The builder chain. A list containing builder names. The search is formed by following the relations between successive builders in the list. It is possible to explicitly supply a relation builder by placing the name of the builder between two builders to search. Example: company,people or typedef,authrel,people.
where - The constraint. this is in essence a SQL where clause, using the NodeManager names from the nodes as tablenames. The syntax is either sql (if preceded by "WHERE') or Examples: "WHERE people.email IS NOT NULL", "(authrel.creat=1) and (people.lastname='admin')"
orderVec - the fieldnames on which you want to sort.
direction - A list of values containing, for each field in the order parameter, a value indicating whether the sort is ascending (UP) or descending (DOWN). If less values are syupplied then there are fields in order, the first value in the list is used for the remaining fields. Default value is 'UP'.
Returns:
a Vector containing all matching nodes

getSelectString

protected java.lang.String getSelectString(java.util.Vector alltables,
                                           java.util.Vector rfields)
Deprecated. 
Creates a select string for the Multi level query. This consists of a list of fieldnames, preceded by a tablename.

Parameters:
alltables - the tablenames to use
rfields - the fields that were requested
Returns:
a select String

getTableString

protected java.lang.String getTableString(java.util.Vector alltables)
Deprecated. 
This method defines what is 'allowed' in tablenames. Multilevel uses this to find out what is a tablename and what not


getRelationString

protected java.lang.String getRelationString(java.util.Vector alltables)
Deprecated. 
Creates a condition string which checks the relations between nodes. The string can then be added to the query's where clause.

Parameters:
alltables - the tablenames to use
Returns:
a condition as a String

getRelationString

protected java.lang.String getRelationString(java.util.Vector alltables,
                                             int searchdir)
Deprecated. 
Creates a condition string which checks the relations between nodes. The string can then be added to the query's where clause.

Parameters:
alltables - the tablenames to use
searchdir - the directionality option to use
Returns:
a condition as a String

idx2char

protected java.lang.String idx2char(int idx)
Deprecated. 
Converts an index to a one-character string. I.e. o becomes 'a', 1 becomes 'b', etc. This is used to map the tables in a List to alternate names (using their index in the list).

Parameters:
idx - the index
Returns:
the one-letter name as a String

getShortedText

public java.lang.String getShortedText(java.lang.String fieldname,
                                       int number)
Deprecated. 
Get text from a blob field. The text is cut if it is to long.

Overrides:
getShortedText in class MMObjectBuilder
Parameters:
fieldname - name of the field
number - number of the object in the table
Returns:
a String containing the contents of a field as text

getShortedByte

public byte[] getShortedByte(java.lang.String fieldname,
                             int number)
Deprecated. 
Get binary data of a database blob field. The data is cut if it is to long.

Overrides:
getShortedByte in class MMObjectBuilder
Parameters:
fieldname - name of the field
number - number of the object in the table
Returns:
an array of byte containing the contents of a field as text


MMBase build 1.7.1.20041002