001: /*
002:
003: * LIUS - Lucene Index Update and Search
004: * http://sourceforge.net/projects/lius/
005: *
006: * Copyright (c) 2005, Laval University Library. All rights reserved.
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Lesser General Public
010: * License as published by the Free Software Foundation; either
011: * version 2.1 of the License, or (at your option) any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public
019: * License along with this library; if not, write to the Free Software
020: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
021: */
022:
023: package ca.ulaval.bibl.lius.index;
024:
025: /**
026:
027: * <p>Titre : Lius (Lucene Index, Update and Search)</p>
028:
029: * <p>Description : Application Java permettant d'indexer du XML, PDF, HTML, JSP, ASP, PHP, Word, Excel et des Objets Java</p>
030:
031: * <p>Copyright : Copyright (c) 2003 Rida Benjelloun</p>
032:
033: *
034:
035: * Changelog:<br/>
036:
037: * 2005/06/02: added support for VCardIndexer and TexIndexer (jf)
038:
039: *
040:
041: * @author Rida Benjelloun
042:
043: * @e-mail rbenjelloun@hotmail.com
044:
045: * rida.benjelloun@bibl.ulaval.ca
046:
047: * @version 0.0.1
048:
049: * @date 09-08-2003
050:
051: */
052:
053: import java.util.Collection;
054:
055: import org.apache.lucene.document.Document;
056:
057: import ca.ulaval.bibl.lius.Lucene.LuceneActions;
058: import ca.ulaval.bibl.lius.config.LiusConfig;
059: import ca.ulaval.bibl.lius.config.LiusConfigBuilder;
060: import ca.ulaval.bibl.lius.config.LiusField;
061:
062: /**
063: *
064: * @author Rida Benjelloun
065: *
066: */
067:
068: public abstract class Indexer {
069:
070: /**
071: *
072: * Méthode retournant un objet de type Lucene document à partir du fichier à
073: *
074: * indexer et du fichier de configuration de Lius
075: *
076: * <br/><br/>
077: *
078: * Method that returns a Lucene Document object from the file to index and
079: *
080: * the Lius configuration file.
081: *
082: */
083:
084: public Document createLuceneDocument(String file,
085:
086: String liusXmlConfigFilePath) {
087:
088: LiusConfig lc = LiusConfigBuilder.getSingletonInstance()
089: .getLiusConfig(
090:
091: liusXmlConfigFilePath);
092:
093: Document doc = createLuceneDocument(file, lc);
094:
095: return doc;
096:
097: }
098:
099: /**
100: *
101: * Méthode retournant un objet de type Lucene document à partir du fichier
102: *
103: * à indexer et du fichier de configuration de Lius exprimé sous forme
104: *
105: * d'objet de type LiusConfig.
106: *
107: * <br/><br/>
108: *
109: * Method that returns a Lucene Document object from a file to index and
110: *
111: * the Lius Configuration as a LiusConfig object.
112: *
113: */
114:
115: public abstract Document createLuceneDocument(String file,
116: LiusConfig lc);
117:
118: //throws LiusException;
119:
120: /**
121: *
122: * Méthode retournant un objet de type Lucene document à partir du fichier à
123: *
124: * indexer et d'une collection d'objets de type LiusField. Chaque objet
125: * LiusField
126: *
127: * contient de l'information sur le nom du champs Lucene, le type, etc.
128: *
129: * <br/><br/>
130: *
131: * Method that retursn Lucene Document object from a file to index and a
132: * Collection
133: *
134: * of LiusField objects. Each LiusField object contains information about
135: * the name
136: *
137: * of the Lucene field, the type, etc.
138: *
139: *
140: *
141: *
142: *
143: */
144:
145: public Document createLuceneDocument(String file,
146: Collection liusFields) {
147:
148: LuceneActions la = LuceneActions.getSingletonInstance();
149:
150: Collection coll = getPopulatedCollection(file, liusFields);
151:
152: LiusField resource = new LiusField();
153:
154: resource.setType("Keyword");
155:
156: resource.setName("path");
157:
158: resource.setValue(file);
159:
160: coll.add(resource);
161:
162: Document doc = la.populateLuceneDoc(coll);
163:
164: return doc;
165:
166: }
167:
168: /**
169: *
170: * Permet de récupérer les champs de Lius à partir du fichier de
171: * configuration
172: *
173: * pour effectuer l'indexation.
174: *
175: * <br/><br/>
176: *
177: * Get Lius fields from the configuration file for indexation.
178: *
179: */
180:
181: public abstract Collection getLiusFields(LiusConfig lc);
182:
183: /**
184: *
185: * Méthode retournant un objet de type Lucene document à partir du fichier à
186: *
187: * indexer et d'une collection d'objets de type LiusField. Chaque objet
188: *
189: * LiusField contient de l'information sur le nom du champs Lucene, le type,
190: *
191: * etc.
192: *
193: * <br/><br/>
194: *
195: * Method that return a Lucene object from the configuration file and a
196: * collection
197: *
198: * of LiusField objects. Each LiusField object contains information about
199: * the Lucene
200: *
201: * field, the type, etc.
202: *
203: */
204:
205: public abstract Collection getPopulatedCollection(Object file,
206:
207: Collection liusFields);
208:
209: public abstract Collection getPopulatedCollection(Object file,
210:
211: String liusConfig);
212:
213: public abstract Collection getPopulatedCollection(Object file,
214:
215: LiusConfig liusConfig);
216:
217: }
|