Changeset 22970

Show
Ignore:
Timestamp:
27.09.2010 14:12:13 (9 years ago)
Author:
sjm84
Message:

Added the ability to change the database type between GDBM, JDBM and SQLite

Location:
main/trunk/gli
Files:
1 added
7 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/classes/dictionary.properties

    r22661 r22970  
    9999CDM.ClassifierManager.Remove:Remove Classifier 
    100100CDM.ClassifierManager.Remove_Tooltip:Remove the selected classifier from the list 
     101CDM.DatabaseTypeManager.Change:Change... 
     102CDM.DatabaseTypeManager.Change_Tooltip:Change the type of database used by this collection 
     103CDM.DatabaseTypeManager.Current_Type:Database in use: {0} 
     104CDM.DatabaseTypeManager.Title:Select the Database 
     105CDM.DatabaseTypeManager.gdbm:GDBM 
     106CDM.DatabaseTypeManager.gdbm_Description: GDBM (or GNU Database Manager) is a simple flat-file database engine which Greenstone uses as the default database for new collections. 
     107CDM.DatabaseTypeManager.jdbm:JDBM 
     108CDM.DatabaseTypeManager.jdbm_Description: JDBM (or Java Database Manager) is essentially a Java implementation of GDBM. Consider using this database engine combined with the Lucene indexer if you are wanting to create a pure Java run-time. 
     109CDM.DatabaseTypeManager.sqlite:SQLITE 
     110CDM.DatabaseTypeManager.sqlite_Description: SQLite is a simple relational database engine. It can be used in Greenstone to provide experimental advanced searching features that are not possible with the other database engines. To enable these features add "sqlform" to the list of SearchTypes in the Format Features section of the Format tab.  
    101111CDM.FormatManager.Add:Add Format 
    102112CDM.FormatManager.Add_Tooltip:Add the specified format command  
  • main/trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java

    r22410 r22970  
    5757public class ClassifierManager 
    5858extends DOMProxyListModel { 
     59 
     60    private DatabaseTypeManager database_type_manager = null; 
     61    private String database_type = null; 
     62 
    5963    /** The controls for editing the contents of this manager. */ 
    6064    private Control controls = null; 
     
    7175        this.model = this; 
    7276        DebugStream.println ("ClassifierManager: " + getSize () + " classifiers parsed."); 
     77 
     78    database_type_manager = new DatabaseTypeManager(); 
     79    database_type = database_type_manager.getDatabaseType(); 
    7380         
    7481        // Force the assigned classifiers to be loaded and cached now 
     
    269276    private class ClassifierControl 
    270277    extends JPanel 
    271     implements Control { 
     278    implements Control, DatabaseTypeManager.DatabaseTypeListener { 
    272279        /** A combobox containing all of the known classifiers, including those that may have already been assigned. */ 
    273280        private JComboBox classifier_combobox = null; 
     
    281288        /** Button to remove the selected classifier. */ 
    282289        private JButton remove = null; 
     290 
     291    private JPanel database_type_panel = (JPanel)database_type_manager.getControls(); 
    283292         
    284293        /** A list of assigned classifiers. */ 
     
    404413            central_pane.setBorder (BorderFactory.createEmptyBorder (5,0,0,0)); 
    405414            central_pane.setLayout (new BorderLayout ()); 
     415            central_pane.add (database_type_panel, BorderLayout.NORTH); 
    406416            central_pane.add (classifier_list_pane, BorderLayout.CENTER); 
    407417            central_pane.add (temp, BorderLayout.SOUTH); 
     
    430440        } 
    431441         
     442 
     443    public void databaseTypeChanged(String new_database_type) 
     444    { 
     445        if(database_type.equals(new_database_type)){ 
     446        return; 
     447        } 
     448        database_type = new_database_type; 
     449    } 
    432450         
    433451        private class AddListener 
  • main/trunk/gli/src/org/greenstone/gatherer/cdm/CollectCfgReadWrite.java

    r20450 r22970  
    9797      return metadataToString (command_element);  
    9898    } 
     99    else if (command_element_name.equals (StaticStrings.DATABASETYPE_ELEMENT)) { 
     100    return metadataToString (command_element);  
     101    }  
    99102    else if(command_element_name.equals (StaticStrings.PLUGIN_ELEMENT)) { 
    100103      return pluginToString (command_element); 
     
    335338    String name_str = command_element.getAttribute (StaticStrings.NAME_ATTRIBUTE); 
    336339    // If the name is one of the special four, we don't write the collectionmeta first. Note maintainer and buildtype are singled out for 'prittying' reasons. 
    337     if(name_str.equals (StaticStrings.COLLECTIONMETADATA_MAINTAINER_STR)|| name_str.equals (StaticStrings.BUILDTYPE_STR) ) { 
     340    if(name_str.equals (StaticStrings.COLLECTIONMETADATA_MAINTAINER_STR)|| name_str.equals (StaticStrings.BUILDTYPE_STR) || name_str.equals (StaticStrings.DATABASETYPE_STR)) { 
    338341      text.append (name_str); 
    339342      text.append (StaticStrings.TAB_CHARACTER); 
     
    578581        command_element = parseMetadata (tokenizer, document); // Revised to handle multiple lines 
    579582      } 
    580       if(command_element == null && (command_type.equals (StaticStrings.COLLECTIONMETADATA_PUBLIC_STR) || command_type.equals (StaticStrings.COLLECTIONMETADATA_CREATOR_STR) || command_type.equals (StaticStrings.COLLECTIONMETADATA_MAINTAINER_STR) || command_type.equals (StaticStrings.BUILDTYPE_STR))) { 
     583      if(command_element == null && (command_type.equals (StaticStrings.COLLECTIONMETADATA_PUBLIC_STR) || command_type.equals (StaticStrings.COLLECTIONMETADATA_CREATOR_STR) || command_type.equals (StaticStrings.COLLECTIONMETADATA_MAINTAINER_STR) || command_type.equals (StaticStrings.BUILDTYPE_STR) || command_type.equals (StaticStrings.DATABASETYPE_STR))) { 
    581584        command_element = parseMetadataSpecial (command_str, document); 
    582585        // pre 2.71 hack 
     
    10251028    else if (name_str.equals (StaticStrings.BUILDTYPE_STR)) { 
    10261029      command_element = document.createElement (StaticStrings.BUILDTYPE_ELEMENT); 
     1030    } 
     1031    else if (name_str.equals (StaticStrings.DATABASETYPE_STR)) { 
     1032      command_element = document.createElement (StaticStrings.DATABASETYPE_ELEMENT); 
    10271033    } 
    10281034    if(command_element != null) { 
  • main/trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfigXMLReadWrite.java

    r22381 r22970  
    991991    return element; 
    992992  } 
     993  
     994  static private Element doDatabaseType (Document to, String att_value) { 
     995         
     996    //construct 'DatabaseType' element 
     997    Element element = to.createElement (StaticStrings.DATABASETYPE_ELEMENT); 
     998    element.setAttribute (StaticStrings.NAME_ATTRIBUTE, StaticStrings.DATABASETYPE_STR); 
     999    element.setAttribute (StaticStrings.LANGUAGE_ATTRIBUTE, StaticStrings.ENGLISH_LANGUAGE_STR); 
     1000    element.setAttribute (StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.TRUE_STR); 
     1001    element.setAttribute (StaticStrings.SPECIAL_ATTRIBUTE, StaticStrings.TRUE_STR); 
     1002 
     1003    XMLTools.setNodeText (element, att_value); 
     1004         
     1005    return element; 
     1006  } 
    9931007     
    9941008  // Convert 'description', 'smallicon' etc. 
     
    13151329    search.setAttribute (StaticStrings.TYPE_ATTRIBUTE, indexer); 
    13161330    to.getDocumentElement ().appendChild (search); 
     1331  } 
     1332  static private void convertDatabaseType (Document from, Document to) { 
     1333    Element e = XMLTools.getNamedElement (from.getDocumentElement (), 
     1334                      StaticStrings.DATABASETYPE_ELEMENT, 
     1335                      StaticStrings.NAME_ATTRIBUTE, StaticStrings.DATABASETYPE_STR); 
     1336    if (e == null) { 
     1337      return; 
     1338    } 
     1339    String db = XMLTools.getNodeText (e); 
     1340    Element dbtype = to.createElement (StaticStrings.INFODB_STR); 
     1341    dbtype.setAttribute (StaticStrings.TYPE_ATTRIBUTE, db); 
     1342    to.getDocumentElement ().appendChild (dbtype); 
    13171343  } 
    13181344  static private void convertDefaultIndex (Document from, Document to, Element search) { 
     
    19571983      appendArrayList (toElement, is_public); 
    19581984    } 
     1985 
     1986    Node databaseNode = XMLTools.getChildByTagNameIndexed (fromElement, StaticStrings.INFODB_STR, 0); 
     1987    String databasetype_value = ((Element)databaseNode).getAttribute (StaticStrings.TYPE_ATTRIBUTE); 
     1988    Element databasetype = doDatabaseType(dOc, databasetype_value); 
     1989    appendProperly (toElement, databasetype); 
    19591990         
    19601991    Node searchNode = XMLTools.getChildByTagNameIndexed (fromElement, StaticStrings.SEARCH_STR, 0); 
     
    20582089    convertDisplayItemList (dOc, skeleton); 
    20592090    convertBuildType (dOc, skeleton); 
     2091    convertDatabaseType (dOc, skeleton); 
    20602092    convertIndex (dOc, skeleton); 
    20612093    convertPlugin (dOc, skeleton);//also do the plugout element 
  • main/trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfiguration.java

    r22772 r22970  
    314314    return element; 
    315315         
     316  }   
     317 
     318public Element getDatabaseType () { 
     319    Element element = getOrCreateElementByTagName (StaticStrings.DATABASETYPE_ELEMENT, null, null); 
     320    element.setAttribute (StaticStrings.NAME_ATTRIBUTE, StaticStrings.DATABASETYPE_STR); 
     321    element.setAttribute (StaticStrings.SPECIAL_ATTRIBUTE, StaticStrings.TRUE_STR); 
     322    return element; 
     323         
    316324  } 
    317325     
  • main/trunk/gli/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java

    r19781 r22970  
    4949    static public DesignChangeListener all_change_listener; 
    5050    static public DesignChangeListener buildcol_change_listener; 
     51    static public DesignChangeListener databasecol_change_listener; 
    5152    /** A list of classifiers to use at build time. */ 
    5253    static public ClassifierManager classifier_manager; 
     
    108109    all_change_listener = new DesignChangeListener(ALL); 
    109110    buildcol_change_listener = new DesignChangeListener(BUILDCOL); 
     111    databasecol_change_listener = new DesignChangeListener(BUILDCOL); 
     112     
    110113    // Parse the collection configuration 
    111114    collect_config = new CollectionConfiguration(collect_config_file); 
  • main/trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java

    r22380 r22970  
    8484    static final public String CONTENT_ATTRIBUTE = "content"; 
    8585    static final public String CONTENT_ELEMENT = "content"; 
     86    static final public String DATABASETYPE_ELEMENT = "infodbtype"; 
     87    static final public String DATABASETYPE_STR = "infodbtype"; 
    8688    static final public String DATELIST_CLASSIFIER = "DateList"; 
    8789    static final public String DEBUG_ARGUMENT = "-debug"; 
     
    151153    static final public String INDEXOPTIONS_STR = "indexoptions"; 
    152154    static final public String INDEXOPTION_DEFAULT_ELEMENT = "DefaultIndexOption"; 
     155    static final public String INFODB_STR = "infodb"; 
    153156    static final public String INT_STR = "int"; 
    154157    static final public String IMPORT_STR = "import";