1 5 package com.teamkonzept.webman; 6 7 import java.sql.*; 8 9 import com.teamkonzept.db.*; 10 import de.webman.generator.*; 11 import com.teamkonzept.webman.db.*; 12 import com.teamkonzept.webman.db.queries.*; 13 import com.teamkonzept.lib.*; 14 15 public class TKWMReferenceSelectorReg extends TKClassRegistry { 16 17 protected TKHashtable resultTypes = new TKHashtable(); 18 19 public void registerClass( String selectionType, String selectionClass, int resultType ) 20 { 21 super.registerClass( selectionType, selectionClass ); 22 resultTypes.put( selectionType, Integer.toString( resultType ) ); 23 } 24 25 public final TKWMReferenceSelector getSelector( String selectionType ) 26 { 27 try { 28 Object o = get(selectionType); 29 return (TKWMReferenceSelector) o; 31 } 32 catch( Throwable t ) { 33 throw new Error ( t.getMessage() ); 34 } 35 } 36 37 public boolean _check( String selectionType ) 38 { 39 return getSelector( selectionType ).checkSelection( ); 40 } 41 42 43 public String _getData( String selectionType, TKHashtable params ) 44 { 45 return getSelector( selectionType ).getSelectionData( params ); 46 } 47 48 public TKDBResult _getValues( String selectionType, String selectionData, int siteNodeId ) 49 { 50 TKDBResult v=null; 51 try { 52 v = getSelector( selectionType ).getSelectionValues( selectionData, siteNodeId ); 53 } catch (SQLException s) { 54 throw new Error ( s.getMessage() ); 55 } 56 return v; 57 } 58 59 public TKVector _getNodes( String selectionType, String selectionData, int siteNodeId ) 60 { 61 TKVector v=null; 62 try { 63 v = getSelector( selectionType ).getSelectionNodes( selectionData, siteNodeId ); 64 } catch (SQLException s) { 65 throw new Error ( s.getMessage() ); 66 } 67 return v; 68 } 69 70 public void _reduceReferences( 71 String selectionType, 72 String selectionData, 73 TKVector allRefUrls, 74 TKVector allRefDocs, 75 TKVector allRefNodes, 76 GenNode currAnchor 77 ) 78 { 79 getSelector( selectionType ).reduceReferences( 80 selectionData, allRefUrls, allRefDocs, allRefNodes, currAnchor 81 ); 82 } 83 84 protected static TKWMReferenceSelectorReg registry = null; 86 protected static boolean initialized = false; 87 88 public static final boolean check( String selectionType ) 89 { 90 if( !initialized ) initialize(); 91 return registry._check( selectionType ); 92 } 93 94 public static final String getData( String selectionType, TKHashtable params ) 95 { 96 if( !initialized ) initialize(); 97 return registry._getData( selectionType, params ); 98 } 99 100 public static final TKDBResult getValues( String selectionType, String selectionData, int siteNodeId ) 101 { 102 if( !initialized ) initialize(); 103 return registry._getValues( selectionType, selectionData, siteNodeId ); 104 } 105 106 public static final TKDBResult getValues( String selectionType, int siteNodeId ) 107 { 108 return getValues( selectionType, null, siteNodeId ); 109 } 110 111 public static final TKVector getNodes( String selectionType, String selectionData, int siteNodeId ) 112 { 113 if( !initialized ) initialize(); 114 return registry._getNodes( selectionType, selectionData, siteNodeId ); 115 } 116 117 public static final TKVector getNodes( String selectionType, int siteNodeId ) 118 { 119 return getNodes( selectionType, null, siteNodeId ); 120 } 121 122 public static final void reduceReferences( 123 String selectionType, 124 String selectionData, 125 TKVector allRefUrls, 126 TKVector allRefDocs, 127 TKVector allRefNodes, 128 GenNode currAnchor 129 ) 130 { 131 if( !initialized ) initialize(); 132 registry._reduceReferences( 133 selectionType, 134 selectionData, 135 allRefUrls, 136 allRefDocs, 137 allRefNodes, 138 currAnchor 139 ); 140 } 141 142 public static final synchronized void initialize() 143 { 144 if( initialized ) return; 145 146 initialized = true; 147 registry = new TKWMReferenceSelectorReg(); 148 149 try { 150 TKQuery q = TKWebmanDBManager.newQuery(TKDBRefSelClassGetAll.class); 151 q.execute(); 152 ResultSet rs = q.fetchResultSet(); 153 154 while( rs.next() ) { 155 registry.registerClass( 156 rs.getString("SELECTION_TYPE"), 157 rs.getString("SELECTION_CLASS"), 158 rs.getInt("RESULT_TYPE") 159 ); 160 } 161 } 162 catch( SQLException e ) { 163 throw new TKSQLError( e.getMessage(), e ); 164 } 165 } 166 } 167 168 | Popular Tags |