Changeset 18610 for gli

Show
Ignore:
Timestamp:
02.03.2009 15:11:40 (11 years ago)
Author:
kjdon
Message:

some indenting change, and set build type after changing the indexes instead of before otherwise be can't tell what our current build type was

Files:
1 modified

Legend:

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

    r18412 r18610  
    123123        mg_to_mgpp = false; 
    124124    } 
    125     build_type  = new_build_type; 
    126125    if (mg_to_mgpp) { 
    127126        changeToMGPPIndexes(); 
     
    129128        changeToMGIndexes(); 
    130129    } 
     130    build_type  = new_build_type; 
    131131    // its really hard to transfer defaults between mgpp/lucene and mg indexes, so we'll just set the first one to be the default 
    132132    Index first_index = (Index) getElementAt(0); 
     
    141141    mg_element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.TRUE_STR); 
    142142    NodeList indexes = mg_element.getElementsByTagName(StaticStrings.INDEX_ELEMENT); 
    143     if(indexes.getLength() != 0) { 
    144         //just reinstate what we had previously 
    145         setRoot(mg_element); 
    146     } else { 
    147         // If mg element has no indexes, and the current mgpp index includes a text one, then generate text indexes for each of the registered levels. 
    148         Index index = getIndex(StaticStrings.TEXT_STR); 
    149         if(index != null) { 
    150         // Replace mgpp element with mg element 
    151         setRoot(mg_element); 
    152         ArrayList levels = CollectionDesignManager.index_manager.getLevels(); 
    153         int level_size = levels.size(); 
    154         for(int i = 0; i < level_size; i++) { 
    155             IndexOption level = (IndexOption) levels.get(i); 
    156             Index new_index = new Index(level.getName(), index.getSources()); 
    157             // Try to retrieve existing metadatum 
    158             String source_str = new_index.getID(); 
    159             CollectionMeta metadatum = CollectionDesignManager.collectionmeta_manager.getMetadatum(StaticStrings.STOP_CHARACTER + source_str, false); 
    160             // If no metadata was found, add new pseudo metadata using the id 
    161             if(metadatum == null) { 
    162             metadatum = new CollectionMeta(StaticStrings.STOP_CHARACTER + source_str); 
    163             metadatum.setAssigned(true); 
    164             metadatum.setValue(source_str); 
    165             } 
    166             // If it was found, ensure it is assigned 
    167             else { 
    168             metadatum.setAssigned(true); 
    169             } 
    170             source_str = null; 
    171             addIndex(new_index, metadatum); 
    172             new_index = null; 
    173             level = null; 
    174         } 
    175         } 
     143    // Replace mgpp element with mg element 
     144    setRoot(mg_element); 
     145     
     146    if(indexes.getLength() == 0) { 
     147      // we need to create some based on the mgpp indexes 
     148       
     149      // If the current mgpp index includes a text one, then generate text indexes for each of the registered levels. 
     150      Index index = getIndex(StaticStrings.TEXT_STR); 
     151      if(index != null) { 
     152        ArrayList levels = CollectionDesignManager.index_manager.getLevels(); 
     153        int level_size = levels.size(); 
     154        for(int i = 0; i < level_size; i++) { 
     155          IndexOption level = (IndexOption) levels.get(i); 
     156          Index new_index = new Index(level.getName(), index.getSources()); 
     157          // Try to retrieve existing metadatum 
     158          String source_str = new_index.getID(); 
     159          CollectionMeta metadatum = CollectionDesignManager.collectionmeta_manager.getMetadatum(StaticStrings.STOP_CHARACTER + source_str, false); 
     160          // If no metadata was found, add new pseudo metadata using the id 
     161          if(metadatum == null) { 
     162        metadatum = new CollectionMeta(StaticStrings.STOP_CHARACTER + source_str); 
     163        metadatum.setAssigned(true); 
     164        metadatum.setValue(source_str); 
     165          } 
     166          // If it was found, ensure it is assigned 
     167          else { 
     168        metadatum.setAssigned(true); 
     169          } 
     170          source_str = null; 
     171          addIndex(new_index, metadatum); 
     172          new_index = null; 
     173          level = null; 
     174        } 
     175      } 
    176176    } 
    177177     
     
    195195         
    196196        ArrayList sources_list = new ArrayList(); 
     197 
    197198        // We first use details from the default index if any 
    198199        if(default_index != null) { 
     
    245246        new_sources = null; 
    246247        source_str = null; 
    247         } 
     248        }          
    248249         
    249250    }