1 package org.openedit.archive.jobtracking; 2 3 import java.io.File ; 4 import java.util.HashMap ; 5 import java.util.Map ; 6 7 import com.openedit.OpenEditException; 8 import com.openedit.WebPageRequest; 9 import com.openedit.archive.Archive; 10 import com.openedit.hittracker.HitTracker; 11 import com.openedit.modules.BaseModule; 12 import com.openedit.modules.archive.ArchiveModule; 13 import com.openedit.store.Store; 14 15 public class JobTrackingModule extends BaseModule 16 { 17 protected Map fieldJobArchives; 18 19 public HitTracker getJobList( WebPageRequest inReq) throws Exception 20 { 21 Archive archive = getArchive(inReq); 22 JobArchive jobArchive = getJobArchive(archive.getStore()); 23 HitTracker jobs = jobArchive.findOpenJobs(archive); 24 inReq.putPageValue("jobs", jobs); 25 inReq.putPageValue("jobarchive", jobArchive); 26 return jobs; 27 } 28 49 50 public void changeJobStatus( WebPageRequest inContext ) throws Exception 51 { 52 String id = inContext.getRequestParameter("jobstatus"); 53 String jobNumber = inContext.getRequestParameter("jobnumber"); 54 if( id != null && jobNumber != null) 55 { 56 } 65 } 66 67 public Archive getArchive( WebPageRequest inReq ) throws OpenEditException 68 { 69 Archive archive = (Archive) inReq.getPageValue( Archive.ARCHIVE_PARAM ); 70 if( archive == null) 71 { 72 ArchiveModule mod = (ArchiveModule)getModule("ArchiveModule"); 73 archive = mod.getArchive(inReq); 74 } 75 return archive; 76 } 77 78 79 protected File getJobsDirectory( Store inStore ) 80 { 81 return new File ( inStore.getStoreDirectory(), "jobs" ); 82 } 83 84 public Job loadJob( WebPageRequest inRequest ) throws Exception 85 { 86 String path = inRequest.getPath(); 87 if (path.endsWith(".html")) 88 { 89 String jobNumber = path.substring(path.lastIndexOf("/") + 1, path.lastIndexOf(".html")); 90 Archive archive = getArchive(inRequest); 92 Job job = getJobArchive(archive.getStore()).getJobById(jobNumber); 93 inRequest.putPageValue("job", job); 94 return job; 95 } 96 return null; 97 } 98 public JobArchive getJobArchive(Store inStore) 99 { 100 JobArchive jobs = (JobArchive)getJobArchives().get(inStore.getCatalogId()); 101 if( jobs == null) 102 { 103 jobs = (JobArchive)getBeanFactory().getBean("jobArchive"); 104 jobs.setStore(inStore); 105 getJobArchives().put( inStore.getCatalogId(), jobs); 106 } 107 return jobs; 108 } 109 protected Map getJobArchives() 110 { 111 if( fieldJobArchives == null) 112 { 113 fieldJobArchives = new HashMap (); 114 } 115 return fieldJobArchives; 116 } 117 118 public void reindex(WebPageRequest inReq) throws Exception 119 { 120 Archive archive = getArchive(inReq); 121 getJobArchive(archive.getStore()).getJobSearch().reIndexAll(); 122 } 123 124 } 125 | Popular Tags |