public class CSPoll extends CSItem
A poll provides a means of obtaining a census of opinions from a website's visitors. A website can have several active polls which may be randomly chosen, if required. A poll comprises a question and a series of answers and can be one of two types : multiple choice or yes/no. Multiple choice polls can have numerous answers identified by the tags A to Z, A1 to Z1, A2 to Z2, etc. Yes/No polls simply have a Yes or a No answer where Yes is identified by the tag A and No by the tag B. Typically, the POLLS section of iCM is used to set up details of a poll.
The CSPoll
class includes methods for the retrieval, update, and removal of a particular poll. It also
provides a method that checks for the existence of a poll. All such methods require that certain database and key
information (poll ID, for example) be specified via the set
methods provided, prior to their
invocation.
All database access/connectivity is handled internally by the CSPoll
class.
CSPollContent
,
CSPollContentAnswer
,
CSPollMultiple
,
Serialized FormModifier and Type | Field and Description |
---|---|
static java.lang.String |
TYPE_MULTIPLE
A valid poll type to be used by the
setType method. |
static java.lang.String |
TYPE_YESNO
A valid poll type to be used by the
setType method. |
ACCESS_GRANTED, DOES_NOT_EXIST, EMPTY, EXISTS, SECURE_ACCESS_DENIED, SECURE_ACCESS_GRANTED, UPDATE_ACTION_INSERTED, UPDATE_ACTION_UPDATED
LEVEL_ALL, LEVEL_ALL_PLUS_RELATED, LEVEL_DETAIL, LEVEL_ID, LEVEL_SUMMARY
Constructor and Description |
---|
CSPoll()
Creates an empty
CSPoll object. |
CSPoll(java.lang.String strPropertyFile)
Creates a
CSPoll object, specifying a property file that contains all of the database connection
details. |
Modifier and Type | Method and Description |
---|---|
void |
delete()
Removes a poll from the database.
|
boolean |
exist()
Checks to see whether a poll exists on the database.
|
void |
get()
Retrieves the details of a poll from the database.
|
java.util.ArrayList |
getAnswers()
Gets the answers that are available for this poll.
|
boolean |
getArchive()
Deprecated.
Poll archiving is not supported.
|
int |
getAuthor()
Gets the poll's author.
|
boolean |
getDisplay()
Indicates whether the poll can be displayed on the website or not.
|
java.util.Date |
getEndDate()
Gets the poll's end date.
|
java.lang.String |
getFilter()
Gets the poll name filter currently specified as key information.
|
int |
getGroupID()
Get the ID of the immediate parent poll group.
|
java.lang.String |
getGroupName()
Get the name of the immediate parent poll group.
|
java.lang.String |
getName()
Gets the name of the poll.
|
int |
getPollID()
Gets the ID of the poll.
|
java.lang.String |
getQuestion()
Gets the poll's question.
|
java.lang.String |
getRootPollIDs()
Gets the IDs of Root Poll Groups.
|
java.util.Date |
getStartDate()
Gets the poll's start date.
|
int |
getTotalVotes()
Gets the total number of poll votes.
|
java.lang.String |
getType()
Gets the poll's type.
|
int |
getVotes(java.lang.String strTag)
Sets the number of votes for a particular answer.
|
void |
setAnswers(java.util.ArrayList arrAnswers)
Sets the answers available for the poll.
|
void |
setArchive(boolean bArchive)
Deprecated.
Poll archiving is not supported.
|
void |
setAuthor(int nAuthor)
Sets the author of the poll.
|
void |
setDetailLevel(int nDetailLevel)
Sets the level of detail to be handled by the
get method. |
void |
setDisplay(boolean bDisplay)
Specifies whether the poll can be displayed on the website or not.
|
void |
setEndDate(java.util.Date objDate)
Sets the poll's end date, the date upon which the poll is to become inactive.
|
void |
setFilter(java.lang.String strFilter)
Sets the poll name filter to be used as key information.
|
void |
setGroupID(int nGroupID)
Set the ID of the immediate parent poll group.
|
void |
setGroupName(java.lang.String strGroupName)
Set the name of the immediate parent poll group.
|
void |
setName(java.lang.String strName)
Sets the name of the poll.
|
void |
setPollID(int nPollID)
Sets the ID of the poll.
|
void |
setQuestion(java.lang.String strQuestion)
Sets the poll's question text.
|
void |
setRootPollIDs(java.lang.String strRootPollIDs)
Sets the IDs of Root Poll Groups.
|
void |
setStartDate(java.util.Date objDate)
Sets the poll's start date, the date upon which the poll is to become active.
|
void |
setTotalVotes(int nTotalVotes)
Sets the total number of votes for the poll.
|
void |
setType(java.lang.String strType)
Sets the type of poll.
|
void |
setVotes(java.lang.String strTag,
int nTotalVotes)
Sets the number of votes for a specific poll answer.
|
java.lang.String |
toString()
Outputs the contents of this
CSPoll object to a String object in a user-friendly
format. |
void |
update()
Updates a poll on the database.
|
equals, getID, getStatus, hashCode, jsonString, serialiseWithTypes, setID, setStatus, unset
clearRecordedGatewayMessages, clone, count, getCache, getCachingEnabled, getDatabaseVersion, getDatabaseVersion, getDebugOutput, getDetailLevel, getPreview, getPropertyFile, getPropertyFileExtension, getPropertyFilePathname, getRecordedGatewayMessages, getRecordGatewayMessages, getSendGatewayMessages, getUseCache, setDebugOutput, setPreview, setPropertyFile, setRecordGatewayMessages, setSendGatewayMessages, setUseCache
public static java.lang.String TYPE_YESNO
setType
method. Specify this to indicate that the
poll comprises a simple Yes/No question.public static java.lang.String TYPE_MULTIPLE
setType
method. Specify this to indicate that the
poll comprises a multiple choice question.public CSPoll()
CSPoll
object.
Use the various set methods provided to initialise the CSPoll
object prior to invoking any of its
query methods.
public CSPoll(java.lang.String strPropertyFile)
CSPoll
object, specifying a property file that contains all of the database connection
details.
Use the various set methods provided to initialise the CSPoll
object prior to invoking any of its
query methods.
strPropertyFile
- The name of the property filepublic void setDetailLevel(int nDetailLevel) throws CSParameterException
get
method.
Valid detail levels for a poll are :
LEVEL_ID - the poll ID
LEVEL_SUMMARY - the poll name, type and question
LEVEL_DETAIL - the poll author, start date and end date
LEVEL_ALL - the poll's answers and the total number of votes
Each detail level processes the information specified alongside it in addition to the information specified for all detail levels listed above it. The default detail level is LEVEL_ALL.
setDetailLevel
in class CSDatabaseItem
nDetailLevel
- The detail level to be usedCSParameterException
- if an invalid detail level is specified.public void setPollID(int nPollID)
setPollID
followed by a call to exist
will determine whether a poll with the
specified ID exists on the database.
setPollID
followed by a call to get
will populate this CSPoll
object
with the specified poll's details.
If a poll ID is specified, the update
method will update, using the contents of this
CSPoll
object, the poll on the database whose ID matches.
setPollID
followed by a call to delete
will remove the poll with the specified
ID from the database.
nPollID
- the numeric identifier of the pollpublic int getPollID()
public void setName(java.lang.String strName)
setName
followed by a call to exist
will determine whether a poll with that name
exists on the database. If the poll ID is known, it will be used in preference to the name.
setName
followed by a call to get
will populate this CSPoll
object
with details of the poll with the specified name. If the poll ID is known, it will be used in preference to the
name.
If no poll ID is specified, the update
method will use the poll name to update, using the
contents of this CSPoll
object, the poll on the database whose name matches. If none exists, a new
one will be created.
setName
followed by a call to delete
will remove the poll with the specified
name from the database. If the poll ID is known, it will be used in preference to the name.
strName
- The poll's namepublic java.lang.String getName()
public void setFilter(java.lang.String strFilter)
If a filter is specified and no % is included in the filter, % is placed at the beginning and end so that any poll whose name is found to CONTAIN the specified text will be retrieved.
setFilter
followed by get
will retrieve a random poll from all those whose name
matches the specified filter - this CSPoll
object will be populated with the retrieved details. A
filter can be specified in conjunction with a type, using setType
, but a poll ID or
name will take precedence over these if supplied.
strFilter
- The poll name filterpublic java.lang.String getFilter()
public void setType(java.lang.String strType)
Sets the type of poll. Defined poll types are :
setType
followed by get
will retrieve a random poll from all those that are of the
specified type - this CSPoll
object will be populated with the retrieved details. A type can be
specified in conjunction with a filter, using setFilter
, but a poll ID or name will
take precedence over these if supplied.
strType
- The poll typepublic java.lang.String getType()
public void setAuthor(int nAuthor)
nAuthor
- The numeric identifier of the poll's author. This should be the ID of one of the users set up via iCM
security.public int getAuthor()
public void setDisplay(boolean bDisplay)
false
,
the poll is not to be displayed on the website.
bDisplay
- true
if the poll can be displayed, false
otherwise.public boolean getDisplay()
true
if the poll can be displayed, false
otherwise.public void setArchive(boolean bArchive)
true
, the poll can be
archived.
bArchive
- true
if the poll can be archived, false
otherwise.public boolean getArchive()
true
if the poll can be archived, false
otherwise.public void setQuestion(java.lang.String strQuestion)
strQuestion
- The question to be asked by the pollpublic java.lang.String getQuestion()
public void setStartDate(java.util.Date objDate)
objDate
- The poll's start datepublic java.util.Date getStartDate()
public void setEndDate(java.util.Date objDate)
objDate
- The poll's end datepublic java.util.Date getEndDate()
public void setTotalVotes(int nTotalVotes)
nTotalVotes
- The total number of votespublic int getTotalVotes()
public void setVotes(java.lang.String strTag, int nTotalVotes)
strTag
- The tag that identifies the answernTotalVotes
- The number of votes for the specified answerpublic int getVotes(java.lang.String strTag)
strTag
- The tag that identifies the answerpublic void setAnswers(java.util.ArrayList arrAnswers)
CSPollContentAnswer
object.
arrAnswers
- An ArrayList of CSPollContentAnswer
objectspublic java.util.ArrayList getAnswers()
CSPollContentAnswer
object.
CSPollContentAnswer
objectspublic void setGroupID(int nGroupID)
This property will only be set for database versions from 5.2.1.0 onwards.
nGroupID
- the ID of the parent poll group.public int getGroupID()
This property will only be set for database versions from 5.2.1.0 onwards.
public void setGroupName(java.lang.String strGroupName)
This property will only be set for database versions from 5.2.1.0 onwards.
strGroupName
- the name of the parent poll group.public java.lang.String getGroupName()
This property will only be set for database versions from 5.2.1.0 onwards.
public void setRootPollIDs(java.lang.String strRootPollIDs)
strRootPollIDs
- A comma seperated list of poll group IDs.public java.lang.String getRootPollIDs()
public boolean exist() throws CSException
Use setPollID
followed by exist
to determine whether a poll with the
specified ID exists on the database.
Use setName
followed by exist
to determine whether a poll with the
specified name exists on the database.
exist
in class CSItem
true
if the poll exists on the databaseCSParameterException
- if an invalid combination of key information has been suppliedCSDatabaseException
- if there are problems accessing the databaseCSException
- the base class for exceptions thrown by this method.public void get() throws CSException
Use setPollID
followed by get
to populate this CSPoll
object with the details of the poll identified by the specified ID.
Use setName
followed by get
to populate this CSPoll
object
with the details of the poll identified by the specified name.
Use setType
followed by get
to populate this CSPoll
object
with the details of a poll selected randomly out of those whose type matches that specified.
Use setFilter
followed by get
to populate this CSPoll
object with the details of a randomly selected poll out of those whose name matches the filter specified. Both a
type and filter may be specified in order to retrieve details of a poll whose name matches the supplied filter
and whose type matches the supplied type. However, a specified poll ID/name will always take precedence over a
filter/type.
When randomly selecting a poll, the selection will be made from polls that are in date and turned on. When retrieving a specific poll, the poll details are returned regardless of its visibility settings.
get
in class CSItem
CSParameterException
- if an invalid combination of key information has been suppliedCSDatabaseException
- if there are problems accessing the databaseCSNotFoundException
- if the specified poll cannot be found on the databaseCSSecurityException
- if security has been breachedCSException
- the base class for exceptions thrown by this method.public void update() throws CSException
Use update
to store the current contents of this CSPoll
object on the database. If
a poll with the current ID/Name already exists, that poll's details will be updated. Otherwise, a new poll will
be created on the database.
update
in class CSItem
CSParameterException
- if an invalid combination of key information has been suppliedCSDatabaseException
- if there are problems accessing the databaseCSNotFoundException
- if the specified poll cannot be found on the databaseCSException
- the base class for exceptions thrown by this method.public void delete() throws CSException
Use setPollID
followed by delete
to remove the poll with the specified ID
from the database.
Use setName
followed by delete
to remove the poll with the specified name
from the database.
delete
in class CSItem
CSParameterException
- if an invalid combination of key information has been suppliedCSDatabaseException
- if there are problems accessing the databaseCSNotFoundException
- if the specified poll cannot be found on the databaseCSException
- the base class for exceptions thrown by this method.Copyright © 2022 Goss Interactive Ltd. All Rights Reserved.