Examples of WeblogHitCount


Examples of org.apache.roller.weblogger.pojos.WeblogHitCount

            throw new WebloggerException("Website cannot be NULL.");
        }
       
        Query q = strategy.getNamedQuery("WeblogHitCount.getByWeblog");
        q.setParameter(1, weblog);
        WeblogHitCount hitCount = null;
        try {
            hitCount = (WeblogHitCount)q.getSingleResult();
        } catch (NoResultException e) {
            hitCount = null;
        }
       
        // create it if it doesn't exist
        if(hitCount == null && amount > 0) {
            hitCount = new WeblogHitCount();
            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

Examples of org.apache.roller.weblogger.pojos.WeblogHitCount

     * @inheritDoc
     */
    public void resetHitCount(Weblog weblog) throws WebloggerException {
        Query q = strategy.getNamedQuery("WeblogHitCount.getByWeblog");
        q.setParameter(1, weblog);
        WeblogHitCount hitCount = null;
        try {
            hitCount = (WeblogHitCount)q.getSingleResult();
            hitCount.setDailyHits(0);
            strategy.store(hitCount);
        } catch (NoResultException e) {
            // ignore: no hit count for weblog
        }      

View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogHitCount

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

Examples of org.apache.roller.weblogger.pojos.WeblogHitCount

            throws Exception {
       
        WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();
       
        // store
        WeblogHitCount testCount = new WeblogHitCount();
        testCount.setWeblog(getManagedWebsite(weblog));
        testCount.setDailyHits(amount);
        mgr.saveHitCount(testCount);
       
        // flush to db
        WebloggerFactory.getWeblogger().flush();
       
        // query for it
        testCount = mgr.getHitCount(testCount.getId());
       
        if(testCount == null)
            throw new WebloggerException("error setting up hit count");
       
        return testCount;
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogHitCount

     */
    public static void teardownHitCount(String id) throws Exception {
       
        // query for it
        WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();
        WeblogHitCount testCount = mgr.getHitCount(id);
       
        // remove
        mgr.removeHitCount(testCount);
       
        // flush to db
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogHitCount

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

Examples of org.apache.roller.weblogger.pojos.WeblogHitCount

     */
    public void testHitCountCRUD() throws Exception {
       
        WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();
       
        WeblogHitCount testCount = new WeblogHitCount();
        testCount.setWeblog(testWeblog);
        testCount.setDailyHits(10);
       
        // create
        mgr.saveHitCount(testCount);
        String id = testCount.getId();
        TestUtils.endSession(true);
       
        // make sure it was created
        WeblogHitCount 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

Examples of org.apache.roller.weblogger.pojos.WeblogHitCount

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

Examples of org.apache.roller.weblogger.pojos.WeblogHitCount

   
    public void testIncrementHitCount() throws Exception {
       
        WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();
       
        WeblogHitCount testCount = new WeblogHitCount();
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        testCount.setWeblog(testWeblog);
        testCount.setDailyHits(10);
       
        // create
        mgr.saveHitCount(testCount);
        String id = testCount.getId();
        TestUtils.endSession(true);
       
        // make sure it was created
        WeblogHitCount hitCount = null;
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        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;
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        hitCount = mgr.getHitCountByWeblog(testWeblog);
        assertNotNull(hitCount);
        assertEquals(35, hitCount.getDailyHits());
       
        // delete
        mgr.removeHitCount(hitCount);
        TestUtils.endSession(true);
       
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogHitCount

        testUser = TestUtils.getManagedUser(testUser);
        Weblog blog1 = TestUtils.setupWeblog("hitCntTest1", testUser);
        Weblog blog2 = TestUtils.setupWeblog("hitCntTest2", testUser);
        Weblog blog3 = TestUtils.setupWeblog("hitCntTest3", testUser);
       
        WeblogHitCount cnt1 = TestUtils.setupHitCount(blog1, 10);
        WeblogHitCount cnt2 = TestUtils.setupHitCount(blog2, 20);
        WeblogHitCount cnt3 = TestUtils.setupHitCount(blog3, 30);
       
        TestUtils.endSession(true);
       
        try {
            // make sure data was properly initialized
            WeblogHitCount 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
            blog1 = TestUtils.getManagedWebsite(blog1);
            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());
       
        } finally {
            // cleanup
            TestUtils.teardownHitCount(cnt1.getId());
            TestUtils.teardownHitCount(cnt2.getId());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.