Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.HitCountData


        try {
            Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
            Criteria criteria = session.createCriteria(HitCountData.class);
           
            criteria.add(Expression.eq("id", id));
            HitCountData hitCount = (HitCountData) criteria.uniqueResult();
           
            return hitCount;
        } catch (HibernateException e) {
            throw new RollerException(e);
        }
View Full Code Here


        try {
            Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
            Criteria criteria = session.createCriteria(HitCountData.class);
           
            criteria.add(Expression.eq("weblog", weblog));
            HitCountData hitCount = (HitCountData) criteria.uniqueResult();
           
            return hitCount;
        } catch (HibernateException e) {
            throw new RollerException(e);
        }
View Full Code Here

       
        Criteria criteria = session.createCriteria(HitCountData.class);
        criteria.add(Expression.eq("weblog", weblog));
        criteria.setMaxResults(1);
       
        HitCountData hitCount = (HitCountData) criteria.uniqueResult();
       
        // create it if it doesn't exist
        if(hitCount == null && amount > 0) {
            hitCount = new HitCountData();
            hitCount.setWeblog(weblog);
            hitCount.setDailyHits(amount);
            strategy.store(hitCount);
        } else if(hitCount != null) {
            hitCount.setDailyHits(hitCount.getDailyHits() + amount);
            strategy.store(hitCount);
        }
    }
View Full Code Here

     */
    public void testHitCountCRUD() throws Exception {
       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
       
        HitCountData testCount = new HitCountData();
        testCount.setWeblog(testWeblog);
        testCount.setDailyHits(10);
       
        // create
        mgr.saveHitCount(testCount);
        String id = testCount.getId();
        TestUtils.endSession(true);
       
        // make sure it was created
        HitCountData hitCount = null;
        hitCount = mgr.getHitCount(id);
        assertNotNull(hitCount);
        assertEquals(testCount, hitCount);
        assertEquals(10, hitCount.getDailyHits());
       
        // update
        hitCount.setDailyHits(25);
        mgr.saveHitCount(hitCount);
        TestUtils.endSession(true);
       
        // make sure it was updated
        hitCount = null;
        hitCount = mgr.getHitCount(id);
        assertNotNull(hitCount);
        assertEquals(testCount, hitCount);
        assertEquals(25, hitCount.getDailyHits());
       
        // delete
        mgr.removeHitCount(hitCount);
        TestUtils.endSession(true);
       
View Full Code Here

   
    public void testHitCountLookups() throws Exception {
       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
       
        HitCountData testCount = new HitCountData();
        testCount.setWeblog(testWeblog);
        testCount.setDailyHits(10);
       
        // create
        mgr.saveHitCount(testCount);
        String id = testCount.getId();
        TestUtils.endSession(true);
       
        // test lookup by id
        HitCountData hitCount = null;
        hitCount = mgr.getHitCount(id);
        assertNotNull(hitCount);
        assertEquals(testCount, hitCount);
        assertEquals(10, hitCount.getDailyHits());
       
        // test lookup by weblog
        hitCount = null;
        hitCount = mgr.getHitCountByWeblog(testWeblog);
        assertNotNull(hitCount);
        assertEquals(testCount, hitCount);
        assertEquals(10, hitCount.getDailyHits());
       
        // delete
        mgr.removeHitCount(hitCount);
        TestUtils.endSession(true);
       
View Full Code Here

   
    public void testIncrementHitCount() throws Exception {
       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
       
        HitCountData testCount = new HitCountData();
        testCount.setWeblog(testWeblog);
        testCount.setDailyHits(10);
       
        // create
        mgr.saveHitCount(testCount);
        String id = testCount.getId();
        TestUtils.endSession(true);
       
        // make sure it was created
        HitCountData hitCount = null;
        hitCount = mgr.getHitCountByWeblog(testWeblog);
        assertNotNull(hitCount);
        assertEquals(10, hitCount.getDailyHits());
       
        // increment
        mgr.incrementHitCount(testWeblog, 25);
        TestUtils.endSession(true);
       
        // make sure it was incremented properly
        hitCount = null;
        hitCount = mgr.getHitCountByWeblog(testWeblog);
        assertNotNull(hitCount);
        assertEquals(35, hitCount.getDailyHits());
       
        // delete
        mgr.removeHitCount(hitCount);
        TestUtils.endSession(true);
       
View Full Code Here

       
        WebsiteData blog1 = TestUtils.setupWeblog("hitCntTest1", testUser);
        WebsiteData blog2 = TestUtils.setupWeblog("hitCntTest2", testUser);
        WebsiteData blog3 = TestUtils.setupWeblog("hitCntTest3", testUser);
       
        HitCountData cnt1 = TestUtils.setupHitCount(blog1, 10);
        HitCountData cnt2 = TestUtils.setupHitCount(blog2, 20);
        HitCountData cnt3 = TestUtils.setupHitCount(blog3, 30);
       
        TestUtils.endSession(true);
       
        // make sure data was properly initialized
        HitCountData testCount = null;
        testCount = mgr.getHitCount(cnt1.getId());
        assertEquals(10, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt2.getId());
        assertEquals(20, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt3.getId());
        assertEquals(30, testCount.getDailyHits());
       
        // reset count for one weblog
        mgr.resetHitCount(blog1);
        TestUtils.endSession(true);
       
        // make sure it reset only one weblog
        testCount = mgr.getHitCount(cnt1.getId());
        assertEquals(0, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt2.getId());
        assertEquals(20, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt3.getId());
        assertEquals(30, testCount.getDailyHits());
       
        // reset all counts
        mgr.resetAllHitCounts();
        TestUtils.endSession(true);
       
        // make sure it reset all counts
        testCount = mgr.getHitCount(cnt1.getId());
        assertEquals(0, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt2.getId());
        assertEquals(0, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt3.getId());
        assertEquals(0, testCount.getDailyHits());
       
        // cleanup
        TestUtils.teardownHitCount(cnt1.getId());
        TestUtils.teardownHitCount(cnt2.getId());
        TestUtils.teardownHitCount(cnt3.getId());
View Full Code Here

       
        WebsiteData blog1 = TestUtils.setupWeblog("hitCntHotTest1", testUser);
        WebsiteData blog2 = TestUtils.setupWeblog("hitCntHotTest2", testUser);
        WebsiteData blog3 = TestUtils.setupWeblog("hitCntHotTest3", testUser);
       
        HitCountData cnt1 = TestUtils.setupHitCount(blog1, 10);
        HitCountData cnt2 = TestUtils.setupHitCount(blog2, 20);
        HitCountData cnt3 = TestUtils.setupHitCount(blog3, 30);
       
        TestUtils.endSession(true);
       
        // make sure data was properly initialized
        HitCountData testCount = null;
        testCount = mgr.getHitCount(cnt1.getId());
        assertEquals(10, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt2.getId());
        assertEquals(20, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt3.getId());
        assertEquals(30, testCount.getDailyHits());
       
        // get hot weblogs
        List hotBlogs = mgr.getHotWeblogs(1, 0, 5);
        assertNotNull(hotBlogs);
        assertEquals(3, hotBlogs.size());
       
        // also check ordering and values
        HitCountData hitCount = null;
        Iterator it = hotBlogs.iterator();
        for(int i=3; it.hasNext(); i--) {
            hitCount = (HitCountData) it.next();
           
            assertEquals(i*10, hitCount.getDailyHits());
        }
       
        // cleanup
        TestUtils.teardownHitCount(cnt1.getId());
        TestUtils.teardownHitCount(cnt2.getId());
View Full Code Here

            WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
            List hotBlogs = mgr.getHotWeblogs(sinceDays, 0, length);
           
            Iterator hitCounts = hotBlogs.iterator();
            while (hitCounts.hasNext()) {
                HitCountData hitCount = (HitCountData) hitCounts.next();
               
                results.add(new StatCount(
                    hitCount.getWeblog().getId(),
                    hitCount.getWeblog().getHandle(),
                    hitCount.getWeblog().getName(),
                    "statCount.weblogDayHits",
                    hitCount.getDailyHits()));             
            }
           
        } catch (Exception e) {
            log.error("ERROR: fetching hot weblog list", e);
        }
View Full Code Here

    //------------------------------------------------------------------------
   
    /** Encapsulates RefererManager */
    public int getDayHits() {
        try {
            HitCountData hitCount = mWeblogMgr.getHitCountByWeblog(mWebsite);
           
            return (hitCount != null) ? hitCount.getDailyHits() : 0;
           
        } catch (RollerException e) {
            mLogger.error("PageModel getDayHits()", e);
        }
        return 0;
View Full Code Here

TOP

Related Classes of org.apache.roller.pojos.HitCountData

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.