Package org.encuestame.persistence.domain.tweetpoll

Examples of org.encuestame.persistence.domain.tweetpoll.TweetPollSavedPublishedStatus


    final SocialAccount socialAccount = createDefaultSettedSocialAccount(this.userAcc);
    assertNotNull(socialAccount);
    final String tweetContent = "Tweet content text";

    final TweetPollSavedPublishedStatus tpSaved2 = createTweetPollSavedPublishedStatus(
        tp2, " ", socialAccount, tweetContent);
    tpSaved2.setApiType(SocialProvider.TWITTER);
    getTweetPoll().saveOrUpdate(tpSaved2);
    assertNotNull(tpSaved2);

    final TweetPollSavedPublishedStatus tpSaved = createTweetPollSavedPublishedStatus(
        this.initTweetPoll, " ", socialAccount, tweetContent);
    tpSaved.setApiType(SocialProvider.TWITTER);
    getTweetPoll().saveOrUpdate(tpSaved);
    assertNotNull(tpSaved);
    final JSONArray geoSocial = this.setJsonParameters(
        "/api/common/geolocation/search/socialnetwork.json",
        "socialGeo");
View Full Code Here


        //Total Usage by Social Networks
        final SocialAccount socialAccount = createDefaultSettedSocialAccount(getSpringSecurityLoggedUserAccount());
        assertNotNull(socialAccount);
        final String tweetContent = "Tweet content text";
        final TweetPollSavedPublishedStatus tpSaved = createTweetPollSavedPublishedStatus(
                myTweetPoll, " ", socialAccount, tweetContent);

        tpSaved.setApiType(SocialProvider.TWITTER);
        getTweetPoll().saveOrUpdate(tpSaved);
        assertNotNull(tpSaved);


        // Total Usaged by HashTag (TweetPoll, Poll or Survey)
View Full Code Here

        @PathVariable final String type,
            HttpServletRequest request, HttpServletResponse response,
            final UserAccount user)
            throws JsonGenerationException, JsonMappingException, IOException {
        try {
          final TweetPollSavedPublishedStatus tweetPoll = getTweetPollService().getTweetPollSavedPublishedStatusById(id);
            final Schedule schedule = this.getTweetPollService().createTweetPollPublishedStatusScheduled(
                bean.getScheduledDate(),
                TypeSearchResult.getTypeSearchResult(type),
                tweetPoll);
            final Map<String, Object> jsonResponse = new HashMap<String, Object>();
View Full Code Here

        //get social account
         final SocialAccount socialAccount = getAccountDao().getSocialAccountById(socialAccountId);
         Set<HashTag> hashTags = new HashSet<>();
         log.debug("publishTweetPoll socialTwitterAccounts: {"+socialAccount);
         //create tweet status
         final TweetPollSavedPublishedStatus publishedStatus = new TweetPollSavedPublishedStatus();
         //social provider.
         publishedStatus.setApiType(socialAccount.getAccounType());
         //checking required values.
         if (type.equals(TypeSearchResult.TWEETPOLL)) {
            //adding tweetpoll
             publishedStatus.setTweetPoll(tweetPoll);
             hashTags = tweetPoll.getHashTags();
         } else if(type.equals(TypeSearchResult.POLL)) {
            //adding tweetpoll
             publishedStatus.setPoll(poll);
             hashTags = poll.getHashTags();
         } else if(type.equals(TypeSearchResult.SURVEY)) {
             publishedStatus.setSurvey(survey);
             hashTags = survey.getHashTags();
         } else {
             log.error("Type not defined");
         }

         if (socialAccount != null) {
             log.debug("socialAccount Account NAME:{"+socialAccount.getSocialAccountName());
             //adding social account
             publishedStatus.setSocialAccount(socialAccount);
             try {
                 log.debug("publishTweetPoll Publishing... "+tweetText.length());
                 final TweetPublishedMetadata metadata = publicTweetPoll(tweetText, socialAccount, hashTags);
                 if (metadata == null || metadata.getTweetId() == null) {
                     throw new EnMeFailSendSocialTweetException("status not valid");
                 }//getMessageProperties(propertieId)
                 if (metadata.getTweetId() == null) {
                     log.warn("tweet id is empty");
                 }
                 //store original tweet id.
                 publishedStatus.setTweetId(metadata.getTweetId());
                 //store original publication date.
                 publishedStatus.setPublicationDateTweet(metadata.getDatePublished());
                 //success publish state..
                 publishedStatus.setStatus(Status.SUCCESS);
                 //store original tweet content.
                 publishedStatus.setTweetContent(metadata.getTextTweeted());
                 //create notification
                 //createNotification(NotificationEnum.TWEETPOLL_PUBLISHED, "tweet published", socialAccount.getAccount());
                 createNotification(NotificationEnum.SOCIAL_MESSAGE_PUBLISHED, tweetText, SocialUtils.getSocialTweetPublishedUrl(
                         metadata.getTweetId(), socialAccount.getSocialAccountName(), socialAccount.getAccounType()), Boolean.TRUE);
             } catch (Exception e) {
                 e.printStackTrace();
                 log.error("Error publish tweet:{"+e);
                 //change status to failed
                 publishedStatus.setStatus(Status.FAILED);
                 //store error descrition
                 if (e.getMessage() != null && e.getMessage().isEmpty()) {
                     publishedStatus.setDescriptionStatus(e.getMessage().substring(254)); //limited to 254 characters.
                 } else {
                     publishedStatus.setDescriptionStatus("");
                 }
                 //save original tweet content.
                 publishedStatus.setTweetContent(tweetText);
             }
         } else {
             log.warn("Twitter Account Not Found [Id:"+socialAccountId+"]");
             publishedStatus.setStatus(Status.FAILED);
             //throw new EnMeFailSendSocialTweetException("Twitter Account Not Found [Id:"+accountId+"]");
             if(type.equals(TypeSearchResult.TWEETPOLL)){
                tweetPoll.setPublishTweetPoll(Boolean.FALSE);
                //getTweetPollDao().saveOrUpdate(tweetPoll);
            }

         }
         log.info("Publish Status Social :{------------>"+publishedStatus.toString());
         getTweetPollDao().saveOrUpdate(publishedStatus);
         return publishedStatus;
    }
View Full Code Here

    /*
     * (non-Javadoc)
     * @see org.encuestame.core.service.imp.ITweetPollService#getTweetPollSavedPublishedStatusById(java.lang.Long)
     */
    public TweetPollSavedPublishedStatus getTweetPollSavedPublishedStatusById(final Long id) throws EnMeNoResultsFoundException{
        final TweetPollSavedPublishedStatus statusBean = getTweetPollDao().getTweetPollPublishedStatusbyId(id);
        if (statusBean == null) {
            throw new EnMeNoResultsFoundException("TweetPollSavedPublishedStatus [" + id
                    + "] is missing");
        }
        return statusBean;
View Full Code Here

        // 2. Iterate the results and for each try to publish again Call
        // Service to publish Tweetpoll/ Poll or Survey.
        // 3. If list > O - iterate list
        if (scheduledRecords.size() > 0) {
            for (Schedule schedule : scheduledRecords) {
                TweetPollSavedPublishedStatus tpollSaved = new TweetPollSavedPublishedStatus();
                // Retrieve attempt constant for properties file.
                if (schedule.getPublishAttempts() < 5) {
                    // Set Status PROCESSING
                    schedule.setStatus(Status.PROCESSING);
                    getScheduledDao().saveOrUpdate(schedule);

                    tpollSaved = this
                            .publishTweetBySocialAccountId(schedule
                                    .getSocialAccount().getId(), schedule
                                    .getTpoll(), schedule.getTweetText(),
                                    schedule.getTypeSearch(), schedule
                                            .getPoll(), schedule.getSurvey());
                     // If tpollsavedpublished isnt null and Status is failed, is
                    // necessary re publish
                    if ((tpollSaved != null) && (tpollSaved.getStatus()).equals(Status.FAILED)) {
                        log.trace("******* Item not published *******");
                        // Update ScheduleRecord and set counter und Date
                        DateTime dt = new DateTime(schedule.getScheduleDate());
                        // Set a new value to republishing
                        schedule.setScheduleDate(dt.plusMinutes(3).toDate());
                        // Increment the counter of attempts
                        int counter = schedule.getPublishAttempts();
                        counter = counter + 1;
                        schedule.setPublishAttempts(counter);
                        schedule.setStatus(Status.FAILED);
                        getScheduledDao().saveOrUpdate(schedule);
                    } else {
                        log.trace("******* Published *******");
                        final Date currentDate = DateUtil.getCurrentCalendarDate();
                        schedule.setStatus(Status.SUCCESS);
                        schedule.setPublicationDate(currentDate);
                        getScheduledDao().saveOrUpdate(schedule);
                        createNotification(NotificationEnum.WELCOME_SIGNUP,
                                getMessageProperties("notification.tweetpoll.scheduled.success",
                                          Locale.ENGLISH, //FIXME: fix this, locale is fixed
                                          new Object[] {tpollSaved.getTweetPoll().getQuestion().getQuestion(), currentDate.toString()}), //FIXME: currentDate shouldbe passed as ISO date.
                                null, false, tpollSaved.getTweetPoll().getEditorOwner());
                    }
                }
            }
        }
     }
View Full Code Here

                   final List<SocialAccount>eeee =  getAccountDao().getSocialVerifiedAccountByUserAccount(u.getAccount(), SocialProvider.TWITTER);
                   for (SocialAccount socialAccountBean : eeee) {
                       for (int i = 0; i < EnMePlaceHolderConfigurer
                                .getIntegerProperty("demo.max.tweetpoll.social.network.published"); i++) {
                        String tweetId = RandomStringUtils.random(6);
                        final TweetPollSavedPublishedStatus publishedStatus = new TweetPollSavedPublishedStatus();
                        //social provider.
                        publishedStatus.setApiType(SocialProvider.TWITTER);
                        publishedStatus.setSocialAccount(socialAccountBean);
                        //adding tweetpoll
                        publishedStatus.setTweetPoll(tweetPollDomain);
                        //store original tweet id.
                         publishedStatus.setTweetId(tweetId);
                         //store original publication date.
                         publishedStatus.setPublicationDateTweet(createRandomDate());
                         //success publish state..
                         publishedStatus.setStatus(Status.SUCCESS);
                         //store original tweet content.
                         publishedStatus.setTweetContent(question.getQuestionName());
                         getTweetPollDao().saveOrUpdate(publishedStatus);
                         //create notification
                         //createNotification(NotificationEnum.TWEETPOLL_PUBLISHED, "tweet published", socialAccount.getAccount());
                         createNotification(NotificationEnum.SOCIAL_MESSAGE_PUBLISHED, question.getQuestionName(), SocialUtils.getSocialTweetPublishedUrl(
                                 tweetId, u.getUsername(), socialAccountBean.getAccounType()), Boolean.TRUE);
View Full Code Here

    public void createTweetPollSavedPublishStatus(final TweetPoll tpoll,
            final SocialAccount socialAccount, final SocialProvider provider) {
        final String randomTweetContent = RandomStringUtils
                .randomAlphanumeric(6);

        final TweetPollSavedPublishedStatus tpSaved = this
                .createTweetPollSavedPublishedStatus(tpoll, " ", socialAccount,
                        randomTweetContent);

        tpSaved.setApiType(provider);
        tpSaved.setPublicationDateTweet(new Date());
        getTweetPoll().saveOrUpdate(tpSaved);
        assertNotNull(tpSaved);

    }
View Full Code Here

            final TweetPoll tpoll, final List<SocialProvider> provider,
            final SocialAccount socialAccount) {
        final String randomTweetContent = RandomStringUtils
                .randomAlphanumeric(6);
        for (SocialProvider providerList : provider) {
            final TweetPollSavedPublishedStatus tpSaved = this.createTweetPollSavedPublishedStatus(tpoll, "", socialAccount, randomTweetContent);
            tpSaved.setApiType(providerList);
            tpSaved.setPublicationDateTweet(new Date());
            getTweetPoll().saveOrUpdate(tpSaved);
            assertNotNull(tpSaved);
        }
    }
View Full Code Here

        // /
        final SocialAccount socialAccount = createDefaultSettedSocialAccount(this.secondary);
        assertNotNull(socialAccount);
        final String tweetContent = "Tweet content text";

        final TweetPollSavedPublishedStatus tpSaved = createTweetPollSavedPublishedStatus(
                tp, " ", socialAccount, tweetContent);

        tpSaved.setApiType(SocialProvider.TWITTER);
        tpSaved.setPublicationDateTweet(calendarDate.getTime());
        getTweetPoll().saveOrUpdate(tpSaved);
        assertNotNull(tpSaved);

        calendarDate.add(Calendar.MONTH, -2);

        final TweetPollSavedPublishedStatus tpSaved2 = createTweetPollSavedPublishedStatus(
                tp, " ", socialAccount, tweetContent);
        tpSaved2.setApiType(SocialProvider.FACEBOOK);
        tpSaved2.setPublicationDateTweet(calendarDate.getTime());
        getTweetPoll().saveOrUpdate(tpSaved2);
        assertNotNull(tpSaved2);

        // TweetPoll 3
        // calendarDate.add(Calendar.MONTH, -1);
        final TweetPoll tp3 = createPublishedTweetPoll(question, this.secondary);
        tp3.getHashTags().add(hashtag1);
        tp3.setCreateDate(calendarDate.getTime());
        getTweetPoll().saveOrUpdate(tp3);

        calendarDate.add(Calendar.MONTH, -2);
        final TweetPollSavedPublishedStatus tpSaved3 = createTweetPollSavedPublishedStatus(
                tp3, " ", socialAccount, tweetContent);
        tpSaved3.setApiType(SocialProvider.FACEBOOK);
        tpSaved3.setPublicationDateTweet(calendarDate.getTime());
        getTweetPoll().saveOrUpdate(tpSaved3);
        assertNotNull(tpSaved3);

        // TweetPoll 4
        final TweetPoll tp4 = createPublishedTweetPoll(question, this.secondary);
        tp4.getHashTags().add(hashtag1);
        tp4.setCreateDate(calendarDate.getTime());
        getTweetPoll().saveOrUpdate(tp4);

        calendarDate.add(Calendar.MONTH, -1);
        final TweetPollSavedPublishedStatus tpSaved4 = createTweetPollSavedPublishedStatus(
                tp4, " ", socialAccount, tweetContent);
        tpSaved4.setApiType(SocialProvider.FACEBOOK);
        tpSaved4.setPublicationDateTweet(calendarDate.getTime());
        getTweetPoll().saveOrUpdate(tpSaved4);
        assertNotNull(tpSaved4);

        final TweetPollSavedPublishedStatus tpSaved5 = createTweetPollSavedPublishedStatus(
                tp2, " ", socialAccount, tweetContent);
        tpSaved5.setApiType(SocialProvider.FACEBOOK);
        tpSaved5.setPublicationDateTweet(calendarDate.getTime());
        getTweetPoll().saveOrUpdate(tpSaved5);
        assertNotNull(tpSaved5);
        //FIXME: methods not longer exist
//        final List<HashTagDetailStats> totalSocialLinksUsagebyHashTagAndTweetPoll = getStatisticsService()
//                .getTweetPollSocialNetworkLinksbyTagAndDateRange(
View Full Code Here

TOP

Related Classes of org.encuestame.persistence.domain.tweetpoll.TweetPollSavedPublishedStatus

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.