001: package de.webman.content.eventhandler;
002:
003: import com.teamkonzept.web.*;
004: import com.teamkonzept.webman.*;
005: import com.teamkonzept.webman.mainint.*;
006: import com.teamkonzept.webman.mainint.db.queries.*;
007: import com.teamkonzept.webman.mainint.events.*;
008: import com.teamkonzept.lib.*;
009: import com.teamkonzept.field.*;
010: import com.teamkonzept.field.db.*;
011: import com.teamkonzept.db.*;
012:
013: import de.webman.content.workflow.*;
014: import java.sql.*;
015:
016: /**
017: * Auflisten aller Versionen eines Contents:
018: *
019: *
020: * @param String event
021: * @author $Author: sebastian $
022: * @version $Revision: 1.10 $
023: */
024: public class CEContentVersionsHandler extends DefaultEventHandler
025: implements ParameterTypes, FrameConstants {
026: private CEContentVersionsHandler() {
027: }
028:
029: private static CEContentVersionsHandler instance = new CEContentVersionsHandler();
030:
031: public static CEContentVersionsHandler getInstance() {
032: return instance;
033: }
034:
035: /**
036: Dieser Handler braucht deutlich weniger Infos als die anderen Handler, die sich
037: mit Versionen befassen, trotzdem in den Cache ???
038: -> Ist andere Datenbankabfrage !!!
039: */
040: public void handleEvent(TKEvent evt) throws TKException {
041: try {
042: CEUtils.checkEvent(evt);
043:
044: TKHTMLTemplate t = evt
045: .getPrepHTMLTemplate("ce_conVersList.tmpl");
046:
047: ContentContext ceContext = CEUtils.keepCEContext(evt, t);
048:
049: // statische Daten der Versionsverwaltung abrufen
050: VersionStatics statics = VersionStatics.setup();
051:
052: String action = evt.getParameter(ACTION, evt.getName());
053:
054: if (action == null || action.length() == 0
055: || action.equalsIgnoreCase("GET")) {
056: if (ceContext.instanceId.intValue() != -1) {
057: TKQuery q = TKDBManager
058: .newQuery(TKDBListContentVersions.class);
059: q.setQueryParams("INSTANCE_ID",
060: ceContext.instanceId);
061: q.execute();
062: ResultSet rs = q.fetchResultSet();
063: TKVector vec = new TKVector();
064: int currentContentId = -1;
065:
066: while (rs.next()) {
067: TKHashtable tb = new TKHashtable();
068: vec.addElement(tb);
069:
070: int statusId = rs.getInt("STATUS_ID");
071:
072: String version = rs.getString("VERSION_ID");
073: String status = rs.getString("STATUS");
074: String info = rs.getString("INFO");
075: String author = rs.getString("AUTHOR");
076: String date = TKContentAttributeTableData.dateFormat
077: .format(rs.getTimestamp("VERSION_DATE"));
078:
079: // hier kann NULL kommen - > Ergebnis ist 0 (kompaktiert)
080: int contentId = rs.getInt("CONTENT_ID");
081:
082: VersionStatus desc = (VersionStatus) statics
083: .getStatusPool().get(
084: new Integer(statusId));
085: if (desc.comment)
086: tb.put("IS_COMMENT", Boolean.TRUE);
087:
088: tb.put("VERSION_ID", version);
089: tb.put("STATUS", status);
090: tb.put("INFO", info);
091: if (author != null)
092: tb.put("AUTHOR", author);
093: tb.put("DATE", date);
094:
095: tb.put("CURR_CONTENT_ID", new Integer(
096: currentContentId));
097: tb.put("CONTENT_ID", new Integer(contentId));
098:
099: if (currentContentId != -1
100: && currentContentId != contentId)
101: tb.put("NEW_CONTENT", Boolean.TRUE);
102:
103: currentContentId = contentId;
104: }
105:
106: t.setListIterator(new TKStandardPluginIterator(
107: "CONTENT_VERSIONS", "VERSION", vec, false,
108: t.getListIterator()));
109: }
110: WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(),
111: t, ContextConstants.CONTENT_EDIT);
112: evt.finishTemplate(t);
113: return;
114: }
115: } catch (Throwable e) {
116: // TO DO : Analyze Exception !
117: throw WebmanExceptionHandler.getException(e);
118: }
119: }
120:
121: public boolean isHandler(TKEvent evt) {
122: return evt.getName().equalsIgnoreCase("CE_CONTENT_VERSIONS");
123: }
124: }
|