KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > content > eventhandler > CEOnlineHandler


1 package de.webman.content.eventhandler;
2
3 import com.teamkonzept.web.*;
4 import com.teamkonzept.webman.*;
5 import com.teamkonzept.webman.db.TKWebmanDBManager;
6 import com.teamkonzept.webman.mainint.*;
7 import com.teamkonzept.webman.mainint.db.*;
8 import com.teamkonzept.webman.mainint.db.queries.content.*;
9 import com.teamkonzept.webman.mainint.db.queries.*;
10 import com.teamkonzept.webman.mainint.events.*;
11 import com.teamkonzept.lib.*;
12 import com.teamkonzept.field.*;
13 import com.teamkonzept.field.db.*;
14 import com.teamkonzept.db.*;
15 import de.webman.content.workflow.*;
16 import de.webman.content.Content;
17 import java.sql.*;
18 import java.io.*;
19
20 /**
21 * Event: Zum Sprung aus OnlineSicht direkt in Webman
22  * @author $Author: sebastian $
23  * @version $Revision: 1.10 $
24 */

25 public class CEOnlineHandler extends DefaultEventHandler implements ParameterTypes, FrameConstants, DatabaseDefaults
26 {
27     /** empty Constructor */
28     private CEOnlineHandler()
29     {}
30     
31     private static CEOnlineHandler instance = new CEOnlineHandler();
32     
33     public static CEOnlineHandler getInstance()
34     {
35         return instance;
36     }
37     
38     public void handleEvent(TKEvent evt) throws TKException
39     {
40         try
41         {
42             CEUtils.checkEvent(evt);
43             TKHTMLTemplate t = evt.getPrepHTMLTemplate( "f_ce.tmpl" );
44             // ist entweder der zu bearbeitende oder ein Bruder des neuen
45
String JavaDoc contentNodeID = evt.getParameter(PARAMETER, "CONTENT_NODE_ID");
46             /** falls GROUP_CONTENT_NODE_ID def. ist wird nicht der Content,
47             sondern nur die CGR angezeigt **/

48             
49             boolean showonlyGroup = false;
50             if (contentNodeID == null)
51             {
52                 showonlyGroup = true;
53                 contentNodeID = evt.getParameter(PARAMETER, "GROUP_CONTENT_NODE_ID");
54             }
55             
56             // Group oder Single ?
57
boolean isGroup = false;
58             // existierenden oder neuen editieren ???
59
boolean neu = evt.getParameter(PARAMETER, "NEW") != null;
60             
61             if (!showonlyGroup)
62                 HTMLUtils.fillFrameSet( t, LEFT_FRAME_WIDTH, "CE_SHOWLIST", "CE_EDIT" );
63             else
64                 HTMLUtils.fillFrameSet( t, LEFT_FRAME_WIDTH, "CE_SHOWLIST", "CE_GROUP_LIST" );
65         
66             // Jetzt den rechten Frame oeffnen
67
// Informationen ueber den Knoten sammeln
68
TKQuery query = TKDBManager.newQuery(TKDBContentTreeGetParentInfo.class);
69             query.setQueryParams("CONTENT_NODE_ID", new Integer JavaDoc(contentNodeID));
70             query.execute();
71             ResultSet rs = query.fetchResultSet();
72             
73             // erst papa
74
// dann eigentlicher Knoten
75
String JavaDoc parentNodeID ="";
76             String JavaDoc parentName = "";
77             String JavaDoc parentShortName = "";
78             String JavaDoc contentNodeName = "";
79             String JavaDoc contentNodeShortName = "";
80             // String gcontentNodeName = "";
81
// String gcontentNodeShortName = "";
82
String JavaDoc contentNodeType = "";
83             String JavaDoc contentForm = "";
84             if (rs.next())
85             {
86                 // Elterninformationen
87
parentNodeID = rs.getString("CONTENT_NODE_ID");
88                 parentName = rs.getString("CONTENT_NODE_NAME");
89                 parentShortName = rs.getString("CONTENT_NODE_SHORTNAME");
90                 contentNodeType = rs.getString("CONTENT_NODE_TYPE");
91                 isGroup = contentNodeType.equals(GROUP);
92                 contentForm = rs.getString("CONTENT_FORM");
93                 // fülle den Nav-Context mit den Info's des Elternknotens;fürs zurückspringen
94
TKParams params = new TKParams();
95                 String JavaDoc grouphelp = "";
96                 if (isGroup)
97                     grouphelp = "GROUP";
98                 params.put(PARAMETER, grouphelp + "CONTENT_NODE_ID", parentNodeID);
99                 params.put(PARAMETER, grouphelp + "CONTENT_NODE_NAME", parentName);
100                 params.put(PARAMETER, grouphelp + "CONTENT_NODE_SHORTNAME", parentShortName);
101                 params.put(PARAMETER, "CONTENT_NODE_TYPE", contentNodeType);
102                 if (contentForm != null)
103                     params.put(PARAMETER, "CONTENT_FORM", contentForm);
104                                 
105                 ContentContext ct = new ContentContext(params, null);
106                 t.set("NAVIGATION_CONTEXT", ct.calculateNavContext());
107                 
108             }
109             if (rs.next())
110             {
111                 contentNodeName = rs.getString("CONTENT_NODE_NAME");
112                 contentNodeShortName = rs.getString("CONTENT_NODE_SHORTNAME");
113                 contentForm = rs.getString("CONTENT_FORM");
114             }
115             Content content = null;
116             if (!neu && !showonlyGroup)
117             {
118                 // aktuelle Infos über den Content sammeln !
119
content = VersionCache.getContentInfo(new Integer JavaDoc(contentNodeID));
120             }
121             TKVector openNodes = new TKVector();
122             openNodes.addElement(parentNodeID);
123             // Open Nodes fuer linken Frame
124
TKStandardIterator iterator1 = new TKStandardIterator( openNodes, t.getListIterator(), "OPEN_NODES", "OPEN_NODES" );
125             t.setListIterator( iterator1 );
126             
127             t.set("GROUP_CONTENT_NODE_ID", parentNodeID);
128             t.set("CONTENT_FORM", contentForm);
129             if (showonlyGroup)
130                 t.set("GROUP_CONTENT_NODE_ID", contentNodeID);
131             if (isGroup || showonlyGroup)
132             {
133                 t.set("GROUP_CONTENT_NODE_NAME", parentName);
134                 t.set("GROUP_CONTENT_NODE_SHORTNAME", parentShortName);
135             }
136             if (!neu)
137             {
138                 t.set("CONTENT_NODE_NAME", contentNodeName);
139                 t.set("CONTENT_NODE_SHORTNAME", contentNodeShortName);
140                 t.set("CONTENT_NODE_ID", contentNodeID);
141                 
142                 if (!showonlyGroup)
143                 {
144                     t.set("INSTANCE_ID", content.getInstanceId());
145                     ContentVersion version = content.getCurrentVersion();
146                     t.set("VERSION_ID" , version.getId());
147                     // Aendern !!! BOESER HACK !
148
t.set("NEW_STATUS", new Integer JavaDoc(1));
149                 }
150             }
151             t.set("CONTENT_NODE_TYPE", contentNodeType);
152             evt.finishTemplate(t);
153         }
154         catch (Throwable JavaDoc e)
155         {
156             // TO DO : Analyze Exception !
157
throw WebmanExceptionHandler.getException(e);
158         }
159     }
160     
161     public boolean isHandler(TKEvent evt)
162     {
163         return evt.getName().equalsIgnoreCase("CE_ONLINE");
164     }
165 }
166
Popular Tags