KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > generator > SiteContentNode


1 package de.webman.generator;
2
3 import com.teamkonzept.lib.*;
4 import java.sql.*;
5 import de.webman.content.Content;
6 import de.webman.content.workflow.*;
7
8 import org.apache.log4j.Category;
9 /**
10     Verwaltet eine Knoten in der Content-Hierarchie.
11     Es gibt zwei Arten von Knoten: Single-Content und Group-Content-Knoten
12     Ein SingleContent-Knoten repräsentiert einen einzelne Content-Datensatz,
13     GroupContent-Knoten verwalten eine Liste von gleichartigen Content-Datensaetzen.
14  * @author $Author: alex $
15  * @version $Revision: 1.5 $
16  */

17 public class SiteContentNode
18 {
19
20     /** Logging Factory */
21     private static Category cat = Category.getInstance(SiteContentNode.class);
22     
23     /**
24         Verweis zurück auf den aktuellen statischen Kontext des laufenden Threads
25     */

26     private GeneratorContext context;
27
28     public final static int NODE_TYPE_GROUP = 2;
29     public final static int NODE_TYPE_SINGLE = 3;
30     
31     /** Id des Knotens */
32     private int id;
33     
34     /** Art des Knotens */
35     private int type;
36     
37     /** Kurzname */
38     private String JavaDoc shortName;
39     
40     /** Langer Name (für Sortierung notwendig) */
41     private String JavaDoc name;
42     
43     /** Content-Type, der den Contents des Knotens zu grunde liegt.*/
44     private int formId;
45     
46     /** Contents des Knotens:
47         Alle Eintraege sind Instanzen der Klasse SiteContent
48     */

49     private TKVector contents;
50     
51     /**
52         Initialisiert das Objekt mit den Daten aus der aktuellen ResultRow
53         des ersten ResultSets der Query-Klasse DBGenContNodeConts
54         
55         contents werden erst durch Aufrufe von addContents ermittelt
56     */

57     public SiteContentNode( GeneratorContext context, ResultSet rs )
58         throws SQLException
59     {
60         this.context = context != null ? context : GeneratorContext.setup ();
61
62         this.id = rs.getInt( "CONTENT_NODE_ID" );
63         this.type = rs.getInt( "CONTENT_NODE_TYPE" );
64         this.shortName = rs.getString( "CONTENT_NODE_SHORTNAME" );
65         this.name = rs.getString( "CONTENT_NODE_NAME" );
66         this.formId = rs.getInt( "CONTENT_FORM" );
67         
68         this.contents = new TKVector();
69     }
70     
71     public int getId()
72     {
73         return id;
74     }
75     
76     public int getType()
77     {
78         return type;
79     }
80     
81     public String JavaDoc getShortName()
82     {
83         return shortName;
84     }
85     
86     public String JavaDoc getName()
87     {
88         return name;
89     }
90     
91     public int getFormularId()
92     {
93         return formId;
94     }
95     
96     public void addContent(SiteContent siteContent)
97     {
98         contents.addElement(siteContent);
99     }
100     
101     public TKVector getContents()
102     {
103         // im Preview Mode hier ein lazy lookup machen ! ist im Moment ausgeschaltet !
104
// vielleicht hier noch ein Merker, damit kein Performanzverlust bei leeren Content Gruppen
105
if (GeneratorContext.isPreviewMode() && contents.size() == 0)
106         {
107             try
108             {
109                 TKVector conts = VersionCache.getVersionInfo(new Integer JavaDoc(id), false);
110                 for (int i = 0; i < conts.size(); i++)
111                 {
112                     Content c = (Content)conts.elementAt(i);
113                     contents.addElement(new SiteContent(context, c.getFormularId().intValue(), c, false));
114                 }
115             }
116             catch (SQLException e)
117             {
118                 cat.error("Couldn't make dynamic content lookup " , e);
119             }
120         }
121         return contents;
122     }
123 }
124
Popular Tags