public class ClusterBuilder extends VirtualBuilder
clusternodes.
Provides these methods to retrieve clusternodes:
getClusterNodes(SearchQuery)
to retrieve clusternodes using a SearchQuery (recommended).
getMultiLevelSearchQuery(List,List,String,List,String,List,List,int)
as a convenience method to create a SearchQuery
searchMultiLevelVector(List,List,String,List,String,List,List,int)
to retrieve clusternodes using a constraint string.
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.
ClusterNode| Modifier and Type | Field and Description |
|---|---|
static int |
SEARCH_ALL
Deprecated.
|
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.
|
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.
|
AGE_PARAMETERS, broadCastChanges, DEFAULT_ALINEA, DEFAULT_EOL, description, descriptions, EVENT_TYPE_LOCAL, EVENT_TYPE_REMOTE, FIELD_NUMBER, FIELD_OBJECT_TYPE, FIELD_OWNER, fields, genericBlobCache, getFunctions, 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, xmlPathmaxNodesFromQuery, mmb, storageConnector, tableNamefunctions| Constructor and Description |
|---|
ClusterBuilder(MMBase m)
Creates
ClusterBuilder instance. |
| Modifier and Type | Method and Description |
|---|---|
(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)
|
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.
|
(package private) String |
getUniqueTableAlias(String tableAlias,
Set<String> tableAliases,
Collection<String> originalAliases)
Returns unique table alias, must be tablename/rolename, optionally
appended with a digit.
|
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)
|
Vector<MMObjectNode> |
searchMultiLevelVector(List<String> snodes,
List<String> fields,
String pdistinct,
List<String> tables,
String where,
List<String> sortFields,
List<String> directions,
int searchDir)
|
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.
|
create, getDBState, getShortedByte, getShortedText, init, insertaddEventListener, 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, wrapcount, count, created, getFullTableName, getMMBase, getNode, getNodes, getNodes, getNodes, getNodeType, getStorageConnector, getTableName, search, searchVector, setMMBase, setTableName, sizeaddFunction, createParameters, getFunction, getFunctions, getFunctionValuepublic static final int SEARCH_BOTH
RelationStep.DIRECTIONS_BOTH
In future versions of MMBase (1.8 and up) this will be the default valuepublic static final int SEARCH_DESTINATION
RelationStep.DIRECTIONS_DESTINATIONpublic static final int SEARCH_SOURCE
RelationStep.DIRECTIONS_SOURCEpublic static final int SEARCH_ALL
RelationStep.DIRECTIONS_ALLpublic static final int SEARCH_EITHER
RelationStep.DIRECTIONS_EITHER.
In future versions of MMBase (1.8 and up) the default value will be
RelationStep.DIRECTIONS_BOTHpublic ClusterBuilder(MMBase m)
ClusterBuilder instance.
Must be called from the MMBase class.m - the MMbase cloud creating the nodepublic static int getSearchDir(String search)
public static String getSearchDirString(int search)
public MMObjectNode getNewNode(String owner)
getNewNode in class VirtualBuilderowner - The administrator creating the new node (ignored).VirtualNode.public String getGUIIndicator(MMObjectNode node)
getGUIIndicator in class VirtualBuildernode - The node to displayStringpublic String getGUIIndicator(MMObjectNode node, Parameters pars)
getGUIIndicator in class MMObjectBuildernode - The node to displaypars - Parameters, see MMObjectBuilder.GUI_PARAMETERSString, null if not specifiedpublic String getBuilderNameFromField(String fieldName)
fieldName - the name of the fieldpublic static String getFieldNameFromField(String fieldname)
fieldname - the name of the fieldpublic FieldDefs getField(String fieldName)
getField in class MMObjectBuilderfieldName - the requested field's namepublic List<CoreField> getFields(int order)
MMObjectBuildergetFields in class MMObjectBuilderorder - One of the sortorders defined in
CoreFieldpublic Collection<CoreField> getFields()
MMObjectBuildergetFields in class MMObjectBuilderCollection with the tables fieldspublic Map<String,CoreField> getFields(MMObjectNode node)
VirtualBuildergetFields in class VirtualBuilderpublic Vector<MMObjectNode> searchMultiLevelVector(int snode, List<String> fields, String pdistinct, List<String> tables, String where, List<String> orderVec, List<String> direction)
searchMultiLevelVector(snodes, fields, pdistinct, tables, where, orderVec, direction, RelationStep.DIRECTIONS_EITHER),
where snodes contains just the number specified by snode.public Vector<MMObjectNode> searchMultiLevelVector(List<String> snodes, List<String> fields, String pdistinct, List<String> tables, String where, List<String> orderVec, List<String> direction)
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)
searchMultiLevelVector(List snodes, List fields, String pdistinct, List tables, String where,
List orderVec, List directions, List searchDirs)QueryConvertor#setConstraint().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.Vector containing all matching nodespublic 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)
QueryConvertor#setConstraint().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.Vector containing all matching nodespublic List<MMObjectNode> getClusterNodes(SearchQuery query)
clusternodes or MMObjectNodes if the
query is a Node-query.
This method uses the MultilevelCache for query resultsquery - The query.public List<MMObjectNode> getClusterNodesFromQueryHandler(SearchQuery query) throws SearchQueryException
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 MultilevelCachequery - The query.SearchQueryException - When an exception occurred while retrieving the results.SearchQueryHandler.getNodes(org.mmbase.storage.search.SearchQuery, org.mmbase.module.core.MMObjectBuilder)public String getShortedText(String fieldname, int number)
fieldname - name of the fieldnumber - number of the object in the tableString containing the contents of a field as textpublic byte[] getShortedByte(String fieldname, int number)
fieldname - name of the fieldnumber - number of the object in the tablebyte containing the contents of a field as textpublic BasicSearchQuery getMultiLevelSearchQuery(List<String> snodes, List<String> fields, String pdistinct, List<String> tables, String where, List<String> sortFields, List<String> directions, int searchDir)
getMultiLevelSearchQuery(List snodes, List fields, String pdistinct, List tables, String where,
List orderVec, List directions, int searchDir)QueryConvertor#setConstraint().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.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)
QueryConvertor#setConstraint().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.Map<String,BasicStep> addSteps(BasicSearchQuery query, List<String> tables, Map<String,Integer> roles, boolean includeAllReference, Map<String,BasicStepField> fieldsByAlias)
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.MMObjectBuilder getBuilder(String tableAlias, Map<String,Integer> roles)
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".String getUniqueTableAlias(String tableAlias, Set<String> tableAliases, Collection<String> originalAliases)
tableAlias - The table alias.tableAliases - The table aliases that are already in use. The
resulting table alias is added to this collection.originalAliases - The originally supplied aliases - generated
aliases should not match any of these.void addFields(BasicSearchQuery query, String expression, Map<String,BasicStep> stepsByAlias, Map<String,BasicStepField> fieldsByAlias)
Fieldnames must be formatted as stepalias.field.
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.void addSortOrders(BasicSearchQuery query, List<String> fieldNames, List<String> directions, Map<String,BasicStepField> fieldsByAlias)
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.Step getNodesStep(List<Step> steps, int nodeNumber)
steps - The steps.nodeNumber - The number identifying the node.null when not found.void addRelationDirections(BasicSearchQuery query, List<Integer> searchDirs, Map<String,Integer> roles)
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.MMBase 1.9-SNAPSHOT - ${javadoctimestamp}