1 /***
2 Copyright (C) 2005 The Java Community
3
4 This program is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free Software
6 Foundation; either version 2 of the License, or (at your option) any later
7 version.
8
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 Place, Suite 330, Boston, MA 02111-1307 USA.
16 */
17 package org.bejug.javacareers.jobs.service;
18
19
20 import java.util.List;
21
22 import org.bejug.javacareers.jobs.search.lucene.ContextSearcher;
23 import org.bejug.javacareers.jobs.search.lucene.PdfException;
24 import org.bejug.javacareers.jobs.search.lucene.PdfIndexer;
25
26 /***
27 * Implementation of LucenePdfService.
28 *
29 * @author Bavo Bruylandt (Last modified by $Author: ge0ffrey $)
30 * @version $Revision: 1.1 $ - $Date: 2005/08/26 07:58:31 $
31 */
32 public class LucenePdfServiceImpl implements LucenePdfService {
33
34 private static final int DEFAULT_LENGTH = 40;
35
36 private PdfIndexer pdfIndexer;
37
38 private ContextSearcher contextSearcher;
39
40 /***
41 * Filepath to Lucene index directory.
42 */
43 private String luceneIndexPath;
44
45 /***
46 * Constructor.
47 */
48 public LucenePdfServiceImpl() {
49
50
51 }
52
53 /***
54 * {@inheritDoc}
55 */
56 public void addToIndex(String filepath, String user) throws PdfException {
57
58 getPdfIndexer().writePdfToIndex(filepath, user);
59 }
60
61 /***
62 * {@inheritDoc}
63 */
64 public void removeFromIndex(String file) throws PdfException {
65 getPdfIndexer().deletePdfFromIndex(file);
66 }
67 /***
68 * {@inheritDoc}
69 */
70 public void setHighlightTags(String startTag, String endTag) {
71 getContextSearcher().setHighlightTags(startTag,endTag);
72 }
73
74 /***
75 * {@inheritDoc}
76 */
77 public List getSearchResultList(String query) throws PdfException {
78 return getContextSearcher().getContext(query, DEFAULT_LENGTH);
79 }
80
81 /***
82 * {@inheritDoc}
83 */
84 public List getSearchResultList(String query, int contextLength)
85 throws PdfException {
86 return getContextSearcher().getContext(query, contextLength);
87 }
88
89 /***
90 * @return pdfIndexer
91 * @throws PdfException if an error.
92 */
93 public PdfIndexer getPdfIndexer() throws PdfException {
94 if (pdfIndexer == null) {
95 pdfIndexer = PdfIndexer.createPdfIndexer(getLuceneIndexPath());
96 }
97 return pdfIndexer;
98 }
99
100 /***
101 * @param pdfIndexer PdfIndexer.
102 */
103 public void setPdfIndexer(PdfIndexer pdfIndexer) {
104 this.pdfIndexer = pdfIndexer;
105 }
106
107 /***
108 * @return contextSearcher.
109 */
110 public ContextSearcher getContextSearcher() {
111 if (contextSearcher == null) {
112 contextSearcher = ContextSearcher.createContextSearch(getLuceneIndexPath());
113 }
114 return contextSearcher;
115 }
116
117 /***
118 * @param contextSearcher ContextSearcher.
119 */
120 public void setContextSearcher(ContextSearcher contextSearcher) {
121 this.contextSearcher = contextSearcher;
122 }
123
124 /***
125 * @return luceneIndexPath
126 */
127 public String getLuceneIndexPath() {
128 return luceneIndexPath;
129 }
130
131 /***
132 * @param luceneIndexPath String
133 */
134 public void setLuceneIndexPath(String luceneIndexPath) {
135 this.luceneIndexPath = luceneIndexPath;
136 }
137 }
138
139 /***
140 * $Log: LucenePdfServiceImpl.java,v $
141 * Revision 1.1 2005/08/26 07:58:31 ge0ffrey
142 * split up the sources in service, serviceimpl and webclient
143 *
144 * Revision 1.8 2005/08/17 09:12:01 schauwvliege
145 * Checkstyle
146 *
147 * Revision 1.7 2005/08/17 09:09:30 schauwvliege
148 * Fixed all unit tests
149 *
150 * Revision 1.6 2005/08/10 09:04:49 bavo_jcs
151 * Optimized imports according to checkstyle
152 *
153 * Revision 1.5 2005/08/09 12:59:56 bavo_jcs
154 * Optimized imports
155 *
156 * Revision 1.4 2005/07/12 10:42:39 bavo_jcs
157 * PDF Ajax integration, added user info
158 *
159 * Revision 1.3 2005/06/14 12:05:52 schauwvliege
160 * CheckStyle and fixing tests
161 *
162 * Revision 1.2 2005/06/09 08:18:52 bejug_cc
163 * Fix initial import
164 *
165 * Revision 1.9 2005/06/07 15:02:35 bbr
166 * Lucene highlightterms added
167 *
168 * Revision 1.8 2005/06/07 14:38:48 bbr
169 * Lucene highlightterms added
170 *
171 * Revision 1.7 2005/05/31 08:47:36 bbr
172 * lucene fix
173 *
174 * Revision 1.6 2005/05/25 13:54:33 bbr
175 * lucene bean
176 *
177 * Revision 1.5 2005/05/25 13:13:48 bbr
178 * lucene bean
179 *
180 * Revision 1.4 2005/05/24 15:33:27 bbr
181 * Using spring sheduling
182 *
183 * Revision 1.3 2005/05/24 07:58:21 bbr
184 * fixed lucene refactoring errors
185 *
186 * Revision 1.2 2005/05/23 17:33:04 sja
187 * Introduced File.separator.
188 *
189 * Revision 1.1 2005/05/23 17:17:14 sja
190 * Moved to org.bejug.javacareers.jobs.service package.
191 *
192 * Revision 1.1 2005/05/23 17:04:57 sja
193 * Moved to org.bejug.javacareers.feeder package.
194 *
195 * Revision 1.3 2005/05/23 15:42:00 bbr
196 * added weight to lucene
197 *
198 * Revision 1.2 2005/05/23 15:33:12 bbr
199 * added weight to lucene
200 *
201 * Revision 1.1 2005/05/23 08:46:33 PSONG09
202 * added feeder source files to project
203 *
204 * Revision 1.4 2005/05/23 07:14:24 stephan_janssen
205 * Code cleanup.
206 *
207 * Revision 1.3 2005/05/20 14:41:46 bavo_jcs
208 * minor changes
209 *
210 * Revision 1.2 2005/05/20 07:45:39 bavo_jcs
211 * -lucene changes
212 *
213 * Revision 1.1 2005/05/18 15:46:39 bavo_jcs
214 * -adeed lucene service
215 *
216 */