Revision 52806
Added by Tsampikos Livisianos almost 6 years ago
modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/cql/ParameterQueryEnhancer.java | ||
---|---|---|
309 | 309 |
String[] openairePublicationIDs = request.getParameterValues("openairePublicationID"); |
310 | 310 |
String[] openaireDatasetIDs = request.getParameterValues("openaireDatasetID"); |
311 | 311 |
String[] openaireSoftwareIDs = request.getParameterValues("openaireSoftwareID"); |
312 |
String[] openaireOtherIDs = request.getParameterValues("openaireOtherID"); |
|
312 | 313 |
String[] openaireProviderIDs = request.getParameterValues("openaireProviderID"); |
313 | 314 |
String[] openaireProjectIDs = request.getParameterValues("openaireProjectID"); |
314 | 315 |
|
315 | 316 |
enhanceQueryWithIds("objidentifier", openairePublicationIDs, queryBuilder); |
316 | 317 |
enhanceQueryWithIds("objidentifier", openaireDatasetIDs, queryBuilder); |
317 | 318 |
enhanceQueryWithIds("objidentifier", openaireSoftwareIDs, queryBuilder); |
319 |
enhanceQueryWithIds("objidentifier", openaireOtherIDs, queryBuilder); |
|
318 | 320 |
enhanceQueryWithIds("resulthostingdatasourceid", openaireProviderIDs, queryBuilder); |
319 | 321 |
enhanceQueryWithIds("relprojectid", openaireProjectIDs, queryBuilder); |
320 | 322 |
} |
modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/web/utils/RequestResponseHandler.java | ||
---|---|---|
16 | 16 |
ORGANIZATION("organization"), |
17 | 17 |
PERSON("person"), |
18 | 18 |
SOFTWARE("software"), |
19 |
OTHER("other"), |
|
19 | 20 |
NONE(""); |
20 | 21 |
|
21 | 22 |
private final List<String> PUBLICATION_FIELD_QUERIES = Arrays.asList("oaftype exact result", "resulttypeid exact publication"); |
22 | 23 |
private final List<String> DATASET_FIELD_QUERIES = Arrays.asList("oaftype exact result", "resulttypeid exact dataset"); |
23 | 24 |
private final List<String> SOFTWARE_FIELD_QUERIES = Arrays.asList("oaftype exact result", "resulttypeid exact software"); |
25 |
private final List<String> OTHER_FIELD_QUERIES = Arrays.asList("oaftype exact result", "resulttypeid exact other"); |
|
24 | 26 |
private final List<String> PROJECT_FIELD_QUERIES = Arrays.asList("oaftype exact project"); |
25 | 27 |
private final List<String> DATASOURCE_FIELD_QUERIES = Arrays.asList("oaftype exact datasource", "(datasourcecompatibilityid <> \"UNKNOWN\")"); |
26 | 28 |
private final List<String> ORGANIZATION_FIELD_QUERIES = Arrays.asList("oaftype exact organization", |
... | ... | |
54 | 56 |
case SOFTWARE: |
55 | 57 |
return SOFTWARE_PREFIX; |
56 | 58 |
|
59 |
case OTHER: |
|
60 |
return OTHER_PREFIX; |
|
61 |
|
|
57 | 62 |
case PROJECT: |
58 | 63 |
return PROJECT_PREFIX; |
59 | 64 |
|
... | ... | |
86 | 91 |
case SOFTWARE: |
87 | 92 |
return "software"; |
88 | 93 |
|
94 |
case OTHER: |
|
95 |
return "other"; |
|
96 |
|
|
89 | 97 |
case PROJECT: |
90 | 98 |
return "projects"; |
91 | 99 |
|
... | ... | |
117 | 125 |
case SOFTWARE: |
118 | 126 |
return SOFTWARE_FIELD_QUERIES; |
119 | 127 |
|
128 |
case OTHER: |
|
129 |
return OTHER_FIELD_QUERIES; |
|
130 |
|
|
120 | 131 |
case PROJECT: |
121 | 132 |
return PROJECT_FIELD_QUERIES; |
122 | 133 |
|
... | ... | |
140 | 151 |
public final static String PUBLICATION_PREFIX = "(oaftype exact result) and (resulttypeid exact publication)"; |
141 | 152 |
public final static String DATASET_PREFIX = "(oaftype exact result) and (resulttypeid exact dataset)"; |
142 | 153 |
public final static String SOFTWARE_PREFIX = "(oaftype exact result) and (resulttypeid exact software)"; |
154 |
public final static String OTHER_PREFIX = "(oaftype exact result) and (resulttypeid exact other)"; |
|
143 | 155 |
public final static String PROJECT_PREFIX = "(oaftype exact project)"; |
144 | 156 |
public final static String DATASOURCE_PREFIX = "(oaftype exact datasource) and (datasourcecompatibilityid <> \"UNKNOWN\")"; |
145 | 157 |
public final static String ORGANIZATION_PREFIX = "(oaftype exact organization and " + |
modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/web/api/SearchApiService.java | ||
---|---|---|
181 | 181 |
} |
182 | 182 |
|
183 | 183 |
@GET |
184 |
@Path("/api/other") |
|
185 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
|
186 |
public Response fetchOther(@QueryParam("q") String keywords, |
|
187 |
@QueryParam("doi") final String doi, |
|
188 |
@QueryParam("sortBy") final String sortBy, |
|
189 |
@DefaultValue("0") @QueryParam("page") int offset, |
|
190 |
@DefaultValue("10") @QueryParam("size") int limit, |
|
191 |
@QueryParam("refine") @DefaultValue("false") boolean refine, |
|
192 |
@QueryParam("fields") final List<String> fields, |
|
193 |
@QueryParam("fq") final List<String> fieldQueries, |
|
194 |
@QueryParam("format") final String format, |
|
195 |
@Context HttpServletRequest request) { |
|
196 |
|
|
197 |
String simpleQuery = buildSearchRequest(RequestResponseHandler.Entity.OTHER, keywords, doi, sortBy, fieldQueries); |
|
198 |
return getResponseByEntity(simpleQuery, RequestResponseHandler.Entity.OTHER, offset, limit, format, request, refine, fields, fieldQueries); |
|
199 |
} |
|
200 |
|
|
201 |
@GET |
|
202 |
@Path("/api/other/count") |
|
203 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
|
204 |
public Response fetchOtherCount(@QueryParam("q") String query, |
|
205 |
@QueryParam("format") final String format, |
|
206 |
@QueryParam("fq") final List<String> fieldQueries, |
|
207 |
@Context final HttpServletRequest request) { |
|
208 |
String fullQuery = buildSearchRequest(RequestResponseHandler.Entity.OTHER, query, fieldQueries); |
|
209 |
return getCount(request, fullQuery, format, fieldQueries); |
|
210 |
} |
|
211 |
|
|
212 |
@GET |
|
213 |
@Path("/api/other/{otherid}") |
|
214 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
|
215 |
public Response fetchOther(@PathParam("otherid") String datasetid, |
|
216 |
@QueryParam("format") final String format, |
|
217 |
@QueryParam("fq") final List<String> fieldQueries, |
|
218 |
@Context final HttpServletRequest request) { |
|
219 |
return getResponseByEntityId(request, RequestResponseHandler.Entity.OTHER, datasetid, format, fieldQueries); |
|
220 |
} |
|
221 |
@GET |
|
184 | 222 |
@Path("/api/projects") |
185 | 223 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
186 | 224 |
public Response fetchProjects(@QueryParam("q") String keywords, |
... | ... | |
301 | 339 |
} |
302 | 340 |
|
303 | 341 |
@GET |
342 |
@Path("/api/projects/{projectId}/other/count") |
|
343 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
|
344 |
public Response fetchProjectOtherCount(@PathParam("projectId") String projectId, |
|
345 |
@DefaultValue("0") @QueryParam("page") int offset, |
|
346 |
@DefaultValue("10") @QueryParam("size") int limit, |
|
347 |
@QueryParam("format") final String format, |
|
348 |
@QueryParam("fq") final List<String> fieldQueries, |
|
349 |
@Context HttpServletRequest request) { |
|
350 |
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.OTHER, "relprojectid", projectId, fieldQueries); |
|
351 |
return getCount(request, fullQuery, format, fieldQueries); |
|
352 |
} |
|
353 |
|
|
354 |
@GET |
|
355 |
@Path("/api/projects/{projectId}/other") |
|
356 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
|
357 |
public Response fetchProjectOther(@PathParam("projectId") String projectId, |
|
358 |
@DefaultValue("0") @QueryParam("page") int offset, |
|
359 |
@DefaultValue("10") @QueryParam("size") int limit, |
|
360 |
@QueryParam("format") final String format, |
|
361 |
@QueryParam("fq") final List<String> fieldQueries, |
|
362 |
@Context HttpServletRequest request) { |
|
363 |
|
|
364 |
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.OTHER, "relprojectid", projectId, fieldQueries); |
|
365 |
return getResponseByEntity(fullQuery, RequestResponseHandler.Entity.OTHER, offset, limit, format, request, false, null, fieldQueries); |
|
366 |
} |
|
367 |
|
|
368 |
@GET |
|
304 | 369 |
@Path("/api/datasources") |
305 | 370 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
306 | 371 |
public Response fetchDatasources(@QueryParam("q") String keywords, |
... | ... | |
890 | 955 |
} else if (type.equalsIgnoreCase(RequestResponseHandler.Entity.SOFTWARE.getPlural())) { |
891 | 956 |
return RequestResponseHandler.Entity.SOFTWARE; |
892 | 957 |
|
958 |
} else if (type.equalsIgnoreCase(RequestResponseHandler.Entity.OTHER.getPlural())) { |
|
959 |
return RequestResponseHandler.Entity.OTHER; |
|
960 |
|
|
893 | 961 |
} else if (type.equalsIgnoreCase(RequestResponseHandler.Entity.PROJECT.getPlural())) { |
894 | 962 |
return RequestResponseHandler.Entity.PROJECT; |
895 | 963 |
|
modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/web/api/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 |
|
modules/uoa-search/trunk/src/main/resources/configuration.xml | ||
---|---|---|
137 | 137 |
<transformation xslt="html_publication.xsl" /> |
138 | 138 |
</transformer> |
139 | 139 |
|
140 |
<transformer name="csv_other"> |
|
141 |
<transformation xslt="csv_publication.xsl" /> |
|
142 |
</transformer> |
|
143 |
|
|
144 |
<transformer name="csv-special_other"> |
|
145 |
<transformation xslt="csv_publication_special.xsl" /> |
|
146 |
</transformer> |
|
147 |
|
|
148 |
<transformer name="html_other"> |
|
149 |
<transformation xslt="html_publication.xsl" /> |
|
150 |
</transformer> |
|
151 |
|
|
140 | 152 |
</transformers> |
141 | 153 |
|
142 | 154 |
<formatters> |
Also available in: Unified diff
add other research products api