<commit_before>/*
 ************************************************************************************
 * Copyright (C) 2001-2009 encuestame: system online surveys Copyright (C) 2009
 * encuestame Development Team.
 * Licensed under the Apache Software License version 2.0
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to  in writing,  software  distributed
 * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
 * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
 * specific language governing permissions and limitations under the License.
 ************************************************************************************
 */
package org.encuestame.test.config;

import java.util.Date;
import java.util.List;

import org.encuestame.persistence.domain.LocationFolderType;
import org.encuestame.persistence.domain.Question;
import org.encuestame.persistence.domain.security.SecUser;
import org.encuestame.persistence.domain.survey.QuestionsAnswers;
import org.encuestame.persistence.domain.survey.TweetPoll;
import org.encuestame.persistence.domain.survey.TweetPollSwitch;
import org.encuestame.utils.security.SignUpBean;
import org.encuestame.utils.web.UnitAnswersBean;
import org.encuestame.utils.web.UnitEmails;
import org.encuestame.utils.web.UnitLists;
import org.encuestame.utils.web.UnitLocationBean;
import org.encuestame.utils.web.UnitLocationFolder;
import org.encuestame.utils.web.UnitPatternBean;
import org.encuestame.utils.web.UnitQuestionBean;
import org.encuestame.utils.web.UnitTweetPoll;
import org.encuestame.utils.web.UnitUserBean;


/**
 * Abstract Base Unit Beans.
 * @author <NAME>, Diana <EMAIL>
 * @since 19/04/2010 20:54:56
 * @version $Id:$
 */

public abstract class AbstractBaseUnitBeans extends AbstractBase{

    /**
     * Create Unit Question Helper.
     * @param questionName
     * @param stateId
     * @param userId
     * @param listAnswers
     * @param pattern
     * @return
     */
    @SuppressWarnings("unchecked")
    public UnitQuestionBean createUnitQuestionBean(
            final String questionName,
            final Long stateId,
            final Long userId,
            final List listAnswers,
            final UnitPatternBean pattern){
         final UnitQuestionBean question = new UnitQuestionBean();
         question.setQuestionName(questionName);
         question.setStateId(stateId);
         question.setUserId(userId);
         question.setListAnswers(listAnswers);
         question.setPattern(pattern);
         return question;
    }

    /**
     * Create Pattern Bean Helper.
     * @param classpattern
     * @param descripcionPattern
     * @param levelpattern
     * @param patronType
     * @param template
     * @return
     */
     public UnitPatternBean createPatternBean(
             final String classpattern,
             final String descripcionPattern,
             final String levelpattern,
             final String patronType,
             final String template){
         final UnitPatternBean unitPatternBean = new UnitPatternBean();
         unitPatternBean.setClasspattern(classpattern);
         unitPatternBean.setDescripcion(descripcionPattern);
         unitPatternBean.setLevelpattern(levelpattern);
         unitPatternBean.setPatronType(patronType);
         unitPatternBean.setTemplate(template);
        return unitPatternBean;
     }

     /**
      *
      * @param answerHash
      * @param answers
      * @param questionId
      * @return
      */
     public UnitAnswersBean createAnswersBean(
             final String answerHash,
             final String answers,
             final Long questionId){
         final UnitAnswersBean answerBean = new UnitAnswersBean();
         answerBean.setAnswerHash(answerHash);
         answerBean.setAnswers(answers);
         answerBean.setQuestionId(questionId);
        return answerBean;
     }


    /**
     * Create Unit Tweet Poll.
     * @param allowLiveResults
     * @param closeNotification
     * @param completed
     * @param publicationDateTweet
     * @param publishPoll
     * @param resultNotification
     * @param schedule
     * @param scheduleDate
     * @param tweetUrl
     * @param userId
     * @param questionBean
     * @param userTwitterAccount
     * @return
     */

     public UnitTweetPoll createTweetPoll(
             final Boolean allowLiveResults,
             final Boolean closeNotification,
             final Boolean completed,
             final Date publicationDateTweet,
             final Boolean publishPoll,
             final Boolean resultNotification,
             final Boolean schedule,
             final Date scheduleDate,
             final String tweetUrl,
             final Long userId,
             final UnitQuestionBean questionBean,
             final String userTwitterAccount

             ){
         UnitTweetPoll unitTweetPoll = new UnitTweetPoll();
         unitTweetPoll.setUserId(userId);
         unitTweetPoll.setAllowLiveResults(allowLiveResults);
         unitTweetPoll.setCloseNotification(closeNotification);
         unitTweetPoll.setCompleted(completed);
         unitTweetPoll.setPublishPoll(publishPoll);
         unitTweetPoll.setQuestionBean(createUnitQuestionBean("", 1L, 1L, null, null));
         unitTweetPoll.setResultNotification(resultNotification);
         unitTweetPoll.setResults(null);
         unitTweetPoll.setSchedule(schedule);
         unitTweetPoll.setScheduleDate(scheduleDate);
         unitTweetPoll.setTweetUrl(tweetUrl);
         unitTweetPoll.setTwitterUserAccount(null);
        return unitTweetPoll;
     }

     /**
      * Helper
      * Create Unit Tweet Poll Publicated
      * @param publicationDateTweet
      * @param publishPoll
      * @param tweetUrl
      * @param userId
      * @param questionBean
      * @param userTwitterAccount
      * @return
      */
      public UnitTweetPoll createUnitTweetPollPublicated(
             final Date publicationDateTweet,
             final Boolean publishPoll,
             final String tweetUrl,
             final Long userId,
             final UnitQuestionBean questionBean,
             final String userTwitterAccount

             ){
     UnitTweetPoll unitTweetPoll = new UnitTweetPoll();
     unitTweetPoll.setUserId(userId);
     unitTweetPoll.setPublishPoll(publishPoll);
     unitTweetPoll.setQuestionBean(createUnitQuestionBean("", 1L, 1L, null, null));
     unitTweetPoll.setResults(null);
     unitTweetPoll.setTweetUrl(tweetUrl);
     unitTweetPoll.setTwitterUserAccount(null);
     return unitTweetPoll;
     }

    /**
     * Helper
     * Create Tweet Poll Publicated
     * @param publishTweetPoll
     * @param completed
     * @param scheduleDate
     * @param tweetOwner
     * @param question
     * @return
     */

     public TweetPoll createTweetPollPublicated(
              Boolean publishTweetPoll,
              Boolean completed,
              Date scheduleDate,
              SecUser tweetOwner,
              Question question){
         final TweetPoll tweetPoll = new TweetPoll();
         tweetPoll.setPublishTweetPoll(publishTweetPoll);
         tweetPoll.setCompleted(completed);
         tweetPoll.setScheduleDate(scheduleDate);
         tweetPoll.setEnabled(true);
         tweetPoll.setCreateDate(new Date());
         tweetPoll.setQuestion(question);
         tweetPoll.setTweetOwner(tweetOwner);
         getTweetPoll().saveOrUpdate(tweetPoll);
         return tweetPoll;
     }

     /**
      *
      * @param tweetPoll<commit_msg>Fixed failure.<commit_after>/*
 ************************************************************************************
 * Copyright (C) 2001-2009 encuestame: system online surveys Copyright (C) 2009
 * encuestame Development Team.
 * Licensed under the Apache Software License version 2.0
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to  in writing,  software  distributed
 * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
 * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
 * specific language governing permissions and limitations under the License.
 ************************************************************************************
 */
package org.encuestame.test.config;

import java.util.Date;
import java.util.List;

import org.encuestame.persistence.domain.LocationFolderType;
import org.encuestame.persistence.domain.Question;
import org.encuestame.persistence.domain.security.SecUser;
import org.encuestame.persistence.domain.survey.QuestionsAnswers;
import org.encuestame.persistence.domain.survey.TweetPoll;
import org.encuestame.persistence.domain.survey.TweetPollSwitch;
import org.encuestame.utils.security.SignUpBean;
import org.encuestame.utils.web.UnitAnswersBean;
import org.encuestame.utils.web.UnitEmails;
import org.encuestame.utils.web.UnitLists;
import org.encuestame.utils.web.UnitLocationBean;
import org.encuestame.utils.web.UnitLocationFolder;
import org.encuestame.utils.web.UnitPatternBean;
import org.encuestame.utils.web.UnitQuestionBean;
import org.encuestame.utils.web.UnitTweetPoll;
import org.encuestame.utils.web.UnitUserBean;


/**
 * Abstract Base Unit Beans.
 * @author <NAME>, Diana <EMAIL>
 * @since 19/04/2010 20:54:56
 * @version $Id:$
 */

public abstract class AbstractBaseUnitBeans extends AbstractBase{

    /**
     * Create Unit Question Helper.
     * @param questionName
     * @param stateId
     * @param userId
     * @param listAnswers
     * @param pattern
     * @return
     */
    @SuppressWarnings("unchecked")
    public UnitQuestionBean createUnitQuestionBean(
            final String questionName,
            final Long stateId,
            final Long userId,
            final List listAnswers,
            final UnitPatternBean pattern){
         final UnitQuestionBean question = new UnitQuestionBean();
         question.setQuestionName(questionName);
         question.setStateId(stateId);
         question.setUserId(userId);
         question.setListAnswers(listAnswers);
         question.setPattern(pattern);
         return question;
    }

    /**
     * Create Pattern Bean Helper.
     * @param classpattern
     * @param descripcionPattern
     * @param levelpattern
     * @param patronType
     * @param template
     * @return
     */
     public UnitPatternBean createPatternBean(
             final String classpattern,
             final String descripcionPattern,
             final String levelpattern,
             final String patronType,
             final String template){
         final UnitPatternBean unitPatternBean = new UnitPatternBean();
         unitPatternBean.setClasspattern(classpattern);
         unitPatternBean.setDescripcion(descripcionPattern);
         unitPatternBean.setLevelpattern(levelpattern);
         unitPatternBean.setPatronType(patronType);
         unitPatternBean.setTemplate(template);
        return unitPatternBean;
     }

     /**
      *
      * @param answerHash
      * @param answers
      * @param questionId
      * @return
      */
     public UnitAnswersBean createAnswersBean(
             final String answerHash,
             final String answers,
             final Long questionId){
         final UnitAnswersBean answerBean = new UnitAnswersBean();
         answerBean.setAnswerHash(answerHash);
         answerBean.setAnswers(answers);
         answerBean.setQuestionId(questionId);
        return answerBean;
     }


    /**
     * Create Unit Tweet Poll.
     * @param allowLiveResults
     * @param closeNotification
     * @param completed
     * @param publicationDateTweet
     * @param publishPoll
     * @param resultNotification
     * @param schedule
     * @param scheduleDate
     * @param tweetUrl
     * @param userId
     * @param questionBean
     * @param userTwitterAccount
     * @return
     */

     public UnitTweetPoll createTweetPoll(
             final Boolean allowLiveResults,
             final Boolean closeNotification,
             final Boolean completed,
             final Date publicationDateTweet,
             final Boolean publishPoll,
             final Boolean resultNotification,
             final Boolean schedule,
             final Date scheduleDate,
             final String tweetUrl,
             final Long userId,
             final UnitQuestionBean questionBean,
             final String userTwitterAccount

             ){
         UnitTweetPoll unitTweetPoll = new UnitTweetPoll();
         unitTweetPoll.setUserId(userId);
         unitTweetPoll.setAllowLiveResults(allowLiveResults);
         unitTweetPoll.setCloseNotification(closeNotification);
         unitTweetPoll.setCompleted(completed);
         unitTweetPoll.setPublishPoll(publishPoll);
         unitTweetPoll.setQuestionBean(createUnitQuestionBean("", 1L, 1L, null, null));
         unitTweetPoll.setResultNotification(resultNotification);
         unitTweetPoll.setResults(null);
         unitTweetPoll.setSchedule(schedule);
         unitTweetPoll.setScheduleDate(scheduleDate);
         unitTweetPoll.setTweetUrl(tweetUrl);
         unitTweetPoll.setTwitterUserAccount(null);
        return unitTweetPoll;
     }

     /**
      * Helper
      * Create Unit Tweet Poll Publicated
      * @param publicationDateTweet
      * @param publishPoll
      * @param tweetUrl
      * @param userId
      * @param questionBean
      * @param userTwitterAccount
      * @return
      */
      public UnitTweetPoll createUnitTweetPollPublicated(
             final Date publicationDateTweet,
             final Boolean publishPoll,
             final String tweetUrl,
             final Long userId,
             final UnitQuestionBean questionBean,
             final String userTwitterAccount

             ){
     UnitTweetPoll unitTweetPoll = new UnitTweetPoll();
     unitTweetPoll.setUserId(userId);
     unitTweetPoll.setPublishPoll(publishPoll);
     unitTweetPoll.setQuestionBean(createUnitQuestionBean("", 1L, 1L, null, null));
     unitTweetPoll.setResults(null);
     unitTweetPoll.setTweetUrl(tweetUrl);
     unitTweetPoll.setTwitterUserAccount(null);
     return unitTweetPoll;
     }

    /**
     * Helper
     * Create Tweet Poll Publicated
     * @param publishTweetPoll
     * @param completed
     * @param scheduleDate
     * @param tweetOwner
     * @param question
     * @return
     */

     public TweetPoll createTweetPollPublicated(
              Boolean publishTweetPoll,
              Boolean completed,
              Date scheduleDate,
              SecUser tweetOwner,
              Question question){
         final TweetPoll tweetPoll = new TweetPoll();
         tweetPoll.setPublishTweetPoll(publishTweetPoll);
         tweetPoll.setCompleted(completed);
         tweetPoll.setScheduleDate(scheduleDate);
         tweetPoll.setCreateDate(new Date());
         tweetPoll.setQuestion(question);
         tweetPoll.setTweetOwner(tweetOwner);
         getTweetPoll().saveOrUpdate(tweetPoll);
         return tweetPoll;
     }

     /**
      *
      * @param tweetPoll
{'fraction_non_alphanumeric': 0.09454855195911414, 'fraction_numerical': 0.004455510418031713, 'mean_word_length': 2.70281416787967, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5456258', 'n_tokens_mistral': 4168, 'n_tokens_neox': 4061, 'n_words': 897}