Package org.encuestame.persistence.domain.security

Examples of org.encuestame.persistence.domain.security.UserAccount


     */
    @Test
    @Category(DefaultTest.class)
    public void testGetUserAccountbyCode() throws EnMeNoResultsFoundException {
        final String inviteCode = RandomStringUtils.randomNumeric(6);
        final UserAccount account = createUserAccount("jota", "jota@jota.com",
                createAccount());
        account.setInviteCode(inviteCode);
        getAccountDao().saveOrUpdate(account);
        final UserAccountBean userAccBean = securityService
                .getUserAccountbyCode(inviteCode);
        assertNotNull(userAccBean);
    }
View Full Code Here


             */
            final TweetPollBean tweetPollBean = new TweetPollBean();
            //tweetPollBean.getHashTags().addAll();
            // save create tweet poll
            double randomUser = RandomUtils.nextInt(totalUsers);
            UserAccount u = userAccount.get(Double.valueOf(randomUser).intValue());
            SecurityUtils.authenticate(u);
            tweetPollBean.setUserId(u.getAccount().getUid());
            tweetPollBean.setCloseNotification(Boolean.FALSE);
           
            tweetPollBean.setResultNotification(Boolean.FALSE);           
            // all published by default
            tweetPollBean.setPublishPoll(Boolean.TRUE);
            // publish aleatory a publish poll.
//            int publish = RandomUtils.nextInt(10);
//            if (publish <= 7) {
//                tweetPollBean.setPublishPoll(Boolean.TRUE); // always TRUE
//            }
            // no scheduled tp in the demo data
            tweetPollBean.setSchedule(Boolean.FALSE);
            try {
                //final Question qm = createQuestion(question, u, QuestionPattern.CUSTOMIZABLE_SELECTION);
                final TweetPoll tweetPollDomain = getTweetPollService().createTweetPoll(tweetPollBean, question.getQuestionName(), u, null);

                //force to be published
                tweetPollDomain.setPublishTweetPoll(true);
                getTweetPollDao().saveOrUpdate(tweetPollDomain);
               
                double hits = getRandomNumberRange(2, EnMePlaceHolderConfigurer
                        .getIntegerProperty("demo.max.tweetpoll.hits"));
                for (int i = 0; i < hits; i++) {
                    getFrontEndService().registerHit(tweetPollDomain, null, null, null, EnMeUtils.ipGenerator(), HitCategory.VISIT);
                }

                double votes = getRandomNumberRange(10, EnMePlaceHolderConfigurer
                        .getIntegerProperty("demo.max.tweetpoll.votes"));
                for (int i = 0; i < votes; i++) {
                    getFrontEndService().registerVote(tweetPollDomain.getTweetPollId(), TypeSearchResult.TWEETPOLL, EnMeUtils.ipGenerator());
                }

                //TODO: make sense?
                //tpx.setHits(Long.valueOf(getRandomNumberRange(6, 5000)));
                //tpx.setNumbervotes(Long.valueOf(getRandomNumberRange(40, 10000)));

                tweetPollDomain.setPublishTweetPoll(true);
                Date tweetPollRandomDate = createRandomDate();
                tweetPollDomain.setCreateDate(tweetPollRandomDate);
                tweetPollDomain.setUpdatedDate(tweetPollRandomDate);
                getTweetPollDao().saveOrUpdate(tweetPollDomain);

                for (int i = 0; i < EnMePlaceHolderConfigurer
                        .getIntegerProperty("demo.max.tweetpoll.folder"); i++) {
                    log.debug("Creating folder name ....");
                    getTweetPollService().createTweetPollFolder(this.DEFAULT_FOLDER_NAME+"_"+i+"_", u.getUsername());
                }
                log.debug("New tweetpoll "+tweetPollDomain.getTweetPollId());

                for (CommentBean commentBean2 : comments) {
                    log.debug("New COMMENT tweetpoll ");
                    final Comment comment = new Comment();
                    comment.setTweetPoll(tweetPollDomain);
                    comment.setCreatedAt(createRandomDate());
                    comment.setComment(commentBean2.getComment());
                    comment.setDislikeVote(Long.valueOf(getRandomNumberRange(EnMePlaceHolderConfigurer
                            .getIntegerProperty("demo.min.comments.unlikes"), EnMePlaceHolderConfigurer
                            .getIntegerProperty("demo.max.comments.unlikes"))));
                    comment.setLikeVote(Long.valueOf(getRandomNumberRange(EnMePlaceHolderConfigurer
                            .getIntegerProperty("demo.min.comments.likes"), EnMePlaceHolderConfigurer
                            .getIntegerProperty("demo.max.comments.likes"))));
                    comment.setUser(userAccount.get(Double.valueOf(getRandomNumberRange(0, totalUsers) - 1).intValue()));
                    getTweetPollDao().saveOrUpdate(comment);
                    log.debug("Saved COMMENT tweetpoll ");
                }

                log.debug("Add hashtag to tweetpoll ");
                for (int i = 0; i < EnMePlaceHolderConfigurer
                        .getIntegerProperty("demo.hashtab.by.item"); i++) {
                    double htx = getRandomNumberRange(0, totalhashtagss) - 1;
                    final HashTagBean b = hashtags.get(Double.valueOf(htx).intValue());
                        log.debug("Adding Hashtag "+b.getHashTagName()+ " to tp "+tweetPollDomain.getTweetPollId());
                        final HashTag h = getTweetPollService().addHashtagToTweetPoll(tweetPollDomain, b);
                        h.setUpdatedDate(createRandomDate());
                        getTweetPollDao().saveOrUpdate(h);
                }

                List<QuestionAnswerBean> listOfAnswers = question.getListAnswers();
                log.debug("Ansswers in this questions  "+listOfAnswers.size());

                for (QuestionAnswerBean questionAnswerBean : listOfAnswers) {
                    final QuestionAnswerBean answerBean = new QuestionAnswerBean(questionAnswerBean.getAnswers());
                    answerBean.setShortUrlType(ShortUrlProvider.NONE);
                    //create tweetpoll swithch
                    final TweetPollSwitch tweetPollSwitch = getTweetPollService().createTweetPollQuestionAnswer(answerBean, tweetPollDomain, null);
                    double totalVotes = getRandomNumberRange(0, EnMePlaceHolderConfigurer.getIntegerProperty("demo.votes.by.tppoll")) - 1;
                    log.debug(totalVotes+" Votes for this tweetpolls switch id "+tweetPollSwitch.getSwitchId());
                    for (int i = 0; i < totalVotes; i++) {
                        getTweetPollService().tweetPollVote(tweetPollSwitch, EnMeUtils.ipGenerator(), createRandomDate());
                    }
                    //social links.
                    //final List<SocialAccountBean> eeeee = getSecurity().getValidSocialAccounts(SocialProvider.TWITTER, true);
                   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);
                       }
                    }
                }

            } catch (EnMeExpcetion e) {
View Full Code Here

            final Integer maxResults,
            final Boolean showUnSharedItems,
            final HttpServletRequest request) throws EnMeNoResultsFoundException {
            //get tweetpolls
      // TODO: parameter showUnSharedItems not used
        final UserAccount user = getUserAccount(username);
        log.debug("getLastItemsPublishedFromUserAccount: "+user.getUsername());
        final List<TweetPoll> lastTp = getTweetPollDao().getTweetPollByUsername(maxResults, user);
        log.debug("getLastItemsPublishedFromUserAccount lastTp: "+lastTp.size());
        final List<Poll> lastPoll = getPollDao().getPollByUserIdDate(null, user, maxResults, EnMeUtils.DEFAULT_START);
        log.debug("getLastItemsPublishedFromUserAccount lastPoll: "+lastPoll.size());
        final List<HomeBean> totalItems = new ArrayList<HomeBean>();
View Full Code Here

                } else if (searchResult.equals(TypeSearchResult.SURVEY)) {
                    //TODO: Vote a Survey.
                }
                //register the vote.
                if (!EnMeUtils.ANONYMOUS_USER.equals(userVote)) {
                    UserAccount userAccount = getUserAccount(userVote);
                    hit.setUserAccount(userAccount);
                    log.debug("registerVote by userAccount: "+userAccount.getUsername());
                }
                hit.setHitDate(Calendar.getInstance().getTime());
                getAccountDao().saveOrUpdate(hit);
            } catch (EnMeNoResultsFoundException e) {
                log.error(e);
View Full Code Here

     */
    public UserAccount createUserAccount(
            final String name,
            final String email,
            final Account secUser) {
        final UserAccount user= new UserAccount();
        user.setCompleteName(name);
        user.setUsername(name);
        user.setPassword("12345");
        user.setUserEmail(email.trim());
        user.setEnjoyDate(new Date());
        user.setInviteCode("xxxxxxx");
        user.setAccount(secUser);
        user.setUserStatus(true);
        getAccountDao().saveOrUpdate(user);
        return user;
    }
View Full Code Here

    public UserAccount createSecondaryUserGroup(
            final String name,
            final String email,
            final Account secUser,
            final Group group){
        final UserAccount user= new UserAccount();
        user.setCompleteName(name);
        user.setUsername(name);
        user.setPassword("12345");
        user.setUserEmail(email);
        user.setEnjoyDate(new Date());
        user.setInviteCode("xxxxxxx");
        user.setAccount(secUser);
        user.setUserStatus(true);
        user.setGroup(group);
        getAccountDao().saveOrUpdate(user);
        return user;
    }
View Full Code Here

     * @param name
     * @param account
     * @return
     */
    public UserAccount createUserAccount(final Boolean status, final Date createdAt , final String name, final Account account){
        final UserAccount userAcc = this.createUserAccount(name, account);
        userAcc.setEnjoyDate(createdAt);
        userAcc.setUserStatus(status);
        getAccountDao().saveOrUpdate(userAcc);
        return userAcc;
     }
View Full Code Here

    /**
     * Create Fast TweetPoll Votes.
     * @return tweet poll
     */
    public TweetPoll createFastTweetPollVotes(){
        final UserAccount secondary = createUserAccount("jhon-"+RandomStringUtils.randomAscii(4), createAccount());
        final Question question = createQuestion("who I am?", "");
        final QuestionAnswer questionsAnswers1 = createQuestionAnswer("yes", question, "12345");
        final QuestionAnswer questionsAnswers2 = createQuestionAnswer("no", question, "12346");
        final TweetPoll tweetPoll = createPublishedTweetPoll(secondary.getAccount(), question);
        final TweetPollSwitch pollSwitch1 = createTweetPollSwitch(questionsAnswers1, tweetPoll);
        final TweetPollSwitch pollSwitch2 = createTweetPollSwitch(questionsAnswers2, tweetPoll);
        createTweetPollResult(pollSwitch1, "192.168.0.1");
        createTweetPollResult(pollSwitch1, "192.168.0.2");
        createTweetPollResult(pollSwitch2, "192.168.0.3");
View Full Code Here

    public GeoPointFolder createGeoPointFolder(
            final GeoPointFolderType type,
            final Account secUsers,
            final String folderName,
            final GeoPointFolder locationFolder){
        final UserAccount userAcc = createUserAccount("Juan", secUsers);
        final GeoPointFolder geoPointFolder = new GeoPointFolder();
        geoPointFolder.setFolderType(type);
        geoPointFolder.setFolderName(folderName);
        geoPointFolder.setUsers(secUsers);
        geoPointFolder.setSubLocationFolder(locationFolder);
View Full Code Here

    @Override
    public UserDetails loadAccountConnection(
            final String profileId,
            final SocialProvider provider)
            throws EnMeNoSuchAccountConnectionException {
        UserAccount accountConnection = null;
        //log.debug("EnMeSocialAccountUserService "+profileId);
        //log.debug("EnMeSocialAccountUserService "+provider);
        try {
           accountConnection = this.accountDao.findAccountByConnection(provider, profileId);
        } catch (EnMeNoResultsFoundException e) {
View Full Code Here

TOP

Related Classes of org.encuestame.persistence.domain.security.UserAccount

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.