KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > webevents > factories > WebEventLocationFactory


1 package com.dotmarketing.portlets.webevents.factories;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.Date JavaDoc;
5 import java.util.GregorianCalendar JavaDoc;
6 import java.util.HashSet JavaDoc;
7
8 import com.dotmarketing.db.DotHibernate;
9 import com.dotmarketing.factories.InodeFactory;
10 import com.dotmarketing.util.Config;
11 import com.dotmarketing.portlets.webevents.model.WebEvent;
12 import com.dotmarketing.portlets.webevents.model.WebEventLocation;
13 /**
14  *
15  * @author Maru
16  */

17 public class WebEventLocationFactory {
18
19     public static java.util.List JavaDoc getAllWebEventLocations() {
20         DotHibernate dh = new DotHibernate(WebEventLocation.class);
21         dh.setQuery(
22             "from inode in class com.dotmarketing.portlets.webevents.model.WebEventLocation order by start_date desc");
23         return dh.list();
24     }
25     public static java.util.List JavaDoc getAllWebEventLocations(String JavaDoc orderby) {
26         DotHibernate dh = new DotHibernate(WebEventLocation.class);
27         dh.setQuery(
28             "from inode in class com.dotmarketing.portlets.webevents.model.WebEventLocation order by " + orderby);
29         return dh.list();
30     }
31     
32     public static java.util.List JavaDoc getWebEventLocationsPerEvent(long webEventInode, String JavaDoc orderby) {
33         DotHibernate dh = new DotHibernate(WebEventLocation.class);
34         dh.setQuery(
35             "from inode in class com.dotmarketing.portlets.webevents.model.WebEventLocation where web_event_inode = ? order by " + orderby);
36         dh.setParam(webEventInode);
37         return dh.list();
38     }
39
40     public static java.util.List JavaDoc getUpcomingWebEventLocationsPerEvent(long webEventInode, String JavaDoc orderby) {
41         DotHibernate dh = new DotHibernate(WebEventLocation.class);
42         dh.setQuery(
43             "from inode in class com.dotmarketing.portlets.webevents.model.WebEventLocation where web_event_inode = ? and start_date >= ? order by " + orderby);
44         dh.setParam(webEventInode);
45         GregorianCalendar JavaDoc cal = new GregorianCalendar JavaDoc ();
46         cal.setTime(new Date JavaDoc());
47         cal.set(GregorianCalendar.HOUR_OF_DAY, 0);
48         cal.set(GregorianCalendar.MINUTE, 0);
49         cal.set(GregorianCalendar.SECOND, 0);
50         dh.setDate(cal.getTime());
51         return dh.list();
52     }
53
54     public static java.util.List JavaDoc getPastWebEventLocationsPerEvent(long webEventInode, String JavaDoc orderby) {
55         DotHibernate dh = new DotHibernate(WebEventLocation.class);
56         dh.setQuery(
57             "from inode in class com.dotmarketing.portlets.webevents.model.WebEventLocation where web_event_inode = ? and start_date < ? order by " + orderby);
58         dh.setParam(webEventInode);
59         GregorianCalendar JavaDoc cal = new GregorianCalendar JavaDoc ();
60         cal.setTime(new Date JavaDoc());
61         cal.set(GregorianCalendar.HOUR_OF_DAY, 23);
62         cal.set(GregorianCalendar.MINUTE, 59);
63         cal.set(GregorianCalendar.SECOND, 59);
64         dh.setParam(cal.getTime());
65         return dh.list();
66     }
67     
68     public static WebEvent getWebEvent(WebEventLocation webeventLocation) {
69         return WebEventFactory.getWebEvent(webeventLocation.getWebEventInode());
70     }
71
72     public static WebEventLocation getWebEventLocation(long inode) {
73         return (WebEventLocation) InodeFactory.getInode(inode, WebEventLocation.class);
74     }
75
76     public static WebEventLocation getWebEventLocation(String JavaDoc inode) {
77         return (WebEventLocation) InodeFactory.getInode(inode, WebEventLocation.class);
78     }
79
80     public static WebEventLocation newInstance() {
81         WebEventLocation m = new WebEventLocation();
82         return m;
83     }
84
85     public static void saveWebEventLocation(WebEventLocation WebEventLocation) {
86         InodeFactory.saveInode(WebEventLocation);
87     }
88
89     public static void deleteWebEventLocation(WebEventLocation WebEventLocation) {
90         InodeFactory.deleteInode(WebEventLocation);
91     }
92
93 }
94
Popular Tags