kom.gateway
Class Build.KOMquery

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--kom.gateway.KomData
                    |
                    +--kom.gateway.Build.KOMquery
Enclosing class:
Build

public class Build.KOMquery
extends KomData

KOMquery allows the users of KOM2000 to specify an evaluation type query without having to specify the raw HTML text. This class has two basic modes--as a real querywizard-type mode and a simpler mode. Real query-wizard mode allows the user to post messages in multiple forums, creating new forums with specified members and to set different types of accessiblity to the query (see the query specification for more information. The simpler mode does not allow the user to specifify a forum explicitly; this must be specified by the programmer by setLocations or an equivalent method. If Pid is not set, the user is only allowed to log in. When Pid is set the user cannot go back to the login screen in the query. See below for different cases.

 KOMquery in query-wizard mode

 user not logged in --> query-wizard step 1 --> query-wizard step 2
                          (login screen)

 user logged in --> query-wizard step 2

 

To generate an HTML representation of this class, certain forms must be present in the KOM database.

Lifecycle of KOMquery:

  1. instantiate
  2. store in user's home directory
  3. form fill-in by user
  4. preview of query
  5. publish
  6. removal from user's home directory
Fields used:
 Pid                  Author reference
 Ploc                 Key for identification
 Cname                Subject of query
 Pdate                Last change date
 Bintro               Query introductory text
 Psecret              CHECKED for a closed query. Not defined for an open query
 Pstep                Current step in wizard
 Paltmax              Maximum number of alternatives (5 is default)
 Balt*:               Query alternatives, containing
   Balttext,          Query in plaintext
 Pscalemax            Maximum number of value alternatives (5 is default)
 Bscale*:             Query scale, containing
   Bscaletext,        Name of the alternative
 Plogin               User login name
 Ploginpw             User password
 Popenness            Who are allowed to answer (anyone, specified, password)
 Brespondents*:       Contains who are allowed to reply if specified or password.
   Prespemail,        Email address, "" means anyone
   Ppw,	          Query password for respondent
 Ploc*:               Contains forums where the query will be posted,
 Pnewloccat           Category reference
 Cnewlocname          Name of new group
 Pnewlocshort         Short name of the group
 Cnewmembermail*      Members in the new group
 

See Also:
Serialized Form

Field Summary
private  int MAXSTEP
          Number of steps in query-guide
 
Fields inherited from class kom.gateway.KomData
ADDKEYANY, ADDKEYFIRST, ADDKEYLAST
 
Fields inherited from class java.util.Hashtable
count, ENTRIES, entrySet, KEYS, keySet, loadFactor, modCount, serialVersionUID, table, threshold, values, VALUES
 
Constructor Summary
(package private) Build.KOMquery()
          Constructs a KOMquery with Paltmax and Pscalemax set to five.
(package private) Build.KOMquery(boolean wizardMode)
          Constructs a KOMquery with the mode specified.
(package private) Build.KOMquery(Build.KOMquery query)
          Clones a KOMquery.
(package private) Build.KOMquery(java.lang.String userRef, java.lang.String queryRef)
          Constructs a KOMquery by fetching it from the query database.
 
Method Summary
(package private)  int addAlternatives(int n)
          Adds empty alternatives to this query.
(package private)  int addScaleValues(int n)
          Adds empty scale values to this query.
private  void dispCategories(java.lang.String frm, boolean open)
          Outputs a SELECT form for choosing category
private  void dispForm()
          Outputs an HTML version of the resulting query form.
private  void dispFormContent()
          Outputs an HTML version of the contents of the resulting queryform (this is not really an HTML form).
 void dispnormal()
          Outputs an HTML version of the query to the output buffer defined in classes above.
 void dispPreview()
          Shows a preview of the query form
(package private)  java.lang.String[] getLocations()
          Gets references to forums where the query will be posted.
(package private)  int getStep()
          Gets the current step in the Query-guide.
(package private)  boolean isLocation(java.lang.String locationRef)
          Tests if a forum is already in list of publishing forums for this query.
(package private)  int nextStep()
          Advances to the next step in the Query-guide.
 void normal()
          Outputs an HTML version of the query to the output buffer defined in classes above.
(package private)  int previousStep()
          Goes back to the previous step in the Query-guide.
 boolean publish()
          Publishes a query in the Kom database--currently not implemented.
 boolean remove()
          Removes this query from the query database.
(package private)  int setAlternatives(java.lang.String[] queryNames)
          Sets the alternatives in this query.
(package private)  int setLocations(java.lang.String[] locationRefs)
          Sets the publishing locations for this query.
(package private)  int setScaleValues(java.lang.String[] scaleValues)
          Sets the scale values for this query.
(package private)  int setStep(int n)
          Sets the current step in the Query-guide.
 java.lang.String store()
          Stores this query in the query database.
(package private)  int trimAlternatives()
          Removes empty alternatives, also sets number of alternatives to reflect the number of filled-in alternatives.
(package private)  int trimScaleValues()
          Removes empty scale values, also sets number of scale values to reflect the number of filled-in scale values.
 
Methods inherited from class kom.gateway.KomData
add, create, debugLog, display, disppriv, errorLog, get, getAllData, getBDATA, getCDATA, getData, getElem, getKeyList, getKeys, getName, getPDATA, getStringValues, getStringVector, getValues, init, isEmpty, mayput, publish, put, put, putBDATA, putCDATA, putData, putfirst, putid, putlast, putPDATA, putValue, qput, remove, setName, setValue, toString
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, readObject, rehash, remove, size, values, writeObject
 
Methods inherited from class java.lang.Object
, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

MAXSTEP

private int MAXSTEP
Number of steps in query-guide
Constructor Detail

Build.KOMquery

Build.KOMquery()
Constructs a KOMquery with Paltmax and Pscalemax set to five.

Build.KOMquery

Build.KOMquery(boolean wizardMode)
Constructs a KOMquery with the mode specified. If realWiz is true setStep is called to specify where the query should start. The current step will be one if the user is not logged in, otherwise current step will be two. Current step is only specified by this constructor if the user is in query wizard mode.
Parameters:
wizardMode - Determines which mode the KOMquery will have. True means that the user will be able to specify multiple posting forums and more.

Build.KOMquery

Build.KOMquery(Build.KOMquery query)
Clones a KOMquery.
Parameters:
query - Object to be cloned.

Build.KOMquery

Build.KOMquery(java.lang.String userRef,
               java.lang.String queryRef)
Constructs a KOMquery by fetching it from the query database. If the specified query is not present in the database, an empty KOMquery is constructed.
Parameters:
userRef - User reference
queryRef - Query reference
Method Detail

store

public java.lang.String store()
Stores this query in the query database. Since attributes Pid and Ploc determine where in the database this query will be stored, Pid and Ploc must be set, otherwise the query will not be stored. Slightly incorrect documentation.
Returns:
Query reference for this query in the query database.

remove

public boolean remove()
Removes this query from the query database. Since attributes Pid and Ploc determine which query should be deleted, these attributes are required. Slightly incorrect documentation.
Returns:
Success status.

normal

public void normal()
Outputs an HTML version of the query to the output buffer defined in classes above.
Overrides:
normal in class KomData

dispnormal

public void dispnormal()
Outputs an HTML version of the query to the output buffer defined in classes above.

dispCategories

private void dispCategories(java.lang.String frm,
                            boolean open)
Outputs a SELECT form for choosing category
Parameters:
frm - Template id
open - Open query if true

dispForm

private void dispForm()
Outputs an HTML version of the resulting query form.

dispFormContent

private void dispFormContent()
Outputs an HTML version of the contents of the resulting queryform (this is not really an HTML form).

dispPreview

public void dispPreview()
Shows a preview of the query form

publish

public boolean publish()
Publishes a query in the Kom database--currently not implemented.
Returns:
Success status.

setAlternatives

int setAlternatives(java.lang.String[] queryNames)
Sets the alternatives in this query. It adds a Balt* field for each alternative containing a Balttext field containing the text for the alternative.
Parameters:
queryNames - Names of alternatives.
Returns:
Number of alternatives specified.

setLocations

int setLocations(java.lang.String[] locationRefs)
Sets the publishing locations for this query. It adds a Plocref* field for each location reference.
Parameters:
locationRefs - Array of location references, for example {"/2/3/"}.
Returns:
Number of unique publishing locations specified.

getLocations

java.lang.String[] getLocations()
Gets references to forums where the query will be posted.
Returns:
References to forums.

isLocation

boolean isLocation(java.lang.String locationRef)
Tests if a forum is already in list of publishing forums for this query.
Parameters:
locationRef - Forum reference.
Returns:
True iff query will be posted to forum specified by locationRef.

addAlternatives

int addAlternatives(int n)
Adds empty alternatives to this query. This method does not really add alternatives in Balt* - it just updates Paltmax to reflect how many alternatives should be presented for the user to be filled in.
Parameters:
n - Number of alternatives that should be added.
Returns:
Number of alternatives that will be presented to the user.

trimAlternatives

int trimAlternatives()
Removes empty alternatives, also sets number of alternatives to reflect the number of filled-in alternatives.
Returns:
Number of alternatives that will be presented to the user.

setScaleValues

int setScaleValues(java.lang.String[] scaleValues)
Sets the scale values for this query. It adds a Bscale* field for each value, containing a Bscaletext field containing the text for the scale value.
Parameters:
scaleValues - Text describing the scale value. For example: bad, average, good.
Returns:
Number of scale values specified.

addScaleValues

int addScaleValues(int n)
Adds empty scale values to this query. This method does not really add scale values in Bscale*; instead it just updates Pscalemax to reflect how many scale values should be presented for the user to be filled in.
Parameters:
n - Number of scale values that should be added.
Returns:
Number of scale values that will be presented to the user.

trimScaleValues

int trimScaleValues()
Removes empty scale values, also sets number of scale values to reflect the number of filled-in scale values.
Returns:
Number of scale values that will be presented to the user.

nextStep

int nextStep()
Advances to the next step in the Query-guide. This method will not advance past MAXSTEP defined for the class.
Returns:
The resulting step in the Query-guide.

previousStep

int previousStep()
Goes back to the previous step in the Query-guide.
Returns:
The resulting step in the Query-guide

setStep

int setStep(int n)
Sets the current step in the Query-guide. Updates step to max(n, MAXSTEP).
Returns:
The resulting step in the Query-guide.

getStep

int getStep()
Gets the current step in the Query-guide.
Returns:
The resulting step in the Query-guide or -1 if not defined.