| org.mmbase.module.core.MMTable org.mmbase.module.core.MMObjectBuilder org.mmbase.module.corebuilders.RelDef
RelDef | public class RelDef extends MMObjectBuilder (Code) | | RelDef, one of the meta stucture nodes, is used to define the possible relation types.
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.
author: Daniel Ockeloen author: Pierre van Rooden version: $Id: RelDef.java,v 1.44 2007/02/25 17:56:58 nklasens Exp $ |
Field Summary | |
final public static int | DIR_BIDIRECTIONAL Value of "dir" field indicating bidirectional relatios. | final public static int | DIR_UNIDIRECTIONAL Value of "dir" field indicating unidirectional relations. | public static boolean | usesbuilder Indicates whether the relationdefinitions use the 'builder' field (that is, whether the
field has been defined in the xml file). |
Constructor Summary | |
public | RelDef() |
Method Summary | |
public boolean | commit(MMObjectNode node) Commit changes to this node and updated the cache. | protected String | findBuilderName(MMObjectNode node) | public InsRel | getBuilder(int rnumber) Returns the builder of a relation definition. | public InsRel | getBuilder(MMObjectNode node) Returns the builder of a relation definition. | public String | getBuilderName(Integer reldefNodeNumber) | public String | getBuilderName(MMObjectNode node) Returns the builder name of a relation definition. | public MMObjectNode | getDefaultForBuilder(InsRel relBuilder) Returns the first occurrence of a reldef node of a relation definition. | public String | getGUIIndicator(MMObjectNode node) Returns a GUI description of a relation definition. | public String | getGUIIndicator(String field, MMObjectNode node) | public int | getGuessedByName(String role) Search the relation definition table for the identifying number of
a relation, by name of the relation to use.
This function is used by descendants of Insrel to determine a default reference to a 'relation definition' (reldef entry).
The 'default' is the relation with the same name as the builder. | public int | getGuessedNumber(String role) Search the relation definition table for the identifying number of
a relation, by name of the relation to use
Similar to
RelDef.getGuessedByName (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).
Parameters: role - The builder name on which to search for the relation A int value indicating the relation's object number, or -1 if not found. | public int | getNumberByName(String role) Search the relation definition table for the identifying number of
a relationdefinition, by name of the role to use. | public 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. | public Enumeration<MMObjectBuilder> | getRelationBuilders() Returns a list of builders currently implementing a relation node. | public int | getRelsNrByName(String sname, String dname) Searches for the relation number on the combination of sname and dname.
When there's no match found in this order a search with a swapped sname and dname will be done.
Note that there is no real assurance that an sname/dname combination must be unique.
Parameters: sname - The first name on which to search for the relation (preferred as the source) Parameters: dname - The second name on which to search for the relation (preferred as the destination) A int value indicating the relation's object number, or -1 if not found. | public Set<Integer> | getRoles() Returns all possible rnumbers ('roles'). | public boolean | init() Initializes the builder by reading the cache. | public int | insert(String owner, MMObjectNode node) Insert a new object, and updated the cache after an insert.
This method indirectly calls
RelDef.preCommit .
Parameters: owner - The administrator creating the node Parameters: node - The object to insert. | public boolean | isRelationBuilder(int number) Checks to see if a given builder (otype) is known to be a relation builder. | public boolean | isRelationTable(String name) Checks to see if a given relation definition is stored in the cache. | public boolean | nodeRemoteChanged(String machine, String number, String builder, String ctype) Called when a remote node is changed. | public void | removeNode(MMObjectNode node) Remove a node from the cloud. | public void | setDefaults(MMObjectNode node) Sets defaults for a new relation definition. | public void | testValidData(MMObjectNode node) Tests whether the data in a node is valid (throws an exception if this is not the case). |
DIR_BIDIRECTIONAL | final public static int DIR_BIDIRECTIONAL(Code) | | Value of "dir" field indicating bidirectional relatios.
|
DIR_UNIDIRECTIONAL | final public static int DIR_UNIDIRECTIONAL(Code) | | Value of "dir" field indicating unidirectional relations.
|
usesbuilder | public static boolean usesbuilder(Code) | | Indicates whether the relationdefinitions use the 'builder' field (that is, whether the
field has been defined in the xml file). Used for backward compatibility.
|
RelDef | public RelDef()(Code) | | Contruct the builder
|
commit | public boolean commit(MMObjectNode node)(Code) | | Commit changes to this node and updated the cache. This method indirectly calls
RelDef.preCommit .
This method does not remove names from the cache, as currently, unique names are not enforced.
Parameters: node - The node to be committed a boolean indicating success |
getBuilder | public InsRel getBuilder(int rnumber)(Code) | | Returns the builder of a relation definition.
the builder |
getBuilderName | public String getBuilderName(Integer reldefNodeNumber)(Code) | | Parameters: reldefNodeNumber - rnumber since: MMBase-1.7 |
getBuilderName | public String getBuilderName(MMObjectNode node)(Code) | | Returns the builder name of a relation definition.
If the buildername cannot be accurately determined, the sname field will be returned instead.
Parameters: node - The reldef Node the builder name |
getDefaultForBuilder | public MMObjectNode getDefaultForBuilder(InsRel relBuilder)(Code) | | Returns the first occurrence of a reldef node of a relation definition.
used to set the default reldef for a specific builder.
the default reldef node, or null if not found. |
getGUIIndicator | public String getGUIIndicator(MMObjectNode node)(Code) | | Returns a GUI description of a relation definition.
The description is dependent on the direction (uni/bi) of the relation
Parameters: node - Relation definition to describe A String of descriptive text |
getGUIIndicator | public String getGUIIndicator(String field, MMObjectNode node)(Code) | | Retrieve descriptors for a relation definition's fields,
specifically a descriptive text for the relation's direction (dir)
Parameters: field - Name of the field whose description should be returned.valid values : 'dir' Parameters: node - Relation definition containing the field's information A descriptive text for the field's contents, or null if no description could be generated |
getGuessedByName | public int getGuessedByName(String role)(Code) | | Search the relation definition table for the identifying number of
a relation, by name of the relation to use.
This function is used by descendants of Insrel to determine a default reference to a 'relation definition' (reldef entry).
The 'default' is the relation with the same name as the builder. If no such relation exists, there is no default.
Parameters: role - The role name on which to search for the relation A int value indicating the relation's object number, or -1 if not found. If multiple relations use theindicated buildername, the first one found is returned.RelDef.getNumberByName |
getGuessedNumber | public int getGuessedNumber(String role)(Code) | | Search the relation definition table for the identifying number of
a relation, by name of the relation to use
Similar to
RelDef.getGuessedByName (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).
Parameters: role - The builder name on which to search for the relation A int value indicating the relation's object number, or -1 if not found. If multiple relations use theindicated buildername, the first one found is returned.RelDef.getNumberByName |
getNumberByName | public int getNumberByName(String role)(Code) | | Search the relation definition table for the identifying number of
a relationdefinition, by name of the role to use.
The name should be either the primary identifying role name (sname),
or a combination of sname and dname separated by a slash ("/").
Parameters: role - The role name on which to search A int value indicating the relation's object number, or -1 if not found. |
getNumberByName | public int getNumberByName(String role, boolean searchBidirectional)(Code) | | Search the relation definition table for the identifying number of
a relationdefinition, by name of the role to use.
Initially, this method seraches on either the primary identifying
role name (sname), or a combination of sname and dname separated by a slash ("/").
If this yields no result, and searchBidirectional is true, the method then searches
on the secondary identifying role name.
The latter is not cached (to avoid conflict and is thus slower).
Parameters: role - The role name on which to search Parameters: searchBidirectional - determines whether to also search in sname A int value indicating the relation's object number, or -1 if not found. |
getRelationBuilders | public Enumeration<MMObjectBuilder> getRelationBuilders()(Code) | | Returns a list of builders currently implementing a relation node.
an Enumeration containing the builders (as otype) |
getRelsNrByName | public int getRelsNrByName(String sname, String dname)(Code) | | Searches for the relation number on the combination of sname and dname.
When there's no match found in this order a search with a swapped sname and dname will be done.
Note that there is no real assurance that an sname/dname combination must be unique.
Parameters: sname - The first name on which to search for the relation (preferred as the source) Parameters: dname - The second name on which to search for the relation (preferred as the destination) A int value indicating the relation's object number, or -1 if not found. If multiple relations use theindicated names, the first one found is returned.RelDef.getNumberByName |
getRoles | public Set<Integer> getRoles()(Code) | | Returns all possible rnumbers ('roles').
since: MMBase-1.9 |
init | public boolean init()(Code) | | Initializes the builder by reading the cache. Also determines whether the 'builder' field is used.
A boolean value, always success (true ), as any exceptions arecaught and logged. |
insert | public int insert(String owner, MMObjectNode node)(Code) | | Insert a new object, and updated the cache after an insert.
This method indirectly calls
RelDef.preCommit .
Parameters: owner - The administrator creating the node Parameters: node - The object to insert. The object need be of the same type as the current builder. An int value which is the new object's unique number, -1 if the insert failed. |
isRelationBuilder | public boolean isRelationBuilder(int number)(Code) | | Checks to see if a given builder (otype) is known to be a relation builder.
Parameters: number - The otype of the builder a boolean indicating success if the builder exists in the cache |
isRelationTable | public boolean isRelationTable(String name)(Code) | | Checks to see if a given relation definition is stored in the cache.
Parameters: name - A String of the relation definitions' name a boolean indicating success if the relationname exists |
nodeRemoteChanged | public boolean nodeRemoteChanged(String machine, String number, String builder, String ctype)(Code) | | Called when a remote node is changed.
If a node is changed or newly created, this adds the new or updated role (sname and dname) to the
cache.
since: MMBase-1.7.1 |
removeNode | public void removeNode(MMObjectNode node)(Code) | | Remove a node from the cloud.
Parameters: node - The node to remove. |
setDefaults | public void setDefaults(MMObjectNode node)(Code) | | Sets defaults for a new relation definition.
Initializes a relation to be bidirectional, and, if applicable, to use the 'insrel' builder.
Parameters: node - Node to be initialized |
testValidData | public void testValidData(MMObjectNode node) throws InvalidDataException(Code) | | Tests whether the data in a node is valid (throws an exception if this is not the case).
Parameters: node - The node whose data to check |
Methods inherited from org.mmbase.module.core.MMObjectBuilder | public void addEventListener(org.mmbase.core.event.EventListener listener)(Code)(Java Doc) public void addField(CoreField def)(Code)(Java Doc) public boolean addLocalObserver(MMBaseObserver obs)(Code)(Java Doc) public boolean addRemoteObserver(MMBaseObserver obs)(Code)(Java Doc) public boolean broadcastChanges()(Code)(Java Doc) public boolean checkAddTmpField(String field)(Code)(Java Doc) public int clearBlobCache(int nodeNumber)(Code)(Java Doc) public boolean commit(MMObjectNode node)(Code)(Java Doc) public boolean create()(Code)(Java Doc) public boolean createAlias(int number, String alias, String owner)(Code)(Java Doc) public boolean createAlias(int number, String alias)(Code)(Java Doc) public void delete()(Code)(Java Doc) final public boolean equals(Object o)(Code)(Java Doc) public boolean equals(MMObjectNode o1, MMObjectNode o2)(Code)(Java Doc) protected Object executeFunction(MMObjectNode node, String function, List> arguments)(Code)(Java Doc) protected Object executeFunction(MMObjectNode node, String function, String field)(Code)(Java Doc) public boolean fieldLocalChanged(String number, String builder, String field, String value)(Code)(Java Doc) public List<MMObjectBuilder> getAncestors()(Code)(Java Doc) protected BlobCache getBlobCache(String fieldName)(Code)(Java Doc) public String getClassName()(Code)(Java Doc) public File getConfigFile()(Code)(Java Doc) public String getConfigResource()(Code)(Java Doc) public int getDBState(String fieldName)(Code)(Java Doc) public int getDBType(String fieldName)(Code)(Java Doc) public DataTypeCollector getDataTypeCollector()(Code)(Java Doc) public MMObjectNode getDefaultTeaser(MMObjectNode node, MMObjectNode tnode)(Code)(Java Doc) public String getDefaultUrl(int src)(Code)(Java Doc) public List<MMObjectBuilder> getDescendants()(Code)(Java Doc) public String getDescription()(Code)(Java Doc) public String getDescription(String lang)(Code)(Java Doc) public Hashtable<String, String> getDescriptions()(Code)(Java Doc) public MMObjectNode getEmptyNode(String owner)(Code)(Java Doc) public FieldDefs getField(String fieldName)(Code)(Java Doc) public Set<String> getFieldNames()(Code)(Java Doc) public Collection<CoreField> getFields()(Code)(Java Doc) public List<CoreField> getFields(int sortOrder)(Code)(Java Doc) protected Function> getFunction(MMObjectNode node, String functionName)(Code)(Java Doc) protected Vector<String> getFunctionParameters(String fields)(Code)(Java Doc) protected Collection<Function<?>> getFunctions(MMObjectNode node)(Code)(Java Doc) public String getGUIIndicator(MMObjectNode node, Parameters pars)(Code)(Java Doc) public String getGUIIndicator(MMObjectNode node)(Code)(Java Doc) public String getGUIIndicator(String fieldName, MMObjectNode node)(Code)(Java Doc) protected String getHTML(String body)(Code)(Java Doc) public String getInitParameter(String name)(Code)(Java Doc) public Map<String, String> getInitParameters()(Code)(Java Doc) public Map getInitParameters(String contextPath)(Code)(Java Doc) public long getInternalVersion()(Code)(Java Doc) public Vector<String> getList(PageInfo sp, StringTagger tagger, StringTokenizer tok)(Code)(Java Doc) protected String getLocaleGUIIndicator(Locale locale, String field, MMObjectNode node)(Code)(Java Doc) protected String getLocaleGUIIndicator(Locale locale, MMObjectNode node)(Code)(Java Doc) public String getMachineName()(Code)(Java Doc) public String getMaintainer()(Code)(Java Doc) public MMObjectNode getNewNode(String owner)(Code)(Java Doc) protected MMObjectNode getNewTmpNode(String owner, String key)(Code)(Java Doc) public FieldDefs getNextField(String currentfield, int sortorder)(Code)(Java Doc) public FieldDefs getNextField(String currentfield)(Code)(Java Doc) public MMObjectNode getNode(String key, boolean useCache)(Code)(Java Doc) public MMObjectNode getNode(String key)(Code)(Java Doc) public MMObjectNode getNode(int number)(Code)(Java Doc) public MMObjectNode getNodeFromCache(Integer number)(Code)(Java Doc) protected String getNodeGUIIndicator(MMObjectNode node, Parameters params)(Code)(Java Doc) public int getNumber()(Code)(Java Doc) public int getObjectType()(Code)(Java Doc) protected Object getObjectValue(MMObjectNode node, String field)(Code)(Java Doc) public MMObjectBuilder getParentBuilder()(Code)(Java Doc) public String getPluralName(String lang)(Code)(Java Doc) public String getPluralName()(Code)(Java Doc) public Hashtable<String, String> getPluralNames()(Code)(Java Doc) public Vector<MMObjectNode> getRelations_main(int src)(Code)(Java Doc) public String getSearchAge()(Code)(Java Doc) public String getShort(String str, int len)(Code)(Java Doc) protected byte[] getShortedByte(String fieldName, MMObjectNode node)(Code)(Java Doc) protected String getShortedText(String fieldName, MMObjectNode node)(Code)(Java Doc) public String getSingularName(String lang)(Code)(Java Doc) public String getSingularName()(Code)(Java Doc) public Hashtable<String, String> getSingularNames()(Code)(Java Doc) public String getSmartPath(String documentRoot, String path, String nodeNumber, String version)(Code)(Java Doc) protected static MMObjectNode getTmpNode(String key)(Code)(Java Doc) protected static String getURLEncode(String body)(Code)(Java Doc) public Object getValue(MMObjectNode node, String field)(Code)(Java Doc) public int getVersion()(Code)(Java Doc) protected static String getWAP(String body)(Code)(Java Doc) public String getXMLPath()(Code)(Java Doc) public boolean hasField(String fieldName)(Code)(Java Doc) public int hashCode()(Code)(Java Doc) public int hashCode(MMObjectNode o)(Code)(Java Doc) public static String hostname_function(String url)(Code)(Java Doc) public boolean init()(Code)(Java Doc) public int insert(int oType, String owner)(Code)(Java Doc) public int insert(String owner, MMObjectNode node)(Code)(Java Doc) public boolean isExtensionOf(MMObjectBuilder o)(Code)(Java Doc) public boolean isNodeCached(Integer number)(Code)(Java Doc) public boolean isVirtual()(Code)(Java Doc) public void loadInitParameters()(Code)(Java Doc) protected Function newFunctionInstance(String name, Parameter[] parameters, ReturnType returnType)(Code)(Java Doc) public boolean nodeLocalChanged(String machine, String number, String builder, String ctype)(Code)(Java Doc) public boolean nodeRemoteChanged(String machine, String number, String builder, String ctype)(Code)(Java Doc) public void notify(NodeEvent event)(Code)(Java Doc) public void notify(RelationEvent event)(Code)(Java Doc) public MMObjectNode preCommit(MMObjectNode node)(Code)(Java Doc) public boolean process(PageInfo sp, StringTokenizer command, Hashtable cmds, Hashtable vars)(Code)(Java Doc) public void removeEventListener(org.mmbase.core.event.EventListener listener)(Code)(Java Doc) public void removeField(String fieldName)(Code)(Java Doc) public boolean removeLocalObserver(MMBaseObserver obs)(Code)(Java Doc) public void removeNode(MMObjectNode node)(Code)(Java Doc) public void removeRelations(MMObjectNode node)(Code)(Java Doc) public boolean removeRemoteObserver(MMBaseObserver obs)(Code)(Java Doc) protected void removeSyncNodes(MMObjectNode node)(Code)(Java Doc) public String replace(PageInfo sp, StringTokenizer tok)(Code)(Java Doc) public MMObjectNode safeCache(Integer n, MMObjectNode node)(Code)(Java Doc) public boolean sendFieldChangeSignal(MMObjectNode node, String fieldName)(Code)(Java Doc) public void setDefaults(MMObjectNode node)(Code)(Java Doc) public void setDescription(String e)(Code)(Java Doc) public void setDescriptions(Hashtable<String, String> e)(Code)(Java Doc) public void setFields(List<CoreField> f)(Code)(Java Doc) public void setInitParameter(String name, String value)(Code)(Java Doc) public void setMaintainer(String m)(Code)(Java Doc) public void setParentBuilder(MMObjectBuilder parent)(Code)(Java Doc) public void setPluralNames(Hashtable<String, String> names)(Code)(Java Doc) public void setSearchAge(String age)(Code)(Java Doc) public void setSingularNames(Hashtable<String, String> names)(Code)(Java Doc) protected String setUniqueValue(MMObjectNode node, String field, String baseValue)(Code)(Java Doc) protected int setUniqueValue(MMObjectNode node, String field, int offset)(Code)(Java Doc) public boolean setValue(MMObjectNode node, String fieldName, Object originalValue)(Code)(Java Doc) public boolean setValue(MMObjectNode node, String fieldName)(Code)(Java Doc) public void setVersion(int i)(Code)(Java Doc) public void setXMLPath(String m)(Code)(Java Doc) public void testValidData(MMObjectNode node) throws InvalidDataException(Code)(Java Doc) public String toString()(Code)(Java Doc) public String toString(MMObjectNode n)(Code)(Java Doc) protected void update()(Code)(Java Doc) protected void updateFields()(Code)(Java Doc) public static String wrap(String text, int width)(Code)(Java Doc)
|
|
|