KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > jsp > taglib > edit > CreateRelationTag


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.bridge.jsp.taglib.edit;
11
12 import org.mmbase.bridge.jsp.taglib.util.Attribute;
13 import javax.servlet.jsp.JspTagException JavaDoc;
14
15 import org.mmbase.bridge.Node;
16 import org.mmbase.bridge.RelationManager;
17 import org.mmbase.bridge.Relation;
18
19 import org.mmbase.bridge.jsp.taglib.NodeTag;
20
21 import org.mmbase.util.logging.Logger;
22 import org.mmbase.util.logging.Logging;
23
24 /**
25  * A tag lib to create relations.
26  *
27  * @author Michiel Meeuwissen
28  * @version $Id: CreateRelationTag.java,v 1.19 2004/07/26 20:18:02 nico Exp $
29  */

30
31 public class CreateRelationTag extends NodeTag {
32
33     private static final Logger log = Logging.getLoggerInstance(CreateRelationTag.class);
34
35     private Attribute role = Attribute.NULL;
36     private Attribute source = Attribute.NULL;
37     private Attribute destination = Attribute.NULL;
38
39     public void setRole(String JavaDoc r) throws JspTagException JavaDoc {
40         role = getAttribute(r);
41     }
42
43     public void setSource(String JavaDoc s) throws JspTagException JavaDoc {
44         source = getAttribute(s);
45     }
46     public void setDestination(String JavaDoc d) throws JspTagException JavaDoc {
47         destination = getAttribute(d);
48     }
49
50     public int doStartTag() throws JspTagException JavaDoc {
51         RelationManager rm = getCloudVar().getRelationManager(role.getString(this));
52         Node sourceNode = getNode(source.getString(this));
53         Node destinationNode = getNode(destination.getString(this));
54
55         if (log.isDebugEnabled()) {
56             log.debug("cloud from relationmanager " + rm.getCloud().getName());
57             log.debug("cloud from source node " + sourceNode.getCloud().getName());
58             log.debug("cloud from dest node " + destinationNode.getCloud().getName());
59         }
60
61         Relation r = rm.createRelation(sourceNode, destinationNode);
62         r.commit();
63
64         setNodeVar(r);
65         fillVars();
66         return EVAL_BODY_BUFFERED;
67     }
68
69 }
70
Popular Tags