KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openedit > archive > jobtracking > JobTrackingModule


1 package org.openedit.archive.jobtracking;
2
3 import java.io.File JavaDoc;
4 import java.util.HashMap JavaDoc;
5 import java.util.Map JavaDoc;
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 JavaDoc fieldJobArchives;
18     
19     public HitTracker getJobList( WebPageRequest inReq) throws Exception JavaDoc
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 /* public List getCustomerList( WebPageRequest inContext ) throws Exception
29     {
30         getJobList( inContext );
31         List jobList = (List)inContext.getPageValue( ORDERLIST );
32         List customerList = new ArrayList();
33         List idList = new ArrayList();
34         for ( Iterator iter = jobList.iterator(); iter.hasNext(); )
35         {
36             SubmittedJob job = (SubmittedJob) iter.next();
37             String id = job.getCustomer().getUserName();
38             if ( idList.contains( id ) )
39             {
40                 continue;
41             }
42             idList.add(id);
43             customerList.add( job.getCustomer() );
44         }
45         inContext.putPageValue( CUSTOMERLIST, customerList );
46         return customerList;
47     }
48 */

49
50     public void changeJobStatus( WebPageRequest inContext ) throws Exception JavaDoc
51     {
52         String JavaDoc id = inContext.getRequestParameter("jobstatus");
53         String JavaDoc jobNumber = inContext.getRequestParameter("jobnumber");
54         if( id != null && jobNumber != null)
55         {
56 // SubmittedJob job = getJobFromNumber(getJobList(inContext), jobNumber);
57
// Store store = getStore(inContext);
58
//
59
// JobState state = new JobState();
60
// state.setId(id);
61
//
62
// JobArchive archive = store.getJobArchive();
63
// archive.changeJobStatus(state, store, job);
64
}
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 JavaDoc getJobsDirectory( Store inStore )
80     {
81         return new File JavaDoc( inStore.getStoreDirectory(), "jobs" );
82     }
83     
84     public Job loadJob( WebPageRequest inRequest ) throws Exception JavaDoc
85     {
86         String JavaDoc path = inRequest.getPath();
87         if (path.endsWith(".html"))
88         {
89             String JavaDoc jobNumber = path.substring(path.lastIndexOf("/") + 1, path.lastIndexOf(".html"));
90             //HitTracker jobList = getJobList( inRequest);
91
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 JavaDoc getJobArchives()
110     {
111         if( fieldJobArchives == null)
112         {
113             fieldJobArchives = new HashMap JavaDoc();
114         }
115         return fieldJobArchives;
116     }
117
118     public void reindex(WebPageRequest inReq) throws Exception JavaDoc
119     {
120         Archive archive = getArchive(inReq);
121         getJobArchive(archive.getStore()).getJobSearch().reIndexAll();
122     }
123
124 }
125
Popular Tags