Changeset 13748 for trunk/gli/src/org/greenstone/gatherer/collection
- Timestamp:
- 2007-01-23T14:28:19+13:00 (17 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/collection
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/Collection.java
r13535 r13748 107 107 } 108 108 // 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"); 111 111 } 112 112 -
trunk/gli/src/org/greenstone/gatherer/collection/ScriptOptions.java
r13738 r13748 41 41 /** The name of the 'true' value. */ 42 42 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 { 89 48 this.values_element = values_element; 90 } 49 this.arguments_element = loadArguments(script_name, Configuration.getLanguage()); 50 } 51 91 52 92 53 /** Retrieve the indexth argument */
Note:
See TracChangeset
for help on using the changeset viewer.