28 searchword = GeneralFunctions.encodeURIComponent(searchword);
29 String url_string =
"http://chronontology.dainst.org/data/period?q=" + searchword +
"&limit=" + RetcatResource.getLimit();
30 URL url =
new URL(url_string);
31 HttpURLConnection conn = (HttpURLConnection) url.openConnection();
32 BufferedReader br =
new BufferedReader(
new InputStreamReader(conn.getInputStream(),
"UTF-8"));
34 StringBuilder response =
new StringBuilder();
35 while ((inputLine = br.readLine()) !=
null) {
36 response.append(inputLine);
40 JSONArray outArray =
new JSONArray();
42 JSONObject jsonObject = (JSONObject)
new JSONParser().parse(response.toString());
43 JSONArray resultsArray = (JSONArray) jsonObject.get(
"results");
44 Map<String, SuggestionItem> autosuggests =
new HashMap<String, SuggestionItem>();
45 for (Object element : resultsArray) {
46 JSONObject tmpElement = (JSONObject) element;
47 JSONObject resourceObject = (JSONObject) tmpElement.get(
"resource");
48 String uriValue = (String) tmpElement.get(
"@id");
49 uriValue =
"http://chronontology.dainst.org" + uriValue;
50 autosuggests.put(uriValue,
new SuggestionItem(uriValue));
51 SuggestionItem tmpAutosuggest = autosuggests.get(uriValue);
52 JSONArray names = (JSONArray) resourceObject.get(
"names");
53 String labelValue =
null;
54 String labelLang =
null;
55 for (Object item : names) {
56 JSONObject tmp = (JSONObject) item;
57 if (tmp.get(
"lang").equals(
"en")) {
58 labelLang = (String) tmp.get(
"lang");
59 JSONArray content = (JSONArray) tmp.get(
"content");
60 labelValue = (String) content.get(0);
63 tmpAutosuggest.setLabel(labelValue);
64 tmpAutosuggest.setLanguage(labelLang);
65 String descriptionValue = (String) resourceObject.get(
"description");
66 if (descriptionValue !=
null) {
67 tmpAutosuggest.setDescription(descriptionValue);
69 tmpAutosuggest.setSchemeTitle(
"ChronOntology");
71 String type =
"chronontology";
74 for (RetcatItem item : LocalRetcatItems.getLocalCatalogue()) {
75 if (item.getType().equals(type)) {
76 quality = item.getQuality();
77 group = item.getGroup();
80 tmpAutosuggest.setType(type);
81 tmpAutosuggest.setQuality(quality);
82 tmpAutosuggest.setGroup(group);