KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > campaigns > factories > ClickFactory


1 package com.dotmarketing.portlets.campaigns.factories;
2
3
4 import com.dotmarketing.beans.Inode;
5 import com.dotmarketing.db.DotHibernate;
6 import com.dotmarketing.factories.InodeFactory;
7 import com.dotmarketing.portlets.campaigns.model.Campaign;
8 import com.dotmarketing.portlets.campaigns.model.Click;
9 import com.dotmarketing.portlets.campaigns.model.Recipient;
10
11 /**
12  * Description of the Class
13  *
14  *@author nan
15  *@created September 21, 2002
16  */

17 public class ClickFactory {
18
19     /**
20      * Gets the newsletter attribute of the ClickFactory class
21      *
22      *@param id Description of the Parameter
23      *@return The newsletter value
24      */

25     public static final Click getClick(String JavaDoc id) {
26         
27         try{
28             return getClick(Long.parseLong(id));
29         }
30         catch(Exception JavaDoc e){
31             return new Click();
32         }
33
34
35     }
36     public static final Click getClick(long id) {
37         DotHibernate dh = new DotHibernate(Click.class);
38         return (Click) dh.load(id);
39     }
40     public static final Click getClickByLinkAndRecipient(String JavaDoc link, Recipient r) {
41         if (link == null || r.getInode() == 0) {
42             return new Click();
43         }
44         
45         //i have errors with hibernate replacing the http:// with http?// so im removing it from the url and doing a like!!!!
46
link = link.replaceAll("http(s)?://","");
47
48         String JavaDoc condition = "link like '%"+link+"'";
49
50         return (Click) InodeFactory.getChildOfClassbyCondition(r,Click.class, condition);
51
52
53     }
54
55     public static Click save(Click click) {
56         DotHibernate.saveOrUpdate(click);
57         return click;
58     }
59     
60     public static final Click getClickByLinkAndCampaign(String JavaDoc link, Campaign q) {
61         if (link == null || q.getInode() == 0) {
62             return new Click();
63         }
64         //i have errors with hibernate replacing the http:// with http?// so im removing it from the url and doing a like!!!!
65
link = link.replaceAll("http(s)?://","");
66
67         String JavaDoc condition = "link like '%"+link+"'";
68
69         return (Click) InodeFactory.getChildOfClassbyCondition(q,Click.class, condition);
70
71
72     }
73     
74     public static java.util.List JavaDoc getClicksByParent(Inode i) {
75         
76         return InodeFactory.getChildrenClass(i, Click.class);
77
78     }
79     
80     public static java.util.List JavaDoc getClicksByParentOrderByCount(Inode i) {
81         
82         
83         return InodeFactory.getChildrenClassByConditionAndOrderBy(i, Click.class, "0=0", "click_count desc");
84         
85
86     }
87     
88     
89     
90     
91 }
92
Popular Tags