Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.WeblogEntryTagAggregateData


        // won't matter
       
        Criteria criteria = session.createCriteria(WeblogEntryTagAggregateData.class)
            .add(conjunction).addOrder(Order.desc("lastUsed")).setMaxResults(1);
       
        WeblogEntryTagAggregateData weblogTagData = (WeblogEntryTagAggregateData) criteria.uniqueResult();

        conjunction = Expression.conjunction();
        conjunction.add(Restrictions.eq("name", name));
        conjunction.add(Restrictions.isNull("weblog"));
       
        criteria = session.createCriteria(WeblogEntryTagAggregateData.class)
            .add(conjunction).addOrder(Order.desc("lastUsed")).setMaxResults(1);
   
        WeblogEntryTagAggregateData siteTagData = (WeblogEntryTagAggregateData) criteria.uniqueResult();
       
        Timestamp lastUsed = new Timestamp((new Date()).getTime());
       
        // create it only if we are going to need it.
        if(weblogTagData == null && amount > 0) {
            weblogTagData = new WeblogEntryTagAggregateData(null, website, name, amount);
            weblogTagData.setLastUsed(lastUsed);
            session.save(weblogTagData);
        } else if(weblogTagData != null) {
            session.createQuery("update WeblogEntryTagAggregateData set total = total + ?, lastUsed = current_timestamp() where name = ? and weblog = ?")
            .setInteger(0, amount)
            .setString(1, weblogTagData.getName())
            .setParameter(2, website)
            .executeUpdate();
        }
       
        // create it only if we are going to need it.       
        if(siteTagData == null && amount > 0) {
            siteTagData = new WeblogEntryTagAggregateData(null, null, name, amount);
            siteTagData.setLastUsed(lastUsed);
            session.save(siteTagData);
        } else if(siteTagData != null) {
            session.createQuery("update WeblogEntryTagAggregateData set total = total + ?, lastUsed = current_timestamp() where name = ? and weblog is null")
            .setInteger(0, amount)
            .setString(1, siteTagData.getName())
            .executeUpdate();           
        }      
       
        // delete all bad counts
        session.createQuery("delete from WeblogEntryTagAggregateData where total <= 0").executeUpdate();
View Full Code Here

TOP

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

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.