Changeset 3384
- Timestamp:
- May 25, 2007, 12:59:22 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java
r3380 r3384 366 366 dc = sc.newDbControl(); 367 367 File f = (File) request.getParameterValue(fileParameter.getName()); 368 PluginConfiguration pc = PluginConfiguration.getById(dc, configuration.getId());369 368 if (f != null) 370 369 { 371 370 f = File.getById(dc, f.getId()); 372 AnyToAny ata = AnyToAny.getNewOrExisting(dc, pc, "Configurationfile", f, true);373 if (!ata.isInDatabase())374 {375 dc.saveItem(ata);376 }377 371 378 372 getManualConfigureParameters(); … … 410 404 storeValue(configuration, request, usedFieldsParameter); 411 405 storeValue(configuration, request, jobParametersParameter); 412 // test the xml in the jobParameters paramere 413 getJobParameters(); 406 // test the xml in the jobParameters parameres 407 getJobParametersFromXML(String.valueOf(configuration.getValue(jobParametersParameter.getName()))); 408 414 409 response.setDone("Plugin configuration done."); 415 410 } … … 738 733 739 734 735 @SuppressWarnings("unchecked") 736 private List<PluginParameter<?>> getJobParametersFromXML(String xml) 737 { 738 try 739 { 740 List<PluginParameter<?>> p = new ArrayList<PluginParameter<?>>(); 741 String doctype = "<!DOCTYPE jobparameters SYSTEM \"base1-plugin-configuration-file.dtd\">"; 742 Document doc = XMLUtil.getValidatedXml(doctype+xml, dtdFile); 743 Iterator<Element> it = doc.getDescendants(new Filter() 744 { 745 public boolean matches(Object o) 746 { 747 if (o instanceof Element) 748 { 749 Element e = (Element) o; 750 return e.getName().equals("parameter"); 751 } 752 return false; 753 } 754 }); 755 while (it.hasNext()) 756 { 757 Element e = it.next(); 758 JobParameter jp = new JobParameter(e); 759 p.add(jp.getPluginParameter()); 760 } 761 return p; 762 } 763 catch (JDOMException e1) 764 { 765 throw new BaseException(e1.getCause()); 766 } 767 catch (IOException e1) 768 { 769 throw new BaseException(e1); 770 } 771 } 772 773 740 774 /** 741 775 * Creates a boolean from a string. … … 966 1000 } 967 1001 jobParameters = new ArrayList<PluginParameter<?>>(); 968 969 try 970 { 971 String doctype = "<!DOCTYPE jobparameters SYSTEM \"base1-plugin-configuration-file.dtd\">"; 972 Document doc = XMLUtil.getValidatedXml(doctype+configuration.getValue(jobParametersParameter.getName()).toString(), dtdFile); 973 Iterator<Element> it = doc.getDescendants(new Filter() 974 { 975 public boolean matches(Object o) 976 { 977 if (o instanceof Element) 978 { 979 Element e = (Element) o; 980 return e.getName().equals("parameter"); 981 } 982 return false; 983 } 984 }); 985 while (it.hasNext()) 986 { 987 Element e = it.next(); 988 JobParameter jp = new JobParameter(e); 989 jobParameters.add(jp.getPluginParameter()); 990 } 991 } 992 catch (JDOMException e) 993 { 994 throw new BaseException(e.getCause()); 995 } 996 catch (IOException e) 997 { 998 throw new BaseException(e.getCause()); 999 } 1000 1002 1001 1003 DbControl dc = null; 1002 1004 try 1003 1005 { 1004 1006 dc = sc.newDbControl(); 1005 Experiment experiment = super.getCurrentExperiment(dc);1007 Experiment experiment = getCurrentExperiment(dc); 1006 1008 String homeDirectoryPath = "/" + PluginConfiguration.getById(dc, configuration.getId()).getName(); 1007 1009 Directory homeDirectory = experiment.getDirectory(); … … 1024 1026 new PathParameterType(Path.Type.DIRECTORY, homeDirectoryPath, true)); 1025 1027 jobParameters.add(pluginDirectoryParameter); 1028 1029 Object xml = configuration.getValue(jobParametersParameter.getName()); 1030 // To make the plugin compatible with older configurations 1031 if (xml == null) 1032 { 1033 Object o = configuration.getValue(fileParameter.getName()); 1034 if (o != null) 1035 { 1036 File f = File.getById(dc, ((File) o).getId()); 1037 xml = getParametersFromBaseFile(f).get(jobParametersParameter.getName()); 1038 } 1039 else 1040 { 1041 throw new BaseException("Cant find the jobparameter specification. Reconfigure the plugin."); 1042 } 1043 } 1044 jobParameters.addAll(getJobParametersFromXML(xml.toString())); 1045 } 1046 catch (IOException e) 1047 { 1048 throw new BaseException(e); 1026 1049 } 1027 1050 finally
Note: See TracChangeset
for help on using the changeset viewer.