Project

General

Profile

Download (1.55 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.hibernate.search;
10

    
11
import org.apache.lucene.document.Document;
12
import org.apache.lucene.document.Field;
13
import org.apache.lucene.document.StringField;
14
import org.hibernate.search.bridge.FieldBridge;
15
import org.hibernate.search.bridge.LuceneOptions;
16
/**
17
 * Lucene index class bridge which sets class information for the objects into the index.
18
 *
19
 * TODO: is this class really needed?
20
 *  1. the canonical name should for all cdm types be he same as the name
21
 *  2. the class name is already stored in the document as _hibernate_class
22
 *
23
 * @author c.mathew
24
 * @version 1.0
25
 * @since 26 Jul 2013
26
 */
27
public class ClassInfoBridge implements FieldBridge {
28

    
29
    @Override
30
    public void set(String name, Object value, Document document,
31
            LuceneOptions luceneOptions) {
32
        Field nameField = new StringField(name + ".name",
33
                value.getClass().getName(),
34
                luceneOptions.getStore());
35
        nameField.setBoost(luceneOptions.getBoost());
36
        document.add(nameField);
37

    
38
        Field canonicalNameField = new StringField(name + ".canonicalName",
39
                value.getClass().getCanonicalName(),
40
                luceneOptions.getStore());
41
        canonicalNameField.setBoost(luceneOptions.getBoost());
42
        document.add(canonicalNameField);
43

    
44
    }
45
}
(3-3/20)