1
|
package org.cybertaxonomy.utis.occurrences;
|
2
|
|
3
|
import java.util.ArrayList;
|
4
|
import java.util.Iterator;
|
5
|
import java.util.List;
|
6
|
|
7
|
import javax.xml.bind.JAXBException;
|
8
|
|
9
|
import org.cybertaxonomy.utis.checklist.DRFChecklistException;
|
10
|
import org.cybertaxonomy.utis.checklist.GBIFBackboneClient;
|
11
|
import org.cybertaxonomy.utis.client.ServiceProviderInfo;
|
12
|
import org.cybertaxonomy.utis.input.DRFCSVInputParser;
|
13
|
import org.cybertaxonomy.utis.input.DRFInputException;
|
14
|
import org.cybertaxonomy.utis.occurrences.GBIFOccurrencesClient;
|
15
|
import org.cybertaxonomy.utis.tnr.msg.TnrMsg;
|
16
|
import org.cybertaxonomy.utis.utils.BiovelUtils;
|
17
|
import org.cybertaxonomy.utis.utils.JSONUtils;
|
18
|
import org.cybertaxonomy.utis.utils.TnrMsgException;
|
19
|
import org.cybertaxonomy.utis.utils.TnrMsgUtils;
|
20
|
import org.junit.BeforeClass;
|
21
|
import org.junit.Test;
|
22
|
|
23
|
import java.io.BufferedWriter;
|
24
|
import java.io.File;
|
25
|
import java.io.FileWriter;
|
26
|
import java.io.IOException;
|
27
|
|
28
|
|
29
|
public class GBIFOccurrencesTest {
|
30
|
private static DRFCSVInputParser parser;
|
31
|
private static List<String> nameCompleteList;
|
32
|
|
33
|
private static ServiceProviderInfo ci;
|
34
|
|
35
|
@BeforeClass
|
36
|
public static void setup() {
|
37
|
nameCompleteList = new ArrayList<String>();
|
38
|
nameCompleteList.add("Ameira divagans");
|
39
|
nameCompleteList.add("Boccardiella ligerica");
|
40
|
//nameCompleteList.add("Coscinodiscus wailesii");
|
41
|
|
42
|
}
|
43
|
|
44
|
@Test
|
45
|
public void convertChecklistInfoToJson() throws DRFChecklistException {
|
46
|
String checklistInfoJson = JSONUtils.convertObjectToJson(ci);
|
47
|
System.out.println("Json : " + checklistInfoJson);
|
48
|
}
|
49
|
|
50
|
@Test
|
51
|
public void getOccurrencesTest() throws DRFChecklistException, IOException {
|
52
|
GBIFOccurrencesClient goc = new GBIFOccurrencesClient();
|
53
|
String occurrences = goc.queryOccurrenceBank(nameCompleteList);
|
54
|
//System.out.println("occurrences : " + occurrences);
|
55
|
/* File file = new File("/home/cmathew/Temp/AchilleaMillefolium/occurrences.txt");
|
56
|
|
57
|
// if file doesnt exists, then create it
|
58
|
if (!file.exists()) {
|
59
|
file.createNewFile();
|
60
|
}
|
61
|
|
62
|
FileWriter fw = new FileWriter(file.getAbsoluteFile());
|
63
|
BufferedWriter bw = new BufferedWriter(fw);
|
64
|
bw.write(occurrences);
|
65
|
bw.close();*/
|
66
|
|
67
|
System.out.println("Done");
|
68
|
|
69
|
}
|
70
|
}
|