public class RelDef extends MMObjectBuilder
A Relation Definition consists of a source and destination, and a descriptor (direction) for it's use (unidirectional or bidirectional).
Relations are mapped to a builder.
This is so that additional functionality can be added by means of a builder (i.e. AuthRel).
The old system mapped the relations to a builder by name.
Unfortunately, this means that some care need be taken when naming relations, as unintentionally
naming a relation to a builder can give bad (if not disastrous) results.
Relations that are not directly mapped to a builder are mapped (internally) to the InsRel builder instead.
The new system uses an additional field to map to a builder.
This 'builder' field contains a reference (otype) to the builder to be used.
If null or 0, the builder is assumed to refer to the InsRel builder.
sname is now the name of the relation and serves no function.
This patched version of RelDef can make use of either direct builder references (through the builder field), or the old system of using names. The system used is determined by examining whether the builder field has been defined in the builder's configuration (xml) file. See the documentation of the relations project at http://www.mmbase.org for more info.
| Modifier and Type | Field and Description |
|---|---|
static int |
DIR_BIDIRECTIONAL
Value of "dir" field indicating bidirectional relatios.
|
static int |
DIR_UNIDIRECTIONAL
Value of "dir" field indicating unidirectional relations.
|
static boolean |
usesbuilder
Indicates whether the relationdefinitions use the 'builder' field (that is, whether the
field has been defined in the xml file).
|
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, nodeCache, oType, pluralNames, searchAge, singularNames, SYSTEM_OWNER, TEMPNODE_DEFAULT_SIZE, temporaryNodes, TMP_FIELD_EXISTS, TMP_FIELD_NUMBER, virtual, WRAP_PARAMETERS, wrapFunctionmaxNodesFromQuery, mmb, storageConnector, tableNamefunctions| Constructor and Description |
|---|
RelDef()
Contruct the builder
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
commit(MMObjectNode node)
Commit changes to this node and updated the cache.
|
protected String |
findBuilderName(MMObjectNode node) |
InsRel |
getBuilder(int rnumber)
Returns the builder of a relation definition.
|
InsRel |
getBuilder(MMObjectNode node)
Returns the builder of a relation definition.
|
String |
getBuilderName(Integer reldefNodeNumber) |
String |
getBuilderName(MMObjectNode node)
Returns the builder name of a relation definition.
|
MMObjectNode |
getDefaultForBuilder(InsRel relBuilder)
Returns the first occurrence of a reldef node of a relation definition.
|
int |
getGuessedByName(String role)
Deprecated.
use
getNumberByName(java.lang.String) instead |
int |
getGuessedNumber(String role)
Deprecated.
renamed to
getNumberByName(java.lang.String) which better explains its use |
String |
getGUIIndicator(MMObjectNode node)
Returns a GUI description of a relation definition.
|
String |
getGUIIndicator(String field,
MMObjectNode node)
Retrieve descriptors for a relation definition's fields,
specifically a descriptive text for the relation's direction (dir)
|
int |
getNumberByName(String role)
Search the relation definition table for the identifying number of
a relationdefinition, by name of the role to use.
|
int |
getNumberByName(String role,
boolean searchBidirectional)
Search the relation definition table for the identifying number of
a relationdefinition, by name of the role to use.
|
Enumeration<MMObjectBuilder> |
getRelationBuilders()
Returns a list of builders currently implementing a relation node.
|
int |
getRelsNrByName(String sname,
String dname)
Deprecated.
use
getNumberByName(java.lang.String) instead |
Set<Integer> |
getRoles()
Returns all possible rnumbers ('roles').
|
boolean |
init()
Initializes the builder by reading the cache.
|
int |
insert(String owner,
MMObjectNode node)
Insert a new object, and updated the cache after an insert.
|
boolean |
isRelationBuilder(int number)
Checks to see if a given builder (otype) is known to be a relation builder.
|
boolean |
isRelationTable(String name)
Checks to see if a given relation definition is stored in the cache.
|
boolean |
nodeRemoteChanged(String machine,
String number,
String builder,
String ctype)
Called when a remote node is changed.
|
void |
removeNode(MMObjectNode node)
Remove a node from the cloud.
|
void |
setDefaults(MMObjectNode node)
Sets defaults for a new relation definition.
|
void |
testValidData(MMObjectNode node)
Tests whether the data in a node is valid (throws an exception if this is not the case).
|
addEventListener, addField, addLocalObserver, addRemoteObserver, broadcastChanges, checkAddTmpField, clearBlobCache, create, createAlias, createAlias, createIfNotExists, delete, equals, equals, executeFunction, executeFunction, fieldLocalChanged, getAncestors, getBlobCache, getClassName, getConfigFile, getConfigResource, getDataTypeCollector, getDBState, getDBType, getDefaultTeaser, getDefaultUrl, getDescendants, getDescription, getDescription, getDescriptions, getEmptyNode, getField, getFieldNames, getFields, getFields, getFunction, getFunctionParameters, getFunctions, getGUIIndicator, getHTML, getInitParameter, getInitParameters, getInitParameters, getInternalVersion, getList, getLocaleGUIIndicator, getLocaleGUIIndicator, getMachineName, getMaintainer, getNewNode, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNodeFromCache, getNodeGUIIndicator, getNumber, getObjectType, getObjectValue, getParentBuilder, getPluralName, getPluralName, getPluralNames, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedInputStream, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, hasField, hashCode, hashCode, hostname_function, insert, isExtensionOf, isNodeCached, isNull, isVirtual, loadInitParameters, newFunctionInstance, nodeLocalChanged, notify, notify, preCommit, process, removeEventListener, removeField, removeLocalObserver, removeRelations, removeRemoteObserver, removeSyncNodes, replace, safeCache, sendFieldChangeSignal, setDescription, setDescriptions, setFields, setInitParameter, setMaintainer, setPluralNames, setSearchAge, setSingularNames, setUniqueValue, setUniqueValue, setValue, setValue, setVersion, setXMLPath, shutdown, 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 DIR_UNIDIRECTIONAL
public static final int DIR_BIDIRECTIONAL
public static boolean usesbuilder
public boolean init()
init in class MMObjectBuilderboolean value, always success (true), as any exceptions are
caught and logged.MMObjectBuilder.create()public String getGUIIndicator(MMObjectNode node)
getGUIIndicator in class MMObjectBuildernode - Relation definition to describeString of descriptive textpublic String getBuilderName(Integer reldefNodeNumber)
reldefNodeNumber - rnumberprotected String findBuilderName(MMObjectNode node)
public String getBuilderName(MMObjectNode node)
sname field will be returned instead.node - The reldef Nodepublic InsRel getBuilder(int rnumber)
public InsRel getBuilder(MMObjectNode node)
public MMObjectNode getDefaultForBuilder(InsRel relBuilder)
null if not found.public void testValidData(MMObjectNode node) throws InvalidDataException
testValidData in class MMObjectBuildernode - The node whose data to checkInvalidDataException - If the data was unrecoverably invalid (the references did not point to existing objects)public int insert(String owner, MMObjectNode node)
MMObjectBuilder.preCommit(org.mmbase.module.core.MMObjectNode).insert in class MMObjectBuilderowner - The administrator creating the nodenode - The object to insert. The object need be of the same type as the current builder.int value which is the new object's unique number, -1 if the insert failed.public boolean commit(MMObjectNode node)
MMObjectBuilder.preCommit(org.mmbase.module.core.MMObjectNode).
This method does not remove names from the cache, as currently, unique names are not enforced.commit in class MMObjectBuildernode - The node to be committedboolean indicating successpublic void removeNode(MMObjectNode node)
removeNode in class MMObjectBuildernode - The node to remove.public void setDefaults(MMObjectNode node)
setDefaults in class MMObjectBuildernode - Node to be initializedpublic String getGUIIndicator(String field, MMObjectNode node)
getGUIIndicator in class MMObjectBuilderfield - Name of the field whose description should be returned.
valid values : 'dir'node - Relation definition containing the field's informationpublic boolean isRelationTable(String name)
name - A String of the relation definitions' nameboolean indicating success if the relationname existspublic boolean isRelationBuilder(int number)
number - The otype of the builderboolean indicating success if the builder exists in the cachepublic Enumeration<MMObjectBuilder> getRelationBuilders()
Enumeration containing the builders (as otype)public int getGuessedNumber(String role)
getNumberByName(java.lang.String) which better explains its usegetGuessedByName(java.lang.String) (but does not make use of dname)
Not very suitable to use, as success is dependent on the uniqueness of the builder in the table (not enforced, so unpredictable).role - The builder name on which to search for the relationint value indicating the relation's object number, or -1 if not found. If multiple relations use the
indicated buildername, the first one found is returned.public int getNumberByName(String role)
role - The role name on which to searchint value indicating the relation's object number, or -1 if not found.public int getNumberByName(String role, boolean searchBidirectional)
role - The role name on which to searchsearchBidirectional - determines whether to also search in snameint value indicating the relation's object number, or -1 if not found.public int getGuessedByName(String role)
getNumberByName(java.lang.String) insteadrole - The role name on which to search for the relationint value indicating the relation's object number, or -1 if not found. If multiple relations use the
indicated buildername, the first one found is returned.public int getRelsNrByName(String sname, String dname)
getNumberByName(java.lang.String) insteadsname - The first name on which to search for the relation (preferred as the source)dname - The second name on which to search for the relation (preferred as the destination)int value indicating the relation's object number, or -1 if not found. If multiple relations use the
indicated names, the first one found is returned.public boolean nodeRemoteChanged(String machine, String number, String builder, String ctype)
nodeRemoteChanged in class MMObjectBuildermachine - Name of the machine that changed the node.number - Number of the changed node as a Stringbuilder - type of the changed nodectype - command type, 'c'=changed, 'd'=deleted', 'r'=relations changed, 'n'=newtrueMMBase 1.9-SNAPSHOT - ${javadoctimestamp}