com.ptc.windchill.upgrade.dust
Class PagingIteratorImpl

java.lang.Object
  extended bycom.ptc.windchill.upgrade.dust.PagingIteratorImpl
All Implemented Interfaces:
Iterator, PagingIteratorIfc
Direct Known Subclasses:
SparsePagingIteratorImpl

public class PagingIteratorImpl
extends Object
implements PagingIteratorIfc

PagingIteratorImpl determines which Paging mechanism to use depending upon what is available. The PDS paging API is available to release 6.0 and later versions of Windchill. For earlier release, use a simplied version of paging provided by this tool. In addition to this, PagingIteratorImpl also hides the fact that paging is occuring, i.e. the program using this class acts as though it is iterating through a simple ResultSet without bothering with the details of paging.


Field Summary
(package private)  Connection conn
           
private static boolean DEVELOPER_MODE
           
(package private)  int offset
           
(package private)  int pageSize
           
(package private)  QuerySpec querySpec
           
private  boolean RELEASE_5
           
(package private)  QueryResult result
           
(package private)  Exception savedException
           
(package private)  long sessionId
           
protected static String TEMP_TABLE__CLASS_NAME
           
protected static String TEMP_TABLE_NAME
           
protected static String TEMP_TABLE_OID
           
protected static String TEMP_TABLE_ROW_ORDER
           
protected static String TEMP_TABLE_SESSION_ID
           
(package private)  int totalSize
           
 
Constructor Summary
protected PagingIteratorImpl()
           
 
Method Summary
 void cleanup()
          Clears out the previous query without starting a new one.
protected  void closePagingSession()
           
protected  void createTempTable()
           
protected  void dropTempTable()
           
protected  int executeStatement(String statement)
           
protected  QueryResult fetchPagingSession(int offset, int page_size, long session_id)
          Returns the next object in the ResultSet.
protected  String getPrimaryTableName(String class_name)
           
 long getSessionId()
          The initial query stores OIDs in a temp table.
 int getTotalSize()
          Returns the number of rows in the temp table for this session id.
 boolean hasNext()
          Returns true if the iteration has more elements.
protected  void init(int page_size)
           
protected  void init(long session_id, int page_size, String class_name)
           
protected  void init(long session_id, String class_name)
           
protected  QuerySpec initPageQuerySpec(String class_name)
           
protected  int initTempTable(long session_id, String id_col, String class_name)
           
protected  boolean isRelease5()
           
static PagingIteratorIfc newPagingIterator(int page_size)
          Instantiates and initializes a PagingIteratorImpl.
static PagingIteratorIfc newPagingIterator(int page_size, String release_level)
          Instantiates and initializes a PagingIteratorImpl.
static PagingIteratorIfc newPagingIterator(int page_size, String release_level, int max_objects)
          Instantiates and initializes a SparsePagingIteratorImpl.
static PagingIteratorIfc newPagingIterator(long session_id, int page_size, String class_name)
          Instantiates and initializes a PagingIteratorImpl.
 Object next()
          Returns the next element in the iteration.
protected  void openPagingSession(String class_name)
          Returns the next object in the ResultSet.
 void remove()
          Removes from the underlying collection the last element returned by the iterator (optional operation).
protected  void reportException(Exception e)
           
 void resetQuery(long session_id, String class_name)
          Clears out the previous query and starts a new paging query with the given QuerySpec.
protected  void setRelease5(String release_level)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEVELOPER_MODE

private static final boolean DEVELOPER_MODE
See Also:
Constant Field Values

TEMP_TABLE_NAME

protected static String TEMP_TABLE_NAME

TEMP_TABLE_OID

protected static String TEMP_TABLE_OID

TEMP_TABLE_ROW_ORDER

protected static String TEMP_TABLE_ROW_ORDER

TEMP_TABLE_SESSION_ID

protected static String TEMP_TABLE_SESSION_ID

TEMP_TABLE__CLASS_NAME

protected static String TEMP_TABLE__CLASS_NAME

sessionId

long sessionId

totalSize

int totalSize

result

QueryResult result

pageSize

int pageSize

offset

int offset

querySpec

QuerySpec querySpec

savedException

Exception savedException

conn

Connection conn

RELEASE_5

private boolean RELEASE_5
Constructor Detail

PagingIteratorImpl

protected PagingIteratorImpl()
Method Detail

newPagingIterator

public static PagingIteratorIfc newPagingIterator(int page_size)
                                           throws WTException
Instantiates and initializes a PagingIteratorImpl.

Throws:
WTException

newPagingIterator

public static PagingIteratorIfc newPagingIterator(int page_size,
                                                  String release_level)
                                           throws WTException
Instantiates and initializes a PagingIteratorImpl.

Throws:
WTException

newPagingIterator

public static PagingIteratorIfc newPagingIterator(int page_size,
                                                  String release_level,
                                                  int max_objects)
                                           throws WTException
Instantiates and initializes a SparsePagingIteratorImpl.

Throws:
WTException

newPagingIterator

public static PagingIteratorIfc newPagingIterator(long session_id,
                                                  int page_size,
                                                  String class_name)
                                           throws WTException
Instantiates and initializes a PagingIteratorImpl.

Throws:
WTException

hasNext

public boolean hasNext()
Returns true if the iteration has more elements.

Specified by:
hasNext in interface Iterator

next

public Object next()
Returns the next element in the iteration.

Specified by:
next in interface Iterator

remove

public void remove()
Removes from the underlying collection the last element returned by the iterator (optional operation). Not implemented yet

Specified by:
remove in interface Iterator

getTotalSize

public int getTotalSize()
Returns the number of rows in the temp table for this session id.

Specified by:
getTotalSize in interface PagingIteratorIfc

getSessionId

public long getSessionId()
The initial query stores OIDs in a temp table. The session id distinguishes this query's data from another session's.

Specified by:
getSessionId in interface PagingIteratorIfc

resetQuery

public void resetQuery(long session_id,
                       String class_name)
                throws WTException
Clears out the previous query and starts a new paging query with the given QuerySpec.

Specified by:
resetQuery in interface PagingIteratorIfc
Throws:
WTException

init

protected void init(int page_size)
             throws WTException
Throws:
WTException

init

protected void init(long session_id,
                    int page_size,
                    String class_name)
             throws WTException
Throws:
WTException

init

protected void init(long session_id,
                    String class_name)
             throws WTException
Throws:
WTException

cleanup

public void cleanup()
             throws WTException
Description copied from interface: PagingIteratorIfc
Clears out the previous query without starting a new one.

Specified by:
cleanup in interface PagingIteratorIfc
Throws:
WTException

createTempTable

protected void createTempTable()
                        throws WTException
Throws:
WTException

dropTempTable

protected void dropTempTable()
                      throws WTException
Throws:
WTException

initTempTable

protected int initTempTable(long session_id,
                            String id_col,
                            String class_name)
                     throws WTException
Throws:
WTException

getPrimaryTableName

protected String getPrimaryTableName(String class_name)
                              throws WTException
Throws:
WTException

initPageQuerySpec

protected QuerySpec initPageQuerySpec(String class_name)
                               throws QueryException,
                                      WTException
Throws:
QueryException
WTException

openPagingSession

protected void openPagingSession(String class_name)
                          throws WTException
Returns the next object in the ResultSet. Takes care of any paging that may be necessary.

Throws:
WTException

fetchPagingSession

protected QueryResult fetchPagingSession(int offset,
                                         int page_size,
                                         long session_id)
                                  throws WTException
Returns the next object in the ResultSet. Takes care of any paging that may be necessary.

Throws:
WTException

closePagingSession

protected void closePagingSession()
                           throws WTException
Throws:
WTException

reportException

protected void reportException(Exception e)

executeStatement

protected int executeStatement(String statement)
                        throws Exception
Throws:
Exception

isRelease5

protected boolean isRelease5()

setRelease5

protected void setRelease5(String release_level)