01: package de.webman.documenttype.eventhandler;
02:
03: import com.teamkonzept.web.*;
04: import com.teamkonzept.webman.*;
05: import com.teamkonzept.webman.db.TKWebmanDBManager;
06: import com.teamkonzept.webman.mainint.*;
07: import com.teamkonzept.webman.mainint.db.*;
08:
09: 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 com.teamkonzept.publishing.markups.*;
16:
17: import java.sql.*;
18: import java.io.*;
19:
20: /**
21: * doPRSavePres
22: *
23: * Speichern einer Presentation
24: * danach linke Liste neu, rechts leere Liste aller Componenten dieser Presentation
25: *
26: * @author $Author: alex $
27: * @version $Revision: 1.4 $
28: */
29: public class DTSavePresHandler extends DefaultEventHandler implements
30: ParameterTypes, FrameConstants, DatabaseDefaults {
31: private DTSavePresHandler() {
32: }
33:
34: /** Singleton Instanz */
35: private static DTSavePresHandler instance = new DTSavePresHandler();
36:
37: public static DTSavePresHandler getInstance() {
38: return instance;
39: }
40:
41: public void handleEvent(TKEvent evt) throws TKException {
42: try {
43: WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(),
44: ContextConstants.PRESENTATIONS);
45: String tmplId = evt.getParameter(PARAMETER,
46: "THE_TEMPLATE_ID");
47: if (tmplId == null || tmplId.equals("")) {
48: throw new TKUserException(
49: "Es muß ein Template angelegt werden",
50: NO_TEMPLATE_DEFINED, USER_SEVERITY, false, null);
51: }
52: String presId = "";
53: String name = evt.getNotNullParameter(PARAMETER,
54: "PRESENTATION_NAME").trim();
55: String shortName = evt.getNotNullParameter(PARAMETER,
56: "PRESENTATION_SHORTNAME").trim();
57: if (name.equals(""))
58: throw new TKUserException(
59: "Name des Dokumententyps darf nicht leer sein",
60: INPUT_CANNOT_BE_EMPTY, USER_SEVERITY, false,
61: null);
62: if (shortName.equals(""))
63: throw new TKUserException(
64: "Kennung des Dokumententyps darf nicht leer sein",
65: INPUT_CANNOT_BE_EMPTY, USER_SEVERITY, false,
66: null);
67: TKQuery q = TKDBManager.newQuery(TKDBPresInsert.class);
68: q.setQueryParams("PRESENTATION_NAME", name);
69: q.setQueryParams("PRESENTATION_SHORTNAME", shortName);
70: q.setQueryParams("TEMPLATE_ID", new Integer(tmplId));
71: q.execute();
72: ResultSet rs = q.fetchResultSet();
73: if (rs.next()) {
74: presId = Integer.toString(rs.getInt("PRESENTATION_ID"));
75: }
76:
77: TKHTMLTemplate frame = evt.getPrepHTMLTemplate("f_pr.tmpl");
78: HTMLUtils.fillFrameSet(frame, LEFT_FRAME_WIDTH_SMALL,
79: "PR_SHOWLIST", "PR_EDIT");
80: frame.set(evt.getParams().getClass(PARAMETER));
81: frame.set("TEMPLATE_ID", tmplId);
82: frame.set("PRESENTATION_ID", presId);
83: frame.set("DESTINATION", presId);
84: WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(),
85: frame, PRESENTATIONS);
86: evt.finishTemplate(frame);
87: } catch (Throwable e) {
88: // TO DO : Analyze Exception !
89: throw WebmanExceptionHandler.getException(e);
90: }
91: }
92:
93: public boolean isHandler(TKEvent evt) {
94: return evt.getName().equalsIgnoreCase("PR_SAVE_PRES");
95: }
96: }
|