Revision 52806
Added by Tsampikos Livisianos over 5 years ago
SearchRequestController.java | ||
---|---|---|
53 | 53 |
private static final String PUBLICATION_BASIC_QUERY = "(oaftype exact result) and (resulttypeid exact publication)"; |
54 | 54 |
private static final String DATASET_BASIC_QUERY = "(oaftype exact result) and (resulttypeid exact dataset)"; |
55 | 55 |
private static final String SOFTWARE_BASIC_QUERY = "(oaftype exact result) and (resulttypeid exact software)"; |
56 |
private static final String OTHER_BASIC_QUERY = "(oaftype exact result) and (resulttypeid exact other)"; |
|
56 | 57 |
private static final String PROJECT_BASIC_QUERY = "(oaftype exact project)"; |
57 | 58 |
|
58 | 59 |
private static final List<String> GLOBAL_PARAMETERS = Arrays.asList("page", "size", "format", "sortBy"); |
... | ... | |
64 | 65 |
private static final List<String> PUB_PARAMETERS = Arrays.asList("openairePublicationID"); |
65 | 66 |
private static final List<String> DATA_PARAMETERS = Arrays.asList("openaireDatasetID"); |
66 | 67 |
private static final List<String> SOFTWARE_PARAMETERS = Arrays.asList("openaireSoftwareID"); |
68 |
private static final List<String> OTHER_PARAMETERS = Arrays.asList("openaireOtherID"); |
|
67 | 69 |
|
68 | 70 |
private static final List<String> PUB_N_DATASET_MODELS = Arrays.asList("dc", "openaire", "sygma"); |
69 | 71 |
private static final List<String> PUB_N_DATASET_FORMATS = Arrays.asList("json", "rss", "xml", "csv", "tsv", "html"); |
... | ... | |
348 | 350 |
|
349 | 351 |
} |
350 | 352 |
|
353 |
@RequestMapping(value = "/api/other", method = RequestMethod.GET, produces = {MediaType.APPLICATION_XML_VALUE,MediaType.APPLICATION_JSON_VALUE}) |
|
354 |
public void searchOther(HttpServletRequest request, HttpServletResponse response) throws Exception { |
|
355 |
|
|
356 |
checkParameters(ListUtils.union(PUB_N_DATA_COMMON_PARAMETERS, OTHER_PARAMETERS),request.getParameterMap()); |
|
357 |
|
|
358 |
int page = readParameter(request, "page", 1); |
|
359 |
int size = readParameter(request, "size", 10); |
|
360 |
checkRequestSize(page, size); |
|
361 |
|
|
362 |
String format = (request.getParameter("format") != null) ? request.getParameter("format") : "xml"; |
|
363 |
createResponseMeta(response, format); |
|
364 |
|
|
365 |
checkFormatParameter(PUB_N_DATASET_FORMATS, format); |
|
366 |
|
|
367 |
String model = request.getParameter("model"); |
|
368 |
checkModelParameter(PUB_N_DATASET_MODELS, model); |
|
369 |
String sTransformer = defineTransformer(model,format); |
|
370 |
|
|
371 |
Collection<String> referrers = readParameter(request,"referrer"); |
|
372 |
String newFormat = defineFormatter(model, format, false, referrers); |
|
373 |
|
|
374 |
String locale = request.getParameter("locale"); |
|
375 |
|
|
376 |
StringBuilder queryBuilder = new StringBuilder(); |
|
377 |
queryBuilder.append(OTHER_BASIC_QUERY); |
|
378 |
|
|
379 |
ParameterQueryEnhancer.enhanceQueryWithFundingLevelParams(queryBuilder, request, vocabularyManager, isModelSygma(model)); |
|
380 |
ParameterQueryEnhancer.enhanceQueryWithOpenAIREIds(queryBuilder, request); |
|
381 |
ParameterQueryEnhancer.enhanceQueryWithMetadataKeywords(queryBuilder, request); |
|
382 |
ParameterQueryEnhancer.enhanceQueryWithFundingParams(queryBuilder, request); |
|
383 |
ParameterQueryEnhancer.enhanceQueryWithCommunityParams(queryBuilder, request); |
|
384 |
ParameterQueryEnhancer.enhanceQueryWithRelProjectParams(queryBuilder, request); |
|
385 |
ParameterQueryEnhancer.enhanceQueryWithAccessRights(queryBuilder, request); |
|
386 |
ParameterQueryEnhancer.enhanceQueryWithDate(queryBuilder, request); |
|
387 |
ParameterQueryEnhancer.enhanceQueryWithDoi(queryBuilder, request); |
|
388 |
|
|
389 |
ParameterQueryEnhancer.enhanceQueryWithResultsSortParameters(queryBuilder, request); |
|
390 |
|
|
391 |
FormattedSearchResult formattedSearchResult = null; |
|
392 |
|
|
393 |
try { |
|
394 |
formattedSearchResult = searchService.search(queryBuilder.toString(),sTransformer, (newFormat!=null)?newFormat:format, locale, page, size); |
|
395 |
|
|
396 |
} catch (Exception e) { |
|
397 |
logger.error("Fail to execute search.", e); |
|
398 |
throw new Exception("Fail to execute search", e); |
|
399 |
} |
|
400 |
|
|
401 |
PrintWriter writer = response.getWriter(); |
|
402 |
writer.append(formattedSearchResult.getFormattedResult()); |
|
403 |
|
|
404 |
} |
|
405 |
|
|
351 | 406 |
@RequestMapping(value = "/api/projects", method = RequestMethod.GET, produces = {MediaType.APPLICATION_XML_VALUE,MediaType.APPLICATION_JSON_VALUE}) |
352 | 407 |
public void searchProjects(HttpServletRequest request, HttpServletResponse response) throws Exception { |
353 | 408 |
|
Also available in: Unified diff
add other research products api