KickJava   Java API By Example, From Geeks To Geeks.

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


1 package de.webman.generator;
2
3 import com.teamkonzept.lib.*;
4 import com.teamkonzept.db.TKDBManager;
5 import com.teamkonzept.db.QueryConstants;
6
7 import java.util.*;
8 import java.sql.*;
9
10 /**
11     Verwaltet die Praesentations-Componenten eines Dokuments ueber die
12     Content in das Dokument integeriert werden soll
13  * @author $Author: alex $
14  * @version $Revision: 1.5 $
15 */

16 public class SiteContentIntegration
17 {
18     /**
19         Verweis zurück auf den aktuellen statischen Kontext des laufenden Threads
20     */

21     private GeneratorContext context;
22
23     /** Das Dokument, dem das Objekt zugeordnet ist */
24     private SiteDocument src;
25     
26     /** der Name der Component */
27     private String JavaDoc integrationShortName;
28     
29     /** die Integrationsart (Single oder Group) */
30     private int integrationType;
31     
32     /** Der Content-Tree-Knoten, ueber den die Inhalte geholt werden */
33     private SiteContentNode contentNode;
34     
35     /** Typ der Sub-Selection in einem Group-Node (Selektionsklasse) */
36     private String JavaDoc selectionType;
37     
38     /** Zusaetzliche Daten fuer Selektionsklasse */
39     private String JavaDoc selectionData;
40     
41     /** Eindeutiger Schluessel fuer selectionHash (s.u.) */
42     private String JavaDoc selectionKey;
43     
44     /**
45         Erzeugt ein Objekt aus der aktuellen ResultRow eines ResultSets der
46         Query DBGenSiteContNodes.
47         
48         Die eventuell notwendige Selection wird erst bei Aufruf von select()
49         durchgefuerhrt.
50      */

51     public SiteContentIntegration( GeneratorContext context, ResultSet rs, SiteDocument src )
52         throws SQLException
53     {
54
55         this.context = context != null ? context : GeneratorContext.setup ();
56         this.src = src;
57         
58         this.integrationShortName = rs.getString( "INTEGRATION_SHORTNAME" );
59         this.integrationType = rs.getInt( "INTEGRATION_TYPE" );
60         int nodeId = rs.getInt( "CONTENT_NODE_ID" );
61         this.contentNode = rs.wasNull() ? null : this.context.contentNodes.getContentNode( nodeId );
62         this.selectionType = rs.getString( "SELECTION_TYPE" );
63
64         // NOTE: as long as we do not use sybase's jdbc 2.0 driver we need to distinguish
65
// between oracle and sybase at this point
66
// because SELECTION_DATA is of type java.sql.Clob and ResultSet.getString()
67
// return null.
68
if( TKDBManager.getDBVendor() == QueryConstants.ORACLE)
69         {
70             Clob clob = rs.getClob("SELECTION_DATA");
71             if (clob != null)
72             {
73                 this.selectionData = clob.getSubString(1, (int) clob.length());
74             }
75         }
76         else
77         {
78             this.selectionData = rs.getString("SELECTION_DATA");
79         }
80         this.selectionKey = null;
81     }
82     
83     public String JavaDoc path()
84     {
85         return src.path()+"."+integrationShortName;
86     }
87     
88     public String JavaDoc toString()
89     {
90         String JavaDoc result =
91             "<content integration '"+path()+"'>"+
92             " integrationType = "+(integrationType==SiteReference.INTEGRATION_TYPE_GROUP?"GROUP":"SINGLE") +
93             " contentNode = "+(contentNode == null ? "primary Group content" : contentNode.getId() +"("+contentNode.getShortName()+")" );
94             
95         if( selectionType != null )
96             result +=
97             " selectionType = "+selectionType+
98             " selectionData = "+selectionData+
99             " ) ";
100         
101         if( contentNode != null ) {
102             result += " contents:";
103             Enumeration e = getContents().elements();
104             while( e.hasMoreElements() ) {
105                 result += " "+e.nextElement();
106             }
107         }
108         
109         return result+" </content integration '"+path()+"'> ";
110     }
111     
112     /**
113         Gewahrleistet, dass eine eventuelle Subselection im selectionHash
114         gespeichert ist und setzt dabei selectionKey auf den Zugriffskey.
115     */

116     public void select()
117     {
118         if( selectionType == null ) return;
119         if( selectionKey != null ) return;
120         
121         selectionKey = context.integrations.newSelection( selectionType, selectionData, contentNode.getId() );
122     }
123
124     /**
125         liefert die Inhalte (TKVector of SiteContent),
126         die der Component zugeordnet sind
127     */

128     public TKVector getContents()
129     {
130         if( contentNode == null ) return null;
131         if( selectionType == null ) return contentNode.getContents();
132         if (selectionKey == null)
133             select();
134         return (TKVector) context.integrations.getSelection( selectionKey );
135     }
136     
137     public String JavaDoc getShortName()
138     {
139         return integrationShortName;
140     }
141     
142     public int getIntegrationType()
143     {
144         return integrationType;
145     }
146     
147     public SiteContentNode getContentNode()
148     {
149         return contentNode;
150     }
151     
152     public SiteDocument getSourceDocument()
153     {
154         return src;
155     }
156 }
157
Popular Tags