public class SurveyDAO extends AbstractDAO
| Modifier and Type | Field and Description | 
|---|---|
private static String | 
__OTHER_OPTION  | 
private I18nUtils | 
_i18nUtils  | 
protected PageDAO | 
_pageDAO
The page DAO 
 | 
private ProfileAssignmentStorageExtensionPoint | 
_profileAssignmentStorageEP  | 
private RightManager | 
_rightManager  | 
protected SiteConfigurationExtensionPoint | 
_siteConfiguration
The site configuration. 
 | 
protected SurveyAnswerDao | 
_surveyAnswerDao
The survey answer dao. 
 | 
private UserHelper | 
_userHelper  | 
static String | 
ROLE
The Avalon role 
 | 
_cocoonContext, _context, _currentUserProvider, _jsonUtils, _observationManager, _resolver, _siteManager, _uploadManager| Constructor and Description | 
|---|
SurveyDAO()  | 
| Modifier and Type | Method and Description | 
|---|---|
private void | 
_setPublicAccess(Survey survey)  | 
private void | 
_setValues(Survey survey,
          Map<String,Object> values)  | 
Map<String,String> | 
copySurvey(String surveyId,
          String label,
          String title)
Copies and pastes a survey. 
 | 
protected Map<String,Map<String,Map<String,Object>>> | 
createStatsMap(Survey survey)
Create the statistics Map for a survey. 
 | 
Map<String,String> | 
createSurvey(Map<String,Object> values,
            String siteName,
            String language)
Creates a survey. 
 | 
Map<String,String> | 
deleteSurvey(String id)
Deletes a survey. 
 | 
protected void | 
dispatchChoiceStats(SurveySession session,
                   Map<String,Map<String,Object>> questionStats,
                   Map<String,Set<String>> valueMap)
Dispatch stats on a choice question. 
 | 
protected void | 
dispatchMatrixStats(SurveySession session,
                   Map<String,Map<String,Object>> questionStats,
                   Map<String,Set<String>> valueMap)
Dispatch stats on a matrix question. 
 | 
protected void | 
dispatchStats(Survey survey,
             Collection<SurveySession> sessions,
             Map<String,Map<String,Map<String,Object>>> stats)
Dispatch the survey user sessions (input) in the statistics map. 
 | 
protected void | 
dispatchTextStats(SurveySession session,
                 Map<String,Map<String,Object>> questionStats,
                 Map<String,Set<String>> valueMap)
Dispatch stats on a text question. 
 | 
Map<String,String> | 
editSurvey(Map<String,Object> values,
          String siteName,
          String language)
Edits a survey. 
 | 
List<Object> | 
getChildren(String id)
Gets the children pages of a survey 
 | 
protected String | 
getChoiceLabel(SurveyQuestion question,
              String choiceId)
Get an option label, depending on the question type. 
 | 
protected String | 
getMailBody(String surveyId,
           String message,
           String siteName)
Get the email body 
 | 
protected String | 
getMailSubject()
Get the email subject 
 | 
protected String | 
getOptionLabel(SurveyQuestion question,
              String optionId)
Get an option label, depending on the question type. 
 | 
protected Survey | 
getParentSurvey(JCRAmetysObject obj)
Get the survey containing the given object. 
 | 
Map<String,Object> | 
getStatistics(String id)
Generates statistics on each question of a survey. 
 | 
Map<String,Object> | 
getSurvey(String id)
Gets properties of a survey 
 | 
Map<String,Object> | 
getSurvey(Survey survey)
Gets properties of a survey 
 | 
protected String | 
getSurveyUri(String surveyId,
            String siteName)
Get the survey page uri 
 | 
protected Map<String,Set<String>> | 
getValueMap(SurveyQuestion question,
           String value)
Get the user-input value as a Map from the database value, which is a single serialized string. 
 | 
protected boolean | 
hasAlreadyAnswered(String surveyId,
                  UserIdentity user)
Determines if the user has already answered to the survey 
 | 
Map<String,String> | 
isOnline(String id)
Gets the online status of a survey 
 | 
boolean | 
isPrivate(Survey survey)
Determines if the survey is private 
 | 
Map<String,String> | 
moveObject(String id,
          String oldParent,
          String newParent,
          int index)
Moves an element of the survey. 
 | 
Map<String,Object> | 
reinitSurvey(String id,
            boolean invalidate)
Reinitializes a survey. 
 | 
protected List<String> | 
removeExistingServices(String siteName,
                      String lang,
                      String surveyId)
Remove the existing services if exists 
 | 
Map<String,Object> | 
sendInvitations(String surveyId,
               String message,
               String siteName)
Sends invitations emails. 
 | 
void | 
service(ServiceManager serviceManager)  | 
Map<String,String> | 
setRedirection(String surveyId,
              String pageId)
Sets a new redirection page to the survey. 
 | 
protected List<Map<String,Object>> | 
statsToArray(Survey survey,
            Map<String,Map<String,Map<String,Object>>> stats)
Transforms the statistics map into an array with some info. 
 | 
Map<String,String> | 
validateSurvey(String id)
Validates a survey. 
 | 
_getCurrentUser, contextualize, getPictureInfo, getSurveyRootNode, setPicture, updateReferencesAfterCopy, updateReferencesAfterCopy, updateReferencesAfterCopygetLogger, setLoggerprivate static final String __OTHER_OPTION
protected SurveyAnswerDao _surveyAnswerDao
protected SiteConfigurationExtensionPoint _siteConfiguration
private I18nUtils _i18nUtils
private RightManager _rightManager
private UserHelper _userHelper
private ProfileAssignmentStorageExtensionPoint _profileAssignmentStorageEP
public SurveyDAO()
public void service(ServiceManager serviceManager) throws ServiceException
service in interface Serviceableservice in class AbstractDAOServiceExceptionpublic Map<String,Object> getSurvey(String id)
id - The id of the surveypublic Map<String,Object> getSurvey(Survey survey)
survey - The surveypublic boolean isPrivate(Survey survey)
survey - The surveypublic Map<String,String> isOnline(String id)
id - The id of the surveypublic List<Object> getChildren(String id)
id - The id of the surveypublic Map<String,String> createSurvey(Map<String,Object> values, String siteName, String language) throws Exception
values - The survey valuessiteName - The site namelanguage - The languageException - if an error occurs during the survey creation processpublic Map<String,String> editSurvey(Map<String,Object> values, String siteName, String language)
values - The survey valuessiteName - The site namelanguage - The languageprivate void _setPublicAccess(Survey survey)
private void _setValues(Survey survey, Map<String,Object> values)
public Map<String,String> copySurvey(String surveyId, String label, String title) throws Exception
surveyId - The id of the survey to copylabel - The labeltitle - The titleException - if an error occurs during the survey copying processpublic Map<String,String> deleteSurvey(String id)
id - The id of the survey to deletepublic Map<String,String> validateSurvey(String id)
id - The id of the survey to validatepublic Map<String,Object> reinitSurvey(String id, boolean invalidate)
id - The id of the survey to validateinvalidate - True to invalidate the surveypublic Map<String,String> setRedirection(String surveyId, String pageId)
surveyId - The id of the survey to edit.pageId - The id of the redirection page.public Map<String,String> moveObject(String id, String oldParent, String newParent, int index) throws Exception
id - The id of the element to move.oldParent - The id of the element's parent.newParent - The id of the new element's parent.index - The index where to move. null to place the element at the end.Exception - if an error occurs when moving an element of the surveypublic Map<String,Object> sendInvitations(String surveyId, String message, String siteName)
surveyId - The id of the survey.message - The message content.siteName - The site name.public Map<String,Object> getStatistics(String id)
id - The survey idprotected List<String> removeExistingServices(String siteName, String lang, String surveyId)
siteName - The site namelang - The languagesurveyId - The id of surveyprotected Survey getParentSurvey(JCRAmetysObject obj)
obj - the object.protected Map<String,Map<String,Map<String,Object>>> createStatsMap(Survey survey)
survey - the survey.protected void dispatchStats(Survey survey, Collection<SurveySession> sessions, Map<String,Map<String,Map<String,Object>>> stats)
survey - the survey.sessions - the user sessions.stats - the statistics Map to fill.protected void dispatchTextStats(SurveySession session, Map<String,Map<String,Object>> questionStats, Map<String,Set<String>> valueMap)
session - the survey session.questionStats - the Map to fill with the stats.valueMap - the value map.protected void dispatchChoiceStats(SurveySession session, Map<String,Map<String,Object>> questionStats, Map<String,Set<String>> valueMap)
session - the survey session.questionStats - the Map to fill with the stats.valueMap - the value map.protected void dispatchMatrixStats(SurveySession session, Map<String,Map<String,Object>> questionStats, Map<String,Set<String>> valueMap)
session - the survey session.questionStats - the Map to fill with the stats.valueMap - the value map.protected List<Map<String,Object>> statsToArray(Survey survey, Map<String,Map<String,Map<String,Object>>> stats)
survey - The surveystats - The filled statistics Map.protected String getOptionLabel(SurveyQuestion question, String optionId)
question - the question.optionId - the option ID.protected String getChoiceLabel(SurveyQuestion question, String choiceId)
question - the question.choiceId - the choice id.protected Map<String,Set<String>> getValueMap(SurveyQuestion question, String value)
question - the question.value - the value from the database.protected boolean hasAlreadyAnswered(String surveyId, UserIdentity user)
surveyId - The survey iduser - the usertrue if the user has already answeredprotected String getMailSubject()
protected String getMailBody(String surveyId, String message, String siteName)
surveyId - The survey idmessage - The messagesiteName - The site nameprotected String getSurveyUri(String surveyId, String siteName)
surveyId - The survey idsiteName - The site name