com.ptc.windchill.upgrade.util
Class PagedTableObjectIterator

java.lang.Object
  extended bycom.ptc.windchill.upgrade.util.PagedTableObjectIterator
All Implemented Interfaces:
Iterator

public class PagedTableObjectIterator
extends Object
implements Iterator

PagedTableObjectIterator 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, PagedTableObjectIterator 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
private  StandardACProcessor acp_
           
(package private)  Connection conn
           
private static boolean DEVELOPER_MODE
           
(package private)  int offset
           
(package private)  int pageSize
           
private  PersistentObjectManager pom_
           
(package private)  QuerySpec querySpec
           
private  boolean RELEASE_5
           
(package private)  QueryResult result
           
(package private)  Exception savedException
           
(package private)  long sessionId
           
private static String TEMP_TABLE__CLASS_NAME
           
private static String TEMP_TABLE_NAME
           
private static String TEMP_TABLE_OID
           
private static String TEMP_TABLE_ROW_ORDER
           
private static String TEMP_TABLE_SESSION_ID
           
(package private)  int totalSize
           
 
Constructor Summary
private PagedTableObjectIterator(PersistentObjectManager pom)
           
 
Method Summary
 void cleanup()
           
private  void closePagingSession()
           
private  void createTempTable()
           
private  void dropTempTable()
           
private  int executeStatement(String statement)
           
private  QueryResult fetchPagingSession(int offset, int page_size, long session_id)
          Returns the next object in the ResultSet.
private  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.
private  void init(int page_size)
           
private  void init(long session_id, int page_size, String class_name)
           
private  void init(long session_id, String class_name)
           
private  QuerySpec initPageQuerySpec(String class_name)
           
private  int initTempTable(long session_id, String id_col, String class_name)
           
private  boolean isRelease5()
           
static PagedTableObjectIterator newPagingIterator(int page_size, PersistentObjectManager pom)
          Instantiates and initializes a PagedTableObjectIterator.
static PagedTableObjectIterator newPagingIterator(long session_id, int page_size, String class_name, PersistentObjectManager pom)
          Instantiates and initializes a PagedTableObjectIterator.
 Object next()
          Returns the next element in the iteration.
private  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).
private  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.
private  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

private static String TEMP_TABLE_NAME

TEMP_TABLE_OID

private static String TEMP_TABLE_OID

TEMP_TABLE_ROW_ORDER

private static String TEMP_TABLE_ROW_ORDER

TEMP_TABLE_SESSION_ID

private static String TEMP_TABLE_SESSION_ID

TEMP_TABLE__CLASS_NAME

private 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

pom_

private PersistentObjectManager pom_

acp_

private StandardACProcessor acp_
Constructor Detail

PagedTableObjectIterator

private PagedTableObjectIterator(PersistentObjectManager pom)
Method Detail

newPagingIterator

public static PagedTableObjectIterator newPagingIterator(int page_size,
                                                         PersistentObjectManager pom)
                                                  throws WTException
Instantiates and initializes a PagedTableObjectIterator.

Throws:
WTException

newPagingIterator

public static PagedTableObjectIterator newPagingIterator(long session_id,
                                                         int page_size,
                                                         String class_name,
                                                         PersistentObjectManager pom)
                                                  throws WTException
Instantiates and initializes a PagedTableObjectIterator.

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.


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.


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.

Throws:
WTException

init

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

init

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

init

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

cleanup

public void cleanup()
             throws WTException
Throws:
WTException

createTempTable

private void createTempTable()
                      throws WTException
Throws:
WTException

dropTempTable

private void dropTempTable()
                    throws WTException
Throws:
WTException

initTempTable

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

getPrimaryTableName

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

initPageQuerySpec

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

openPagingSession

private 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

private 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

private void closePagingSession()
                         throws WTException
Throws:
WTException

reportException

private void reportException(Exception e)

executeStatement

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

isRelease5

private boolean isRelease5()

setRelease5

private void setRelease5(String release_level)