@Test public void suggestAsXMLWithEditAccessAndSortByEid() throws Exception { Document response = parseXML(this.component.suggestAsXML("dOe", 4, "edit", EID, "desc")); NodeList suggestions = response.getElementsByTagName("rs"); Mockito.verify(this.queryManager).createQuery( "select doc.name from Document doc, doc.object(PhenoTips.PatientClass) as patient" + " where doc.name <> :t" + " and lower(doc.name) like :input or lower(patient.external_id) like :input" + " or lower(patient.first_name) like :input or lower(patient.last_name) like :input" + " order by patient.external_id desc", Query.XWQL); Mockito.verify(this.query).bindValue("t", "PatientTemplate"); Mockito.verify(this.query).bindValue("input", "%doe%"); Assert.assertEquals(2, suggestions.getLength()); Assert.assertEquals("/view/writablePatient1", ((Element) suggestions.item(0)).getAttribute(ID)); Assert.assertEquals("wiki:data.writablePatient1", ((Element) suggestions.item(0)).getAttribute("info")); Assert.assertEquals("writablePatient1, name: McCoy, identifier: Beast", ((Element) suggestions.item(0)).getTextContent()); Assert.assertEquals("/view/writablePatient2", ((Element) suggestions.item(1)).getAttribute(ID)); Assert.assertEquals("wiki:data.writablePatient2", ((Element) suggestions.item(1)).getAttribute("info")); Assert.assertEquals("writablePatient2", ((Element) suggestions.item(1)).getTextContent()); }
@Override public String suggestAsXML(String input, int maxResults, String requiredPermission, String orderField, String order) { if (StringUtils.isEmpty(input)) { throw new WebApplicationException(Response.Status.BAD_REQUEST); } List<Patient> patients = getMatchingPatients(input.toLowerCase(), orderField, order, maxResults, Right.toRight(requiredPermission)); StringBuilder xmlResult = new StringBuilder("<results>"); for (Patient patient : patients) { appentPatientXML(patient, xmlResult); } xmlResult.append("</results>"); return xmlResult.toString(); }
DefaultPatientsSuggestionsResourceImpl extends XWikiResource implements PatientsSuggestionsResource { @Override public String suggestAsXML(String input, int maxResults, String requiredPermission, String orderField, String order) { if (StringUtils.isEmpty(input)) { throw new WebApplicationException(Response.Status.BAD_REQUEST); } List<Patient> patients = getMatchingPatients(input.toLowerCase(), orderField, order, maxResults, Right.toRight(requiredPermission)); StringBuilder xmlResult = new StringBuilder("<results>"); for (Patient patient : patients) { appentPatientXML(patient, xmlResult); } xmlResult.append("</results>"); return xmlResult.toString(); } }
DefaultPatientsSuggestionsResourceImpl extends XWikiResource implements PatientsSuggestionsResource { @Override public String suggestAsXML(String input, int maxResults, String requiredPermission, String orderField, String order) { if (StringUtils.isEmpty(input)) { throw new WebApplicationException(Response.Status.BAD_REQUEST); } List<Patient> patients = getMatchingPatients(input.toLowerCase(), orderField, order, maxResults, Right.toRight(requiredPermission)); StringBuilder xmlResult = new StringBuilder("<results>"); for (Patient patient : patients) { appentPatientXML(patient, xmlResult); } xmlResult.append("</results>"); return xmlResult.toString(); }  }
DefaultPatientsSuggestionsResourceImpl extends XWikiResource implements PatientsSuggestionsResource { @Override public String suggestAsXML(String input, int maxResults, String requiredPermission, String orderField, String order) { if (StringUtils.isEmpty(input)) { throw new WebApplicationException(Response.Status.BAD_REQUEST); } List<Patient> patients = getMatchingPatients(input.toLowerCase(), orderField, order, maxResults, Right.toRight(requiredPermission)); StringBuilder xmlResult = new StringBuilder("<results>"); for (Patient patient : patients) { appentPatientXML(patient, xmlResult); } xmlResult.append("</results>"); return xmlResult.toString(); }  @Override String suggestAsJSON(String input, int maxResults, String requiredPermission, String orderField,
        String order); @Override String suggestAsXML(String input, int maxResults, String requiredPermission, String orderField, String order); }
DefaultPatientsSuggestionsResourceImpl extends XWikiResource implements PatientsSuggestionsResource { @Override public String suggestAsXML(String input, int maxResults, String requiredPermission, String orderField, String order) { if (StringUtils.isEmpty(input)) { throw new WebApplicationException(Response.Status.BAD_REQUEST); } List<Patient> patients = getMatchingPatients(input.toLowerCase(), orderField, order, maxResults, Right.toRight(requiredPermission)); StringBuilder xmlResult = new StringBuilder("<results>"); for (Patient patient : patients) { appentPatientXML(patient, xmlResult); } xmlResult.append("</results>"); return xmlResult.toString(); }  @Override String suggestAsJSON(String input, int maxResults, String requiredPermission, String orderField,
        String order); @Override String suggestAsXML(String input, int maxResults, String requiredPermission, String orderField, String order);  }