28 searchword = GeneralFunctions.encodeURIComponent(searchword);
29 String url_string =
"http://peripleo.pelagios.org/peripleo/search?query=" + searchword +
"&types=place&limit=" + RetcatResource.getLimit();
30 URL url =
new URL(url_string);
31 HttpURLConnection conn = (HttpURLConnection) url.openConnection();
33 BufferedReader br =
new BufferedReader(
new InputStreamReader(conn.getInputStream(),
"UTF-8"));
35 StringBuilder response =
new StringBuilder();
36 while ((inputLine = br.readLine()) !=
null) {
37 response.append(inputLine);
41 JSONObject jsonObject = (JSONObject)
new JSONParser().parse(response.toString());
42 JSONArray resultsArray = (JSONArray) jsonObject.get(
"items");
43 Map<String, SuggestionItem> autosuggests =
new HashMap<String, SuggestionItem>();
44 for (Object element : resultsArray) {
45 JSONObject tmpElement = (JSONObject) element;
46 String uriValue = (String) tmpElement.get(
"identifier");
47 if (uriValue.contains(
"pleiades.stoa.org")) {
48 autosuggests.put(uriValue,
new SuggestionItem(uriValue));
49 SuggestionItem tmpAutosuggest = autosuggests.get(uriValue);
50 String labelValue = (String) tmpElement.get(
"title");
51 tmpAutosuggest.setLabel(labelValue);
52 String descriptionValue = (String) tmpElement.get(
"description");
53 if (descriptionValue !=
null) {
54 tmpAutosuggest.setDescription(descriptionValue);
56 tmpAutosuggest.setSchemeTitle(
"Pleides Places");
58 String type =
"pleiades";
61 for (RetcatItem item : LocalRetcatItems.getLocalCatalogue()) {
62 if (item.getType().equals(type)) {
63 quality = item.getQuality();
64 group = item.getGroup();
67 tmpAutosuggest.setType(type);
68 tmpAutosuggest.setQuality(quality);
69 tmpAutosuggest.setGroup(group);