Package org.encuestame.persistence.domain

Examples of org.encuestame.persistence.domain.AccessRate


         final Question question = createQuestion("Who are you?", "");
         final TweetPoll tp = createPublishedTweetPoll(getSpringSecurityLoggedUserAccount().getAccount(), question);
         final String ipAddress = "192.168.1.81";
         flushIndexes();
         // I like it vote.
         final AccessRate rate = getFrontEndService().registerAccessRate(
                 TypeSearchResult.TWEETPOLL,
                 tp.getTweetPollId(),
                 ipAddress,
                 Boolean.TRUE);
         Assert.assertNotNull(rate);

         // I like it vote again.
         String ipAddress2 = "192.168.1.82";
         final AccessRate rate2 = getFrontEndService().registerAccessRate(
                 TypeSearchResult.TWEETPOLL,
                 tp.getTweetPollId(),
                 ipAddress2,
                 Boolean.TRUE);
         Assert.assertNotNull(rate2);

         // I don't like it vote.
         final AccessRate rate3 = getFrontEndService().registerAccessRate(
                 TypeSearchResult.TWEETPOLL,
                 tp.getTweetPollId(),
                 ipAddress,
                 Boolean.FALSE);
         Assert.assertNotNull(rate3);
View Full Code Here


     * java.lang.String, java.lang.Boolean)
     */
    public AccessRate registerAccessRate(final TypeSearchResult type,
            final Long itemId, final String ipAddress, final Boolean rate)
            throws EnMeExpcetion {
        AccessRate recordAccessRate = new AccessRate();
        if (ipAddress != null) {
            if (type.equals(TypeSearchResult.TWEETPOLL)) {
                // Find tweetPoll by itemId.
                final TweetPoll tweetPoll = this.getTweetPoll(itemId);
                Assert.assertNotNull(tweetPoll);
View Full Code Here

    private AccessRate checkExistTweetPollPreviousRecord(final TweetPoll tpoll,
            final String ipAddress, final Boolean option) throws EnMeExpcetion {
        // Search record by tweetPpll in access Rate domain.
        List<AccessRate> rateList = this.getAccessRateItem(ipAddress,
                tpoll.getTweetPollId(), TypeSearchResult.TWEETPOLL);
        final AccessRate accessRate;
        if (rateList.size() > 1) {
            throw new EnMeExpcetion(
                    "Access rate list found coudn't be greater than one ");
        } else if (rateList.size() == 1) {
            // Get first element from access rate list
            accessRate = rateList.get(0);
            // Check if the option selected is the same that you have registered
            if (accessRate.getRate() == option) {
                log.warn("The option was previously selected "
                        + accessRate.getRate());
            } else {
                // We proceed to update the record in the table access Rate.
                accessRate.setRate(option);
                // Update the value in the fields of TweetPoll
                this.setTweetPollSocialOption(option, tpoll);
                // Save access rate record.
                getFrontEndDao().saveOrUpdate(accessRate);
            }
View Full Code Here

    private AccessRate checkExistPollPreviousRecord(final Poll poll,
            final String ipAddress, final Boolean option) throws EnMeExpcetion {
        // Search record by poll in access Rate domain.
        List<AccessRate> rateList = this.getAccessRateItem(ipAddress,
                poll.getPollId(), TypeSearchResult.POLL);
        final AccessRate accessRate;
        if (rateList.size() > 1) {
            throw new EnMeExpcetion(
                    "Access rate list found coudn't be greater than one ");
        } else if (rateList.size() == 1) {
            // Get first element from access rate list
            accessRate = rateList.get(0);
            // Check if the option selected is the same that you have registered
            if (accessRate.getRate() == option) {
                log.warn("The option was previously selected "
                        + accessRate.getRate());
            } else {
                // We proceed to update the record in the table access Rate.
                accessRate.setRate(option);
                // Update the value in the fields of TweetPoll
                this.setPollSocialOption(option, poll);
                // Save access rate record.
                getFrontEndDao().saveOrUpdate(accessRate);
            }
View Full Code Here

    private AccessRate checkExistSurveyPreviousRecord(final Survey survey,
            final String ipAddress, final Boolean option) throws EnMeExpcetion {
        // Search record by survey in access Rate domain.
        List<AccessRate> rateList = this.getAccessRateItem(ipAddress,
                survey.getSid(), TypeSearchResult.SURVEY);
        final AccessRate accessRate;
        if (rateList.size() > 1) {
            throw new EnMeExpcetion(
                    "Access rate list found coudn't be greater than one ");
        } else if (rateList.size() == 1) {
            // Get first element from access rate list
            accessRate = rateList.get(0);
            // Check if the option selected is the same that you have registered
            if (accessRate.getRate() == option) {
                log.warn("The option was previously selected "
                        + accessRate.getRate());
            } else {
                // We proceed to update the record in the table access Rate.
                accessRate.setRate(option);
                // Update the value in the fields of survey
                this.setSurveySocialOption(option, survey);
                // Save access rate record.
                getFrontEndDao().saveOrUpdate(accessRate);
            }
View Full Code Here

     */
    @Transactional(readOnly = false)
    private AccessRate newAccessRateItem(final TweetPoll tweetPoll,
            final Poll poll, final Survey survey, final String ipAddress,
            final Boolean rate) {
        final AccessRate itemRate = new AccessRate();
        itemRate.setTweetPoll(tweetPoll);
        itemRate.setPoll(poll);
        itemRate.setSurvey(survey);
        itemRate.setRate(rate);
        itemRate.setUser(null);
        itemRate.setIpAddress(ipAddress);
        getTweetPollDao().saveOrUpdate(itemRate);
        return itemRate;
    }
View Full Code Here

     * @param ipAddress
     * @return
     */
    public AccessRate createAccessRateItem(final Boolean rate, final TweetPoll tpoll, final Survey survey, final Poll poll,
            final UserAccount user, final String ipAddress){
        final AccessRate vote = new AccessRate();
        vote.setRate(rate);
        vote.setTweetPoll(tpoll);
        vote.setPoll(poll);
        vote.setSurvey(survey);
        vote.setUser(user);
        vote.setIpAddress(ipAddress);
        vote.setUpdatedDate(Calendar.getInstance().getTime());
        getTweetPoll().saveOrUpdate(vote);
        return vote;
    }
View Full Code Here

         final Question question = createQuestion("Who will win the Champions League match today?", "");
         final Account account = createAccount();
         final UserAccount user = createUserAccount("carlos", account);
         final TweetPoll tpoll = createPublishedTweetPoll(account, question);
         final Comment comment = createDefaultTweetPollComment("my first comment", tpoll, user);
         final AccessRate rateItem = new AccessRate();
         rateItem.setRate(Boolean.TRUE);
         rateItem.setUser(user);
         rateItem.setTweetPoll(tpoll);
         rateItem.setPoll(null);
         rateItem.setSurvey(null);
         rateItem.setUpdatedDate(Calendar.getInstance().getTime());
         rateItem.setComments(comment);

    }
View Full Code Here

TOP

Related Classes of org.encuestame.persistence.domain.AccessRate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.