KickJava   Java API By Example, From Geeks To Geeks.

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


1 package de.webman.generator;
2
3 import com.teamkonzept.db.*;
4 import com.teamkonzept.lib.*;
5 import de.webman.content.workflow.*;
6 import de.webman.content.Content;
7 import de.webman.generator.db.queries.*;
8
9 import java.util.Enumeration JavaDoc;
10 import java.sql.*;
11 import org.apache.log4j.Category;
12
13 /**
14  * Verwaltet die statischen Daten und Methoden von SiteContentNode
15  * liest alle referenzierten Contents ein und fuehrt den Workflow durch
16  * @author $Author: alex $
17  * @version $Revision: 1.8.6.1 $
18  */

19 public class SiteContentNodeStatics
20 {
21
22     /** Log4J Category */
23     private static Category cat = Category.getInstance(SiteContentNodeStatics.class.getName());
24     
25     /**
26         Verweis zurück auf den aktuellen statischen Kontext des laufenden Threads
27     */

28     GeneratorContext context;
29
30     /**
31         enhaelt alle referenzierten Content-Nodes der Site
32         Key := Integer( ContentNodeId )
33         Value = SiteContentNode
34     */

35     private TKHashtable contentNodeHash;
36     
37     public SiteContentNodeStatics (GeneratorContext context)
38     {
39         this.context = context != null ? context : GeneratorContext.setup ();
40         this.contentNodeHash = null;
41     }
42
43
44     /**
45      * Erzeugt einer Hashtable aller content nodes (SiteContentNode).
46      * Zu jedem group content node werden dann die zugehoerigen content Instanzen
47      * erzeugt und eingetragen, die einem Filterkriterium genügen.
48      * Bei den single content nodes wird der zugehoerige content auch im Falle
49      * des Fehlschlagens des Filterkriteriums erzeugt.
50      *
51      */

52     public void getFilteredInstances () throws Throwable JavaDoc
53     {
54         /* to avoid multipe resultsets, the original query is split in two parts */
55         cat.debug("Getting Query 1");
56         TKQuery q_1 = TKDBManager.newQuery(GenContNodeConts_Part_1.class);
57         TKQuery q_2 = TKDBManager.newQuery(GenContNodeConts_Part_2.class);
58         q_1.execute();
59         cat.debug("Query 1 finished");
60         ResultSet rs = q_1.fetchResultSet();
61         // Liste aller Contentnodes anlegen:
62
contentNodeHash = new TKHashtable();
63         while( rs.next() )
64         {
65             SiteContentNode node = new SiteContentNode( context, rs );
66             contentNodeHash.put( new Integer JavaDoc( node.getId() ), node );
67         }
68         q_1.close();
69         /*if (GeneratorContext.isPreviewMode()) aus Performanzgruenden bei der IndexgenerierungPreview raus
70             return;*/

71         TKVector allInstances = VersionCache.doReadInstances(q_2);
72         int instIndex = 0;
73          // Initialize workflow.
74
VersionStatics statics = VersionStatics.getStatics();
75         TKHashtable statusPool = VersionStatus.selectSingles(statics, false);
76         TKHashtable filter = VersionSelection.initContentFilter(statusPool);
77         while (instIndex < allInstances.size())
78         {
79             Content content = (Content) allInstances.elementAt(instIndex);
80             instIndex++;
81             // Alle Contents werden nochmal durch den Standardfilter gejagt, um auszuschließen,
82
// dass z.B. Contents mit Loeschvermerk beruecksichtigt werden
83
if (content.filterTransitions(filter, "SRC"))
84             {
85                 SiteContentNode node = ((SiteContentNode) contentNodeHash.get (content.getRefNodeId()));
86
87                 // Non-generatable group contents should not appear in the site tree.
88
// We only exclude group node contents here.
89
// Single node contents will remain in the site tree, this will
90
// result in empty pages... must be an error detected later!
91
// (Remark: Error detection is not done here, since we couldn't
92
// formulate a 'qualified' error message yet...)
93
if (node.getType() == SiteContentNode.NODE_TYPE_GROUP)
94                 {
95                     if (context.isWorkflowIgnored()== false && content.getGeneratableVersion() == null)
96                     continue;
97                 }
98                 node.addContent(
99                     new SiteContent(
100                         context, node.getFormularId(), content, false));
101             }
102         }
103     }
104
105     /**
106         holt alle referenzierten Content-Nodes der Site, sowie deren
107         Inhalte aus der DB und fuellt damit contentNodeHash.
108     */

109     public void getContents()
110     {
111         try {
112             getFilteredInstances();
113         }
114         catch (SQLException e)
115         {
116             cat.error("getContents failed", e);
117             e.printStackTrace(System.out);
118             throw new TKSQLError (e.getMessage(), e);
119         }
120         catch (Throwable JavaDoc t)
121         {
122             cat.error("getContents failed", t);
123             t.printStackTrace(System.out);
124             
125             throw new Error JavaDoc (t.getMessage());
126         }
127     }
128
129     /**
130         gibt den, zur uebergebenen Id gehoerenden SiteContentNode zurueck
131         Wenn es den Knoten nicht gibt, wird null zurueckgegeben.
132     */

133     public final SiteContentNode getContentNode( int nodeId )
134     {
135         if( contentNodeHash == null ) return null;
136         return (SiteContentNode) contentNodeHash.get( new Integer JavaDoc( nodeId ) );
137     }
138 }
139
140 /**
141  * haelt alle Infos zu einer Version
142  * @author $Author: alex $
143  * @version $Revision: 1.8.6.1 $
144 */

145 class VersionData
146 {
147     Integer JavaDoc statusID;
148     String JavaDoc author;
149     java.util.Date JavaDoc date;
150 }
Popular Tags