001: package de.webman.content.eventhandler;
002:
003: import com.teamkonzept.web.*;
004: import com.teamkonzept.webman.*;
005: import com.teamkonzept.webman.db.TKWebmanDBManager;
006: import com.teamkonzept.webman.mainint.*;
007: import com.teamkonzept.webman.mainint.db.*;
008: import com.teamkonzept.webman.mainint.db.queries.content.*;
009: import com.teamkonzept.webman.mainint.db.queries.*;
010: import com.teamkonzept.webman.mainint.events.*;
011: import com.teamkonzept.lib.*;
012: import com.teamkonzept.field.*;
013: import com.teamkonzept.field.db.*;
014: import com.teamkonzept.db.*;
015: import de.webman.content.workflow.*;
016: import de.webman.content.Content;
017: import java.sql.*;
018: import java.io.*;
019:
020: /**
021: * Event: Zum Sprung aus OnlineSicht direkt in Webman
022: * @author $Author: sebastian $
023: * @version $Revision: 1.10 $
024: */
025: public class CEOnlineHandler extends DefaultEventHandler implements
026: ParameterTypes, FrameConstants, DatabaseDefaults {
027: /** empty Constructor */
028: private CEOnlineHandler() {
029: }
030:
031: private static CEOnlineHandler instance = new CEOnlineHandler();
032:
033: public static CEOnlineHandler getInstance() {
034: return instance;
035: }
036:
037: public void handleEvent(TKEvent evt) throws TKException {
038: try {
039: CEUtils.checkEvent(evt);
040: TKHTMLTemplate t = evt.getPrepHTMLTemplate("f_ce.tmpl");
041: // ist entweder der zu bearbeitende oder ein Bruder des neuen
042: String contentNodeID = evt.getParameter(PARAMETER,
043: "CONTENT_NODE_ID");
044: /** falls GROUP_CONTENT_NODE_ID def. ist wird nicht der Content,
045: sondern nur die CGR angezeigt **/
046:
047: boolean showonlyGroup = false;
048: if (contentNodeID == null) {
049: showonlyGroup = true;
050: contentNodeID = evt.getParameter(PARAMETER,
051: "GROUP_CONTENT_NODE_ID");
052: }
053:
054: // Group oder Single ?
055: boolean isGroup = false;
056: // existierenden oder neuen editieren ???
057: boolean neu = evt.getParameter(PARAMETER, "NEW") != null;
058:
059: if (!showonlyGroup)
060: HTMLUtils.fillFrameSet(t, LEFT_FRAME_WIDTH,
061: "CE_SHOWLIST", "CE_EDIT");
062: else
063: HTMLUtils.fillFrameSet(t, LEFT_FRAME_WIDTH,
064: "CE_SHOWLIST", "CE_GROUP_LIST");
065:
066: // Jetzt den rechten Frame oeffnen
067: // Informationen ueber den Knoten sammeln
068: TKQuery query = TKDBManager
069: .newQuery(TKDBContentTreeGetParentInfo.class);
070: query.setQueryParams("CONTENT_NODE_ID", new Integer(
071: contentNodeID));
072: query.execute();
073: ResultSet rs = query.fetchResultSet();
074:
075: // erst papa
076: // dann eigentlicher Knoten
077: String parentNodeID = "";
078: String parentName = "";
079: String parentShortName = "";
080: String contentNodeName = "";
081: String contentNodeShortName = "";
082: // String gcontentNodeName = "";
083: // String gcontentNodeShortName = "";
084: String contentNodeType = "";
085: String contentForm = "";
086: if (rs.next()) {
087: // Elterninformationen
088: parentNodeID = rs.getString("CONTENT_NODE_ID");
089: parentName = rs.getString("CONTENT_NODE_NAME");
090: parentShortName = rs
091: .getString("CONTENT_NODE_SHORTNAME");
092: contentNodeType = rs.getString("CONTENT_NODE_TYPE");
093: isGroup = contentNodeType.equals(GROUP);
094: contentForm = rs.getString("CONTENT_FORM");
095: // fülle den Nav-Context mit den Info's des Elternknotens;fürs zurückspringen
096: TKParams params = new TKParams();
097: String grouphelp = "";
098: if (isGroup)
099: grouphelp = "GROUP";
100: params.put(PARAMETER, grouphelp + "CONTENT_NODE_ID",
101: parentNodeID);
102: params.put(PARAMETER, grouphelp + "CONTENT_NODE_NAME",
103: parentName);
104: params.put(PARAMETER, grouphelp
105: + "CONTENT_NODE_SHORTNAME", parentShortName);
106: params.put(PARAMETER, "CONTENT_NODE_TYPE",
107: contentNodeType);
108: if (contentForm != null)
109: params.put(PARAMETER, "CONTENT_FORM", contentForm);
110:
111: ContentContext ct = new ContentContext(params, null);
112: t.set("NAVIGATION_CONTEXT", ct.calculateNavContext());
113:
114: }
115: if (rs.next()) {
116: contentNodeName = rs.getString("CONTENT_NODE_NAME");
117: contentNodeShortName = rs
118: .getString("CONTENT_NODE_SHORTNAME");
119: contentForm = rs.getString("CONTENT_FORM");
120: }
121: Content content = null;
122: if (!neu && !showonlyGroup) {
123: // aktuelle Infos über den Content sammeln !
124: content = VersionCache.getContentInfo(new Integer(
125: contentNodeID));
126: }
127: TKVector openNodes = new TKVector();
128: openNodes.addElement(parentNodeID);
129: // Open Nodes fuer linken Frame
130: TKStandardIterator iterator1 = new TKStandardIterator(
131: openNodes, t.getListIterator(), "OPEN_NODES",
132: "OPEN_NODES");
133: t.setListIterator(iterator1);
134:
135: t.set("GROUP_CONTENT_NODE_ID", parentNodeID);
136: t.set("CONTENT_FORM", contentForm);
137: if (showonlyGroup)
138: t.set("GROUP_CONTENT_NODE_ID", contentNodeID);
139: if (isGroup || showonlyGroup) {
140: t.set("GROUP_CONTENT_NODE_NAME", parentName);
141: t.set("GROUP_CONTENT_NODE_SHORTNAME", parentShortName);
142: }
143: if (!neu) {
144: t.set("CONTENT_NODE_NAME", contentNodeName);
145: t.set("CONTENT_NODE_SHORTNAME", contentNodeShortName);
146: t.set("CONTENT_NODE_ID", contentNodeID);
147:
148: if (!showonlyGroup) {
149: t.set("INSTANCE_ID", content.getInstanceId());
150: ContentVersion version = content
151: .getCurrentVersion();
152: t.set("VERSION_ID", version.getId());
153: // Aendern !!! BOESER HACK !
154: t.set("NEW_STATUS", new Integer(1));
155: }
156: }
157: t.set("CONTENT_NODE_TYPE", contentNodeType);
158: evt.finishTemplate(t);
159: } catch (Throwable e) {
160: // TO DO : Analyze Exception !
161: throw WebmanExceptionHandler.getException(e);
162: }
163: }
164:
165: public boolean isHandler(TKEvent evt) {
166: return evt.getName().equalsIgnoreCase("CE_ONLINE");
167: }
168: }
|