Revision b1d7bf10
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/parser/SuggestParser.java | ||
---|---|---|
16 | 16 |
import org.json.JSONException; |
17 | 17 |
import org.json.JSONObject; |
18 | 18 |
|
19 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestTerm; |
|
19 | 20 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.OntologyTermWrapper; |
20 | 21 |
|
21 | 22 |
/** |
... | ... | |
28 | 29 |
List<OntologyTermWrapper> wrapperList = new ArrayList<>(); |
29 | 30 |
try { |
30 | 31 |
JSONObject jsonResponse = new JSONObject(response); |
31 |
JSONArray responseArray = jsonResponse.getJSONArray("results");
|
|
32 |
JSONArray responseArray = ParserUtil.parseResults(jsonResponse);
|
|
32 | 33 |
for(int i=0;i<responseArray.length();i++){ |
33 |
JSONObject terminology = responseArray.getJSONObject(i); |
|
34 |
String label = terminology.getString("label"); |
|
35 |
String uri = terminology.getString("uri"); |
|
36 |
String sourceTerminology = terminology.getString("sourceTerminology"); |
|
37 |
wrapperList.add(new OntologyTermWrapper(uri, label, sourceTerminology)); |
|
34 |
JSONObject jsonObject = responseArray.getJSONObject(i); |
|
35 |
String label = ParserUtil.parseLabel(jsonObject); |
|
36 |
String uri= ParserUtil.parseUri(jsonObject); |
|
37 |
String sourceTerminology = ParserUtil.parseTerminology(jsonObject); |
|
38 |
String request = new RequestTerm(uri, sourceTerminology).request(); |
|
39 |
//load term description |
|
40 |
String description = TermParser.parseSingleTerm(request).getDescription(); |
|
41 |
OntologyTermWrapper wrapper = new OntologyTermWrapper(uri, label, sourceTerminology); |
|
42 |
wrapper.setDescription(description); |
|
43 |
wrapperList.add(wrapper); |
|
38 | 44 |
} |
39 | 45 |
} catch (JSONException jsonException) { |
40 | 46 |
jsonException.printStackTrace(); |
Also available in: Unified diff
ref #7362 Refactor json parser + add term request