Statistics
| Revision:

root / tmp / org.txm.tigersearch.rcp / groovy / org / txm / importer / tigersearch / TSImporter.groovy @ 966

History | View | Annotate | Download (1.2 kB)

1 911 mdecorde
package org.txm.importer.tigersearch
2 911 mdecorde
3 911 mdecorde
import org.txm.Toolbox
4 911 mdecorde
import org.txm.importer.xtz.ImportModule;
5 911 mdecorde
import org.txm.importer.xtz.XTZImporter
6 911 mdecorde
import org.txm.metadatas.Metadatas
7 911 mdecorde
import org.txm.utils.io.FileCopy
8 911 mdecorde
9 911 mdecorde
/**
10 911 mdecorde
 * Only build the Metadatas object since all XML-TXM files already exists.
11 911 mdecorde
 * Metadatas is used to build text order.
12 911 mdecorde
 *
13 911 mdecorde
 *
14 911 mdecorde
 * @author mdecorde
15 911 mdecorde
 *
16 911 mdecorde
 */
17 911 mdecorde
class TSImporter extends XTZImporter {
18 911 mdecorde
19 911 mdecorde
        public TSImporter(ImportModule module) {
20 911 mdecorde
                super(module);
21 911 mdecorde
        }
22 911 mdecorde
23 911 mdecorde
        @Override
24 911 mdecorde
        public void process() {
25 911 mdecorde
                File binDir = module.getBinaryDirectory();
26 911 mdecorde
27 911 mdecorde
                //prepare metadata if any
28 966 mdecorde
                File allmetadatafile = Metadatas.findMetadataFile(inputDirectory);
29 911 mdecorde
                println allmetadatafile
30 911 mdecorde
                if (allmetadatafile.exists()) {
31 966 mdecorde
                        File copy = new File(binDir, allmetadatasfile.getName())
32 911 mdecorde
                        if (!FileCopy.copy(allmetadatafile, copy)) {
33 911 mdecorde
                                println "Error: could not create a copy of the metadata file "+allmetadatafile.getAbsoluteFile();
34 911 mdecorde
                                return;
35 911 mdecorde
                        }
36 911 mdecorde
                        this.metadata = new Metadatas(copy,
37 911 mdecorde
                                        Toolbox.getPreference(Toolbox.METADATA_ENCODING),
38 911 mdecorde
                                        Toolbox.getPreference(Toolbox.METADATA_COLSEPARATOR),
39 911 mdecorde
                                        Toolbox.getPreference(Toolbox.METADATA_TXTSEPARATOR), 1)
40 911 mdecorde
                }
41 911 mdecorde
                isSuccessFul = true;
42 911 mdecorde
        }
43 911 mdecorde
}