1 package com.dotmarketing.portlets.userclicks.factories; 2 3 4 import com.dotmarketing.beans.Clickstream; 5 import com.dotmarketing.beans.ClickstreamRequest; 6 import com.dotmarketing.db.DotConnect; 7 import com.dotmarketing.db.DotHibernate; 8 9 10 14 public class UserClickFactory { 15 16 private static final String GET_TOP_USER_CLICKSTREAMS = "SELECT {clickstream.*} from clickstream where user_id = ? order by clickstream_id desc"; 17 private static final String COUNT_USER_CLICKS = "SELECT count(*) as test from clickstream where user_id = ?"; 18 19 public static java.util.List getTopUserClicks(String UserId){ 20 DotHibernate dh = new DotHibernate(Clickstream.class); 21 dh.setMaxResults(5); 22 dh.setSQLQuery(GET_TOP_USER_CLICKSTREAMS); 23 dh.setParam(UserId); 24 25 return dh.list(); 26 } 27 28 public static java.util.List getUserClicks(String UserId, int offset, int limit){ 29 DotHibernate dh = new DotHibernate(Clickstream.class); 30 dh.setQuery("from inode in class " + Clickstream.class.getName() + " where user_id = ? order by clickstream_id desc"); 31 dh.setParam(UserId); 32 dh.setFirstResult(offset); 33 dh.setMaxResults(limit); 34 return dh.list(); 35 36 } 37 38 public static java.util.List getAllUserClicks(String UserId){ 39 DotHibernate dh = new DotHibernate(Clickstream.class); 40 dh.setQuery("from inode in class " + Clickstream.class.getName() + " where user_id = ? order by clickstream_id desc"); 41 dh.setParam(UserId); 42 return dh.list(); 43 44 } 45 46 public static int countUserClicks(String UserId){ 47 DotConnect db = new DotConnect(); 48 db.setSQL(COUNT_USER_CLICKS); 49 db.addParam(UserId); 50 return db.getInt("test"); 51 52 } 53 54 55 56 } 57 | Popular Tags |