Package org.encuestame.persistence.domain

Examples of org.encuestame.persistence.domain.Hit


    @Test
    public void testHashTagStatByRange() throws ServletException, IOException{
      final Calendar myDate = Calendar.getInstance();
      final HashTag hashTag1 = createHashTag("software2")
      
      final Hit hit1 = createHashTagHit(hashTag1, "192.168.1.1");
      final Hit hit2 = createHashTagHit(hashTag1, "192.168.1.2");
      
      hit1.setHitDate(myDate.getTime());
      getTweetPoll().saveOrUpdate(hit1);
    
      myDate.add(Calendar.DATE, -4);
      hit2.setHitDate(myDate.getTime());
      getTweetPoll().saveOrUpdate(hit2);
     
      initService("/api/common/hashtags/stats/button/range.json", MethodJson.GET);
    setParameter("tagName", hashTag1.getHashTag());
    setParameter("period", "7");
View Full Code Here


        Status status = Status.SUCCESS;
        final Long INCREASE_VOTES = 1L;
        final String userVote = getUserPrincipalUsername();
        log.debug("registerVote: "+userVote);
        final Hit hit = new Hit();
        hit.setHitCategory(HitCategory.VOTE);
        hit.setIpAddress(ipAddress);
            try {
                //vote process
                if (searchResult.equals(TypeSearchResult.TWEETPOLL)) {
                    final TweetPoll tp = getTweetPollService().getTweetPollPublishedById(itemId);
                    final Long votes = tp.getNumbervotes() + INCREASE_VOTES;
                    tp.setNumbervotes(votes);
                    hit.setTweetPoll(tp);
                    getTweetPollDao().saveOrUpdate(tp);
                } else if (searchResult.equals(TypeSearchResult.POLL)) {
                    final Poll poll = getPollService().getPollById(itemId);
                    final Long votes = poll.getNumbervotes() + INCREASE_VOTES;
                    poll.setNumbervotes(votes);
                    getPollDao().saveOrUpdate(poll);
                    hit.setPoll(poll);
                } 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);
                status = Status.FAILED;
            }
View Full Code Here

     * org.encuestame.persistence.domain.HashTag, java.lang.String)
     */
    public Boolean registerHit(final TweetPoll tweetPoll, final Poll poll,
            final Survey survey, final HashTag tag, final String ip, final HitCategory hitCategory)
            throws EnMeNoResultsFoundException {
        final Hit hit;
        Long hitCount = 1L;
        Boolean register = false;
        // HashTag
        if (ip != null) {
            if (tag != null) {
View Full Code Here

     */

    @Transactional(readOnly = false)
    private Hit newHitItem(final TweetPoll tweetPoll, final Poll poll,
            final Survey survey, final HashTag tag, final String ipAddress, final HitCategory hitCategory) {
        final Hit hitItem = new Hit();
        hitItem.setHitDate(Calendar.getInstance().getTime());
        hitItem.setHashTag(tag);
        hitItem.setIpAddress(ipAddress);
        hitItem.setTweetPoll(tweetPoll);
        hitItem.setPoll(poll);
        hitItem.setSurvey(survey);
        hitItem.setHitCategory(hitCategory);
        getFrontEndDao().saveOrUpdate(hitItem);
        return hitItem;
    }
View Full Code Here

    @Test
    public void testGetTotalHitsUsagebyHashTagAndDateRange() throws EnMeNoResultsFoundException, EnMeSearchException{
        final Calendar myDate = Calendar.getInstance();
        final HashTag hashTag1 = createHashTag("software2");

        final Hit hit1 = createHashTagHit(hashTag1, "192.168.1.1");
        final Hit hit2 = createHashTagHit(hashTag1, "192.168.1.2");

        hit1.setHitDate(myDate.getTime());
        getTweetPoll().saveOrUpdate(hit1);

        myDate.add(Calendar.DATE, -4);
        hit2.setHitDate(myDate.getTime());
        getTweetPoll().saveOrUpdate(hit2);


        final List<HashTagDetailStats> tagHitsDetailList = getStatisticsService().getTotalHitsUsagebyHashTagAndDateRange(hashTag1.getHashTag(), SearchPeriods.SEVENDAYS, this.request);
        Assert.assertEquals("Should be equals", 2, tagHitsDetailList.size());
View Full Code Here

     * @param ipAddress
     * @return
     */
    public Hit createHit(final TweetPoll tweetPoll, final Poll poll, final Survey survey, final HashTag hashTag,
            final String ipAddress){
        final Hit hit = new Hit();
        hit.setHitDate(Calendar.getInstance().getTime());
        hit.setIpAddress(ipAddress);
        hit.setPoll(poll);
        hit.setSurvey(survey);
        hit.setTweetPoll(tweetPoll);
        hit.setHashTag(hashTag);
        hit.setHitCategory(HitCategory.VISIT);
        getFrontEndDao().saveOrUpdate(hit);
        return hit;
    }
View Full Code Here

    * @param ipAddress
    * @param hitDate
    * @return
    */
    public Hit createHashTagHit(final HashTag tag, final String ipAddress, final Date hitDate){
        final Hit visit = this.createHit(null, null, null, tag, ipAddress);
        visit.setHitDate(hitDate);
        return visit;
    }
View Full Code Here

    /**
     * Test {@link Hit} Domain.
     */
    @Test
    public void testHit() {
        final Hit hit = new Hit();
        hit.setHashTag(this.initHashTag);
        hit.setHitCategory(hitCat);
        hit.setHitDate(new Date());
        hit.setIpAddress("");
        hit.setPoll(initPoll);
        hit.setSurvey(initSurvey);
        hit.setTweetPoll(initTweetPoll);
        hit.setUserAccount(initUser);
        getHashTagDao().saveOrUpdate(hit);
        assertNotNull(hit.getId());
    }
View Full Code Here

        final HashTag hashTag1 = createHashTag("software2");

        final String ipAddress1 = "192.168.1.1";
        final String ipAddress2 = "192.168.1.2";

        final Hit hit1 = createHashTagHit(hashTag1, ipAddress1);
        final Hit hit2 = createHashTagHit(hashTag1, ipAddress2);

        hit1.setHitDate(myDate.getTime());
        getTweetPoll().saveOrUpdate(hit1);

        // It created today, setted with minus 5 days. so the new date is between friday or Saturday ago
        // out of range
        myDate.add(Calendar.DATE, -9);
        hit2.setHitDate(myDate.getTime());
        getTweetPoll().saveOrUpdate(hit2);

        // Retrieve hits for tag Id in the last 7 days.
        List<Hit> myHits = getFrontEndDao().getHashTagHitsbyDateRange( hashTag1.getHashTagId(), 7);
        assertEquals("Should be equals", 1, myHits.size());
View Full Code Here

TOP

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

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.