001: package de.webman.generator;
002:
003: import com.teamkonzept.lib.*;
004: import java.sql.*;
005: import de.webman.content.Content;
006: import de.webman.content.workflow.*;
007:
008: import org.apache.log4j.Category;
009:
010: /**
011: Verwaltet eine Knoten in der Content-Hierarchie.
012: Es gibt zwei Arten von Knoten: Single-Content und Group-Content-Knoten
013: Ein SingleContent-Knoten repräsentiert einen einzelne Content-Datensatz,
014: GroupContent-Knoten verwalten eine Liste von gleichartigen Content-Datensaetzen.
015: * @author $Author: alex $
016: * @version $Revision: 1.5 $
017: */
018: public class SiteContentNode {
019:
020: /** Logging Factory */
021: private static Category cat = Category
022: .getInstance(SiteContentNode.class);
023:
024: /**
025: Verweis zurück auf den aktuellen statischen Kontext des laufenden Threads
026: */
027: private GeneratorContext context;
028:
029: public final static int NODE_TYPE_GROUP = 2;
030: public final static int NODE_TYPE_SINGLE = 3;
031:
032: /** Id des Knotens */
033: private int id;
034:
035: /** Art des Knotens */
036: private int type;
037:
038: /** Kurzname */
039: private String shortName;
040:
041: /** Langer Name (für Sortierung notwendig) */
042: private String name;
043:
044: /** Content-Type, der den Contents des Knotens zu grunde liegt.*/
045: private int formId;
046:
047: /** Contents des Knotens:
048: Alle Eintraege sind Instanzen der Klasse SiteContent
049: */
050: private TKVector contents;
051:
052: /**
053: Initialisiert das Objekt mit den Daten aus der aktuellen ResultRow
054: des ersten ResultSets der Query-Klasse DBGenContNodeConts
055:
056: contents werden erst durch Aufrufe von addContents ermittelt
057: */
058: public SiteContentNode(GeneratorContext context, ResultSet rs)
059: throws SQLException {
060: this .context = context != null ? context : GeneratorContext
061: .setup();
062:
063: this .id = rs.getInt("CONTENT_NODE_ID");
064: this .type = rs.getInt("CONTENT_NODE_TYPE");
065: this .shortName = rs.getString("CONTENT_NODE_SHORTNAME");
066: this .name = rs.getString("CONTENT_NODE_NAME");
067: this .formId = rs.getInt("CONTENT_FORM");
068:
069: this .contents = new TKVector();
070: }
071:
072: public int getId() {
073: return id;
074: }
075:
076: public int getType() {
077: return type;
078: }
079:
080: public String getShortName() {
081: return shortName;
082: }
083:
084: public String getName() {
085: return name;
086: }
087:
088: public int getFormularId() {
089: return formId;
090: }
091:
092: public void addContent(SiteContent siteContent) {
093: contents.addElement(siteContent);
094: }
095:
096: public TKVector getContents() {
097: // im Preview Mode hier ein lazy lookup machen ! ist im Moment ausgeschaltet !
098: // vielleicht hier noch ein Merker, damit kein Performanzverlust bei leeren Content Gruppen
099: if (GeneratorContext.isPreviewMode() && contents.size() == 0) {
100: try {
101: TKVector conts = VersionCache.getVersionInfo(
102: new Integer(id), false);
103: for (int i = 0; i < conts.size(); i++) {
104: Content c = (Content) conts.elementAt(i);
105: contents.addElement(new SiteContent(context, c
106: .getFormularId().intValue(), c, false));
107: }
108: } catch (SQLException e) {
109: cat.error("Couldn't make dynamic content lookup ", e);
110: }
111: }
112: return contents;
113: }
114: }
|