org.gusdb.wdk.model
Class Answer

java.lang.Object
  extended by org.gusdb.wdk.model.Answer

public class Answer
extends java.lang.Object

A list of RecordInstances representing one page of the answer to a Question. The constructor of the Answer provides a handle (QueryInstance) on the ResultList that is the list of primary keys for the all the records (not * just one page) that are the answer to the Question. The ResultList also has a column that contains the row number (RESULT_TABLE_I) so that a list of primary keys for a single page can be efficiently accessed. The Answer is lazy in that it only constructs the set of RecordInstances for the page when the first RecordInstance is requested. The initial request triggers the creation of skeletal RecordInstances for the page. They contain only primary keys (these being acquired from the ResultList). These skeletal RecordInstances are also lazy in that they only run an attributes query when an attribute provided by that query is requested. When they do run an attribute query, its QueryInstance is put into joinMode. This means that the attribute query joins with the table containing the primary keys, and, in one database query, generates rows containing the attribute values for all the RecordInstances in the page. The method integrateAttributesQueryResult is invoked by the first RecordInstance in the page upon the first request for an attribute provided by an attributes query. The query is a join with the list of primary keys, and so has a row for each RecordInstance in the page, and columns that provide the attribute values (plus RESULT_TABLE_I). The values in the rows are integrated into the corresponding RecordInstance (now no longer skeletal). integrateAttributesQueryResult may be called a number of times, depending upon how many attribute queries the record class contains. Attribute queries are guaranteed to provide one row for each RecordInstance in the page. An exception is thrown otherwise.


Method Summary
 QueryInstance getAttributesQueryInstance()
           
 java.util.Map getDisplayParams()
           
 QueryInstance getIdsQueryInstance()
           
 boolean getIsBoolean()
           
 RecordInstance getNextRecordInstance()
           
 int getPageSize()
           
 java.util.Map getParams()
           
 Question getQuestion()
          provide property that user's term for question
 int getResultSize()
           
 boolean hasMoreRecordInstances()
           
 boolean isSummaryAttribute(java.lang.String attName)
           
 java.lang.String printAsRecords()
           
 java.lang.String printAsSummary()
          print summary attributes, one per line Note: not sure why this is needed
 java.lang.String printAsTable()
          print summary attributes in tab delimited table with header of attr.
 void resetRecordInstanceCounter()
           
 void resetRecordInstanceCurser()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getQuestion

public Question getQuestion()
provide property that user's term for question


getPageSize

public int getPageSize()

getResultSize

public int getResultSize()
                  throws WdkModelException
Throws:
WdkModelException

getParams

public java.util.Map getParams()
Returns:
Map where key is param name and value is param value

getDisplayParams

public java.util.Map getDisplayParams()
Returns:
Map where key is param display name and value is param value

getIsBoolean

public boolean getIsBoolean()

getAttributesQueryInstance

public QueryInstance getAttributesQueryInstance()

getIdsQueryInstance

public QueryInstance getIdsQueryInstance()

isSummaryAttribute

public boolean isSummaryAttribute(java.lang.String attName)

getNextRecordInstance

public RecordInstance getNextRecordInstance()
                                     throws WdkModelException
Throws:
WdkModelException

hasMoreRecordInstances

public boolean hasMoreRecordInstances()
                               throws WdkModelException
Throws:
WdkModelException

resetRecordInstanceCurser

public void resetRecordInstanceCurser()

printAsRecords

public java.lang.String printAsRecords()
                                throws WdkModelException,
                                       WdkUserException
Throws:
WdkModelException
WdkUserException

printAsSummary

public java.lang.String printAsSummary()
                                throws WdkModelException,
                                       WdkUserException
print summary attributes, one per line Note: not sure why this is needed

Throws:
WdkModelException
WdkUserException

printAsTable

public java.lang.String printAsTable()
                              throws WdkModelException,
                                     WdkUserException
print summary attributes in tab delimited table with header of attr. names

Throws:
WdkModelException
WdkUserException

resetRecordInstanceCounter

public void resetRecordInstanceCounter()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object