Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.RuntimeCollective.questionnaire.bean
Class Questionnaire  view Questionnaire download Questionnaire.java

java.lang.Object
  extended bycom.RuntimeCollective.permission.bean.SimplePermissible
      extended bycom.RuntimeCollective.sitemap.bean.SimplePublishable
          extended bycom.RuntimeCollective.questionnaire.bean.Questionnaire
All Implemented Interfaces:
com.RuntimeCollective.webapps.bean.EntityBean, com.RuntimeCollective.permission.bean.Permissible, com.RuntimeCollective.webapps.bean.PermissionBean, com.RuntimeCollective.sitemap.bean.Publishable, java.io.Serializable
Direct Known Subclasses:
ClusterSafeQuestionnaire

public class Questionnaire
extends com.RuntimeCollective.sitemap.bean.SimplePublishable
implements com.RuntimeCollective.sitemap.bean.Publishable

The Questionnaire class, which is basically a Publishable container of Questions and UserAnswers. With a Name and Description thrown in.

It reuses SimplePublishable.

If you want to be spared the hassle of writing JSPs to edit your Questionnaires, do have a look at the pages written for the Sussex Enterprise project. You can find them by checking out the relevent project: "cvs co rsework", then look in rsework/web/admin.

The pages only deal with simple Polls (ie one question). The pages are called add/edit/deletePollXXX.jsp. The rsework/struts-config.xml file is also worth checking, for the action mappings etc.

And while you're at it, why not vanilla the pages and copy them to questionnaire/web/admin ...

You can also check the Sussex Enterprise staging server (ask Fabrice, JoeH or Sophie).

Version:
$Id: Questionnaire.java,v 1.26 2003/10/13 11:29:27 miles Exp $

Field Summary
protected  boolean AnonP
          AnonP - Whether or not you need to be logged in to vote (anonomous poll)
static java.lang.String DATABASE_TABLE
          The name of the database table for this bean type.
protected  java.lang.String Description
          The description
protected  java.lang.String Name
          The name
static java.lang.String QUESTION_TABLE
           
(package private)  java.util.ArrayList Questions
          The Questions
protected  boolean Secret
          Whether the results of the poll are secret to normal users
(package private)  java.util.ArrayList TheUserAnswers
          The UserAnswers
 
Fields inherited from class com.RuntimeCollective.sitemap.bean.SimplePublishable
AlwaysLive, AND_STATUS, ESC, GoDeadDate, GoLiveDate, IsNew, NeedApproval, ORDER_BY_LAST_MOD_DATE, SELECT_ID_FROM, Status, StatusLastModifiedDate, WHERE_ALWAYS_LIVE
 
Fields inherited from class com.RuntimeCollective.permission.bean.SimplePermissible
DATABASE_PRULEMAP_TABLE, id, PermissionRuleIds
 
Fields inherited from interface com.RuntimeCollective.sitemap.bean.Publishable
STATUS_APPROVED, STATUS_ARCHIVED, STATUS_EDITED, STATUS_TO_BE_APPROVED
 
Fields inherited from interface com.RuntimeCollective.permission.bean.Permissible
EDIT_ACTION, VIEW_ACTION
 
Fields inherited from interface com.RuntimeCollective.webapps.bean.EntityBean
INTERFACE_BEAN, NULL_ID
 
Constructor Summary
Questionnaire()
          Construct a new blank Questionnaire, giving it a new unique ID.
Questionnaire(int id)
          Get a current Questionnaire from the RuntimeDataSource, given an id.
 
Method Summary
 void addQuestion(Question question)
          Add a Question to this Questionnaire
 void addUserAnswers(UserAnswers userAnswers)
          Add a UserAnswers to this Questionnaire
 void delete()
          Delete this bean from the database.
 java.util.Iterator getAllUserAnswers()
          Get all UserAnswers from this Questionnaire
 java.util.Iterator getAllUserAnswers(boolean membersOnly)
          Get all member UserAnswers OR anon UserAnswers
 java.util.Iterator getAllUserAnswersForUser(com.RuntimeCollective.webapps.bean.User user)
          Get all UserAnswers from a given User for this Questionnaire
 boolean getAnonP()
          Get the AnonP
 java.lang.String getDescription()
          Get the description
 int getIndexOfQuestion(Question question)
          Get the (first) index of a Question in this Questionnaire
 int getIndexOfUserAnswers(UserAnswers userAnswers)
          Get the (first) index of a UserAnswers in this Questionnaire
 java.lang.String getName()
          Get the name
static java.util.Iterator getNotPolls(boolean liveOnly)
          Static method to get all the questionnaires that are not polls from the database.
static java.util.List getNotPollsAsList(boolean liveOnly)
          Static method to get all the polls from the database.
 int getNumberOfAnonVotes()
          Get the number of anonomous votes, ie the number of UsersAnswers where the userId is -1
 int getNumberOfLoggedOnVotes()
          Get the number of logged on user votes, ie votes not made anon
 int getNumberOfVotes()
          Get the number of votes, ie the number of UserAnswers
static java.util.Iterator getPolls(boolean liveOnly)
          Static method to get all the polls from the database.
static java.util.List getPollsAsList(boolean liveOnly)
          Static method to get all the polls from the database.
 Question getQuestion(int position)
          Get a Question from this Questionnaire
 java.util.Iterator getQuestions()
          Get all Questions from this Questionnaire
 boolean getSecret()
          Get whether the results of the poll are secret to normal users
 UserAnswers getUserAnswers(int position)
          Get a UserAnswers from this Questionnaire
 boolean isAnonP()
          Get the AnonP
 boolean isSecret()
          Get whether the results of the poll are secret to normal users
 void removeQuestion(Question question)
          Remove a Question from this Questionnaire
 void removeUserAnswers(UserAnswers userAnswers)
          Remove a UserAnswers from this Questionnaire
 void save()
          Save this bean to the database.
 void setAnonP(boolean anonP)
          Set the AnonP
 void setDescription(java.lang.String description)
          Set the description
 void setName(java.lang.String name)
          Set the name
 void setQuestion(int position, Question question)
          Set a Question in this Questionnaire
 void setSecret(boolean secret)
          Set whether the results of the poll are secret to normal users
 void setUserAnswers(int position, UserAnswers userAnswers)
          Set a UserAnswers in this Questionnaire
 
Methods inherited from class com.RuntimeCollective.sitemap.bean.SimplePublishable
checkStillApproved, getAlwaysLive, getGoDeadDate, getGoLiveDate, getIsNew, getNeedApproval, getStatus, getStatusLastModifiedDate, getToBeApprovedPublishables, isAlwaysLive, isApproved, isArchived, isEdited, isLive, isNew, isToBeApproved, markAsApproved, markAsArchived, markAsEdited, markAsToBeApproved, needsApproval, publish, saveArchivedData, setAlwaysLive, setGoDeadDate, setGoLiveDate, setIsNew, setNeedApproval, setStatus, setStatusLastModifiedDate
 
Methods inherited from class com.RuntimeCollective.permission.bean.SimplePermissible
canEdit, canPerformAction, canView, getActionPermissionRule, getActions, getAuthorisationPathForAction, getAuthorisationPathForAction, getId, loadRules, removeActionPermissionRule, saveRules, setActionPermissionRule, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.RuntimeCollective.sitemap.bean.Publishable
getAlwaysLive, getGoDeadDate, getGoLiveDate, getIsNew, getNeedApproval, getStatus, getStatusLastModifiedDate, isAlwaysLive, isApproved, isArchived, isEdited, isLive, isNew, isToBeApproved, markAsApproved, markAsArchived, markAsEdited, markAsToBeApproved, needsApproval, publish, saveArchivedData, setAlwaysLive, setGoDeadDate, setGoLiveDate, setIsNew, setNeedApproval, setStatus, setStatusLastModifiedDate
 
Methods inherited from interface com.RuntimeCollective.permission.bean.Permissible
canEdit, canPerformAction, canView, getActionPermissionRule, getActions, getAuthorisationPathForAction, getAuthorisationPathForAction, getId, setActionPermissionRule, setId
 

Field Detail

DATABASE_TABLE

public static final java.lang.String DATABASE_TABLE
The name of the database table for this bean type.

See Also:
Constant Field Values

QUESTION_TABLE

public static final java.lang.String QUESTION_TABLE
See Also:
Constant Field Values

Name

protected java.lang.String Name
The name


Description

protected java.lang.String Description
The description


AnonP

protected boolean AnonP
AnonP - Whether or not you need to be logged in to vote (anonomous poll)


Secret

protected boolean Secret
Whether the results of the poll are secret to normal users


Questions

java.util.ArrayList Questions
The Questions


TheUserAnswers

java.util.ArrayList TheUserAnswers
The UserAnswers

Constructor Detail

Questionnaire

public Questionnaire()
Construct a new blank Questionnaire, giving it a new unique ID.


Questionnaire

public Questionnaire(int id)
Get a current Questionnaire from the RuntimeDataSource, given an id.

Method Detail

save

public void save()
Save this bean to the database.

Specified by:
save in interface com.RuntimeCollective.permission.bean.Permissible

delete

public void delete()
Delete this bean from the database.

Specified by:
delete in interface com.RuntimeCollective.permission.bean.Permissible

setName

public void setName(java.lang.String name)
Set the name


getName

public java.lang.String getName()
Get the name


setDescription

public void setDescription(java.lang.String description)
Set the description


getDescription

public java.lang.String getDescription()
Get the description


setAnonP

public void setAnonP(boolean anonP)
Set the AnonP


getAnonP

public boolean getAnonP()
Get the AnonP


isAnonP

public boolean isAnonP()
Get the AnonP


setSecret

public void setSecret(boolean secret)
Set whether the results of the poll are secret to normal users


getSecret

public boolean getSecret()
Get whether the results of the poll are secret to normal users


isSecret

public boolean isSecret()
Get whether the results of the poll are secret to normal users


addQuestion

public void addQuestion(Question question)
Add a Question to this Questionnaire


removeQuestion

public void removeQuestion(Question question)
Remove a Question from this Questionnaire


getQuestion

public Question getQuestion(int position)
Get a Question from this Questionnaire


setQuestion

public void setQuestion(int position,
                        Question question)
Set a Question in this Questionnaire


getIndexOfQuestion

public int getIndexOfQuestion(Question question)
Get the (first) index of a Question in this Questionnaire


getQuestions

public java.util.Iterator getQuestions()
Get all Questions from this Questionnaire


addUserAnswers

public void addUserAnswers(UserAnswers userAnswers)
Add a UserAnswers to this Questionnaire


removeUserAnswers

public void removeUserAnswers(UserAnswers userAnswers)
Remove a UserAnswers from this Questionnaire


getUserAnswers

public UserAnswers getUserAnswers(int position)
Get a UserAnswers from this Questionnaire


setUserAnswers

public void setUserAnswers(int position,
                           UserAnswers userAnswers)
Set a UserAnswers in this Questionnaire


getIndexOfUserAnswers

public int getIndexOfUserAnswers(UserAnswers userAnswers)
Get the (first) index of a UserAnswers in this Questionnaire


getAllUserAnswers

public java.util.Iterator getAllUserAnswers()
Get all UserAnswers from this Questionnaire


getAllUserAnswers

public java.util.Iterator getAllUserAnswers(boolean membersOnly)
Get all member UserAnswers OR anon UserAnswers


getAllUserAnswersForUser

public java.util.Iterator getAllUserAnswersForUser(com.RuntimeCollective.webapps.bean.User user)
Get all UserAnswers from a given User for this Questionnaire


getNumberOfVotes

public int getNumberOfVotes()
Get the number of votes, ie the number of UserAnswers


getNumberOfAnonVotes

public int getNumberOfAnonVotes()
Get the number of anonomous votes, ie the number of UsersAnswers where the userId is -1


getNumberOfLoggedOnVotes

public int getNumberOfLoggedOnVotes()
Get the number of logged on user votes, ie votes not made anon


getPolls

public static java.util.Iterator getPolls(boolean liveOnly)
Static method to get all the polls from the database.


getPollsAsList

public static java.util.List getPollsAsList(boolean liveOnly)
Static method to get all the polls from the database.


getNotPolls

public static java.util.Iterator getNotPolls(boolean liveOnly)
Static method to get all the questionnaires that are not polls from the database.


getNotPollsAsList

public static java.util.List getNotPollsAsList(boolean liveOnly)
Static method to get all the polls from the database.