Changeset 5204
- Timestamp:
- Dec 16, 2009, 2:29:50 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/src/docbook/appendix/incompatible.xml
r5060 r5204 43 43 </para> 44 44 </note> 45 46 <sect1 id="appendix.incompatible.2.15"> 47 <title>BASE 2.15 release</title> 48 49 <bridgehead> 50 Base1PluginExecuter and enumerated parameters 51 </bridgehead> 52 53 <para> 54 Enumerated parameters as handled by the Base1PluginExecuter consists 55 of key/value pairs, for example 0=No, 1=Yes. The 'value' is what the user 56 sees in the GUI while running jobs and the 'key' is what is sent to 57 the plug-in in the parameter file. Starting with BASE 2.15 the 'value' 58 is saved in the database instead of the 'key'. At runtime, a reverse 59 lookup is used to convert the 'value' into the 'key' that is written 60 to the parameters file. <emphasis>The reverse lookup only works 61 if all values are unique.</emphasis> BASE will check for this at 62 configuration time and throw an exception if this is not the 63 case. To solve this problem the plug-in should be reconfigured. 64 </para> 65 66 </sect1> 45 67 46 68 <sect1 id="appendix.incompatible.2.13"> -
trunk/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java
r5187 r5204 45 45 import net.sf.basedb.core.ItemQuery; 46 46 import net.sf.basedb.core.Job; 47 import net.sf.basedb.core.ParameterType; 47 48 import net.sf.basedb.core.Path; 48 49 import net.sf.basedb.core.PathParameterType; … … 61 62 import net.sf.basedb.core.plugin.GuiContext; 62 63 import net.sf.basedb.core.plugin.InteractivePlugin; 63 import net.sf.basedb.core.plugin.ParameterValues;64 64 import net.sf.basedb.core.plugin.Permissions; 65 65 import net.sf.basedb.core.plugin.Request; … … 474 474 for (PluginParameter<?> p : getJobParameters()) 475 475 { 476 storeValue(job, request, p); 476 ParameterType<?> pType = p.getParameterType(); 477 Object value = request.getParameterValue(p.getName()); 478 if (pType.isEnumeration() && value != null) 479 { 480 // The 'key' value is sent in the request, but we 481 // want to store the 'value' value instead 482 Enumeration<?, String> e = pType.getEnumeration(); 483 for (int i = 0; i < e.size(); ++i) 484 { 485 if (value.equals(e.getKey(i))) 486 { 487 value = e.getValue(i); 488 break; 489 } 490 } 491 ParameterType<String> tmp = new StringParameterType(65535, null, false); 492 job.setValue(p.getName(), tmp, (String)value); 493 } 494 else 495 { 496 storeValue(job, request, p); 497 } 477 498 } 478 499 response.setDone("Job configuration complete", Job.ExecutionTime.SHORT); … … 860 881 String name = pp.getName(); 861 882 Object value = job.getValue(name); 883 ParameterType<?> pType = pp.getParameterType(); 884 if (pType.isEnumeration() && value != null) 885 { 886 // The 'value' value is stored in the database, but 887 // we need to export the 'key' value 888 Enumeration<?, String> e = pType.getEnumeration(); 889 for (int i = 0; i < e.size(); ++i) 890 { 891 if (value.equals(e.getValue(i))) 892 { 893 value = e.getKey(i); 894 break; 895 } 896 } 897 } 862 898 exporter.setParameter(name, value == null ? "" : value.toString()); 863 899 } … … 1576 1612 String[] enums = base1ConfigLine[6].split("\\\\t"); 1577 1613 if (enums.length % 2 != 0) throw new BaseException("name/value pairs in enum isnt even: "+base1ConfigLine[6]); 1614 Set<String> values = new HashSet<String>(); 1578 1615 for (int i = 0; i < enums.length; i += 2) 1579 1616 { 1580 1617 enumOptions.add(enums[i], enums[i+1]); 1618 if (!values.add(enums[i+1])) 1619 { 1620 throw new BaseException("Enumeration value for parameter '" + name + 1621 "' is not unique: " + enums[i+1]); 1622 } 1581 1623 } 1582 1624 } … … 1617 1659 else if (child.getName().equals("enumoptions")) 1618 1660 { 1661 Set<String> values = new HashSet<String>(); 1619 1662 Iterator<Element> it2 = child.getDescendants(new ElementFilter()); 1620 1663 while (it2.hasNext()) … … 1622 1665 Element value = it2.next(); 1623 1666 enumOptions.add(value.getAttributeValue("key"), value.getValue()); 1667 if (!values.add(value.getValue())) 1668 { 1669 throw new BaseException("Enumeration value for parameter '" + name + 1670 "' is not unique: " + value.getValue()); 1671 } 1624 1672 } 1625 1673 } -
trunk/src/test/data/test.nullplugin.base
r4537 r5204 20 20 % 21 21 1 h section 30 settings 0 22 2 t str String parame r 30 test 022 2 t str String parameter 30 test 0 23 23 3 i int Integer parameter 30 0 24 24 4 f float Float parameter 30 0 25 25 5 a text Text parameter 30,30 0 26 6 n ann annotation paremeter 30 0 026 6 n ann Annotation parameter 30 0 0 27 27 7 h hstr 30 0 28 8 e enum Enum par emter 30 1 0\tYes\t1\tNo\t2\tMaybe 028 8 e enum Enum parameter 30 1 0\tYes\t1\tNo\t2\tMaybe 0 29 29 -
trunk/src/test/data/test.nullplugin.cleanstd.base
r4776 r5204 20 20 % 21 21 1 h section 30 settings 0 22 2 t str String parame r 30 test 022 2 t str String parameter 30 test 0 23 23 3 i int Integer parameter 30 0 24 24 4 f float Float parameter 30 0 25 25 5 a text Text parameter 30,30 0 26 6 n ann annotation paremeter 30 0 026 6 n ann Annotation parameter 30 0 0 27 27 7 h hstr 30 0 28 8 e enum Enum par emter 30 1 0\tYes\t1\tNo\t2\tMaybe 028 8 e enum Enum parameter 30 1 0\tYes\t1\tNo\t2\tMaybe 0 29 29 -
trunk/src/test/data/test.nullplugin.matrix.base
r4537 r5204 20 20 % 21 21 1 h section 30 settings 0 22 2 t str String parame r 30 test 022 2 t str String parameter 30 test 0 23 23 3 i int Integer parameter 30 0 24 24 4 f float Float parameter 30 0 25 25 5 a text Text parameter 30,30 0 26 6 n ann annotation paremeter 30 0 026 6 n ann Annotation parameter 30 0 0 27 27 7 h hstr 30 0 28 8 e enum Enum par emter 30 1 0\tYes\t1\tNo\t2\tMaybe 028 8 e enum Enum parameter 30 1 0\tYes\t1\tNo\t2\tMaybe 0 29 29
Note: See TracChangeset
for help on using the changeset viewer.