Changeset 14522


Ignore:
Timestamp:
2007-09-17T13:16:23+12:00 (17 years ago)
Author:
xiao
Message:

modify to write out index options eg casefold and stem, to collectionConfig.xml from the internal structure (probably modified in the GLI.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/cdm/CollectionConfiguration.java

    r14204 r14522  
    33233323        //Convert default index
    33243324        convertDefaultIndex (from, to, search);
     3325        convertIndexOptions(from, to, search);
    33253326    }
    33263327    // Convert levels for mgpp/lucene. This method is called by converIndex() when mgpp indexer is detected.
     
    33883389        search.appendChild (default_level);
    33893390       
     3391    }
     3392    // Convert indexoptions for mg/mgpp/lucene. This method is called by convertIndex().
     3393    private void convertIndexOptions (Document from, Document to, Element search) {
     3394        Element source = from.getDocumentElement ();
     3395        Element index_option = XMLTools.getNamedElement (source,
     3396        StaticStrings.INDEXOPTIONS_ELEMENT,
     3397        StaticStrings.NAME_ATTRIBUTE, StaticStrings.INDEXOPTIONS_STR);
     3398        if (index_option == null) {
     3399            return;
     3400        }
     3401        //Debugging purposes
     3402        if (index_option.getAttribute (StaticStrings.ASSIGNED_ATTRIBUTE).equals (StaticStrings.FALSE_STR)) {
     3403            DebugStream.println ("There should be an IndexOption element which is assigned 'true': possible bug.");
     3404        }
     3405        Element indexOptionEl = to.createElement(StaticStrings.INDEXOPTION_STR);
     3406        NodeList option_elements = index_option.getElementsByTagName (StaticStrings.OPTION_ELEMENT);
     3407        int num_elements = option_elements.getLength ();       
     3408        // Don't output anything if no index
     3409        if(num_elements == 0) {
     3410            return ;//
     3411        }
     3412        search.appendChild (indexOptionEl);
     3413       
     3414        for(int k = 0; k < num_elements; k++) {
     3415            Element e = (Element) option_elements.item (k);
     3416            String name_att = e.getAttribute(StaticStrings.NAME_ATTRIBUTE);
     3417            Element optionEl = to.createElement(StaticStrings.OPTION_STR);
     3418            optionEl.setAttribute(StaticStrings.NAME_ATTRIBUTE, name_att);
     3419            indexOptionEl.appendChild(optionEl);
     3420        }
     3421           
    33903422    }
    33913423    // Append the element son to the element mother in the appropriate position.
Note: See TracChangeset for help on using the changeset viewer.