Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java
r3264 r3380 71 71 import net.sf.basedb.util.Enumeration; 72 72 import net.sf.basedb.util.RemovableUtil; 73 import net.sf.basedb.util.XMLUtil; 73 74 import net.sf.basedb.util.parser.FlatFileParser; 75 76 import org.jdom.Document; 77 import org.jdom.Element; 78 import org.jdom.JDOMException; 79 import org.jdom.filter.Filter; 74 80 75 81 import java.io.BufferedInputStream; … … 82 88 import java.io.InputStream; 83 89 import java.io.OutputStream; 90 import java.net.URL; 84 91 import java.sql.SQLException; 85 92 import java.util.ArrayList; … … 90 97 import java.util.HashMap; 91 98 import java.util.HashSet; 99 import java.util.Iterator; 92 100 import java.util.List; 93 101 import java.util.Map; … … 124 132 private static final Set<Permissions> permissions = new HashSet<Permissions>(); 125 133 134 private static final URL dtdFile = Base1PluginExecuter.class.getResource("/net/sf/basedb/core/dtd/base1-plugin-configuration-file.dtd"); 135 126 136 /* Configuration parameters */ 127 137 … … 172 182 173 183 /** 174 * The maximu number of channels, 0 means unlimited.184 * The maximum number of channels, 0 means unlimited. 175 185 */ 176 186 private PluginParameter<Integer> maxChannelsParameter; … … 198 208 private PluginParameter<String> usedFieldsParameter; 199 209 210 /** 211 * This parameter describes the job parameters that the base1 plugin needs. 212 */ 213 private PluginParameter<String> jobParametersParameter = new PluginParameter<String>( 214 "jobParameters", 215 "Job parameters", 216 "An XML text that describes the job parameters.", 217 new StringParameterType(null, null, true)); 218 200 219 /* Job parameters */ 201 220 /** … … 233 252 */ 234 253 private java.io.File execDirectory; 254 255 private int pluginDirectoryId = -1; 235 256 236 257 /* From InteractivePlugin iterface */ … … 320 341 throw new BaseException("Unable to configure job from configuration file. "+e.getMessage()); 321 342 } 343 catch (JDOMException e) 344 { 345 throw new BaseException("There is something wrong with the jobparameter xml. "+e.getMessage()); 346 } 322 347 } 323 348 else … … 338 363 { 339 364 storeValue(configuration, request, execPathParameter); 340 storeValue(configuration, request, fileParameter);341 365 342 366 dc = sc.newDbControl(); … … 353 377 354 378 getManualConfigureParameters(); 355 Map<String, String> headers = get BaseFileHeaders(f);379 Map<String, String> headers = getParametersFromBaseFile(f); 356 380 configuration.setValue(serialFormatParameter.getName(), serialFormatParameter.getParameterType(), getBoolean(headers.get(serialFormatParameter.getName()))); 357 381 configuration.setValue(versionNumberParameter.getName(), versionNumberParameter.getParameterType(), headers.get(versionNumberParameter.getName())); … … 364 388 configuration.setValue(usedColumnsParameter.getName(), usedColumnsParameter.getParameterType(), headers.get(usedColumnsParameter.getName())); 365 389 configuration.setValue(usedFieldsParameter.getName(), usedFieldsParameter.getParameterType(), headers.get(usedFieldsParameter.getName())); 390 configuration.setValue(jobParametersParameter.getName(), jobParametersParameter.getParameterType(), headers.get(jobParametersParameter.getName())); 366 391 367 392 response.setDone("Configured plug-in with file."); … … 384 409 storeValue(configuration, request, usedColumnsParameter); 385 410 storeValue(configuration, request, usedFieldsParameter); 386 387 //TODO: Ask about parameters and create a config file 411 storeValue(configuration, request, jobParametersParameter); 412 // test the xml in the jobParameters paramere 413 getJobParameters(); 388 414 response.setDone("Plugin configuration done."); 389 415 } … … 439 465 440 466 441 /** 442 * Creates the plugin directory specified by {@link Base1PluginExecuter#pluginDirectoryParameter}. 443 */ 444 private void createPluginDirectory() 467 private int createPluginDirectory() 445 468 { 446 469 DbControl dc = null; 470 int id = -1; 447 471 try 448 472 { 449 473 dc = sc.newDbControl(); 450 Directory parent = Directory.getByPath(dc, getPluginDirectoryPath().getParent()); 451 if (Directory.exists(dc, parent, getPluginDirectoryPath().getDirectory(getPluginDirectoryPath().getDirectoryCount() - 1))) 452 { 453 int directoryId = Directory.getIdFromPath(dc, getPluginDirectoryPath()); 454 RemovableUtil.removeRecursively(dc, Item.DIRECTORY, Collections.singleton(directoryId), true); 474 String pathName = (String) job.getValue(pluginDirectoryParameter.getName()) + "/" + job.getId(); 475 Path.makeSafeFilename(pathName, ""); 476 Path path = new Path(pathName, Path.Type.DIRECTORY); 477 try 478 { 479 id = Directory.getIdFromPath(dc, path); 480 // delete existing 481 RemovableUtil.removeRecursively(dc, Item.DIRECTORY, Collections.singleton(id), true); 455 482 dc.commit(); 456 483 dc = sc.newDbControl(); 457 484 } 458 Directory d = Directory.getNew(dc, getPluginDirectoryPath()); 459 dc.saveItem(d); 485 catch(ItemNotFoundException e) 486 {} 487 488 Directory jobDirectory = Directory.getNew(dc, path); 489 dc.saveItem(jobDirectory); 460 490 dc.commit(); 491 id = jobDirectory.getId(); 461 492 } 462 493 finally 463 494 { 464 if (dc != null) dc.close(); 465 } 466 } 467 495 if (dc != null) 496 dc.close(); 497 } 498 return id; 499 } 500 468 501 469 502 @Override … … 517 550 getConfigureJobParameters(); 518 551 progress.display(0, "Exporting data to be used by plugin."); 519 createPluginDirectory();520 552 File stdin = exportData(dc); 521 553 copy(stdin, getExecDirectory()); 522 554 progress.display(10, "Running on remote computation server."); 555 556 System.err.println(getExecLine()); 523 557 524 String execPath = (String) configuration.getValue(execPathParameter.getName()); 525 String execName = (String) configuration.getValue(execNameParameter.getName()); 526 Process p = Runtime.getRuntime().exec(execPath + java.io.File.separator + execName, null, getExecDirectory()); 558 Process p = Runtime.getRuntime().exec(getExecLine(), null, getExecDirectory()); 527 559 528 560 ByteArrayOutputStream err = new ByteArrayOutputStream(); … … 587 619 try 588 620 { 589 Directory d = Directory.getByPath(dc, getPluginDirectoryPath());621 Directory d = getPluginDirectory(dc); 590 622 File file = File.getFile(dc, d, "stdin.txt", true); 591 623 file.setMimeTypeAuto("text/plain", null); … … 628 660 { 629 661 throw new BaseException(e); 630 } 662 } 631 663 } 632 664 … … 639 671 * @return A list of {@link AnnotationType AnnotationTypes} 640 672 */ 641 private List<AnnotationType> getAnnotationTypes(DbControl dc, Experiment e) 642 { 643 ItemQuery<AnnotationType> query = e.getExperimentalFactors(); 644 query.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS); 645 query.order(Orders.asc(Hql.property("name"))); 646 return query.list(dc); 647 } 648 649 650 /** 651 * Get the headers from a configuration file. 673 private List<AnnotationType> getAnnotationTypes() 674 { 675 DbControl dc = null; 676 List<AnnotationType> list = null; 677 try 678 { 679 dc = sc.newDbControl(); 680 Experiment e = super.getCurrentExperiment(dc); 681 ItemQuery<AnnotationType> query = e.getExperimentalFactors(); 682 query.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS); 683 query.order(Orders.asc(Hql.property("name"))); 684 list = query.list(dc); 685 } 686 finally 687 { 688 if (dc != null) dc.close(); 689 } 690 return list; 691 } 692 693 694 /** 695 * Get the data from the configuration file. 652 696 * 653 697 * @param f The file. … … 655 699 * @throws IOException If there i any problem reading from file. 656 700 */ 657 private Map<String, String> get BaseFileHeaders(File f)701 private Map<String, String> getParametersFromBaseFile(File f) 658 702 throws IOException 659 703 { … … 673 717 headers.put(header, ffp.getHeader(header)); 674 718 } 719 720 String parameters = "<jobparameters>\n"; 721 while (ffp.hasMoreData()) 722 { 723 FlatFileParser.Data dataline = ffp.nextData(); 724 try 725 { 726 JobParameter jp = new JobParameter(dataline.line().split("\t")); 727 parameters += jp + "\n"; 728 } 729 catch(BaseException e) 730 { 731 throw new BaseException("Error on line "+dataline.lineNo()+" in the configurationfile.", e); 732 } 733 } 734 parameters += "</jobparameters>"; 735 headers.put(jobParametersParameter.getName(), parameters); 675 736 return headers; 676 737 } … … 774 835 parameters.add(maxChannelsParameter); 775 836 837 parameters.add(jobParametersParameter); 838 776 839 configureManual = new RequestInformation( 777 840 Base1PluginExecuter.COMMAND_MANUAL_CONFIG, … … 794 857 */ 795 858 private RequestInformation getConfigureJobParameters() 796 throws IOException 859 throws IOException, JDOMException 797 860 { 798 861 if (configureJob == null) … … 853 916 return execDirectory; 854 917 } 918 919 920 private String getExecLine() 921 { 922 String execPath = (String) configuration.getValue(execPathParameter.getName()); 923 String execName = (String) configuration.getValue(execNameParameter.getName()); 924 String s = java.io.File.separator; 925 if (execPath.endsWith(s) || execName.startsWith(s)) 926 { 927 s = ""; 928 } 929 String line = execPath + s + execName; 930 return line; 931 } 855 932 856 933 … … 880 957 * @throws IOException Thrown if there is any problem reading the configuration file. 881 958 */ 959 @SuppressWarnings("unchecked") 882 960 private List<PluginParameter<?>> getJobParameters() 883 throws IOException961 throws BaseException 884 962 { 885 963 if (jobParameters != null) … … 887 965 return jobParameters; 888 966 } 889 jobParameters = new ArrayList<PluginParameter<?>>(); 890 DbControl dc = null; 967 jobParameters = new ArrayList<PluginParameter<?>>(); 891 968 892 969 try 893 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 1001 DbControl dc = null; 1002 try 1003 { 894 1004 dc = sc.newDbControl(); 895 AnyToAny ata = AnyToAny.getByName(dc, configuration.getPluginConfiguration(), "Configurationfile"); 896 if (ata == null) 897 { 898 throw new BaseException("The plugin needs a configuration file to find the job parameters"); 899 } 900 File f = File.getById(dc, ata.getTo().getId()); 901 Experiment experiment = getCurrentBioAssaySet(dc).getExperiment(); 902 FlatFileParser ffp = getInitializedFlatFileParser(f.getDownloadStream(0)); 903 ffp.setMinDataColumns(8); 904 FlatFileParser.Line section = ffp.nextSection(); 905 while (section != null && !section.name().equals("plugin")) 906 { 907 section = ffp.nextSection(); 908 } 909 ffp.parseHeaders(); 910 List<String> columns = Arrays.asList(ffp.getHeader("columns").split("\\t")); 911 int valueTypeCol = columns.indexOf("valueType"); 912 int nameCol = columns.indexOf("name"); 913 int commonNameCol = columns.indexOf("commonName"); 914 int optionsCol = columns.indexOf("options"); 915 int defaultValueCol = columns.indexOf("defaultValue"); 916 int enumOptionsCol = columns.indexOf("enumOptions"); 917 int removedCol = columns.indexOf("removed"); 918 while (ffp.hasMoreData()) 919 { 920 FlatFileParser.Data dataline = ffp.nextData(); 921 if (!Boolean.valueOf(dataline.get(removedCol))) 922 { 923 String name = dataline.get(nameCol); 924 String commonName = dataline.get(commonNameCol); 925 String options = dataline.get(optionsCol); 926 String defaultValue = dataline.get(defaultValueCol); 927 String enumOptions = dataline.get(enumOptionsCol); 928 929 PluginParameter<?> parameter = null; 930 switch (dataline.get(valueTypeCol).charAt(0)) 931 { 932 // String parameter 933 case 't': 934 { 935 StringParameterType type = new StringParameterType(255, defaultValue, false, 1, new Integer(options), 1); 936 parameter = new PluginParameter<String>(name, commonName, "", type); 937 jobParameters.add(parameter); 938 break; 939 } 940 // Integer parameter 941 case 'i': 942 { 943 Integer defValue = defaultValue == null ? null : new Integer(defaultValue); 944 IntegerParameterType type = new IntegerParameterType(null, null, defValue, false, 1, new Integer(options), 1, null); 945 parameter = new PluginParameter<Integer>(name, commonName, "", type); 946 jobParameters.add(parameter); 947 break; 948 } 949 // HiddenString parameter 950 case 'h': 951 { 952 StringParameterType type = new StringParameterType(255, defaultValue, false, 1, 0, 1); 953 parameter = new PluginParameter<String>(name, null, "", type); 954 jobParameters.add(parameter); 955 break; 956 } 957 // Float parameter 958 case 'f': 959 { 960 Float defValue = defaultValue == null ? null : new Float(defaultValue); 961 FloatParameterType type = new FloatParameterType(null, null, defValue, false, 1, new Integer(options), 1, null); 962 parameter = new PluginParameter<Float>(name, commonName, "", type); 963 jobParameters.add(parameter); 964 break; 965 } 966 // TextField parameter 967 case 'a': 968 { 969 String[] wh = options.split(","); 970 StringParameterType type = new StringParameterType( 971 null, 972 defaultValue, 973 false, 974 1, 975 new Integer(wh[0]), 976 wh.length > 1 ? new Integer(wh[1]) : 1); 977 parameter = new PluginParameter<String>(name, commonName, "", type); 978 jobParameters.add(parameter); 979 break; 980 } 981 // Annotation parameter 982 case 'n': 983 { 984 List<AnnotationType> annotations = getAnnotationTypes(dc, experiment); 985 if (!annotations.isEmpty()) 986 { 987 Enumeration<String, String> enums = new Enumeration<String, String>(); 988 for (AnnotationType at : annotations) 989 { 990 enums.add(at.getName(), at.getName()); 991 } 992 StringParameterType type = new StringParameterType(255, defaultValue, true, 1, new Integer(options), 1, enums); 993 parameter = new PluginParameter<String>(name, commonName, "", type); 994 jobParameters.add(parameter); 995 } 996 break; 997 } 998 // Enum Parameter 999 case 'e': 1000 { 1001 Enumeration<String, String> enums = new Enumeration<String, String>(); 1002 String[] enumOptionsSplit = enumOptions.split("\\\\t"); 1003 for (int i = 0; i < enumOptionsSplit.length; i += 2) 1004 { 1005 enums.add(enumOptionsSplit[i], enumOptionsSplit[i + 1]); 1006 } 1007 StringParameterType type = new StringParameterType(255, defaultValue, true, 1, new Integer(options), 1, enums); 1008 parameter = new PluginParameter<String>(name, commonName, "", type); 1009 jobParameters.add(parameter); 1010 break; 1011 } 1012 } 1013 } 1014 } 1005 Experiment experiment = super.getCurrentExperiment(dc); 1015 1006 String homeDirectoryPath = "/" + PluginConfiguration.getById(dc, configuration.getId()).getName(); 1016 1007 Directory homeDirectory = experiment.getDirectory(); … … 1036 1027 finally 1037 1028 { 1038 dc.close();1039 } 1029 if (dc != null) dc.close(); 1030 } 1040 1031 1041 1032 return jobParameters; 1042 1033 } 1043 1034 1044 1045 /** 1046 * Creates the {@link Path} to the plugin directory. 1035 /** 1036 * Get a {@link Directory directory} 1047 1037 * 1048 * @return The path 1049 */ 1050 private Path getPluginDirectoryPath() 1051 { 1052 Path p = new Path((String) job.getValue(pluginDirectoryParameter.getName()) + "/" + job.getId(), Path.Type.DIRECTORY); 1053 return p; 1038 * @return 1039 */ 1040 private Directory getPluginDirectory(DbControl dc) 1041 { 1042 if (pluginDirectoryId == -1) 1043 { 1044 pluginDirectoryId = createPluginDirectory(); 1045 } 1046 return Directory.getById(dc, pluginDirectoryId); 1054 1047 } 1055 1048 … … 1167 1160 int repCol = columns.indexOf("reporter"); 1168 1161 int dataCol = columns.indexOf("assayData"); 1162 //TODO: should use the channels field to decide number of intensities 1169 1163 int int1Col = assayFields.indexOf("intensity1"); 1170 1164 int int2Col = assayFields.indexOf("intensity2"); … … 1328 1322 { 1329 1323 dc = sc.newDbControl(); 1330 Directory homeDirectory = Directory.getByPath(dc, getPluginDirectoryPath());1324 Directory homeDirectory = getPluginDirectory(dc); 1331 1325 importTempFiles(dc, getExecDirectory().listFiles(), homeDirectory); 1332 1326 dc.commit(); … … 1483 1477 } 1484 1478 } 1479 1480 private class JobParameter 1481 { 1482 private int position; 1483 1484 private Base1JobParameterType type; 1485 1486 private String name; 1487 1488 private String commonName; 1489 1490 private String options; 1491 1492 private String defaultValue; 1493 1494 private Enumeration<String, String> enumOptions = new Enumeration<String, String>(); 1495 1496 private boolean removed = false; 1497 1498 JobParameter(String... base1ConfigLine) 1499 { 1500 if (base1ConfigLine.length != 8) 1501 { 1502 throw new BaseException("Must have 8 parameters."); 1503 } 1504 if (base1ConfigLine[0].equals("")) 1505 { 1506 throw new BaseException("Position cannot be null"); 1507 } 1508 position = Integer.parseInt(base1ConfigLine[0]); 1509 if (base1ConfigLine[1].length() != 1) 1510 { 1511 throw new BaseException("Type must one character"); 1512 } 1513 type = Base1JobParameterType.get(base1ConfigLine[1].charAt(0)); 1514 name = base1ConfigLine[2]; 1515 commonName = base1ConfigLine[3]; 1516 options = base1ConfigLine[4]; 1517 defaultValue = base1ConfigLine[5]; 1518 1519 if (type == Base1JobParameterType.ENUMERATION) 1520 { 1521 String[] enums = base1ConfigLine[6].split("\\\\t"); 1522 if (enums.length % 2 != 0) throw new BaseException("name/value pairs in enum isnt even: "+base1ConfigLine[6]); 1523 for (int i = 0; i < enums.length; i += 2) 1524 { 1525 enumOptions.add(enums[i], enums[i+1]); 1526 } 1527 } 1528 removed = !base1ConfigLine[7].equals("0"); 1529 } 1530 1531 @SuppressWarnings("unchecked") 1532 JobParameter(Element e) 1533 { 1534 try 1535 { 1536 position = e.getAttribute("position").getIntValue(); 1537 type = Base1JobParameterType.get(e.getAttribute("type").getValue().charAt(0)); 1538 Iterator<Element> it = e.getDescendants(new Filter() 1539 { 1540 public boolean matches(Object o) 1541 { 1542 if (o instanceof Element) 1543 { 1544 return true; 1545 } 1546 return false; 1547 } 1548 }); 1549 while (it.hasNext()) 1550 { 1551 Element child = it.next(); 1552 if (child.getName().equals("name")) 1553 { 1554 name = child.getValue(); 1555 } 1556 else if (child.getName().equals("commonname")) 1557 { 1558 commonName = child.getValue(); 1559 } 1560 else if (child.getName().equals("options")) 1561 { 1562 options = child.getValue(); 1563 } 1564 else if (child.getName().equals("defaultvalue")) 1565 { 1566 defaultValue = child.getValue(); 1567 } 1568 else if (child.getName().equals("removed")) 1569 { 1570 removed = true; 1571 } 1572 else if (child.getName().equals("enumoptions")) 1573 { 1574 Iterator<Element> it2 = child.getDescendants(new Filter() 1575 { 1576 public boolean matches(Object o) 1577 { 1578 if (o instanceof Element) 1579 { 1580 return true; 1581 } 1582 return false; 1583 } 1584 }); 1585 while (it2.hasNext()) 1586 { 1587 Element value = it2.next(); 1588 enumOptions.add(value.getAttributeValue("key"), value.getValue()); 1589 } 1590 } 1591 } 1592 } 1593 catch (JDOMException ex) 1594 { 1595 throw new BaseException(ex); 1596 } 1597 } 1598 1599 public PluginParameter<?> getPluginParameter() 1600 { 1601 PluginParameter<?> parameter; 1602 switch (type) 1603 { 1604 case STRING: 1605 { 1606 StringParameterType t = new StringParameterType(255, defaultValue, false, 1, new Integer(options), 1); 1607 parameter = new PluginParameter<String>(name, commonName, "", t); 1608 break; 1609 } 1610 case INTEGER: 1611 { 1612 Integer defValue = defaultValue == null ? null : new Integer(defaultValue); 1613 IntegerParameterType t = new IntegerParameterType( 1614 null, 1615 null, 1616 defValue, 1617 false, 1618 1, 1619 new Integer(options), 1620 1, 1621 null); 1622 parameter = new PluginParameter<Integer>(name, commonName, "", t); 1623 break; 1624 } 1625 case HIDDEN_STRING: 1626 { 1627 StringParameterType t = new StringParameterType(255, defaultValue, false, 1, 0, 1); 1628 parameter = new PluginParameter<String>(name, null, "", t); 1629 break; 1630 } 1631 case FLOAT: 1632 { 1633 Float defValue = defaultValue == null ? null : new Float(defaultValue); 1634 FloatParameterType t = new FloatParameterType(null, null, defValue, false, 1, new Integer(options), 1, null); 1635 parameter = new PluginParameter<Float>(name, commonName, "", t); 1636 break; 1637 } 1638 case TEXT: 1639 { 1640 String[] wh = options.split(","); 1641 StringParameterType t = new StringParameterType(null, defaultValue, false, 1, new Integer(wh[0]), wh.length > 1 ? new Integer(wh[1]) : 1); 1642 parameter = new PluginParameter<String>(name, commonName, "", t); 1643 break; 1644 } 1645 case ANNOTATION: 1646 { 1647 List<AnnotationType> annotations = getAnnotationTypes(); 1648 Enumeration<String, String> enums = new Enumeration<String, String>(); 1649 for (AnnotationType at : annotations) 1650 { 1651 enums.add(at.getName(), at.getName()); 1652 } 1653 StringParameterType t = new StringParameterType(255, defaultValue, true, 1, new Integer(options), 1, enums); 1654 parameter = new PluginParameter<String>(name, commonName, "", t); 1655 jobParameters.add(parameter); 1656 break; 1657 } 1658 case ENUMERATION: 1659 { 1660 StringParameterType t = new StringParameterType(255, defaultValue, true, 1, new Integer(options), 1, enumOptions); 1661 parameter = new PluginParameter<String>(name, commonName, "", t); 1662 break; 1663 } 1664 default: 1665 parameter = null; 1666 } 1667 return parameter; 1668 } 1669 1670 @Override 1671 public String toString() 1672 { 1673 String s = "<parameter position=\""+position+"\" type=\""+type+"\">\n"; 1674 s += "\t<name>"+name+"</name>\n"; 1675 s += "\t<commonname>"+commonName+"</commonname>\n"; 1676 s += "\t<options>"+options+"</options>\n"; 1677 s += "\t<defaultvalue>"+defaultValue+"</defaultvalue>\n"; 1678 if (enumOptions.size() > 0) 1679 { 1680 s += "\t<enumoptions>\n"; 1681 for (int i = 0; i < enumOptions.size(); ++i) 1682 { 1683 s += "\t\t<value key=\""+enumOptions.getKey(i)+"\">"; 1684 s += enumOptions.getValue(i); 1685 s += "</value>\n"; 1686 } 1687 s += "\t</enumoptions>\n"; 1688 } 1689 if (removed) s += "<removed/>"; 1690 s += "</parameter>"; 1691 return s; 1692 } 1693 } 1694 1695 private enum Base1JobParameterType 1696 { 1697 HIDDEN_STRING('h'), STRING('t'), INTEGER('i'), FLOAT('f'), TEXT('a'), ANNOTATION('n'), ENUMERATION('e'); 1698 1699 private final char c; 1700 1701 private Base1JobParameterType(char c) 1702 { 1703 this.c = c; 1704 } 1705 1706 public static Base1JobParameterType get(char c) 1707 { 1708 switch (c) 1709 { 1710 case 'h' : return HIDDEN_STRING; 1711 case 't' : return STRING; 1712 case 'i' : return INTEGER; 1713 case 'f' : return FLOAT; 1714 case 'a' : return TEXT; 1715 case 'n' : return ANNOTATION; 1716 case 'e' : return ENUMERATION; 1717 default: 1718 throw new BaseException("Unknown type: "+c); 1719 } 1720 } 1721 1722 @Override 1723 public String toString() 1724 { 1725 return String.valueOf(c); 1726 } 1727 } 1485 1728 }
Note: See TracChangeset
for help on using the changeset viewer.