29 searchword = GeneralFunctions.encodeURIComponent(searchword);
30 String PERSONDBHOST =
"http://" + ConfigProperties.getPropertyParam(
"host") +
"/persondb";
31 String url_string = PERSONDBHOST +
"/search?query=" + searchword;
32 URL url =
new URL(url_string);
33 HttpURLConnection conn = (HttpURLConnection) url.openConnection();
34 conn.setRequestProperty(
"Accept",
"application/json");
35 BufferedReader br =
new BufferedReader(
new InputStreamReader(conn.getInputStream(),
"UTF-8"));
37 StringBuilder response =
new StringBuilder();
38 while ((inputLine = br.readLine()) !=
null) {
39 response.append(inputLine);
43 JSONArray jsonArray = (JSONArray)
new JSONParser().parse(response.toString());
44 Map<String, SuggestionItem> autosuggests =
new HashMap<String, SuggestionItem>();
45 for (Object element : jsonArray) {
46 JSONObject tmpElement = (JSONObject) element;
47 String uriValue = (String) tmpElement.get(
"id");
48 String uri = PERSONDBHOST +
"/persons/" + uriValue;
49 autosuggests.put(uri,
new SuggestionItem(uri));
50 SuggestionItem tmpAutosuggest = autosuggests.get(uri);
51 String firstName = (String) tmpElement.get(
"firstName");
52 String lastName = (String) tmpElement.get(
"lastName");
53 String labelValue = firstName +
" " + lastName;
54 tmpAutosuggest.setLabel(labelValue);
55 String affilliation = (String) tmpElement.get(
"affilliation");
56 tmpAutosuggest.setDescription(affilliation);
57 tmpAutosuggest.setSchemeTitle(
"Person Database");
59 String type =
"persondb";
62 for (RetcatItem item : LocalRetcatItems.getLocalCatalogue()) {
63 if (item.getType().equals(type)) {
64 quality = item.getQuality();
65 group = item.getGroup();
68 tmpAutosuggest.setType(type);
69 tmpAutosuggest.setQuality(quality);
70 tmpAutosuggest.setGroup(group);