1 22 23 package org.xquark.extractor.oracle; 24 25 import java.sql.SQLException ; 26 import java.sql.Statement ; 27 import java.util.ArrayList ; 28 import java.util.List ; 29 30 import org.xquark.extractor.algebra.*; 31 import org.xquark.extractor.sql.SqlExpression; 32 import org.xquark.extractor.metadata.MetaDataManager; 33 import org.xquark.extractor.runtime.Query; 34 import org.xquark.extractor.runtime.SynchronizedResultSet; 35 import org.xquark.xml.xdbc.XMLDBCException; 36 import org.xquark.xquery.metadata.resolver.MetadataAccess; 37 import org.xquark.xquery.parser.XQueryException; 38 import org.xquark.xquery.parser.XQueryExpression; 39 40 public class Oracle7QueryFactory extends OracleQueryFactory { 41 private static final String RCSRevision = "$Revision: 1.5 $"; 42 private static final String RCSName = "$Name: $"; 43 44 private PreEvaluationVisitor _pev; 45 46 public Oracle7QueryFactory(MetaDataManager metadataManager, MetadataAccess metadata) throws XMLDBCException { 47 super(metadataManager, metadata); 48 } 49 50 protected void createVisitors() { 51 TypeInterpreter ti = new TypeInterpreter(); 52 _genAlgebraVisitor = new GenAlgebraVisitor(ti, _metadataManager, _attIDProvider, _relIDProvider); 53 54 _algebraTypeVisitor = new AlgebraTypeVisitor(); 55 _removeProjectVisitor = new RemoveIntermediateProjectVisitor(); 56 _brav = new BuildReferredAttributes(); 57 _apv = new AnalyzePredicateVisitor(); 58 59 _genSqlVisitor = new org.xquark.extractor.oracle.OracleGenSqlVisitor(_relIDProvider); 60 _genSqlVisitor.setMetadataManager(_metadataManager); 61 62 _pev = new PreEvaluationVisitor(); 63 } 64 65 protected Query.SQLExecutionInfo compileSingleQDB(XQueryExpression xQuery, boolean keyNeeded) 66 throws XQueryException, XMLDBCException { 67 69 SynchronizedResultSet retVal = null; 70 Expression algebraTree = null; 71 Mapper mapper = null; 72 73 74 _genAlgebraVisitor.reinit(); 75 76 if (keyNeeded) { List souArgList = new ArrayList (); 78 souArgList.add(xQuery); 79 _genAlgebraVisitor.noticSortedOuterUnion(souArgList); 80 } 81 xQuery.accept(_genAlgebraVisitor); 82 algebraTree = _genAlgebraVisitor.getAlgebraTree(); 83 84 _removeProjectVisitor.reinit(); 87 algebraTree.accept(_removeProjectVisitor); 88 89 algebraTree.accept(_brav); 90 91 92 _apv.reinit(); 93 algebraTree.accept(_apv); 94 95 algebraTree.accept(new RemoveNestedAggregation(_attIDProvider, _relIDProvider)); 96 97 _algebraTypeVisitor.reinit(); 98 algebraTree.accept(_algebraTypeVisitor); 99 100 _pev.setGenSqlVisitor(_genSqlVisitor); 101 try { Statement jdbcStatement = _stmt.createJdbcStatement(); 103 _pev.setJdbcStatement(jdbcStatement); 104 jdbcStatement.close(); 105 } 106 catch (SQLException ex) { 107 throw new XMLDBCException(ex.getMessage(), ex); 108 } 109 algebraTree.accept(_pev); 110 111 mapper = algebraTree.getMapper(); 112 113 _genSqlVisitor.reinit(); 114 SqlExpression sql = algebraTree.accept(_genSqlVisitor); 115 116 117 sql.generateRequestList(); 118 return new Query.SQLExecutionInfo(sql, algebraTree.getMapper()); 119 } 120 } 121 | Popular Tags |