Changeset 6470
- Timestamp:
- Nov 4, 2021, 11:59:33 AM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/branches/4.33-stable/src/net/sf/basedb/reggie/servlet/ExportServlet.java
r6336 r6470 606 606 long parsedCharacters = header.length()+1; 607 607 String[] dataIn = header.split("\t", 2); 608 if (dataIn.length != 2) 609 { 610 throw new IOException("The file need at least 2 header columns"); 611 } 608 if (dataIn.length == 2) outColumns.add(new RestOfData(dataIn[1])); 612 609 613 610 int lastCol = outColumns.size(); 614 Object[] headerOut = new Object[lastCol +1];611 Object[] headerOut = new Object[lastCol]; 615 612 for (int colNo = 0; colNo < lastCol; colNo++) 616 613 { 617 614 headerOut[colNo] = outColumns.get(colNo).getHeader(); 618 615 } 619 headerOut[lastCol] = dataIn[1];620 616 621 617 int lineOut = 0; … … 631 627 progress.display((int)(100*parsedCharacters / totalBytes), "Working... " + inputLine.lineNo + " lines parsed so far..."); 632 628 633 dataIn = data.split("\t", 2); 634 if (dataIn.length != 2) 635 { 636 throw new IOException("On line " + inputLine.lineNo + ": The file need at least 2 data columns"); 637 } 638 639 inputLine.fromId = Values.getStringOrNull(dataIn[0]); 629 inputLine.cols = data.split("\t", 2); 630 inputLine.fromId = Values.getStringOrNull(inputLine.cols[0]); 640 631 if (inputLine.fromId == null) 641 632 { … … 660 651 output[colNo] = outColumns.get(colNo).convert(inputLine); 661 652 } 662 output[lastCol] = dataIn[1];663 653 dataOut.add(output); 664 654 lineOut++; … … 1486 1476 { 1487 1477 int lineNo; 1478 String[] cols; 1488 1479 String fromId; 1489 1480 BioSource patient; … … 1696 1687 1697 1688 /** 1689 Get the rest of the data on the line. 1690 @since 4.33.4 1691 */ 1692 static class RestOfData 1693 extends OutputColumn 1694 { 1695 1696 RestOfData(String restHeader) 1697 { 1698 super(restHeader); 1699 } 1700 1701 @Override 1702 public String convert(InputLine ctx) 1703 { 1704 return ctx.cols.length == 2 ? ctx.cols[1] : null; 1705 } 1706 } 1707 1708 /** 1698 1709 Get the external (release) ID from the patient. 1699 1710 */
Note: See TracChangeset
for help on using the changeset viewer.