2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.view
.webimport
.termimport
.parser
;
11 import java
.util
.ArrayList
;
12 import java
.util
.Collection
;
13 import java
.util
.List
;
15 import org
.json
.JSONArray
;
16 import org
.json
.JSONException
;
17 import org
.json
.JSONObject
;
19 import eu
.etaxonomy
.taxeditor
.view
.webimport
.termimport
.wrapper
.OntologyTermWrapper
;
26 public class OntologyTermParser
{
27 public static Collection
<OntologyTermWrapper
> parse(String response
, String terminology
){
28 List
<OntologyTermWrapper
> wrapperList
= new ArrayList
<>();
30 JSONObject jsonResponse
= new JSONObject(response
);
31 JSONArray responseArray
= ParserUtil
.parseResults(jsonResponse
);
32 for(int i
=0;i
<responseArray
.length();i
++){
33 JSONObject jsonObject
= responseArray
.getJSONObject(i
);
34 String label
= ParserUtil
.parseLabel(jsonObject
);
35 String uriString
= ParserUtil
.parseUri(jsonObject
);
36 wrapperList
.add(new OntologyTermWrapper(uriString
, label
, terminology
));
38 } catch (JSONException e
) {