org.mmbase.module.core
Class ClusterBuilder

Package class diagram package ClusterBuilder
java.lang.Object
  extended by org.mmbase.util.functions.FunctionProvider
      extended by org.mmbase.module.core.MMTable
          extended by org.mmbase.module.core.MMObjectBuilder
              extended by org.mmbase.module.core.VirtualBuilder
                  extended by org.mmbase.module.core.ClusterBuilder
All Implemented Interfaces:
EventListener, NodeEventListener, RelationEventListener

public class ClusterBuilder
extends VirtualBuilder

The builder for clusternodes.

Provides these methods to retrieve clusternodes:

Individual nodes in a 'cluster' node can be retrieved by calling the node's getNodeValue() method, using the builder name (or step alias) as argument.

Version:
$Id: ClusterBuilder.java 45150 2011-02-10 09:18:12Z michiel $
Author:
Rico Jansen, Pierre van Rooden, Rob van Maris
See Also:
ClusterNode
To Do:
XXXX. This 'builder' is actually singleton (only one instance is created). It does therefore not support getFields, so this is more or less hacked in bridge. Perhaps in 'core' a similar approach as now in birdge must be taken, so no ClusterBuilder, but only Virtual builders, one for every query result.

Field Summary
(package private)  CoreClusterQueries clusterQueries
          Deprecated. Use CoreClusterQueries.INSTANCE
static int SEARCH_ALL
          Deprecated. use RelationStep.DIRECTIONS_ALL
static int SEARCH_BOTH
          Deprecated. use RelationStep.DIRECTIONS_BOTH In future versions of MMBase (1.8 and up) this will be the default value
static int SEARCH_DESTINATION
          Deprecated. use RelationStep.DIRECTIONS_DESTINATION
static int SEARCH_EITHER
          Deprecated. use RelationStep.DIRECTIONS_EITHER. In future versions of MMBase (1.8 and up) the default value will be RelationStep.DIRECTIONS_BOTH
static int SEARCH_SOURCE
          Deprecated. use RelationStep.DIRECTIONS_SOURCE
 
Fields inherited from class org.mmbase.module.core.MMObjectBuilder
AGE_PARAMETERS, broadCastChanges, DEFAULT_ALINEA, DEFAULT_EOL, description, descriptions, EVENT_TYPE_LOCAL, EVENT_TYPE_REMOTE, FIELD_NUMBER, FIELD_OBJECT_TYPE, FIELD_OWNER, fields, genericBlobCache, getFunctionsFunction, GUI_INDICATOR, GUI_PARAMETERS, guiFunction, infoFunction, internalVersion, maintainer, nodeCache, oType, pluralNames, searchAge, singularNames, SYSTEM_OWNER, TEMPNODE_DEFAULT_SIZE, temporaryNodes, TMP_FIELD_EXISTS, TMP_FIELD_NUMBER, TMP_FIELD_RESOLVED, virtual, WRAP_PARAMETERS, wrapFunction, xmlPath
 
Fields inherited from class org.mmbase.module.core.MMTable
maxNodesFromQuery, mmb, storageConnector, tableName
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions, getFunctions
 
Constructor Summary
ClusterBuilder(MMBase m)
          Creates ClusterBuilder instance.
 
Method Summary
(package private)  void addFields(BasicSearchQuery query, String expression, Map<String,BasicStep> stepsByAlias, Map<String,BasicStepField> fieldsByAlias)
          Retrieves fieldnames from an expression, and adds these to a search query.
(package private)  void addRelationDirections(BasicSearchQuery query, List<Integer> searchDirs, Map<String,Integer> roles)
          Adds relation directions.
(package private)  void addSortOrders(BasicSearchQuery query, List<String> fieldNames, List<String> directions, Map<String,BasicStepField> fieldsByAlias)
          Adds sorting orders to a search query.
(package private)  Map<String,BasicStep> addSteps(BasicSearchQuery query, List<String> tables, Map<String,Integer> roles, boolean includeAllReference, Map<String,BasicStepField> fieldsByAlias)
          Creates a full chain of steps, adds these to the specified query.
(package private)  MMObjectBuilder getBuilder(String tableAlias, Map<String,Integer> roles)
          Gets builder corresponding to the specified table alias.
 String getBuilderNameFromField(String fieldName)
          Determines the builder part of a specified field.
 List<MMObjectNode> getClusterNodes(SearchQuery query)
          Executes query, returns results as clusternodes or MMObjectNodes if the query is a Node-query.
 List<MMObjectNode> getClusterNodesFromQueryHandler(SearchQuery query)
          Executes query, returns results as clusternodes or MMObjectNodes if the query is a Node-query.
 FieldDefs getField(String fieldName)
          Return a field.
static String getFieldNameFromField(String fieldname)
          Determines the fieldname part of a specified field (without the builder name).
 Collection<CoreField> getFields()
          Return a copy of the list of field definitions of this table.
 List<CoreField> getFields(int order)
          Gets the field definitions for the editor, sorted according to the specified order, and excluding the fields that have not been assigned a valid position (valid is >= 0).
 Map<String,CoreField> getFields(MMObjectNode node)
          Get text from a blob field from a database.
 String getGUIIndicator(MMObjectNode node)
          What should a GUI display for this node.
 String getGUIIndicator(MMObjectNode node, Parameters pars)
          What should a GUI display for this node/field combo.
 BasicSearchQuery getMultiLevelSearchQuery(List<String> snodes, List<String> fields, String pdistinct, List<String> tables, String where, List<String> sortFields, List<String> directions, int searchDir)
          Deprecated. use getMultiLevelSearchQuery(List snodes, List fields, String pdistinct, List tables, String where, List orderVec, List directions, List searchDir)
 BasicSearchQuery getMultiLevelSearchQuery(List<String> snodes, List<String> fields, String pdistinct, List<String> tables, String where, List<String> sortFields, List<String> directions, List<Integer> searchDirs)
          Creates search query that selects all the objects that match the searchkeys.
 MMObjectNode getNewNode(String owner)
          Get a new node, using this builder as its parent.
(package private)  Step getNodesStep(List<Step> steps, int nodeNumber)
          Gets first step from list, that corresponds to the builder of a specified node - or one of its parentbuilders.
static int getSearchDir(String search)
          Translates a string to a search direction constant.
static String getSearchDirString(int search)
          Translates a search direction constant to a string.
 byte[] getShortedByte(String fieldname, int number)
          Get binary data of a database blob field.
 String getShortedText(String fieldname, int number)
          Get text from a blob field.
 Vector<MMObjectNode> searchMultiLevelVector(int snode, List<String> fields, String pdistinct, List<String> tables, String where, List<String> orderVec, List<String> direction)
          Same as searchMultiLevelVector(snodes, fields, pdistinct, tables, where, orderVec, direction, RelationStep.DIRECTIONS_EITHER), where snodes contains just the number specified by snode.
 Vector<MMObjectNode> searchMultiLevelVector(List<String> snodes, List<String> fields, String pdistinct, List<String> tables, String where, List<String> orderVec, List<String> direction)
          Same as searchMultiLevelVector(snodes, fields, pdistinct, tables, where, orderVec, direction, RelationStep.DIRECTIONS_EITHER).
 Vector<MMObjectNode> searchMultiLevelVector(List<String> snodes, List<String> fields, String pdistinct, List<String> tables, String where, List<String> sortFields, List<String> directions, int searchDir)
          Deprecated. use searchMultiLevelVector(List snodes, List fields, String pdistinct, List tables, String where, List orderVec, List directions, List searchDirs)
 Vector<MMObjectNode> searchMultiLevelVector(List<String> snodes, List<String> fields, String pdistinct, List<String> tables, String where, List<String> sortFields, List<String> directions, List<Integer> searchDirs)
          Return all the objects that match the searchkeys.
 
Methods inherited from class org.mmbase.module.core.VirtualBuilder
create, getDBState, getShortedByte, getShortedText, init, insert
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addEventListener, addField, addLocalObserver, addRemoteObserver, broadcastChanges, checkAddTmpField, clearBlobCache, commit, createAlias, createAlias, createIfNotExists, delete, equals, equals, executeFunction, executeFunction, fieldLocalChanged, getAncestors, getBlobCache, getClassName, getConfigFile, getConfigResource, getDataTypeCollector, getDBType, getDefaultTeaser, getDefaultUrl, getDescendants, getDescription, getDescription, getDescriptions, getEmptyNode, getFieldNames, getFunction, getFunctionParameters, getFunctions, getFunctionValue, getGUIIndicator, getHTML, getInitParameter, getInitParameters, getInitParameters, getInternalVersion, getList, getLocaleGUIIndicator, getLocaleGUIIndicator, getMachineName, getMaintainer, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNodeFromCache, getNodeGUIIndicator, getNumber, getObjectType, getObjectValue, getParentBuilder, getPluralName, getPluralName, getPluralNames, getRelations_main, getSearchAge, getShort, getShortedInputStream, getSingularName, getSingularName, getSingularNames, getSmartPath, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, hasField, hashCode, hashCode, hostname_function, insert, isExtensionOf, isNodeCached, isNull, isVirtual, loadInitParameters, newFunctionInstance, nodeLocalChanged, nodeRemoteChanged, notify, notify, preCommit, process, putTmpNode, removeEventListener, removeField, removeLocalObserver, removeNode, removeRelations, removeRemoteObserver, removeSyncNodes, removeTmpNode, replace, safeCache, safeCommit, safeInsert, sendFieldChangeSignal, setDefaults, setDescription, setDescriptions, setFields, setInitParameter, setInitParameters, setMaintainer, setParentBuilder, setPluralNames, setSearchAge, setSingularNames, setUniqueValue, setUniqueValue, setValue, setValue, setVersion, setXMLPath, shutdown, testValidData, toString, toString, update, updateFields, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
count, count, created, getFullTableName, getMMBase, getNode, getNodes, getNodes, getNodes, getNodeType, getStorageConnector, getTableName, search, searchVector, setMMBase, setTableName, size
 
Methods inherited from class org.mmbase.util.functions.FunctionProvider
addFunction, createParameters, getFunction, getFunctions, getFunctionValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SEARCH_BOTH

public static final int SEARCH_BOTH
Deprecated. use RelationStep.DIRECTIONS_BOTH In future versions of MMBase (1.8 and up) this will be the default value
Search for all valid relations. When searching relations, return both relations from source to deastination and from destination to source, provided there is an allowed relation in that directon.

See Also:
Constant Field Values

SEARCH_DESTINATION

public static final int SEARCH_DESTINATION
Deprecated. use RelationStep.DIRECTIONS_DESTINATION
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
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
Search for all relations. When searching a multilevel, return both relations from source to deastination and from destination to source. Allowed relations are not checked - ALL relations are used. This makes more inefficient queries, but it is not really wrong.

See Also:
Constant Field Values

SEARCH_EITHER

public static final int SEARCH_EITHER
Deprecated. use RelationStep.DIRECTIONS_EITHER. In future versions of MMBase (1.8 and up) the default value will be RelationStep.DIRECTIONS_BOTH
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 directions ARE somehow supported, the system only returns source to destination relations. This is the default value (for compatibility purposes).

See Also:
Constant Field Values

clusterQueries

final CoreClusterQueries clusterQueries
Deprecated. Use CoreClusterQueries.INSTANCE
Constructor Detail

ClusterBuilder

public ClusterBuilder(MMBase m)
Creates ClusterBuilder instance. Must be called from the MMBase class.

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

getSearchDir

public static int getSearchDir(String search)
Translates a string to a search direction constant.

Since:
MMBase-1.6

getSearchDirString

public static String getSearchDirString(int search)
Translates a search direction constant to a string.

Since:
MMBase-1.6

getNewNode

public MMObjectNode getNewNode(String owner)
Get a new node, using this builder as its parent. The new node is a cluster node. Unlike most other nodes, a cluster node does not have a number, owner, or otype fields.

Overrides:
getNewNode in class VirtualBuilder
Parameters:
owner - The administrator creating the new node (ignored).
Returns:
A newly initialized VirtualNode.

getGUIIndicator

public String getGUIIndicator(MMObjectNode node)
What should a GUI display for this node. This version displays the contents of the 'name' field(s) that were retrieved. XXX: should be changed to something better

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

getGUIIndicator

public String getGUIIndicator(MMObjectNode node,
                              Parameters pars)
What should a GUI display for this node/field combo. For a multilevel node, the builder tries to determine the original builder of a field, and invoke the method using that builder.

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

getBuilderNameFromField

public String getBuilderNameFromField(String fieldName)
Determines the builder part of a specified field.

Parameters:
fieldName - the name of the field
Returns:
the name of the field's builder

getFieldNameFromField

public static String getFieldNameFromField(String fieldname)
Determines the fieldname part of a specified field (without the builder name).

Parameters:
fieldname - the name of the field
Returns:
the name of the field without its builder

getField

public FieldDefs getField(String fieldName)
Return a field.

Overrides:
getField in class MMObjectBuilder
Parameters:
fieldName - the requested field's name
Returns:
the field

getFields

public List<CoreField> getFields(int order)
Description copied from class: MMObjectBuilder
Gets the field definitions for the editor, sorted according to the specified order, and excluding the fields that have not been assigned a valid position (valid is >= 0). This method makes an explicit sort (it does not use a cached list).

Overrides:
getFields in class MMObjectBuilder
Parameters:
order - One of the sortorders defined in CoreField
Returns:
The ordered list of field definitions.

getFields

public Collection<CoreField> getFields()
Description copied from class: MMObjectBuilder
Return a copy of the list of field definitions of this table.

Overrides:
getFields in class MMObjectBuilder
Returns:
An unmodifiable Collection with the tables fields

getFields

public Map<String,CoreField> getFields(MMObjectNode node)
Description copied from class: VirtualBuilder
Get text from a blob field from a database.

Overrides:
getFields in class VirtualBuilder
Since:
MMBase-1.8

searchMultiLevelVector

public Vector<MMObjectNode> searchMultiLevelVector(int snode,
                                                   List<String> fields,
                                                   String pdistinct,
                                                   List<String> tables,
                                                   String where,
                                                   List<String> orderVec,
                                                   List<String> direction)
Same as searchMultiLevelVector(snodes, fields, pdistinct, tables, where, orderVec, direction, RelationStep.DIRECTIONS_EITHER), where snodes contains just the number specified by snode.

See Also:
searchMultiLevelVector(List, List, String, List, String, List, List, List)

searchMultiLevelVector

public Vector<MMObjectNode> searchMultiLevelVector(List<String> snodes,
                                                   List<String> fields,
                                                   String pdistinct,
                                                   List<String> tables,
                                                   String where,
                                                   List<String> orderVec,
                                                   List<String> direction)
Same as searchMultiLevelVector(snodes, fields, pdistinct, tables, where, orderVec, direction, RelationStep.DIRECTIONS_EITHER).

See Also:
searchMultiLevelVector(List,List,String,List,String,List,List,int)

searchMultiLevelVector

public Vector<MMObjectNode> searchMultiLevelVector(List<String> snodes,
                                                   List<String> fields,
                                                   String pdistinct,
                                                   List<String> tables,
                                                   String where,
                                                   List<String> sortFields,
                                                   List<String> directions,
                                                   int searchDir)
Deprecated. use searchMultiLevelVector(List snodes, List fields, String pdistinct, List tables, String where, List orderVec, List directions, List searchDirs)

Return all the objects that match the searchkeys. The constraint must be in one of the formats specified by QueryConvertor#setConstraint().

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, must be in one of the formats specified by QueryConvertor#setConstraint(). E.g. "WHERE news.title LIKE '%MMBase%' AND news.title > 100"
sortFields - the fieldnames on which you want to sort.
directions - 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'.
searchDir - Specifies in which direction relations are to be followed, this must be one of the values defined by this class.
Returns:
a Vector containing all matching nodes

searchMultiLevelVector

public Vector<MMObjectNode> searchMultiLevelVector(List<String> snodes,
                                                   List<String> fields,
                                                   String pdistinct,
                                                   List<String> tables,
                                                   String where,
                                                   List<String> sortFields,
                                                   List<String> directions,
                                                   List<Integer> searchDirs)
Return all the objects that match the searchkeys. The constraint must be in one of the formats specified by QueryConvertor#setConstraint().

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, must be in one of the formats specified by QueryConvertor#setConstraint(). E.g. "WHERE news.title LIKE '%MMBase%' AND news.title > 100"
sortFields - the fieldnames on which you want to sort.
directions - 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'.
searchDirs - Specifies in which direction relations are to be followed. You can specify a direction for each relation in the path. If you specify less directions than there are relations, the last specified direction is used for the remaining relations. If you specify an empty list the default direction is BOTH.
Returns:
a Vector containing all matching nodes

getClusterNodes

public List<MMObjectNode> getClusterNodes(SearchQuery query)
Executes query, returns results as clusternodes or MMObjectNodes if the query is a Node-query. This method uses the MultilevelCache for query results

Parameters:
query - The query.
Returns:
The clusternodes.
Since:
MMBase-1.7

getClusterNodesFromQueryHandler

public List<MMObjectNode> getClusterNodesFromQueryHandler(SearchQuery query)
                                                   throws SearchQueryException
Executes query, returns results as clusternodes or MMObjectNodes if the query is a Node-query. The results are retrieved directly from storage without the MultilevelCache getClusterNodes(SearchQuery) which uses the MultilevelCache

Parameters:
query - The query.
Returns:
The clusternodes.
Throws:
SearchQueryException - When an exception occurred while retrieving the results.
Since:
MMBase-1.7
See Also:
org.mmbase.storage.search.SearchQueryHandler#getNodes

getShortedText

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

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(String fieldname,
                             int number)
Get binary data of a database blob field. The data is cut if it is to long.

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

getMultiLevelSearchQuery

public BasicSearchQuery getMultiLevelSearchQuery(List<String> snodes,
                                                 List<String> fields,
                                                 String pdistinct,
                                                 List<String> tables,
                                                 String where,
                                                 List<String> sortFields,
                                                 List<String> directions,
                                                 int searchDir)
Deprecated. use getMultiLevelSearchQuery(List snodes, List fields, String pdistinct, List tables, String where, List orderVec, List directions, List searchDir)

Creates search query that selects all the objects that match the searchkeys. The constraint must be in one of the formats specified by QueryConvertor#setConstraint().

Parameters:
snodes - null or a list of numbers of nodes to start the search with. These have to be present in the first table listed in the tables parameter.
fields - List of fieldnames to return. These should be formatted as stepalias.field, e.g. 'people.lastname'
pdistinct - 'YES' if the records returned need to be distinct (ignoring case). 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, must be in one of the formats specified by QueryConvertor#setConstraint(). E.g. "WHERE news.title LIKE '%MMBase%' AND news.title > 100"
sortFields - null or a list of fieldnames on which you want to sort.
directions - null or a list of values containing, for each field in the sortFields parameter, a value indicating whether the sort is ascending (UP) or descending (DOWN). If less values are supplied then there are fields in order, the first value in the list is used for the remaining fields. Default value is 'UP'.
searchDir - Specifies in which direction relations are to be followed, this must be one of the values defined by this class.
Returns:
the resulting search query.
Since:
MMBase-1.7

getMultiLevelSearchQuery

public BasicSearchQuery getMultiLevelSearchQuery(List<String> snodes,
                                                 List<String> fields,
                                                 String pdistinct,
                                                 List<String> tables,
                                                 String where,
                                                 List<String> sortFields,
                                                 List<String> directions,
                                                 List<Integer> searchDirs)
Creates search query that selects all the objects that match the searchkeys. The constraint must be in one of the formats specified by QueryConvertor#setConstraint().

Parameters:
snodes - null or a list of numbers of nodes to start the search with. These have to be present in the first table listed in the tables parameter.
fields - List of fieldnames to return. These should be formatted as stepalias.field, e.g. 'people.lastname'
pdistinct - 'YES' if the records returned need to be distinct (ignoring case). 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, must be in one of the formats specified by QueryConvertor#setConstraint(). E.g. "WHERE news.title LIKE '%MMBase%' AND news.title > 100"
sortFields - null or a list of fieldnames on which you want to sort.
directions - null or a list of values containing, for each field in the sortFields parameter, a value indicating whether the sort is ascending (UP) or descending (DOWN). If less values are supplied then there are fields in order, the first value in the list is used for the remaining fields. Default value is 'UP'.
searchDirs - Specifies in which direction relations are to be followed, this must be one of the values defined by this class.
Returns:
the resulting search query.
Since:
MMBase-1.7

addSteps

Map<String,BasicStep> addSteps(BasicSearchQuery query,
                               List<String> tables,
                               Map<String,Integer> roles,
                               boolean includeAllReference,
                               Map<String,BasicStepField> fieldsByAlias)
Creates a full chain of steps, adds these to the specified query. This includes adding necessary relation tables when not explicitly specified, and generating unique table aliases where necessary. Optionally adds "number"-fields for all tables in the original chain.

Parameters:
query - The searchquery.
tables - The original chain of tables.
roles - Map of tablenames mapped to Integer values, representing the nodenumber of a corresponing RelDef node. This method adds entries for table aliases that specify a role, e.g. "related" or "related2".
includeAllReference - Indicates if the "number"-fields must included in the query for all tables in the original chain.
fieldsByAlias - Map, mapping aliases (fieldname prefixed by table alias) to the stepfields in the query. An entry is added for each stepfield added to the query.
Returns:
Map, maps original table names to steps.
Since:
MMBase-1.7

getBuilder

MMObjectBuilder getBuilder(String tableAlias,
                           Map<String,Integer> roles)
Gets builder corresponding to the specified table alias. This amounts to removing the optionally appended digit from the table alias, and interpreting the result as either a tablename or a relation role.

Parameters:
tableAlias - The table alias. Must be tablename or relation role, optionally appended with a digit, e.g. images, images3, related and related4.
roles - Map of tablenames mapped to Integer values, representing the nodenumber of a corresponing RelDef node. This method adds entries for table aliases that specify a role, e.g. "related" or "related2".
Returns:
The builder.
Since:
MMBase-1.7

addFields

void addFields(BasicSearchQuery query,
               String expression,
               Map<String,BasicStep> stepsByAlias,
               Map<String,BasicStepField> fieldsByAlias)
Retrieves fieldnames from an expression, and adds these to a search query. The expression may be either a fieldname or a a functionname with a (commaseparated) parameterlist between parenthesis (parameters being expressions themselves).

Fieldnames must be formatted as stepalias.field.

Parameters:
query - The query.
expression - The expression.
stepsByAlias - Map, mapping step aliases to the steps in the query.
fieldsByAlias - Map, mapping field aliases (fieldname prefixed by table alias) to the stepfields in the query. An entry is added for each stepfield added to the query.
Since:
MMBase-1.7

addSortOrders

void addSortOrders(BasicSearchQuery query,
                   List<String> fieldNames,
                   List<String> directions,
                   Map<String,BasicStepField> fieldsByAlias)
Adds sorting orders to a search query.

Parameters:
query - The query.
fieldNames - The fieldnames prefixed by the table aliases.
directions - The corresponding sorting directions ("UP"/"DOWN").
fieldsByAlias - Map, mapping field aliases (fieldname prefixed by table alias) to the stepfields in the query.
Since:
MMBase-1.7

getNodesStep

Step getNodesStep(List<Step> steps,
                  int nodeNumber)
Gets first step from list, that corresponds to the builder of a specified node - or one of its parentbuilders.

Parameters:
steps - The steps.
nodeNumber - The number identifying the node.
Returns:
The step, or null when not found.
Since:
MMBase-1.7

addRelationDirections

void addRelationDirections(BasicSearchQuery query,
                           List<Integer> searchDirs,
                           Map<String,Integer> roles)
Adds relation directions.

Parameters:
query - The search query.
searchDirs - Specifies in which direction relations are to be followed. You can specify a direction for each relation in the path. If you specify less directions than there are relations, the last specified direction is used for the remaining relations. If you specify an empty list the default direction is BOTH.
roles - Map of tablenames mapped to Integer values, representing the nodenumber of the corresponing RelDef node.
Since:
MMBase-1.7


MMBase2 Core 2.0-SNAPSHOT - 2013-03-30T06:36