1 package com.dotmarketing.portlets.jobs.factories; 2 import java.util.List ; 3 4 import com.dotmarketing.db.DotHibernate; 5 import com.dotmarketing.portlets.jobs.model.Resume; 6 import com.dotmarketing.util.Config; 7 15 public class ResumeFactory { 16 17 public static Resume getResume(String id) { 18 DotHibernate dh = new DotHibernate(Resume.class); 19 dh.setQuery("from resume in class com.dotmarketing.portlets.jobs.model.Resume where resume.inode = ?"); 20 dh.setParam(id); 21 return (Resume)dh.load(); 22 } 23 24 public static List getResumes(String orderBy) { 25 DotHibernate dh = new DotHibernate(Resume.class); 26 dh.setQuery("from resume in class com.dotmarketing.portlets.jobs.model.Resume order by " + orderBy); 27 return dh.list(); 28 } 29 30 public static List getResumes() { 31 DotHibernate dh = new DotHibernate(Resume.class); 32 dh.setQuery("from resume in class com.dotmarketing.portlets.jobs.model.Resume order by creationdate desc"); 33 return dh.list(); 34 } 35 36 public static Resume save(Resume x) { 37 DotHibernate.saveOrUpdate(x); 38 return x; 39 } 40 41 public static void delete(Resume r) { 42 DotHibernate.delete(r); 43 } 44 45 public static List getActiveResumes(int limit, int offset) { 46 DotHibernate dh = new DotHibernate(Resume.class); 47 dh.setQuery("from resume in class com.dotmarketing.portlets.jobs.model.Resume where resume.active = " + com.dotmarketing.db.DbConnectionFactory.getDBTrue() + " and expirationdate >= ? order by resume.creationdate desc"); 48 dh.setParam(new java.util.Date ()); 49 if (limit!=0) { 50 dh.setFirstResult(offset); 51 dh.setMaxResults(limit); 52 } 53 return dh.list(); 54 } 55 56 public static List getResumesBySearch(String s, int limit, int offset) { 57 String superString = "%" + s + "%"; 58 DotHibernate dh = new DotHibernate(Resume.class); 59 dh.setQuery("from resume in class com.dotmarketing.portlets.jobs.model.Resume where resume.active = " + com.dotmarketing.db.DbConnectionFactory.getDBTrue() + " and expirationdate >= ? and (resume.name like ? or resume.objective like ? or resume.qualification like ? ) order by resume.creationdate desc"); 60 dh.setParam(new java.util.Date ()); 61 dh.setParam(superString); 62 dh.setParam(superString); 63 dh.setParam(superString); 64 if (limit!=0) { 65 dh.setFirstResult(offset); 66 dh.setMaxResults(limit); 67 } 68 69 return dh.list(); 70 } 71 72 public static List getResumesByLocation(String location, int limit, int offset) { 73 String locationString = "%" + location + "%"; 74 DotHibernate dh = new DotHibernate(Resume.class); 75 dh.setQuery("from resume in class com.dotmarketing.portlets.jobs.model.Resume where resume.active = " + com.dotmarketing.db.DbConnectionFactory.getDBTrue() + " and expirationdate >= ? and (resume.location like ? or resume.city like ?) order by resume.creationdate desc"); 76 dh.setParam(new java.util.Date ()); 77 dh.setParam(locationString); 78 dh.setParam(locationString); 79 if (limit!=0) { 80 dh.setFirstResult(offset); 81 dh.setMaxResults(limit); 82 } 83 return dh.list(); 84 } 85 86 public static List getResumesBySearchAndLocation(String s, String location, int limit, int offset) { 87 String superString = "%" + s + "%"; 88 String locationString = "%" + location + "%"; 89 DotHibernate dh = new DotHibernate(Resume.class); 90 dh.setQuery("from resume in class com.dotmarketing.portlets.jobs.model.Resume where resume.active = " + com.dotmarketing.db.DbConnectionFactory.getDBTrue() + " and expirationdate >= ? and (resume.name like ? or resume.objective like ? or resume.qualification like ?) and (resume.city like ? or resume.location like ?) order by resume.creationdate desc"); 91 dh.setParam(new java.util.Date ()); 92 dh.setParam(superString); 93 dh.setParam(superString); 94 dh.setParam(superString); 95 dh.setParam(locationString); 96 dh.setParam(locationString); 97 if (limit!=0) { 98 dh.setFirstResult(offset); 99 dh.setMaxResults(limit); 100 } 101 return dh.list(); 102 } 103 104 105 106 } 107 | Popular Tags |