1 22 23 28 29 package org.xquark.mapper.storage; 30 31 import java.sql.SQLException ; 32 import java.util.Iterator ; 33 import java.util.List ; 34 import java.util.Map ; 35 36 import org.apache.commons.logging.Log; 37 import org.apache.commons.logging.LogFactory; 38 import org.xquark.mapper.RepositoryException; 39 import org.xquark.mapper.dbms.AbstractConnection; 40 import org.xquark.mapper.dbms.TableSpec; 41 import org.xquark.mapper.mapping.TableMapping; 42 import org.xquark.mapper.metadata.CollectionMappingInfo; 43 import org.xquark.mapper.metadata.CollectionMetadata; 44 import org.xquark.xml.xdbc.XMLDBCException; 45 46 49 class InteractiveQueryExplorer extends QueryExplorer 50 { 51 private static final String RCSRevision = "$Revision: 1.2 $"; 52 private static final String RCSName = "$Name: $"; 53 54 private static Log log = LogFactory.getLog(InteractiveQueryExplorer.class); 55 56 57 InteractiveQueryExplorer(_RepositoryCollection collection) throws SQLException , XMLDBCException 58 { 59 super(collection); 60 AbstractConnection connection = collection.getRepositoryConnection().getConnection(); 61 CollectionMetadata meta = collection.getMetadata(); 62 wNode = qNode = new InteractiveQueryStructExplorer(meta.getTableInfo(TableSpec.TYPE_STRUCT), meta.getUOIDManager()); 63 extraNode = qExtraNode = new InteractiveQueryExtraDataExplorer(meta.getTableInfo(TableSpec.TYPE_EXTRA)); 64 } 65 66 72 void initExploration(VarInfoSet varInfoSet, AbstractConnection connection) 73 throws SQLException , XMLDBCException 74 { 75 if (log.isDebugEnabled()) 76 log.debug("QueryExplorer::initExploration [varInfoSet]=" + varInfoSet); 77 78 Object [] ret = dispatchSubPaths(varInfoSet); 80 Map tableMappingSubset = (Map )ret[0]; 81 List subPathNodes = (List )ret[1]; 82 83 Iterator it = tableMappingSubset.entrySet().iterator(); 85 Map.Entry entry; 86 CollectionMappingInfo tableStmts; 87 int tableIndex; 88 89 CollectionMetadata meta = collection.getMetadata(); 90 while (it.hasNext()) 91 { 92 entry = (Map.Entry )it.next(); 93 tableIndex = ((TableMapping)entry.getKey()).getTableIndex(); 94 tableStmts = (CollectionMappingInfo)meta.getMappingStatements(tableIndex); 95 if (queryTuples[tableIndex] == null) 96 queryTuples[tableIndex] = new InteractiveQueryTuple(tableStmts, meta.getMappingPID(tableIndex)); 97 ((InteractiveQueryTuple)queryTuples[tableIndex]).prepareStatement((List )entry.getValue(), 98 meta, connection); 99 } 100 101 ((InteractiveQueryStructExplorer)qNode).prepareStatement(subPathNodes, connection); 103 ((InteractiveQueryExtraDataExplorer)qExtraNode).prepareStatement(subPathNodes, connection); 104 } 105 106 void execQuery(long first, long last, short path) throws SQLException , RepositoryException 107 { 108 for (int i=0; i < queryTuples.length; i++) 109 { 110 if (queryTuples[i] != null) 111 ((InteractiveQueryTuple)queryTuples[i]).execQuery(first, last, path); 112 } 113 ((InteractiveQueryStructExplorer)qNode).execQuery(first, last, path); 114 ((InteractiveQueryExtraDataExplorer)qExtraNode).execQuery(first, last, path); 115 } 116 } 117 | Popular Tags |