Revision 3694
Added by Jing Tao almost 17 years ago
test/edu/ucsb/nceas/metacattest/UploadIPCCDataTest.java | ||
---|---|---|
105 | 105 |
private static String DOT = "."; |
106 | 106 |
private static String SUCCESSLOG = "update.log"; |
107 | 107 |
private static String ERRORLOG = "error.log"; |
108 |
private static String CURRENT_CORRECTFILENAME = "correct_filename.csv"; |
|
108 | 109 |
private File log = new File(SUCCESSLOG); |
109 | 110 |
private File error = new File (ERRORLOG); |
110 | 111 |
|
... | ... | |
127 | 128 |
public static Test suite() |
128 | 129 |
{ |
129 | 130 |
TestSuite suite = new TestSuite(); |
130 |
suite.addTest(new UploadIPCCDataTest("upload")); |
|
131 |
//suite.addTest(new UploadIPCCDataTest("upload")); |
|
132 |
//suite.addTest(new UploadIPCCDataTest("getCurrent_CorrectFileNamesPair")); |
|
131 | 133 |
return suite; |
132 | 134 |
} |
133 | 135 |
|
... | ... | |
564 | 566 |
//e.printStackTrace(System.out); |
565 | 567 |
} |
566 | 568 |
} |
569 |
|
|
570 |
/* |
|
571 |
* Read a csv file which contains current data file name and correct data file name. |
|
572 |
* The format of csv file is: |
|
573 |
* currentname1,correctname1 |
|
574 |
* currentname2,correctname2 |
|
575 |
* ........ |
|
576 |
* The return value is hash table, the current data file name is key and correct file name is |
|
577 |
* value. |
|
578 |
*/ |
|
579 |
private Hashtable getCurrent_CorrectFileNamesPair() throws Exception |
|
580 |
{ |
|
581 |
Hashtable fileNamesHash = new Hashtable(); |
|
582 |
File current_correctFileNames = new File(CURRENT_CORRECTFILENAME); |
|
583 |
FileReader fileReader= new FileReader(current_correctFileNames); |
|
584 |
BufferedReader readDocList = new BufferedReader(fileReader); |
|
585 |
// Read every line from the text file, this line will look like: |
|
586 |
// currentname1,correctname1 |
|
587 |
String lineString = readDocList.readLine(); |
|
588 |
while (lineString != null) |
|
589 |
{ |
|
590 |
//Get the comma index number |
|
591 |
int commaIndex = lineString.indexOf(","); |
|
592 |
if (commaIndex != -1) |
|
593 |
{ |
|
594 |
//Get the current file name part |
|
595 |
String currentName = lineString.substring(0, commaIndex); |
|
596 |
//Get the correct file name part |
|
597 |
String correctName = lineString.substring(commaIndex+1, lineString.length()); |
|
598 |
if (currentName != null && correctName != null) |
|
599 |
{ |
|
600 |
fileNamesHash.put(currentName.trim(), correctName.trim()); |
|
601 |
} |
|
602 |
} |
|
603 |
lineString = readDocList.readLine(); |
|
604 |
} |
|
605 |
return fileNamesHash; |
|
606 |
} |
|
567 | 607 |
} |
Also available in: Unified diff
Modify this class in order to correct data file name in some IPCC eml documents