pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.component.survey.model
Class Questionnaire

java.lang.Object
  extended by org.torweg.pulse.util.entity.AbstractBasicEntity
      extended by org.torweg.pulse.component.survey.model.Questionnaire
All Implemented Interfaces:
java.io.Serializable

@Entity
public class Questionnaire
extends AbstractBasicEntity

The Questionnaire stores the AbstractTypedAnswer<?>s for a Survey.

Version:
$Revision: 1586 $
Author:
Daniel Dietz
See Also:
Serialized Form

Constructor Summary
protected Questionnaire()
          Default constructor.
  Questionnaire(Survey sur)
          Creates a new Questionnaire for the given Survey.
 
Method Summary
 boolean addAnswer(AbstractTypedAnswer<?> answer)
          Adds an {@code AbstractTypedAnswer<?
 AbstractTypedAnswer<?> getAnswer(AbstractQuestion quest)
          Returns the {@code AbstractTypedAnswer<?
 java.util.List<? extends AbstractTypedAnswer<?>> getAnswers()
          Returns the answers of the Questionnaire.
 java.util.Date getStorageDate()
          Returns the storage-Date.
 Survey getSurvey(org.hibernate.Session s)
          Returns the Survey the Questionnaire belongs to.
 java.lang.Long getSurveyId()
          Returns the id of the Survey the Questionnaire belongs to.
 java.lang.String getSurveyToken()
          Returns the surveyToken-string.
 java.lang.Long getUserId()
          Returns the userId.
 Questionnaire setStorageDate(java.util.Date storage)
          Sets the storage-Date.
 void setSurveyToken(java.lang.String surveyTok)
          Sets the surveyToken-string.
 void setUserId(java.lang.Long uId)
          Sets the userId.
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractBasicEntity
compareTo, equals, getFullQualifiedClassNameJAXB, getId, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Questionnaire

protected Questionnaire()
Default constructor.


Questionnaire

public Questionnaire(Survey sur)
Creates a new Questionnaire for the given Survey.

Parameters:
sur - the Survey
Method Detail

getSurveyId

public final java.lang.Long getSurveyId()
Returns the id of the Survey the Questionnaire belongs to.

Returns:
the id of the Survey

setUserId

public final void setUserId(java.lang.Long uId)
Sets the userId.

Parameters:
uId - the userId to set

getUserId

public final java.lang.Long getUserId()
Returns the userId.

Returns:
the userId

addAnswer

public final boolean addAnswer(AbstractTypedAnswer<?> answer)
Adds an AbstractTypedAnswer&lt;?&gt; to the Questionnaire.

If Questionnaire.answers already contains an AbstractTypedAnswer&lt;?&gt; with AbstractTypedAnswer&lt;?&gt;. getQuestionId().equals(answer.getQuestionId()) that AbstractTypedAnswer&lt;?&gt; will be replaced by the given answer.

Parameters:
answer - the AbstractTypedAnswer&lt;?&gt; to add
Returns:
true if the given answer has been added, false otherwise

getAnswers

public final java.util.List<? extends AbstractTypedAnswer<?>> getAnswers()
Returns the answers of the Questionnaire.

Returns:
the List&lt;? extends AbstractTypedAnswer&lt;?&gt;&gt;

getAnswer

public final AbstractTypedAnswer<?> getAnswer(AbstractQuestion quest)
Returns the AbstractTypedAnswer&lt;?&gt; for the given AbstractQuestion.

Parameters:
quest - the AbstractQuestion
Returns:
the AbstractTypedAnswer&lt;?&gt; for the given AbstractQuestion or null if the Questionnaire does not have an AbstractTypedAnswer&lt;?&gt; for the given AbstractQuestion

getSurvey

public final Survey getSurvey(org.hibernate.Session s)
Returns the Survey the Questionnaire belongs to.

Parameters:
s - the hibernateTM-Session
Returns:
the Survey the Questionnaire belongs to if a Survey could be loaded, null otherwise

setSurveyToken

public final void setSurveyToken(java.lang.String surveyTok)
Sets the surveyToken-string.

Parameters:
surveyTok - the surveyToken-string

getSurveyToken

public final java.lang.String getSurveyToken()
Returns the surveyToken-string.

Returns:
the surveyToken-string

setStorageDate

public final Questionnaire setStorageDate(java.util.Date storage)
Sets the storage-Date.

Parameters:
storage - the storage-Date to set
Returns:
the modified Questionnaire

getStorageDate

public final java.util.Date getStorageDate()
Returns the storage-Date.

Returns:
the storage-Date