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

Quick Search    Search Deep

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

java.lang.Object
  extended bycom.RuntimeCollective.permission.bean.SimplePermissible
      extended bycom.RuntimeCollective.sitemap.bean.SimplePublishable
          extended bycom.RuntimeCollective.questionnaire.bean.Questionnaire
              extended bycom.RuntimeCollective.questionnaire.bean.ClusterSafeQuestionnaire
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

public class ClusterSafeQuestionnaire
extends Questionnaire

An extension of Questionnaire that is (I really hope) cluster-safe (i.e. works with the SynchronizedEBS).

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

Field Summary
private  java.util.List unsaved
          A list of UserAnswers added to this Questionnaire since the last save.
 
Fields inherited from class com.RuntimeCollective.questionnaire.bean.Questionnaire
AnonP, DATABASE_TABLE, Description, Name, QUESTION_TABLE, Questions, Secret, TheUserAnswers
 
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
ClusterSafeQuestionnaire()
           
ClusterSafeQuestionnaire(int id)
          Get a current Questionnaire from the RuntimeDataSource, given an id.
 
Method Summary
 void addUserAnswers(UserAnswers userAnswers)
          Add a UserAnswers to this Questionnaire
 java.util.Iterator getAllUserAnswers()
          Get all UserAnswers from this Questionnaire
 java.util.Iterator getAllUserAnswers(boolean membersOnly)
          Get all member UserAnswers OR anon UserAnswers
protected  java.util.List getAllUserAnswersAsList()
          List version of getAllUserAnswers().
 java.util.Iterator getAllUserAnswersForUser(com.RuntimeCollective.webapps.bean.User user)
          Get all UserAnswers from a given User for this Questionnaire
 int getIndexOfUserAnswers(UserAnswers userAnswers)
          Get the (first) index of a UserAnswers in this Questionnaire
 int getNumberOfAnonVotes()
          Get the number of anonomous votes, ie the number of UsersAnswers where the userId is -1
 int getNumberOfVotes()
          Get the number of votes, ie the number of UserAnswers
protected  java.lang.Integer getProvisionalPosition()
          Gets the next possible position for a UserAnswer, by examining the database
 UserAnswers getUserAnswers(int position)
          Get a UserAnswers from this Questionnaire
protected  java.lang.Integer idFromUA(java.lang.Object o)
          Returns the ID of a UserAnswers object, if indeed this object is a UserAnswers
protected  void init()
          Initialise this object.
 void removeUserAnswers(UserAnswers userAnswers)
          Remove a UserAnswers from this Questionnaire
 void save()
          Save this bean to the database.
 void setUserAnswers(int position, UserAnswers userAnswers)
          Set a UserAnswers in this Questionnaire.
protected  UserAnswers uaFromId(java.lang.Object o)
          Returns a UserAnswers from an Integer object , if indeed this object is an Integer
protected  int updateProvisionalPosition(int unsavedIndex)
          Check the provisional position for the UserAnswer stored at position unsavedIndex in the unsaved List, to make sure it hasn't been used by another UserAnswer in the meantime.
 
Methods inherited from class com.RuntimeCollective.questionnaire.bean.Questionnaire
addQuestion, delete, getAnonP, getDescription, getIndexOfQuestion, getName, getNotPolls, getNotPollsAsList, getNumberOfLoggedOnVotes, getPolls, getPollsAsList, getQuestion, getQuestions, getSecret, isAnonP, isSecret, removeQuestion, setAnonP, setDescription, setName, setQuestion, setSecret
 
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

unsaved

private java.util.List unsaved
A list of UserAnswers added to this Questionnaire since the last save.

Constructor Detail

ClusterSafeQuestionnaire

public ClusterSafeQuestionnaire()

ClusterSafeQuestionnaire

public ClusterSafeQuestionnaire(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
Overrides:
save in class Questionnaire

addUserAnswers

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

Overrides:
addUserAnswers in class Questionnaire

removeUserAnswers

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

Overrides:
removeUserAnswers in class Questionnaire

getUserAnswers

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

Overrides:
getUserAnswers in class Questionnaire

setUserAnswers

public void setUserAnswers(int position,
                           UserAnswers userAnswers)
Set a UserAnswers in this Questionnaire. (This adds it to the "unsaved" list.)

Overrides:
setUserAnswers in class Questionnaire

getIndexOfUserAnswers

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

Overrides:
getIndexOfUserAnswers in class Questionnaire

getAllUserAnswers

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

Overrides:
getAllUserAnswers in class Questionnaire

getAllUserAnswersAsList

protected java.util.List getAllUserAnswersAsList()
List version of getAllUserAnswers().

Adding to / removing from this list will have no effect on the underlying Questionnaire. It is a throwaway list.


getAllUserAnswers

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

Overrides:
getAllUserAnswers in class Questionnaire

getAllUserAnswersForUser

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

Overrides:
getAllUserAnswersForUser in class Questionnaire

getNumberOfVotes

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

Overrides:
getNumberOfVotes in class Questionnaire

getNumberOfAnonVotes

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

Overrides:
getNumberOfAnonVotes in class Questionnaire

init

protected void init()
Initialise this object.


getProvisionalPosition

protected java.lang.Integer getProvisionalPosition()
Gets the next possible position for a UserAnswer, by examining the database


updateProvisionalPosition

protected int updateProvisionalPosition(int unsavedIndex)
Check the provisional position for the UserAnswer stored at position unsavedIndex in the unsaved List, to make sure it hasn't been used by another UserAnswer in the meantime. If it has, refresh it, and return it.


idFromUA

protected java.lang.Integer idFromUA(java.lang.Object o)
                              throws java.lang.ClassCastException
Returns the ID of a UserAnswers object, if indeed this object is a UserAnswers


uaFromId

protected UserAnswers uaFromId(java.lang.Object o)
                        throws java.lang.ClassCastException
Returns a UserAnswers from an Integer object , if indeed this object is an Integer