@Test public void testCreateAnnotationPage() { List<W3CAnnotation> annoList = new ArrayList<W3CAnnotation>(); annoList.add(createDummyAnnotation("1")); String query = "http: boolean isW3c = true; PageParameters pageParams = new PageParameters(); pageParams.setTotal(12); pageParams.setFirstPageNumber("1"); pageParams.setLastPageNumber("2"); pageParams.setNextPageNumber("2"); pageParams.setPreviousPageNumber(null); pageParams.setStartIndex(0); int totalHits = 11; Map<String,Object> json = annotationUtils.createAnnotationPage(query, annoList, isW3c, pageParams, totalHits, false); LOG.info(json); assertTrue("http: assertTrue("http: assertTrue("http: assertNull(json.get("hits")); assertFalse("http: isW3c = false; json = annotationUtils.createAnnotationPage(query, annoList, isW3c, pageParams, totalHits, false); assertFalse("http: assertTrue("sc:AnnotationList".equals(json.get("@type"))); assertNull(json.get("hits")); LOG.info(json); }
public Map<String, Object> createAnnotationPage(String query, List<W3CAnnotation> annoList, boolean isW3c, PageParameters pageParams, int totalHits, boolean isMixedSearch) { if (null == annoList || annoList.isEmpty()) { return null; } Map<String, Object> root; if (isMixedSearch) { root = new LinkedHashMap<>(); this.setResources(root, isW3c); } else { if (AnnotationSearchServiceImpl.DEFAULT_PAGING_NUMBER <= totalHits) { root = this.buildAnnotationPageHead(query, isW3c, pageParams, false); } else { root = this.buildAnnotationListHead(query, isW3c, false); } } List resources = this.getResources(root, isW3c); for (W3CAnnotation w3CAnnotation : annoList) { resources.add(w3CAnnotation.getJsonMap()); } return root; }
AnnotationUtils extends CommonUtils { public Map<String, Object> createAnnotationPage(String query, List<W3CAnnotation> annoList, boolean isW3c, PageParameters pageParams, int totalHits, boolean isMixedSearch) { if (null == annoList || annoList.isEmpty()) { return null; } Map<String, Object> root; if (isMixedSearch) { root = new LinkedHashMap<>(); this.setResources(root, isW3c); } else { if (AnnotationSearchServiceImpl.DEFAULT_PAGING_NUMBER <= totalHits) { root = this.buildAnnotationPageHead(query, isW3c, pageParams, false); } else { root = this.buildAnnotationListHead(query, isW3c, false); } } List resources = this.getResources(root, isW3c); for (W3CAnnotation w3CAnnotation : annoList) { resources.add(w3CAnnotation.getJsonMap()); } return root; } }
AnnotationUtils extends CommonUtils { public Map<String, Object> createAnnotationPage(String query, List<W3CAnnotation> annoList, boolean isW3c, PageParameters pageParams, int totalHits, boolean isMixedSearch) { if (null == annoList || annoList.isEmpty()) { return null; } Map<String, Object> root; if (isMixedSearch) { root = new LinkedHashMap<>(); this.setResources(root, isW3c); } else { if (AnnotationSearchServiceImpl.DEFAULT_PAGING_NUMBER <= totalHits) { root = this.buildAnnotationPageHead(query, isW3c, pageParams, false); } else { root = this.buildAnnotationListHead(query, isW3c, false); } } List resources = this.getResources(root, isW3c); for (W3CAnnotation w3CAnnotation : annoList) { resources.add(w3CAnnotation.getJsonMap()); } return root; }  }
AnnotationUtils extends CommonUtils { public Map<String, Object> createAnnotationPage(String query, List<W3CAnnotation> annoList, boolean isW3c, PageParameters pageParams, int totalHits, boolean isMixedSearch) { if (null == annoList || annoList.isEmpty()) { return null; } Map<String, Object> root; if (isMixedSearch) { root = new LinkedHashMap<>(); this.setResources(root, isW3c); } else { if (AnnotationSearchServiceImpl.DEFAULT_PAGING_NUMBER <= totalHits) { root = this.buildAnnotationPageHead(query, isW3c, pageParams, false); } else { root = this.buildAnnotationListHead(query, isW3c, false); } } List resources = this.getResources(root, isW3c); for (W3CAnnotation w3CAnnotation : annoList) { resources.add(w3CAnnotation.getJsonMap()); } return root; }  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> createAnnotationPage(String query, List<W3CAnnotation> annoList, boolean isW3c, PageParameters pageParams, int totalHits, boolean isMixedSearch) { if (null == annoList || annoList.isEmpty()) { return null; } Map<String, Object> root; if (isMixedSearch) { root = new LinkedHashMap<>(); this.setResources(root, isW3c); } else { if (AnnotationSearchServiceImpl.DEFAULT_PAGING_NUMBER <= totalHits) { root = this.buildAnnotationPageHead(query, isW3c, pageParams, false); } else { root = this.buildAnnotationListHead(query, isW3c, false); } } List resources = this.getResources(root, isW3c); for (W3CAnnotation w3CAnnotation : annoList) { resources.add(w3CAnnotation.getJsonMap()); } return root; }  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; }