Class SurveyDAO

    • Method Detail

      • getSurvey

        public Map<String,​ObjectgetSurvey​(String id)
        Gets properties of a survey
        Parameters:
        id - The id of the survey
        Returns:
        The properties
      • getSurvey

        public Map<String,​ObjectgetSurvey​(Survey survey)
        Gets properties of a survey
        Parameters:
        survey - The survey
        Returns:
        The properties
      • isPrivate

        public boolean isPrivate​(Survey survey)
        Determines if the survey is private
        Parameters:
        survey - The survey
        Returns:
        true if the survey is reading restricted
      • isOnline

        public Map<String,​StringisOnline​(String id)
        Gets the online status of a survey
        Parameters:
        id - The id of the survey
        Returns:
        A map indicating if the survey is valid and if it is online
      • getChildren

        public List<ObjectgetChildren​(String id)
        Gets the children pages of a survey
        Parameters:
        id - The id of the survey
        Returns:
        A map of pages properties
      • createSurvey

        public Map<String,​StringcreateSurvey​(Map<String,​Object> values,
                                                     String siteName,
                                                     String language)
                                              throws Exception
        Creates a survey.
        Parameters:
        values - The survey values
        siteName - The site name
        language - The language
        Returns:
        The id of the created survey
        Throws:
        Exception - if an error occurs during the survey creation process
      • editSurvey

        public Map<String,​StringeditSurvey​(Map<String,​Object> values,
                                                   String siteName,
                                                   String language)
        Edits a survey.
        Parameters:
        values - The survey values
        siteName - The site name
        language - The language
        Returns:
        The id of the edited survey
      • copySurvey

        public Map<String,​StringcopySurvey​(String surveyId,
                                                   String label,
                                                   String title)
                                            throws Exception
        Copies and pastes a survey.
        Parameters:
        surveyId - The id of the survey to copy
        label - The label
        title - The title
        Returns:
        The id of the created survey
        Throws:
        Exception - if an error occurs during the survey copying process
      • deleteSurvey

        public Map<String,​StringdeleteSurvey​(String id)
        Deletes a survey.
        Parameters:
        id - The id of the survey to delete
        Returns:
        The id of the deleted survey
      • validateSurvey

        public Map<String,​StringvalidateSurvey​(String id)
        Validates a survey.
        Parameters:
        id - The id of the survey to validate
        Returns:
        The id of the validated survey
      • reinitSurvey

        public Map<String,​ObjectreinitSurvey​(String id,
                                                     boolean invalidate)
        Reinitializes a survey.
        Parameters:
        id - The id of the survey to validate
        invalidate - True to invalidate the survey
        Returns:
        The id of the reinitialized survey
      • setRedirection

        public Map<String,​StringsetRedirection​(String surveyId,
                                                       String pageId)
        Sets a new redirection page to the survey.
        Parameters:
        surveyId - The id of the survey to edit.
        pageId - The id of the redirection page.
        Returns:
        The id of the edited survey
      • moveObject

        public Map<String,​StringmoveObject​(String id,
                                                   String oldParent,
                                                   String newParent,
                                                   long index)
                                            throws Exception
        Moves an element of the survey.
        Parameters:
        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.
        Returns:
        A map with the ids of the element, the old parent and the new parent
        Throws:
        Exception - if an error occurs when moving an element of the survey
      • sendInvitations

        public Map<String,​ObjectsendInvitations​(String surveyId,
                                                        String message,
                                                        String siteName)
        Sends invitations emails.
        Parameters:
        surveyId - The id of the survey.
        message - The message content.
        siteName - The site name.
        Returns:
        An empty map
      • getStatistics

        public Map<String,​ObjectgetStatistics​(String id)
        Generates statistics on each question of a survey.
        Parameters:
        id - The survey id
        Returns:
        A map containing the statistics
      • removeExistingServices

        protected List<StringremoveExistingServices​(String siteName,
                                                      String lang,
                                                      String surveyId)
        Remove the existing services if exists
        Parameters:
        siteName - The site name
        lang - The language
        surveyId - The id of survey
        Returns:
        The list of modified pages ids
      • createStatsMap

        protected Map<String,​Map<String,​Map<String,​Object>>> createStatsMap​(Survey survey)
        Create the statistics Map for a survey.
        Parameters:
        survey - the survey.
        Returns:
        the statistics Map. It is of the following form: questionId -> optionId ->choiceId -> count.
      • getOptionLabel

        protected String getOptionLabel​(SurveyQuestion question,
                                        String optionId)
        Get an option label, depending on the question type.
        Parameters:
        question - the question.
        optionId - the option ID.
        Returns:
        the question label, can be the empty string.
      • getChoiceLabel

        protected String getChoiceLabel​(SurveyQuestion question,
                                        String choiceId)
        Get an option label, depending on the question type.
        Parameters:
        question - the question.
        choiceId - the choice id.
        Returns:
        the option label, can be the empty string.
      • getValueMap

        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.
        Parameters:
        question - the question.
        value - the value from the database.
        Returns:
        the value as a Map.
      • hasAlreadyAnswered

        protected boolean hasAlreadyAnswered​(String surveyId,
                                             UserIdentity user)
        Determines if the user has already answered to the survey
        Parameters:
        surveyId - The survey id
        user - the user
        Returns:
        true if the user has already answered
      • getMailBody

        protected String getMailBody​(String surveyId,
                                     String message,
                                     String siteName)
        Get the email body
        Parameters:
        surveyId - The survey id
        message - The message
        siteName - The site name
        Returns:
        The text body
      • getSurveyUri

        protected String getSurveyUri​(String surveyId,
                                      String siteName)
        Get the survey page uri
        Parameters:
        surveyId - The survey id
        siteName - The site name
        Returns:
        The survey absolute uri