Changeset 6087 for trunk/gli/src/org/greenstone/gatherer/collection
- Timestamp:
- 2003-12-02T17:18:37+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/BuildOptions.java
r5581 r6087 9 9 import org.greenstone.gatherer.msm.MSMUtils; 10 10 import org.greenstone.gatherer.util.ArrayTools; 11 import org.greenstone.gatherer.util.Codec; 12 import org.greenstone.gatherer.util.StaticStrings; 11 13 import org.greenstone.gatherer.util.Utility; 12 14 import org.w3c.dom.*; … … 48 50 build_arguments_element = loadArguments("buildcol.pl"); 49 51 import_arguments_element = loadArguments("import.pl"); 50 52 // And if that too fails, load the default argument templates 51 53 if(build_arguments_element == null || import_arguments_element == null) { 52 54 Document build_document = Utility.parse("xml/buildcol.xml", true); … … 61 63 ///atherer.println("Loaded BO arguments from scripts."); 62 64 } 63 65 // 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. 64 66 Gatherer.config.setArguments(build_arguments_element); 65 67 Gatherer.config.setArguments(import_arguments_element); … … 248 250 } 249 251 } 252 else if(node_name.equals(StaticStrings.RANGE_ELEMENT)) { 253 String range_raw = MSMUtils.getValue(node); 254 int comma_index = -1; 255 if((comma_index = range_raw.indexOf(StaticStrings.COMMA_CHARACTER)) != -1) { 256 if(comma_index > 0) { 257 try { 258 String first_number = range_raw.substring(0, comma_index); 259 argument.setMinimum(Integer.parseInt(first_number)); 260 first_number = null; 261 } 262 catch(Exception exception) { 263 } 264 } 265 266 if(comma_index + 1 < range_raw.length()) { 267 try { 268 String second_number = range_raw.substring(comma_index + 1); 269 argument.setMaximum(Integer.parseInt(second_number)); 270 second_number = null; 271 } 272 catch(Exception exception) { 273 } 274 } 275 } 276 // Else it wasn't a valid range anyway, so ignore it 277 range_raw = null; 278 } 250 279 } 251 280 } … … 299 328 values.add("-" + argument_element.getAttribute(NAME)); 300 329 // Now retrieve the value. 301 String argument_value = MSMUtils.getValue(argument_element);330 String argument_value = Codec.transform(MSMUtils.getValue(argument_element), Codec.DOM_TO_TEXT); 302 331 // If there is a value, tokenize it by commas only. 303 332 if(argument_value != null && argument_value.length() > 0) { … … 319 348 Element arguments_element = null; 320 349 // Run the required program. 321 /** @todo - I never finished implementing this. Have to test that the perl script handles being loaded in this way. 322 try { 323 String args[] = new String[3]; 324 args[0] = Gatherer.config.perl_path; 325 args[1] = filename; 326 args[2] = "-xml"; 327 // Create the process. 328 Runtime runtime = Runtime.getRuntime(); 329 Process process = runtime.exec(args); 330 //InputStream input_stream = process.getErrorStream(); 331 InputSource source = new InputSource(new InputStreamReader(process.getErrorStream())); 332 DOMParser parser = new DOMParser(); 333 parser.parse(source); 334 Document document = parser.getDocument(); 335 arguments_element = document.getDocumentElement(); 336 } 337 catch (Exception error) { 338 Gatherer.println("Error in BuildOptions.loadArguments(): " + error); 339 Gatherer.printStackTrace(error); 340 } 341 */ 350 try { 351 String args[]; 352 if(Utility.isWindows()) { 353 args = new String[4]; 354 args[0] = Gatherer.config.perl_path; 355 args[1] = "-S"; 356 args[2] = Gatherer.config.getScriptPath() + filename; 357 args[3] = "-xml"; 358 } 359 else { 360 args = new String[2]; 361 args[0] = Gatherer.config.getScriptPath() + filename; 362 args[1] = "-xml"; 363 } 364 // Create the process. 365 Runtime runtime = Runtime.getRuntime(); 366 Process process = runtime.exec(args); 367 //InputStream input_stream = process.getErrorStream(); 368 InputSource source = new InputSource(new InputStreamReader(process.getErrorStream())); 369 DOMParser parser = new DOMParser(); 370 parser.parse(source); 371 Document document = parser.getDocument(); 372 arguments_element = document.getDocumentElement(); 373 } 374 catch (Exception error) { 375 Gatherer.println("Error in BuildOptions.loadArguments(): " + error); 376 Gatherer.printStackTrace(error); 377 } 342 378 return arguments_element; 343 379 }
Note:
See TracChangeset
for help on using the changeset viewer.