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 16 public class SiteContentIntegration 17 { 18 21 private GeneratorContext context; 22 23 24 private SiteDocument src; 25 26 27 private String integrationShortName; 28 29 30 private int integrationType; 31 32 33 private SiteContentNode contentNode; 34 35 36 private String selectionType; 37 38 39 private String selectionData; 40 41 42 private String selectionKey; 43 44 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 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 path() 84 { 85 return src.path()+"."+integrationShortName; 86 } 87 88 public String toString() 89 { 90 String 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 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 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 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 |