KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > jobs > factories > SearchfirmFactory


1 package com.dotmarketing.portlets.jobs.factories;
2 import java.util.List JavaDoc;
3
4 import com.dotmarketing.db.DotHibernate;
5 import com.dotmarketing.factories.InodeFactory;
6 import com.dotmarketing.portlets.jobs.model.Searchfirm;
7 import com.dotmarketing.util.Config;
8 /**
9  * @author Steven Sajous
10  *
11  * To change this generated comment edit the template variable "typecomment":
12  * Window>Preferences>Java>Templates.
13  * To enable and disable the creation of type comments go to
14  * Window>Preferences>Java>Code Generation.
15  */

16 public class SearchfirmFactory extends InodeFactory{
17     
18     public static Searchfirm getSearchfirm(String JavaDoc id) {
19         DotHibernate dh = new DotHibernate(Searchfirm.class);
20         dh.setQuery("from searchfirm in class com.dotmarketing.portlets.jobs.model.Searchfirm where searchfirm.inode = ?");
21         dh.setParam(id);
22         return (Searchfirm)dh.load();
23     }
24     
25     public static List JavaDoc getSearchfirms(String JavaDoc orderby) {
26         DotHibernate dh = new DotHibernate(Searchfirm.class);
27         dh.setQuery("from searchfirm in class com.dotmarketing.portlets.jobs.model.Searchfirm order by " + orderby);
28         return dh.list();
29     }
30     
31     public static List JavaDoc getSearchfirms() {
32         DotHibernate dh = new DotHibernate(Searchfirm.class);
33         dh.setQuery("from searchfirm in class com.dotmarketing.portlets.jobs.model.Searchfirm order by creationdate desc, searchfirm.name");
34         return dh.list();
35     }
36
37     public static void save(Searchfirm x) {
38         saveInode(x);
39     }
40     
41     public static void delete(Searchfirm r) {
42         DotHibernate.delete(r);
43     }
44     
45     public static List JavaDoc getSearchFirmsByOrderBy(String JavaDoc field) {
46         DotHibernate dh = new DotHibernate(Searchfirm.class);
47         dh.setQuery("from searchfirm in class com.dotmarketing.portlets.jobs.model.Searchfirm order by ?, creationdate desc");
48         dh.setParam("searchfirm." + field);
49         return dh.list();
50     }
51     public static List JavaDoc getSearchFirmsBySearchAndLocation(String JavaDoc s, String JavaDoc location, int limit, int offset) {
52         String JavaDoc superString = "%" + s + "%";
53         String JavaDoc locationString = "%" + location + "%";
54         DotHibernate dh = new DotHibernate(Searchfirm.class);
55         dh.setQuery("from searchfirm in class com.dotmarketing.portlets.jobs.model.Searchfirm where searchfirm.active = " + com.dotmarketing.db.DbConnectionFactory.getDBTrue() + " and (searchfirm.organization like ? or searchfirm.description like ? or searchfirm.title like ?) and (searchfirm.streetaddress1 like ? or searchfirm.streetaddress2 like ?) order by searchfirm.creationdate desc");
56         dh.setParam(superString);
57         dh.setParam(superString);
58         dh.setParam(superString);
59         dh.setParam(locationString);
60         dh.setParam(locationString);
61         if (limit!=0) {
62             dh.setFirstResult(offset);
63             dh.setMaxResults(limit);
64         }
65         return dh.list();
66     }
67
68     public static List JavaDoc getSearchFirmsByLocation(String JavaDoc location, int limit, int offset) {
69         String JavaDoc locationString = "%" + location + "%";
70         DotHibernate dh = new DotHibernate(Searchfirm.class);
71         dh.setQuery("from searchfirm in class com.dotmarketing.portlets.jobs.model.Searchfirm where searchfirm.active = " + com.dotmarketing.db.DbConnectionFactory.getDBTrue() + " and (searchfirm.streetaddress1 like ? or searchfirm.streetaddress2 like ?) order by searchfirm.creationdate desc");
72         dh.setParam(locationString);
73         dh.setParam(locationString);
74         if (limit!=0) {
75             dh.setFirstResult(offset);
76             dh.setMaxResults(limit);
77         }
78         return dh.list();
79     }
80     
81     public static List JavaDoc getSearchFirmsBySearch(String JavaDoc s, int limit, int offset) {
82         String JavaDoc superString = "%" + s + "%";
83         DotHibernate dh = new DotHibernate(Searchfirm.class);
84         dh.setQuery("from searchfirm in class com.dotmarketing.portlets.jobs.model.Searchfirm where searchfirm.active = " + com.dotmarketing.db.DbConnectionFactory.getDBTrue() + " and (searchfirm.organization like ? or searchfirm.description like ? or searchfirm.title like ? ) order by searchfirm.creationdate desc");
85         dh.setParam(superString);
86         dh.setParam(superString);
87         dh.setParam(superString);
88         if (limit!=0) {
89             dh.setFirstResult(offset);
90             dh.setMaxResults(limit);
91         }
92         
93         return dh.list();
94     }
95
96     public static List JavaDoc getActiveFirmlist(int limit, int offset) {
97         DotHibernate dh = new DotHibernate(Searchfirm.class);
98         dh.setQuery("from searchfirm in class com.dotmarketing.portlets.jobs.model.Searchfirm where searchfirm.active = " + com.dotmarketing.db.DbConnectionFactory.getDBTrue() + " order by searchfirm.creationdate desc");
99         if (limit!=0) {
100             dh.setFirstResult(offset);
101             dh.setMaxResults(limit);
102         }
103         return dh.list();
104     }
105
106 }
107
Popular Tags