001: /*
002:
003: This software is OSI Certified Open Source Software.
004: OSI Certified is a certification mark of the Open Source Initiative.
005:
006: The license (Mozilla version 1.0) can be read at the MMBase site.
007: See http://www.MMBase.org/license
008:
009: */
010:
011: package org.mmbase.bridge;
012:
013: /**
014: * This interface represents a relation constraint (or contex, if you like).
015: * More specifically, it represents a relation manager (itself a node manager) as it applies between bnode belonging to
016: * two other node managers.
017: * Some of the information here is retrieved from the NodeManager used to build the catual relation node
018: * (the data as described in the xml builder config file). This NodeManager is also referred to as the parent.
019: * Other data is retrieved from a special (hidden) object that decsribes what relations apply between two nodes.
020: * (formerly known as the TypeRel builder).
021: * This includes direction and cardinality, and the NodeManagers of nodes itself. These fields cannot be changed
022: * except through the use of an administration module.
023: * This interface is therefore not a real mmbase 'object' in itself - it exists of two objects joined together.
024: *
025: * @author Rob Vermeulen
026: * @author Pierre van Rooden
027: * @version $Id: RelationManager.java,v 1.9 2007/11/28 15:09:55 michiel Exp $
028: */
029: public interface RelationManager extends NodeManager {
030: /**
031: * Directionality constant : uni-directional
032: */
033: public final static int UNIDIRECTIONAL = 1;
034:
035: /**
036: * Directionality constant : bi-directional
037: */
038: public final static int BIDIRECTIONAL = 2;
039:
040: /**
041: * Retrieves the role of the source to the destination
042: * @return the role as a <code>String</code>
043: */
044: public String getForwardRole();
045:
046: /**
047: * Retrieves the role of the destination to the source
048: * @return the role as a <code>String</code>
049: */
050: public String getReciprocalRole();
051:
052: /**
053: * Retrieves the gui name (prompt) of the role from source to destination
054: * @return the name as a <code>String</code>
055: */
056: public String getForwardGUIName();
057:
058: /**
059: * Retrieves the gui name (prompt) of the role from destination to source
060: * @return the name as a <code>String</code>
061: */
062: public String getReciprocalGUIName();
063:
064: /**
065: * Retrieves the directionality for this type (the default assigned to a new relation).
066: * @return one of the directionality constants
067: */
068: public int getDirectionality();
069:
070: /**
071: * Retrieves the NodeManager of node that can act as the source of a relation of this type.
072: * @return the source NodeManager
073: */
074: public NodeManager getSourceManager();
075:
076: /**
077: * Retrieves the type of node that can act as the destination of a relation of this type.
078: * @return the destination NodeManager
079: */
080: public NodeManager getDestinationManager();
081:
082: /**
083: * Adds a relation from this type.
084: * @param sourceNode the node from which you want to relate
085: * @param destinationNode the node to which you want to relate
086: * @return the added relation
087: */
088: public Relation createRelation(Node sourceNode, Node destinationNode);
089:
090: /**
091: * This method from Node is redeclared here to prevent an ambiguous invocation of method.
092: * reson: the the method in the base class (Node) is more specific than the one in the RelationManager
093: * (RelationManager extends Node).
094: * @param sourceNode source node of the relation
095: * @param relationManager relation manager of the relation
096: * @return new Relation
097: **/
098: public Relation createRelation(Node sourceNode,
099: RelationManager relationManager);
100:
101: /**
102: * Retrieves all the relations of this type from a given node.
103: * This method returns all relations of a certain node <em>not considering role, source
104: * manager and destination manager<em>, but only the builder of relation (e.g. it queries either
105: * insrel, or an extension thereof).
106: *
107: * See {@link Node#getRelations(String, NodeManager, String)}.
108: *
109: * @param node the node from which to give the relations
110: * @return a list of relations
111: * @todo I think this is a silly method.
112: */
113: public RelationList getRelations(Node node);
114:
115: /**
116: * Check if the current user may create a new relation of this type between
117: * the specified nodes.
118: * @param sourceNode source node of the relation
119: * @param destinationNode destination node of the relation
120: *
121: * @return Check if the current user may create a new relation of this type
122: * between the specified nodes.
123: */
124: public boolean mayCreateRelation(Node sourceNode,
125: Node destinationNode);
126:
127: }
|