@Test public void testCreateAutocompleteList() { String w3cContext = "http: List <SuggestOption> options = new ArrayList<SuggestOption>(); SuggestOption suggestOption = new SuggestOption("tested"); options.add(suggestOption); boolean isW3c = true; String queryString = "http: String motivation = ""; String date = ""; String user = ""; Map<String,Object> json = annotationUtils.createAutocompleteList(options, isW3c, queryString, motivation, date, user); LOG.info(" "); LOG.info(json); @SuppressWarnings("unchecked") List <String>ignoredList = (ArrayList<String>)json.get("ignored"); assertNull(ignoredList); String id = (String)json.get("@id"); assertEquals(id,"http: String context = (String)json.get("@context"); assertEquals(context,w3cContext); motivation = "commenting"; queryString = "http: json = annotationUtils.createAutocompleteList(options, isW3c, queryString, motivation, date, user); LOG.info(" "); LOG.info(json); ignoredList = (ArrayList<String>)json.get("ignored"); assertTrue(ignoredList.contains("motivation")); id = (String)json.get("@id"); assertEquals(id,"http: context = (String)json.get("@context"); assertEquals(context,w3cContext); SuggestOption suggestOption2 = new SuggestOption("testes"); options.add(suggestOption2); date = "12/04/1970"; queryString = "http: json = annotationUtils.createAutocompleteList(options, isW3c, queryString, motivation, date, user); ignoredList = (ArrayList<String>)json.get("ignored"); assertTrue(ignoredList.contains("motivation")); assertTrue(ignoredList.contains("date")); LOG.info(" "); LOG.info(json); id = (String)json.get("@id"); assertEquals(id,"http: context = (String)json.get("@context"); assertEquals(context,w3cContext); isW3c = false; json = annotationUtils.createAutocompleteList(options, isW3c, queryString, motivation, date, user); LOG.info(" "); LOG.info(json); id = (String)json.get("@id"); assertEquals(id,"http: queryString = "http: json = annotationUtils.createAutocompleteList(options, isW3c, queryString, motivation, date, user); id = (String)json.get("@id"); assertEquals(id,"http: context = (String)json.get("@context"); assertEquals(context,w3cContext); motivation = "commenting tagging"; user = "frank"; queryString = "http: json = annotationUtils.createAutocompleteList(options, isW3c, queryString, motivation, date, user); LOG.info(" "); LOG.info(json); id = (String)json.get("@id"); assertEquals(id,"http: context = (String)json.get("@context"); assertEquals(context,w3cContext); ignoredList = (ArrayList<String>)json.get("ignored"); assertTrue(ignoredList.contains("motivation")); assertTrue(ignoredList.contains("date")); assertTrue(ignoredList.contains("user")); }
public Map<String, Object> createAutocompleteList(List<SuggestOption> options, boolean isW3c, String queryString, String motivation, String date, String user) { if (null == options || options.isEmpty()) { return null; } try { Map<String, Object> root = this.buildAutoCompleteHead(queryString, motivation, date, user); List resources = (List) root.get(OA_TERMSLIST); for (SuggestOption option : options) { Map<String, Object> optionRoot = new LinkedTreeMap<>(); String optionText = option.getText(); optionRoot.put("match", optionText); optionRoot.put("url", getSearchQueryFromAutocompleteQuery(queryString, optionText)); if (!resources.contains(optionRoot)) { resources.add(optionRoot); } } LOG.debug("resources are " + JsonUtils.toString(root)); return root; } catch (IOException ioe) { LOG.error("Error getting default file " + ioe); return null; } }
AnnotationUtils extends CommonUtils { public Map<String, Object> createAutocompleteList(List<SuggestOption> options, boolean isW3c, String queryString, String motivation, String date, String user) { if (null == options || options.isEmpty()) { return null; } try { Map<String, Object> root = this.buildAutoCompleteHead(queryString, motivation, date, user); List resources = (List) root.get(OA_TERMSLIST); for (SuggestOption option : options) { Map<String, Object> optionRoot = new LinkedTreeMap<>(); String optionText = option.getText(); optionRoot.put("match", optionText); optionRoot.put("url", getSearchQueryFromAutocompleteQuery(queryString, optionText)); if (!resources.contains(optionRoot)) { resources.add(optionRoot); } } LOG.debug("resources are " + JsonUtils.toString(root)); return root; } catch (IOException ioe) { LOG.error("Error getting default file " + ioe); return null; } } }
AnnotationUtils extends CommonUtils { public Map<String, Object> createAutocompleteList(List<SuggestOption> options, boolean isW3c, String queryString, String motivation, String date, String user) { if (null == options || options.isEmpty()) { return null; } try { Map<String, Object> root = this.buildAutoCompleteHead(queryString, motivation, date, user); List resources = (List) root.get(OA_TERMSLIST); for (SuggestOption option : options) { Map<String, Object> optionRoot = new LinkedTreeMap<>(); String optionText = option.getText(); optionRoot.put("match", optionText); optionRoot.put("url", getSearchQueryFromAutocompleteQuery(queryString, optionText)); if (!resources.contains(optionRoot)) { resources.add(optionRoot); } } LOG.debug("resources are " + JsonUtils.toString(root)); return root; } catch (IOException ioe) { LOG.error("Error getting default file " + ioe); return null; } }  }
AnnotationUtils extends CommonUtils { public Map<String, Object> createAutocompleteList(List<SuggestOption> options, boolean isW3c, String queryString, String motivation, String date, String user) { if (null == options || options.isEmpty()) { return null; } try { Map<String, Object> root = this.buildAutoCompleteHead(queryString, motivation, date, user); List resources = (List) root.get(OA_TERMSLIST); for (SuggestOption option : options) { Map<String, Object> optionRoot = new LinkedTreeMap<>(); String optionText = option.getText(); optionRoot.put("match", optionText); optionRoot.put("url", getSearchQueryFromAutocompleteQuery(queryString, optionText)); if (!resources.contains(optionRoot)) { resources.add(optionRoot); } } LOG.debug("resources are " + JsonUtils.toString(root)); return root; } catch (IOException ioe) { LOG.error("Error getting default file " + ioe); return null; } }  Map<String, Object> createAnnotationPage(String query, List<W3CAnnotation> annoList, boolean isW3c,
	    PageParameters pageParams, int totalHits, boolean isMixedSearch); Map<String, Object> createAutocompleteList(List<SuggestOption> options, boolean isW3c, String queryString,
	    String motivation, String date, String user); List<W3CAnnotation> getW3CAnnotations(String[] annotationArray); String convertSpecialCharacters(String input); int[] getPageParams(Map<String, Object> root, boolean isW3c); }
AnnotationUtils extends CommonUtils { public Map<String, Object> createAutocompleteList(List<SuggestOption> options, boolean isW3c, String queryString, String motivation, String date, String user) { if (null == options || options.isEmpty()) { return null; } try { Map<String, Object> root = this.buildAutoCompleteHead(queryString, motivation, date, user); List resources = (List) root.get(OA_TERMSLIST); for (SuggestOption option : options) { Map<String, Object> optionRoot = new LinkedTreeMap<>(); String optionText = option.getText(); optionRoot.put("match", optionText); optionRoot.put("url", getSearchQueryFromAutocompleteQuery(queryString, optionText)); if (!resources.contains(optionRoot)) { resources.add(optionRoot); } } LOG.debug("resources are " + JsonUtils.toString(root)); return root; } catch (IOException ioe) { LOG.error("Error getting default file " + ioe); return null; } }  Map<String, Object> createAnnotationPage(String query, List<W3CAnnotation> annoList, boolean isW3c,
	    PageParameters pageParams, int totalHits, boolean isMixedSearch); Map<String, Object> createAutocompleteList(List<SuggestOption> options, boolean isW3c, String queryString,
	    String motivation, String date, String user); List<W3CAnnotation> getW3CAnnotations(String[] annotationArray); String convertSpecialCharacters(String input); int[] getPageParams(Map<String, Object> root, boolean isW3c); static final String SERVICE_NAME; }