01: package de.webman.config.eventhandler;
02:
03: import java.util.*;
04: import java.sql.*;
05:
06: import com.teamkonzept.web.*;
07: import com.teamkonzept.lib.*;
08: import com.teamkonzept.db.*;
09: import com.teamkonzept.webman.*;
10: import com.teamkonzept.webman.mainint.*;
11: import com.teamkonzept.webman.mainint.db.queries.*;
12: import com.teamkonzept.webman.mainint.events.*;
13:
14: /**
15: Löscht eine Propertygruppe sammt ihrer Properties und stellt ein frameset dar, rechts die Liste der Propertygruppen,
16: links leer.
17: * @author $Author: uli $
18: * @version $Revision: 1.4 $
19: */
20: public class COPropGroupDeleteHandler extends DefaultEventHandler
21: implements ParameterTypes, DatabaseDefaults, FrameConstants {
22: private COPropGroupDeleteHandler() {
23: }
24:
25: private static COPropGroupDeleteHandler instance = new COPropGroupDeleteHandler();
26:
27: public static COPropGroupDeleteHandler getInstance() {
28: return instance;
29: };
30:
31: public void handleEvent(TKEvent evt) throws TKException {
32: try {
33: WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(),
34: ContextConstants.CUSTOMIZE_PROPERTIES); // check if event is allowed
35: String propGroupId = evt.getParameter(PARAMETER,
36: "PROPGROUP_ID");
37: String propGroupName = evt.getParameter(PARAMETER,
38: "PROPGROUP_NAME");
39: propGroupId = (propGroupId != null ? propGroupId : "-1");
40: if (!propGroupId.equals("-1")) {
41: // find the properties of this group
42: TKQuery q = TKDBManager
43: .newQuery(TKDBPropGroupGetGroupProps.class);
44: q.setQueryParams("PROPGROUP_ID", new Integer(
45: propGroupId));
46: q.execute();
47: ResultSet rs = q.fetchResultSet();
48:
49: // löschen der properties der gruppe
50: while (rs != null && rs.next()) {
51: q = TKDBManager.newQuery(TKDBPropDelete.class);
52: q.setQueryParams("PROP_ID", new Integer(rs
53: .getInt("PROP_ID")));
54: q.execute();
55: }
56:
57: // löschen der gruppe selbst
58: q = TKDBManager.newQuery(TKDBPropGroupDelete.class);
59: q.setQueryParams("PROPGROUP_ID", new Integer(
60: propGroupId));
61: q.execute();
62:
63: // Notify listeners.
64: ConfigurationManager.getInstance().notifyListeners(
65: propGroupName);
66: }
67:
68: TKHTMLTemplate t = evt
69: .getPrepHTMLTemplate("f_co_propgroup.tmpl");
70: HTMLUtils.fillFrameSet(t, LEFT_FRAME_WIDTH,
71: "CO_PROPGROUP_LIST", "EMPTY");
72: evt.finishTemplate(t);
73: } catch (Throwable e) {
74: throw WebmanExceptionHandler.getException(e);
75: }
76: }
77:
78: public boolean isHandler(TKEvent evt) {
79: return evt.getName().equalsIgnoreCase("CO_PROPGROUP_DELETE");
80: }
81:
82: }
|