Changeset 13748


Ignore:
Timestamp:
2007-01-23T14:28:19+13:00 (17 years ago)
Author:
mdewsnip
Message:

No longer saves the import.pl and buildcol.pl arguments in the GLI config.xml file. This was dodgy with different languages, and the saved options were often out of date. Now the options are simply read when required (similar to the plugin and classifier options).

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/collection/Collection.java

    r13535 r13748  
    107107    }
    108108    // Finally create all of the child managers that are directly dependant on a collection
    109     build_options = new ScriptOptions(getBuildValues(), "buildcol.pl", true);
    110     import_options = new ScriptOptions(getImportValues(), "import.pl", true);
     109    build_options = new ScriptOptions(getBuildValues(), "buildcol.pl");
     110    import_options = new ScriptOptions(getImportValues(), "import.pl");
    111111    }
    112112   
  • trunk/gli/src/org/greenstone/gatherer/collection/ScriptOptions.java

    r13738 r13748  
    4141    /** The name of the 'true' value. */
    4242    static final private String TRUE = "true";
    43     /** When constructing a ScriptOptions object we first try to retrieve the valid arguments from config.xml - if saved is true. If that fails we then try to parse the arguments noticed when calling script_name -xml. If that also fails, we try to load the default arguments from the xml template library. */
    44     public ScriptOptions(Element values_element, String script_name, boolean saved) {
    45     // first check the saved arguments language
    46     String interface_lang = Configuration.getLanguage();
    47     String args_lang = Configuration.getArgumentsLanguage();
    48     if (saved && interface_lang.equals(args_lang)) {
    49         // Try to retrieve the arguments for import and build.
    50         arguments_element = Configuration.getArguments(script_name);
    51     }
    52     // If that fails try to reconstruct the arguments
    53     if(arguments_element == null) {
    54         boolean used_defaults = false;
    55         arguments_element = loadArguments(script_name, interface_lang);
    56        
    57         // And if that too fails, load the default argument templates
    58         if(arguments_element == null) {
    59         // replace .pl with .xml to get the template name
    60         String template_name = script_name.replaceAll("\\.pl$", "\\.xml");
    61         Document document = XMLTools.parseXMLFile("xml/" + template_name, true);
    62         if (document != null) {
    63             arguments_element = document.getDocumentElement();
    64             document = null;
    65             used_defaults = true;
    66 
    67         } else {
    68             return;
    69         }
    70         ///atherer.println("Loaded default BO arguments from templates.");
    71         }
    72         else {
    73         ///atherer.println("Loaded BO arguments from scripts.");
    74         }
    75         // By now we should definately have the arguments. However the reason we are here is because they are not stored in the config.xml file, to make sure they are stored now.
    76         if (saved) {
    77         if (used_defaults) {
    78             Configuration.setArgumentsLanguage("en");
    79         } else {
    80             Configuration.setArgumentsLanguage(interface_lang);
    81         }
    82         Configuration.setArguments(arguments_element);
    83         }
    84     }
    85     else {
    86         DebugStream.println("Loaded BO arguments from config.xml");
    87     }
    88     // Now take a note of the values too.
     43
     44
     45    /** Parse the arguments from running "script_name -xml" */
     46    public ScriptOptions(Element values_element, String script_name)
     47    {
    8948    this.values_element = values_element;
    90     }
     49    this.arguments_element = loadArguments(script_name, Configuration.getLanguage());
     50    }
     51
    9152
    9253    /** Retrieve the indexth argument */
  • trunk/gli/src/org/greenstone/gatherer/gui/ExplodeMetadataDatabasePrompt.java

    r13594 r13748  
    102102    String dom_string = "<Options/>";
    103103    Document doc = XMLTools.parseXML(new StringReader(dom_string));
    104     options = new ScriptOptions(doc.getDocumentElement(), "explode_metadata_database.pl", false);
     104    options = new ScriptOptions(doc.getDocumentElement(), "explode_metadata_database.pl");
    105105   
    106106    // Creation
Note: See TracChangeset for help on using the changeset viewer.