use of org.alfresco.rest.api.search.model.SearchSQLQuery in project alfresco-remote-api by Alfresco.
the class SearchSQLApiWebscriptTests method testSearchQueryParamsTimezone.
@Test
public void testSearchQueryParamsTimezone() throws Exception {
String query = "select SITE from alfresco";
SearchSQLQuery searchQuery = new SearchSQLQuery(query, "solr", emptyList(), 1000, false, "Israel", emptyList());
SearchParameters sparams = webscript.buildSearchParameters(searchQuery);
assertNotNull(sparams);
assertEquals(query, sparams.getQuery());
assertEquals(false, sparams.isIncludeMetadata());
assertEquals(Collections.EMPTY_LIST, sparams.getLocales());
assertEquals("solr", sparams.getExtraParameters().get("format"));
assertEquals("Israel", sparams.getTimezone());
}
use of org.alfresco.rest.api.search.model.SearchSQLQuery in project alfresco-remote-api by Alfresco.
the class SearchSQLApiWebscriptTests method testSearchQueryParamsFormatNull.
@Test
public void testSearchQueryParamsFormatNull() throws Exception {
String query = "select SITE from alfresco";
SearchSQLQuery searchQuery = new SearchSQLQuery(query, "", emptyList(), 1000, false, "", emptyList());
SearchParameters sparams = webscript.buildSearchParameters(searchQuery);
assertNotNull(sparams);
assertEquals(query, sparams.getQuery());
assertEquals(false, sparams.isIncludeMetadata());
assertEquals(Collections.EMPTY_LIST, sparams.getLocales());
assertEquals(null, sparams.getExtraParameters().get("format"));
assertEquals(null, sparams.getTimezone());
searchQuery = new SearchSQLQuery(query, null, emptyList(), 1000, true, "", emptyList());
sparams = webscript.buildSearchParameters(searchQuery);
assertNotNull(sparams);
assertEquals(query, sparams.getQuery());
assertEquals(true, sparams.isIncludeMetadata());
assertEquals(Collections.EMPTY_LIST, sparams.getLocales());
assertEquals(null, sparams.getExtraParameters().get("format"));
assertEquals(null, sparams.getTimezone());
}
use of org.alfresco.rest.api.search.model.SearchSQLQuery in project alfresco-remote-api by Alfresco.
the class SearchSQLApiWebscriptTests method testSearchQueryParams.
@Test
public void testSearchQueryParams() throws Exception {
String query = "select SITE from alfresco";
SearchSQLQuery searchQuery = new SearchSQLQuery(query, "solr", emptyList(), 1000, false, "", emptyList());
SearchParameters sparams = webscript.buildSearchParameters(searchQuery);
assertNotNull(sparams);
assertEquals(query, sparams.getQuery());
assertEquals(false, sparams.isIncludeMetadata());
assertEquals(Collections.EMPTY_LIST, sparams.getLocales());
assertEquals("solr", sparams.getExtraParameters().get("format"));
assertEquals(null, sparams.getTimezone());
}
use of org.alfresco.rest.api.search.model.SearchSQLQuery in project alfresco-remote-api by Alfresco.
the class SearchSQLParseTest method testSQLDeserializeQuery.
@Test
public void testSQLDeserializeQuery() throws IOException {
String query = "{\"stmt\": \"select cm_name from alfresco\"}";
SearchSQLQuery searchQuery = parse(query);
assertEquals("select cm_name from alfresco", searchQuery.getStmt());
}
use of org.alfresco.rest.api.search.model.SearchSQLQuery in project alfresco-remote-api by Alfresco.
the class SearchSQLApiWebscript method execute.
@Override
public void execute(WebScriptRequest webScriptRequest, WebScriptResponse res) throws IOException {
try {
// Turn JSON into a Java object representation
SearchSQLQuery searchQuery = extractJsonContent(webScriptRequest, assistant.getJsonHelper(), SearchSQLQuery.class);
SearchParameters sparams = buildSearchParameters(searchQuery);
ResultSet results = searchService.query(sparams);
FilteringResultSet frs = (FilteringResultSet) results;
SolrSQLJSONResultSet ssjr = (SolrSQLJSONResultSet) frs.getUnFilteredResultSet();
// When solr format is requested pass the solr output directly.
if (searchQuery.getFormat().equalsIgnoreCase("solr")) {
res.getWriter().write(ssjr.getSolrResponse());
} else {
CollectionWithPagingInfo<TupleList> nodes = resultMapper.toCollectionWithPagingInfo(ssjr.getDocs(), searchQuery);
renderJsonResponse(res, nodes, assistant.getJsonHelper());
}
setResponse(res, DEFAULT_SUCCESS);
} catch (Exception exception) {
if (exception instanceof LuceneQueryParserException) {
renderException(exception, res, assistant);
} else {
renderException(new WebScriptException(400, exception.getMessage()), res, assistant);
}
}
}
Aggregations