@Test public void children() throws Exception { String parentType = "COMPLAINT"; String parentId = "999"; String childType = "TASK"; Boolean activeOnly = false; Boolean exceptDeletedOnly = true; String query = "parent_object_type_s:" + parentType + " AND parent_object_id_i:" + parentId + " AND object_type_s:" + childType; if (activeOnly) { query += " AND -status_s:COMPLETE AND -status_s:DELETE AND -status_s:CLOSED"; } if (exceptDeletedOnly) { if (!activeOnly) { query += " AND -status_s:DELETED AND -status_s:DELETE"; } } String solrResponse = "{ \"solrResponse\": \"this is a test response.\" }"; expect(mockAuthentication.getName()).andReturn("user").atLeastOnce(); expect(mockExecuteSolrQuery.getResultsByPredefinedQuery(mockAuthentication, SolrCore.QUICK_SEARCH, query, 0, 10, "")) .andReturn(solrResponse); replayAll(); MvcResult result = mockMvc.perform( get("/api/v1/plugin/search/children") .param("parentId", parentId) .param("parentType", parentType) .param("childType", childType) .principal(mockAuthentication)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); verifyAll(); String jsonString = result.getResponse().getContentAsString(); log.debug("Got JSON: " + jsonString); assertEquals(solrResponse, jsonString); }
@RequestMapping(value = "/children", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String children( @RequestParam(value = "parentType", required = true) String parentType, @RequestParam(value = "parentId", required = true) Long parentId, @RequestParam(value = "childType", required = false, defaultValue = "") String childType, @RequestParam(value = "activeOnly", required = false, defaultValue = "false") boolean activeOnly, @RequestParam(value = "exceptDeletedOnly", required = false, defaultValue = "true") boolean exceptDeletedOnly, @RequestParam(value = "extra", required = false) List<String> extra, @RequestParam(value = "s", required = false, defaultValue = "") String sort, @RequestParam(value = "start", required = false, defaultValue = "0") int startRow, @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows, Authentication authentication) throws MuleException { String query = "parent_object_type_s:" + parentType + " AND parent_object_id_i:" + parentId; if (!"".equals(childType)) { query = query + " AND object_type_s:" + childType; } if (activeOnly) { query += " AND -status_s:COMPLETE AND -status_s:DELETE AND -status_s:CLOSED AND -status_s:CLOSE"; } if (exceptDeletedOnly) { if (!activeOnly) { query += " AND -status_s:DELETED AND -status_s:DELETE"; } } if (extra != null && extra.size() > 0) { for (String extraParam : extra) { query += " AND " + extraParam; } } if (log.isDebugEnabled()) { log.debug("User '" + authentication.getName() + "' is searching for '" + query + "'"); } String results = getExecuteSolrQuery().getResultsByPredefinedQuery(authentication, SolrCore.QUICK_SEARCH, query, startRow, maxRows, sort); return results; }
SearchChildrenAPIController { @RequestMapping(value = "/children", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String children( @RequestParam(value = "parentType", required = true) String parentType, @RequestParam(value = "parentId", required = true) Long parentId, @RequestParam(value = "childType", required = false, defaultValue = "") String childType, @RequestParam(value = "activeOnly", required = false, defaultValue = "false") boolean activeOnly, @RequestParam(value = "exceptDeletedOnly", required = false, defaultValue = "true") boolean exceptDeletedOnly, @RequestParam(value = "extra", required = false) List<String> extra, @RequestParam(value = "s", required = false, defaultValue = "") String sort, @RequestParam(value = "start", required = false, defaultValue = "0") int startRow, @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows, Authentication authentication) throws MuleException { String query = "parent_object_type_s:" + parentType + " AND parent_object_id_i:" + parentId; if (!"".equals(childType)) { query = query + " AND object_type_s:" + childType; } if (activeOnly) { query += " AND -status_s:COMPLETE AND -status_s:DELETE AND -status_s:CLOSED AND -status_s:CLOSE"; } if (exceptDeletedOnly) { if (!activeOnly) { query += " AND -status_s:DELETED AND -status_s:DELETE"; } } if (extra != null && extra.size() > 0) { for (String extraParam : extra) { query += " AND " + extraParam; } } if (log.isDebugEnabled()) { log.debug("User '" + authentication.getName() + "' is searching for '" + query + "'"); } String results = getExecuteSolrQuery().getResultsByPredefinedQuery(authentication, SolrCore.QUICK_SEARCH, query, startRow, maxRows, sort); return results; } }
SearchChildrenAPIController { @RequestMapping(value = "/children", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String children( @RequestParam(value = "parentType", required = true) String parentType, @RequestParam(value = "parentId", required = true) Long parentId, @RequestParam(value = "childType", required = false, defaultValue = "") String childType, @RequestParam(value = "activeOnly", required = false, defaultValue = "false") boolean activeOnly, @RequestParam(value = "exceptDeletedOnly", required = false, defaultValue = "true") boolean exceptDeletedOnly, @RequestParam(value = "extra", required = false) List<String> extra, @RequestParam(value = "s", required = false, defaultValue = "") String sort, @RequestParam(value = "start", required = false, defaultValue = "0") int startRow, @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows, Authentication authentication) throws MuleException { String query = "parent_object_type_s:" + parentType + " AND parent_object_id_i:" + parentId; if (!"".equals(childType)) { query = query + " AND object_type_s:" + childType; } if (activeOnly) { query += " AND -status_s:COMPLETE AND -status_s:DELETE AND -status_s:CLOSED AND -status_s:CLOSE"; } if (exceptDeletedOnly) { if (!activeOnly) { query += " AND -status_s:DELETED AND -status_s:DELETE"; } } if (extra != null && extra.size() > 0) { for (String extraParam : extra) { query += " AND " + extraParam; } } if (log.isDebugEnabled()) { log.debug("User '" + authentication.getName() + "' is searching for '" + query + "'"); } String results = getExecuteSolrQuery().getResultsByPredefinedQuery(authentication, SolrCore.QUICK_SEARCH, query, startRow, maxRows, sort); return results; }  }
SearchChildrenAPIController { @RequestMapping(value = "/children", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String children( @RequestParam(value = "parentType", required = true) String parentType, @RequestParam(value = "parentId", required = true) Long parentId, @RequestParam(value = "childType", required = false, defaultValue = "") String childType, @RequestParam(value = "activeOnly", required = false, defaultValue = "false") boolean activeOnly, @RequestParam(value = "exceptDeletedOnly", required = false, defaultValue = "true") boolean exceptDeletedOnly, @RequestParam(value = "extra", required = false) List<String> extra, @RequestParam(value = "s", required = false, defaultValue = "") String sort, @RequestParam(value = "start", required = false, defaultValue = "0") int startRow, @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows, Authentication authentication) throws MuleException { String query = "parent_object_type_s:" + parentType + " AND parent_object_id_i:" + parentId; if (!"".equals(childType)) { query = query + " AND object_type_s:" + childType; } if (activeOnly) { query += " AND -status_s:COMPLETE AND -status_s:DELETE AND -status_s:CLOSED AND -status_s:CLOSE"; } if (exceptDeletedOnly) { if (!activeOnly) { query += " AND -status_s:DELETED AND -status_s:DELETE"; } } if (extra != null && extra.size() > 0) { for (String extraParam : extra) { query += " AND " + extraParam; } } if (log.isDebugEnabled()) { log.debug("User '" + authentication.getName() + "' is searching for '" + query + "'"); } String results = getExecuteSolrQuery().getResultsByPredefinedQuery(authentication, SolrCore.QUICK_SEARCH, query, startRow, maxRows, sort); return results; }  @RequestMapping(value = "/children", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody String children(
            @RequestParam(value = "parentType", required = true) String parentType,
            @RequestParam(value = "parentId", required = true) Long parentId,
            @RequestParam(value = "childType", required = false, defaultValue = "") String childType,
            @RequestParam(value = "activeOnly", required = false, defaultValue = "false") boolean activeOnly,
            @RequestParam(value = "exceptDeletedOnly", required = false, defaultValue = "true") boolean exceptDeletedOnly,
            @RequestParam(value = "extra", required = false) List<String> extra,
            @RequestParam(value = "s", required = false, defaultValue = "") String sort,
            @RequestParam(value = "start", required = false, defaultValue = "0") int startRow,
            @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows,
            Authentication authentication); @RequestMapping(value = "/children/advanced", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody String advancedChildren(
            @RequestParam(value = "parentType", required = true) String parentType,
            @RequestParam(value = "parentId", required = true) Long parentId,
            @RequestParam(value = "childType", required = false, defaultValue = "") String childType,
            @RequestParam(value = "activeOnly", required = false, defaultValue = "false") boolean activeOnly,
            @RequestParam(value = "exceptDeletedOnly", required = false, defaultValue = "true") boolean exceptDeletedOnly,
            @RequestParam(value = "extra", required = false) List<String> extra,
            @RequestParam(value = "s", required = false, defaultValue = "") String sort,
            @RequestParam(value = "start", required = false, defaultValue = "0") int startRow,
            @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows,
            Authentication authentication); ExecuteSolrQuery getExecuteSolrQuery(); void setExecuteSolrQuery(ExecuteSolrQuery executeSolrQuery); }
SearchChildrenAPIController { @RequestMapping(value = "/children", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String children( @RequestParam(value = "parentType", required = true) String parentType, @RequestParam(value = "parentId", required = true) Long parentId, @RequestParam(value = "childType", required = false, defaultValue = "") String childType, @RequestParam(value = "activeOnly", required = false, defaultValue = "false") boolean activeOnly, @RequestParam(value = "exceptDeletedOnly", required = false, defaultValue = "true") boolean exceptDeletedOnly, @RequestParam(value = "extra", required = false) List<String> extra, @RequestParam(value = "s", required = false, defaultValue = "") String sort, @RequestParam(value = "start", required = false, defaultValue = "0") int startRow, @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows, Authentication authentication) throws MuleException { String query = "parent_object_type_s:" + parentType + " AND parent_object_id_i:" + parentId; if (!"".equals(childType)) { query = query + " AND object_type_s:" + childType; } if (activeOnly) { query += " AND -status_s:COMPLETE AND -status_s:DELETE AND -status_s:CLOSED AND -status_s:CLOSE"; } if (exceptDeletedOnly) { if (!activeOnly) { query += " AND -status_s:DELETED AND -status_s:DELETE"; } } if (extra != null && extra.size() > 0) { for (String extraParam : extra) { query += " AND " + extraParam; } } if (log.isDebugEnabled()) { log.debug("User '" + authentication.getName() + "' is searching for '" + query + "'"); } String results = getExecuteSolrQuery().getResultsByPredefinedQuery(authentication, SolrCore.QUICK_SEARCH, query, startRow, maxRows, sort); return results; }  @RequestMapping(value = "/children", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody String children(
            @RequestParam(value = "parentType", required = true) String parentType,
            @RequestParam(value = "parentId", required = true) Long parentId,
            @RequestParam(value = "childType", required = false, defaultValue = "") String childType,
            @RequestParam(value = "activeOnly", required = false, defaultValue = "false") boolean activeOnly,
            @RequestParam(value = "exceptDeletedOnly", required = false, defaultValue = "true") boolean exceptDeletedOnly,
            @RequestParam(value = "extra", required = false) List<String> extra,
            @RequestParam(value = "s", required = false, defaultValue = "") String sort,
            @RequestParam(value = "start", required = false, defaultValue = "0") int startRow,
            @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows,
            Authentication authentication); @RequestMapping(value = "/children/advanced", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody String advancedChildren(
            @RequestParam(value = "parentType", required = true) String parentType,
            @RequestParam(value = "parentId", required = true) Long parentId,
            @RequestParam(value = "childType", required = false, defaultValue = "") String childType,
            @RequestParam(value = "activeOnly", required = false, defaultValue = "false") boolean activeOnly,
            @RequestParam(value = "exceptDeletedOnly", required = false, defaultValue = "true") boolean exceptDeletedOnly,
            @RequestParam(value = "extra", required = false) List<String> extra,
            @RequestParam(value = "s", required = false, defaultValue = "") String sort,
            @RequestParam(value = "start", required = false, defaultValue = "0") int startRow,
            @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows,
            Authentication authentication); ExecuteSolrQuery getExecuteSolrQuery(); void setExecuteSolrQuery(ExecuteSolrQuery executeSolrQuery);  }