Revision 44271
Added by Katerina Iatropoulou about 8 years ago
modules/uoa-search/branches/newAPI/src/main/java/eu/dnetlib/data/search/solr/SolrResultSet.java | ||
---|---|---|
222 | 222 |
e.printStackTrace(); |
223 | 223 |
} |
224 | 224 |
|
225 |
logger.debug("HELLO!");
|
|
225 |
logger.debug("HELLO from " + from + " to " + to);
|
|
226 | 226 |
|
227 | 227 |
for (int i = from - 1; i < to; i++) { |
228 | 228 |
for (FacetField field : facetFields) { |
... | ... | |
237 | 237 |
|
238 | 238 |
map.get(field.getName()).add(new Gson().toJson(bf)); |
239 | 239 |
} |
240 |
|
|
241 | 240 |
} |
242 | 241 |
} |
243 | 242 |
|
244 |
|
|
245 |
logger.debug("HERE!!!!"); |
|
246 |
|
|
247 | 243 |
for (String index : map.keySet()) { |
248 | 244 |
StringBuilder builder = new StringBuilder(); |
249 |
builder.append("{\"" + index + "\"" + " : "); |
|
250 |
builder.append(new Gson().toJson(map.get(index))); |
|
251 |
builder.append("}"); |
|
245 |
builder.append("\"" + index + "\"" + " : "); |
|
246 |
builder.append(map.get(index)); |
|
252 | 247 |
res.add(builder.toString()); |
253 |
logger.debug("ADDING " + builder.toString()); |
|
254 | 248 |
} |
255 | 249 |
} |
256 | 250 |
|
modules/uoa-search/branches/newAPI/src/main/java/eu/dnetlib/data/search/web/api/SearchApiService.java | ||
---|---|---|
15 | 15 |
import javax.ws.rs.core.Context; |
16 | 16 |
import javax.ws.rs.core.MediaType; |
17 | 17 |
import javax.ws.rs.core.Response; |
18 |
import java.util.List; |
|
19 |
import java.util.Locale; |
|
18 |
import java.util.*; |
|
20 | 19 |
|
21 | 20 |
/** |
22 | 21 |
* Created by kiatrop on 2/6/2016. |
... | ... | |
39 | 38 |
@DefaultValue("10") @QueryParam("size") final int limit, |
40 | 39 |
@QueryParam("refine") @DefaultValue("false") final boolean refine, |
41 | 40 |
@QueryParam("fields") final List<String> fields, |
41 |
@QueryParam("type") final String type, |
|
42 |
@QueryParam("lang") final String lang, |
|
43 |
@QueryParam("community") final String community, |
|
44 |
@QueryParam("funder") final String funder, |
|
45 |
@QueryParam("funderlv0") final String funderlv0, |
|
46 |
@QueryParam("funderlv1") final String funderlv1, |
|
47 |
@QueryParam("funderlv2") final String funderlv2, |
|
48 |
@QueryParam("op") final List<String> op, |
|
42 | 49 |
@Context final HttpServletRequest request) { |
43 | 50 |
|
44 |
return getResponseByEntity(query, RequestResponseHandler.Entity.PUBLICATION, offset, limit, request, refine, fields); |
|
51 |
Map<String, String[]> parameterMap = request.getParameterMap(); |
|
52 |
|
|
53 |
Map<String, String[]> operatorTypeValues = new HashMap<String, String[]>(); |
|
54 |
Map<String, String[]> parameterTypeValues = new HashMap<String, String[]>(); |
|
55 |
extractParameterOperatorsNValues(parameterMap, operatorTypeValues, parameterTypeValues); |
|
56 |
|
|
57 |
return getResponseByEntity(query, operatorTypeValues , parameterTypeValues, RequestResponseHandler.Entity.PUBLICATION, offset, limit, request, refine, fields); |
|
45 | 58 |
} |
46 | 59 |
|
60 |
private String enhanceQuery(String query, Map<String, String[]> operatorTypeValues, Map<String, String[]> parameterTypeValues) { |
|
61 |
StringBuilder queryBuilder = new StringBuilder(); |
|
62 |
|
|
63 |
//TODO handle q parameter |
|
64 |
for(String operatorType:operatorTypeValues.keySet()) { |
|
65 |
logger.debug(" parameter " + operatorType); |
|
66 |
logger.debug(" operatorTypeValues keys" + operatorTypeValues.keySet()); |
|
67 |
logger.debug(" operatorTypeValues values" + Arrays.asList(operatorTypeValues.values())); |
|
68 |
logger.debug(" parameterTypeValues keys" + parameterTypeValues.keySet()); |
|
69 |
logger.debug(" parameterTypeValues values" + Arrays.asList(parameterTypeValues.values())); |
|
70 |
|
|
71 |
//enhance messages with >, < ?? or maybe move all checks in the beginning? |
|
72 |
if (operatorTypeValues.get(operatorType).length != parameterTypeValues.get(CQLQueryGeneration.resultParameterOperatorMap.get(operatorType)).length ) { |
|
73 |
throw new IllegalArgumentException("Parameters and Operators are not matched"); |
|
74 |
} |
|
75 |
|
|
76 |
String parameterName = CQLQueryGeneration.resultParameterOperatorMap.get(operatorType); |
|
77 |
|
|
78 |
for(int i = 0; i < operatorTypeValues.get(operatorType).length; i++) { |
|
79 |
String indexField = CQLQueryGeneration.resultParameterIndexMap.get(CQLQueryGeneration.resultParameterOperatorMap.get(operatorType)); |
|
80 |
|
|
81 |
if (indexField != null) { |
|
82 |
logger.debug(indexField + " " + operatorTypeValues.get(operatorType)[i] + " " + parameterTypeValues.get(parameterName)[i]); |
|
83 |
queryBuilder.append(indexField + " " + operatorTypeValues.get(operatorType)[i] + parameterTypeValues.get(parameterName)[i]); |
|
84 |
|
|
85 |
} else { //TODO check if needed |
|
86 |
logger.debug("and here!"); |
|
87 |
logger.debug(" " + operatorTypeValues.get(operatorType)[i] + " " + parameterTypeValues.get(operatorType)[i]); |
|
88 |
queryBuilder.append(" " + operatorTypeValues.get(operatorType)[i] + " " + parameterTypeValues.get(operatorType)[i]); |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
} |
|
93 |
|
|
94 |
return queryBuilder.toString(); |
|
95 |
} |
|
96 |
|
|
47 | 97 |
@GET |
98 |
@Path("/api/publications/count") |
|
99 |
@Produces(MediaType.APPLICATION_JSON) |
|
100 |
public Response fetchPublicationsCount(@QueryParam("q") String query){ |
|
101 |
return getCountByEntity(query, RequestResponseHandler.Entity.PUBLICATION); |
|
102 |
} |
|
103 |
|
|
104 |
|
|
105 |
@GET |
|
48 | 106 |
@Path("/api/publications/{publicationid}") |
49 | 107 |
@Produces(MediaType.APPLICATION_JSON) |
50 | 108 |
public Response fetchPublicationsById(@PathParam("publicationid") String publicationid) { |
... | ... | |
52 | 110 |
return getResponseByEntity(RequestResponseHandler.Entity.PUBLICATION, publicationid); |
53 | 111 |
} |
54 | 112 |
|
55 |
@GET |
|
113 |
/* @GET
|
|
56 | 114 |
@Path("/api/datasets") |
57 | 115 |
@Produces(MediaType.APPLICATION_JSON) |
58 | 116 |
public Response fetchDatasets(@QueryParam("q") String query, |
... | ... | |
64 | 122 |
|
65 | 123 |
return getResponseByEntity(query, RequestResponseHandler.Entity.DATASET, offset, limit, request, refine, fields); |
66 | 124 |
} |
125 |
*/ |
|
126 |
@GET |
|
127 |
@Path("/api/datasets/count") |
|
128 |
@Produces(MediaType.APPLICATION_JSON) |
|
129 |
public Response fetchDatesetsCount(@QueryParam("q") String query){ |
|
130 |
return getCountByEntity(query, RequestResponseHandler.Entity.DATASET); |
|
131 |
} |
|
67 | 132 |
|
68 | 133 |
@GET |
69 | 134 |
@Path("/api/datasets/{datasetid}") |
... | ... | |
72 | 137 |
return getResponseByEntity(RequestResponseHandler.Entity.DATASET, datasetid); |
73 | 138 |
} |
74 | 139 |
|
140 |
/* |
|
75 | 141 |
@GET |
76 | 142 |
@Path("/api/projects") |
77 | 143 |
@Produces(MediaType.APPLICATION_JSON) |
... | ... | |
84 | 150 |
|
85 | 151 |
return getResponseByEntity(query, RequestResponseHandler.Entity.PROJECT, offset, limit, request, refine, fields); |
86 | 152 |
} |
153 |
*/ |
|
87 | 154 |
|
88 | 155 |
@GET |
156 |
@Path("/api/projects/count") |
|
157 |
@Produces(MediaType.APPLICATION_JSON) |
|
158 |
public Response fetchProjectsCount(@QueryParam("q") String query){ |
|
159 |
return getCountByEntity(query, RequestResponseHandler.Entity.PROJECT); |
|
160 |
} |
|
161 |
|
|
162 |
@GET |
|
89 | 163 |
@Path("/api/projects/{projectid}") |
90 | 164 |
@Produces(MediaType.APPLICATION_JSON) |
91 | 165 |
public Response fetchProjects(@PathParam("projectid") String projectid) { |
... | ... | |
115 | 189 |
return getResponseByEntity(RequestResponseHandler.Entity.DATASET, "relprojectid", projectId, offset, limit, request); |
116 | 190 |
} |
117 | 191 |
|
118 |
|
|
192 |
/* |
|
119 | 193 |
@GET |
120 | 194 |
@Path("/api/datasources") |
121 | 195 |
@Produces(MediaType.APPLICATION_JSON) |
... | ... | |
128 | 202 |
|
129 | 203 |
return getResponseByEntity(query, RequestResponseHandler.Entity.DATASOURCE, offset, limit, request, refine, fields); |
130 | 204 |
} |
205 |
*/ |
|
206 |
@GET |
|
207 |
@Path("/api/datasources/count") |
|
208 |
@Produces(MediaType.APPLICATION_JSON) |
|
209 |
public Response fetchDatasourcesCount(@QueryParam("q") String query){ |
|
210 |
return getCountByEntity(query, RequestResponseHandler.Entity.DATASOURCE); |
|
211 |
} |
|
131 | 212 |
|
132 | 213 |
@GET |
133 | 214 |
@Path("/api/datasources/{datasourceid}") |
134 | 215 |
@Produces(MediaType.APPLICATION_JSON) |
216 |
public Response fetchDatasources(@PathParam("datasourceid") String datasourceid, |
|
217 |
@DefaultValue("1") @QueryParam("page") int offset, |
|
218 |
@DefaultValue("10") @QueryParam("size") int limit, |
|
219 |
@Context HttpServletRequest request) { |
|
220 |
|
|
221 |
return getResponseByEntity(RequestResponseHandler.Entity.PUBLICATION, "......", datasourceid, offset, limit, request); |
|
222 |
|
|
223 |
} |
|
224 |
|
|
225 |
@GET |
|
226 |
@Path("/api/datasources/{datasourceid}/publications") |
|
227 |
@Produces(MediaType.APPLICATION_JSON) |
|
135 | 228 |
public Response fetchDatasources(@PathParam("datasourceid") String datasourceid) { |
136 | 229 |
return getResponseByEntity(RequestResponseHandler.Entity.DATASOURCE, datasourceid); |
137 | 230 |
|
138 | 231 |
} |
139 | 232 |
|
140 |
|
|
233 |
/* |
|
141 | 234 |
@GET |
142 | 235 |
@Path("/api/organizations") |
143 | 236 |
@Produces(MediaType.APPLICATION_JSON) |
... | ... | |
146 | 239 |
@DefaultValue("10") @QueryParam("size") final int limit, |
147 | 240 |
@QueryParam("refine") @DefaultValue("false") final boolean refine, |
148 | 241 |
@QueryParam("fields") final List<String> fields, |
149 |
@Context final HttpServletRequest request) {
|
|
242 |
@Context final HttpServletRequest request, @Context final UriInfo uriInfo) {
|
|
150 | 243 |
|
244 |
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters(); |
|
151 | 245 |
return getResponseByEntity(query, RequestResponseHandler.Entity.ORGANIZATION, offset, limit, request, refine, fields); |
152 | 246 |
} |
247 |
*/ |
|
153 | 248 |
|
249 |
@GET |
|
250 |
@Path("/api/organizations/count") |
|
251 |
@Produces(MediaType.APPLICATION_JSON) |
|
252 |
public Response fetchOrganizationsCount(@QueryParam("q") String query){ |
|
253 |
return getCountByEntity(query, RequestResponseHandler.Entity.ORGANIZATION); |
|
254 |
} |
|
154 | 255 |
|
155 | 256 |
@GET |
156 | 257 |
@Path("/api/organizations/{organizationid}") |
... | ... | |
171 | 272 |
|
172 | 273 |
|
173 | 274 |
@GET |
275 |
@Path("/api/organizations/{organizationid}/projects") |
|
276 |
@Produces(MediaType.APPLICATION_JSON) |
|
277 |
public Response fetchOrganizationProjects(@PathParam("organizationid") String organizationid, |
|
278 |
@DefaultValue("1") @QueryParam("page") int offset, |
|
279 |
@DefaultValue("10") @QueryParam("size") int limit, |
|
280 |
@Context HttpServletRequest request) { |
|
281 |
return getResponseByEntity(RequestResponseHandler.Entity.PROJECT, "relprojectid", organizationid, offset, limit, request); |
|
282 |
} |
|
283 |
|
|
284 |
/* |
|
285 |
@GET |
|
174 | 286 |
@Path("/api/people") |
175 | 287 |
@Produces(MediaType.APPLICATION_JSON) |
176 | 288 |
public Response fetchPeople(@QueryParam("q") String query, |
... | ... | |
181 | 293 |
@Context final HttpServletRequest request) { |
182 | 294 |
return getResponseByEntity(query, RequestResponseHandler.Entity.PERSON, offset, limit, request, refine, fields); |
183 | 295 |
} |
296 |
*/ |
|
184 | 297 |
|
185 | 298 |
@GET |
299 |
@Path("/api/people/count") |
|
300 |
@Produces(MediaType.APPLICATION_JSON) |
|
301 |
public Response fetchPeopleCount(@QueryParam("q") String query){ |
|
302 |
return getCountByEntity(query, RequestResponseHandler.Entity.PERSON); |
|
303 |
} |
|
304 |
|
|
305 |
@GET |
|
186 | 306 |
@Path("/api/people/{personid}") |
187 | 307 |
@Produces(MediaType.APPLICATION_JSON) |
188 | 308 |
public Response fetchPeople(@PathParam("personid") String personid) { |
... | ... | |
210 | 330 |
} |
211 | 331 |
|
212 | 332 |
|
213 |
public String builtQueryByEntity(String query, RequestResponseHandler.Entity entity, int offset, int limit) throws SearchServiceException {
|
|
333 |
public String builtQueryByEntity(String query, RequestResponseHandler.Entity entity) {
|
|
214 | 334 |
StringBuilder queryBuilder = new StringBuilder(); |
215 | 335 |
queryBuilder.append(entity.getQueryPrefix()); |
216 | 336 |
|
... | ... | |
221 | 341 |
return queryBuilder.toString(); |
222 | 342 |
} |
223 | 343 |
|
344 |
public void extractParameterOperatorsNValues(Map<String, String[]> parameterMap, Map<String, String[]> operatorTypeValues, Map<String, String[]> parameterTypeValues) { |
|
345 |
for (String parameter:parameterMap.keySet()) { |
|
346 |
logger.debug(" parameter " + parameter); |
|
347 |
logger.debug(" CQLQueryGeneration.resultParameterOperatorMap keys " + CQLQueryGeneration.resultParameterOperatorMap.keySet()); |
|
348 |
logger.debug(" CQLQueryGeneration.resultParameterOperatorMap values " + CQLQueryGeneration.resultParameterIndexMap.keySet()); |
|
349 |
|
|
350 |
if (CQLQueryGeneration.resultParameterOperatorMap.get(parameter) != null) { |
|
351 |
operatorTypeValues.put(parameter, parameterMap.get(parameter)); |
|
352 |
|
|
353 |
} else if (CQLQueryGeneration.resultParameterIndexMap.get(parameter) != null) { |
|
354 |
parameterTypeValues.put(parameter, parameterMap.get(parameter)); |
|
355 |
|
|
356 |
} else if (!parameter.equals("q") && !parameter.equals("size") && !parameter.equals("page") && !parameter.equals("fields") && !parameter.equals("refine")){ |
|
357 |
throw new IllegalArgumentException("The parameter " + parameter + " is not supported."); |
|
358 |
} |
|
359 |
|
|
360 |
if (parameterTypeValues.get(parameter) == null) { |
|
361 |
logger.debug("parameterTypeValues is null"); |
|
362 |
} else { |
|
363 |
logger.debug("parameterTypeValues " + Arrays.asList(parameterTypeValues.get(parameter))); |
|
364 |
} |
|
365 |
|
|
366 |
if (operatorTypeValues.get(parameter) == null) { |
|
367 |
logger.debug("operatorTypeValues is null"); |
|
368 |
} else { |
|
369 |
logger.debug("operatorTypeValues " + Arrays.asList(operatorTypeValues.get(parameter))); |
|
370 |
} |
|
371 |
} |
|
372 |
|
|
373 |
//TODO make checks per type???? |
|
374 |
if (operatorTypeValues.size() < parameterTypeValues.size()) { |
|
375 |
throw new IllegalArgumentException("An operator is missing."); |
|
376 |
|
|
377 |
} else if (operatorTypeValues.size() > parameterTypeValues.size()) { |
|
378 |
throw new IllegalArgumentException("Unmatched operator."); |
|
379 |
} |
|
380 |
} |
|
381 |
|
|
382 |
private Response getCountByEntity(String query, RequestResponseHandler.Entity entity) { |
|
383 |
String fullQuery = builtQueryByEntity(query, entity); |
|
384 |
try { |
|
385 |
SearchResult searchResult = searchService.search(fullQuery, null, Locale.getDefault().toString(), 0, 0); |
|
386 |
return Response.status(Response.Status.OK).entity(ResponseFormatter.createCountMeta(fullQuery.replace("\"", "\\\""), searchResult.getTotal())).build(); |
|
387 |
|
|
388 |
} catch (SearchServiceException sse) { |
|
389 |
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ResponseFormatter.compose500Message("Fail to fetch count for query " + fullQuery.replace("\"", "\\\"") + ".", sse.getMessage())).build(); |
|
390 |
} |
|
391 |
} |
|
392 |
|
|
224 | 393 |
private Response getResponseByEntity(RequestResponseHandler.Entity entity, String entityId) { |
225 | 394 |
try { |
226 | 395 |
SearchResult searchResult = searchService.search(entity.getQueryPrefix() + " and ( objIdentifier exact \""+ entityId + "\" )", null, Locale.getDefault().toString(), 1, 1); |
... | ... | |
240 | 409 |
} |
241 | 410 |
} |
242 | 411 |
|
243 |
private Response getResponseByEntity(String query, RequestResponseHandler.Entity entity, int offset, int limit, HttpServletRequest request, boolean refine, List<String> refinefields) { |
|
412 |
private Response getResponseByEntity(String query, Map<String, String[]> operatorTypeValues, Map<String, String[]>parameterTypeValues, RequestResponseHandler.Entity entity, int offset, int limit, HttpServletRequest request, boolean refine, List<String> refinefields) {
|
|
244 | 413 |
try { |
245 |
String fullQuery = builtQueryByEntity(query, entity, offset, limit);
|
|
414 |
String fullQuery = enhanceQuery(query, operatorTypeValues, parameterTypeValues);
|
|
246 | 415 |
SearchResult searchResult = searchService.search(fullQuery, null, Locale.getDefault().toString(), offset, limit); |
247 | 416 |
StringBuilder entitesBuilder = xmlResults2JSON(searchResult.getSearchResults()); |
248 | 417 |
StringBuilder refineBuilder = null; |
249 | 418 |
|
250 | 419 |
if(refine) { |
420 |
refineBuilder = new StringBuilder(); |
|
251 | 421 |
SearchResult refineResults = searchService.refine(fullQuery, null, Locale.getDefault().toString(), refinefields); |
252 |
refineBuilder = JSONResults2JSON(refineResults.getBrowseResults()); |
|
422 |
int i = 0; |
|
423 |
for (String json: refineResults.getBrowseResults()) { |
|
424 |
if (i == (refineResults.getBrowseResults().size() - 1)) { |
|
425 |
refineBuilder.append(json); |
|
426 |
} else { |
|
427 |
refineBuilder.append(json).append(","); |
|
428 |
} |
|
429 |
i++; |
|
430 |
} |
|
253 | 431 |
} |
254 | 432 |
|
255 | 433 |
return Response.status(Response.Status.OK).entity(ResponseFormatter.createEntitiesResponse(request, entity, fullQuery.replace("\"", "\\\""), |
modules/uoa-search/branches/newAPI/src/main/java/eu/dnetlib/data/search/web/api/CQLQueryGeneration.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.search.web.api; |
2 | 2 |
|
3 |
import java.util.HashMap; |
|
3 | 4 |
import java.util.List; |
5 |
import java.util.Map; |
|
4 | 6 |
|
5 | 7 |
/** |
6 | 8 |
* Created by kiatrop on 28/9/2016. |
... | ... | |
29 | 31 |
|
30 | 32 |
} |
31 | 33 |
|
34 |
public static final Map<String, String> resultParameterIndexMap; |
|
35 |
static |
|
36 |
{ |
|
37 |
resultParameterIndexMap = new HashMap<String, String>(); |
|
38 |
resultParameterIndexMap.put( "type", "instancetypenameid"); |
|
39 |
resultParameterIndexMap.put("lang", "resultlanguageid"); |
|
40 |
resultParameterIndexMap.put("community", "communityid"); |
|
41 |
resultParameterIndexMap.put("funder", "relfunderid"); |
|
42 |
resultParameterIndexMap.put("funderlv0", "relfundinglevel0_id"); |
|
43 |
resultParameterIndexMap.put("funderlv1", "relfundinglevel1_id"); |
|
44 |
resultParameterIndexMap.put("funderlv2", "relfundinglevel2_id"); |
|
45 |
} |
|
46 |
|
|
47 |
public static final Map<String, String> resultParameterOperatorMap; |
|
48 |
static |
|
49 |
{ |
|
50 |
resultParameterOperatorMap = new HashMap<String, String>(); |
|
51 |
resultParameterOperatorMap.put("tp", "type"); |
|
52 |
resultParameterOperatorMap.put("ln", "lang"); |
|
53 |
resultParameterOperatorMap.put("cm", "community"); |
|
54 |
resultParameterOperatorMap.put("fn", "funder"); |
|
55 |
resultParameterOperatorMap.put("fn0", "funderlv0"); |
|
56 |
resultParameterOperatorMap.put("fn1", "funderlv1"); |
|
57 |
resultParameterOperatorMap.put("fn2", "funderlv2"); |
|
58 |
} |
|
59 |
|
|
60 |
|
|
32 | 61 |
public static void appendSimpleTerm(StringBuilder stringBuilder, Operator queryOperator, String termValue) { |
33 | 62 |
stringBuilder.append(' ').append(queryOperator).append(' ').append(termValue); |
34 | 63 |
} |
modules/uoa-search/branches/newAPI/src/main/java/eu/dnetlib/data/search/web/api/ResponseFormatter.java | ||
---|---|---|
16 | 16 |
private static final String error500Message = "{ \"status\" : \"fail\", \"code\" : \"500\", \"message\" : \"%s\", \"description\" : \"%s\" }"; |
17 | 17 |
|
18 | 18 |
private static final String metaBasic = "{\"status\": \"success\", \"code\":\"200\" }"; //TODO add self |
19 |
private static final String countSearch = "{\"status\": \"success\", \"code\":\"200\", \"query\":\"%s\", \"total\":\"%s\"}"; //only count |
|
19 | 20 |
private static final String metaSearch = "{\"status\": \"success\", \"code\":\"200\", \"query\":\"%s\", \"total\":\"%s\", \"page\":\"%s\", \"size\":\"%s\", \"_links\": %s}"; |
20 | 21 |
|
21 | 22 |
private static final String _links = "{\"first\": {\"href\":\"%s\"}, " + |
... | ... | |
43 | 44 |
private static final String singleResponse = "{\"meta\": %s, %s }"; |
44 | 45 |
|
45 | 46 |
|
47 |
public static String createCountMeta(String query, int total) { |
|
48 |
return String.format(countSearch, query, total); |
|
49 |
} |
|
50 |
|
|
46 | 51 |
private static String createMetaSearch(HttpServletRequest request, String query, int total, int currentOffset, int limit) { |
47 | 52 |
return formatMetaSearch(query, total+"", currentOffset+"", limit+"", createPaging(request, total, currentOffset, limit)); |
48 | 53 |
} |
... | ... | |
72 | 77 |
if (!refine) |
73 | 78 |
return String.format(response, createMetaSearch(request, query, Integer.valueOf(total), Integer.valueOf(limit), Integer.valueOf(currentOffset)), entities, "", ""); |
74 | 79 |
|
75 |
return String.format(response, createMetaSearch(request, query, Integer.valueOf(total), Integer.valueOf(limit), Integer.valueOf(currentOffset)), entities, ",", "\"refineResults\" : " + refineResults.toString());
|
|
80 |
return String.format(response, createMetaSearch(request, query, Integer.valueOf(total), Integer.valueOf(limit), Integer.valueOf(currentOffset)), entities, ",", "\"refineResults\" : { " + refineResults.toString() + "}");
|
|
76 | 81 |
} |
77 | 82 |
|
78 | 83 |
private static String createPaging(HttpServletRequest request, int total, int currentOffset, int limit) { |
modules/uoa-search/branches/newAPI/src/main/resources/eu/dnetlib/data/search/springContext-searchService.xml | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 | 2 |
|
3 | 3 |
<beans xmlns="http://www.springframework.org/schema/beans" |
4 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
5 |
xmlns:context="http://www.springframework.org/schema/context" |
|
6 |
xmlns:cxf="http://cxf.apache.org/core"
|
|
7 |
xmlns:jaxws="http://cxf.apache.org/jaxws" |
|
8 |
xmlns:p="http://http://www.springframework.org/schema/p" |
|
9 |
xmlns:template="http://dnetlib.eu/springbeans/template" |
|
10 |
xmlns:t="http://dnetlib.eu/springbeans/t"
|
|
11 |
|
|
12 |
xsi:schemaLocation=" |
|
4 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
5 |
xmlns:context="http://www.springframework.org/schema/context"
|
|
6 |
xmlns:cxf="http://cxf.apache.org/core"
|
|
7 |
xmlns:jaxws="http://cxf.apache.org/jaxws"
|
|
8 |
xmlns:p="http://http://www.springframework.org/schema/p"
|
|
9 |
xmlns:template="http://dnetlib.eu/springbeans/template"
|
|
10 |
xmlns:t="http://dnetlib.eu/springbeans/t"
|
|
11 |
|
|
12 |
xsi:schemaLocation="
|
|
13 | 13 |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd |
14 | 14 |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd |
15 | 15 |
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd |
16 | 16 |
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd |
17 | 17 |
http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd" |
18 |
default-autowire="byName"> |
|
18 |
default-autowire="byName">
|
|
19 | 19 |
|
20 |
<alias name="indexServiceLocator" alias="service.indexServiceLocator" />
|
|
21 |
<alias name="resultSetFactory" alias="service.resultSetFactory" />
|
|
20 |
<alias name="indexServiceLocator" alias="service.indexServiceLocator" />
|
|
21 |
<alias name="resultSetFactory" alias="service.resultSetFactory" />
|
|
22 | 22 |
|
23 |
<alias name="${services.search.indexMode}.indexServiceLocator" alias="search.indexServiceLocator" />
|
|
24 |
<alias name="${services.search.indexMode}.resultSetFactory" alias="search.resultSetFactory" />
|
|
23 |
<alias name="${services.search.indexMode}.indexServiceLocator" alias="search.indexServiceLocator" />
|
|
24 |
<alias name="${services.search.indexMode}.resultSetFactory" alias="search.resultSetFactory" />
|
|
25 | 25 |
|
26 | 26 |
<!-- query rewrite rules --> |
27 | 27 |
<bean id="prefixRule" class="eu.dnetlib.data.search.app.plan.PrefixRule"> |
... | ... | |
33 | 33 |
<bean id="collectionRule" class="eu.dnetlib.data.search.app.plan.CollectionRewriteRule"> |
34 | 34 |
<property name="name" value="collection expand rule" /> |
35 | 35 |
<property name="fieldName" value="collection" /> |
36 |
<property name="collectionLookUp" ref="collectionLookUp" />
|
|
36 |
<property name="collectionLookUp" ref="collectionLookUp" /> |
|
37 | 37 |
</bean> |
38 | 38 |
|
39 |
<!-- |
|
39 | 40 |
<bean id="blackboardHandler" class="eu.dnetlib.enabling.tools.blackboard.BlackboardHandlerImpl"> |
40 | 41 |
<property name="registryLocator" ref="cnr.registryLocator"/> |
41 | 42 |
<property name="messageFactory"> |
... | ... | |
44 | 45 |
</bean> |
45 | 46 |
</property> |
46 | 47 |
</bean> |
48 |
--> |
|
49 |
<bean id="searchServiceBlackboardHandler" class="eu.dnetlib.data.search.app.SearchServiceBlackboardHandler" lazy-init="true"> |
|
50 |
<property name="searchService" ref="searchService" /> |
|
51 |
<property name="lookUpServiceServiceLocator" ref="lookupServiceLocator" /> |
|
52 |
<!-- <property name="blackboardHandler" ref="blackboardHandler" /> --> |
|
53 |
<property name="registryServiceServiceLocator" ref="registryServiceLocator"/> |
|
54 |
</bean> |
|
47 | 55 |
|
48 |
<bean id="searchServiceBlackboardHandler" class="eu.dnetlib.data.search.app.SearchServiceBlackboardHandler" lazy-init="true"> |
|
49 |
<property name="searchService" ref="searchService" /> |
|
50 |
<property name="lookUpServiceServiceLocator" ref="lookupServiceLocator" /> |
|
51 |
<property name="blackboardHandler" ref="blackboardHandler" /> |
|
52 |
<property name="registryServiceServiceLocator" ref="registryServiceLocator"/> |
|
53 |
</bean> |
|
54 |
|
|
55 | 56 |
<!-- the service bean --> |
56 | 57 |
<bean id="searchService" |
57 |
class="eu.dnetlib.data.search.app.SearchServiceImpl" |
|
58 |
autowire="no"> |
|
58 |
class="eu.dnetlib.data.search.app.SearchServiceImpl"
|
|
59 |
autowire="no">
|
|
59 | 60 |
<property name="snManager" ref="snManager" /> |
60 | 61 |
<property name="serviceIdentity"> |
61 |
<bean class="eu.dnetlib.utils.ServiceIdentityFactory"
|
|
62 |
factory-method="createIdentity" > |
|
62 |
<bean class="eu.dnetlib.utils.ServiceIdentityFactory" |
|
63 |
factory-method="createIdentity" >
|
|
63 | 64 |
<constructor-arg value="${services.search.serviceName}" /> |
64 | 65 |
</bean> |
65 | 66 |
</property> |
66 | 67 |
<property name="mdFormat" value="${services.search.mdFormat}" /> |
67 |
<property name="indexLayout" value="${services.search.indexLayout}" />
|
|
68 |
<property name="indexLayout" value="${services.search.indexLayout}" />
|
|
68 | 69 |
<property name="indexLocator" ref="search.indexServiceLocator" /> |
69 |
<property name="lookUpServiceServiceLocator" ref="lookupServiceLocator" />
|
|
70 |
<property name="lookUpServiceServiceLocator" ref="lookupServiceLocator" />
|
|
70 | 71 |
<property name="rsFactory" ref="search.resultSetFactory" /> |
71 | 72 |
<property name="transformerFactory" ref="transformerFactory"/> |
72 |
<property name="blackboardNotificationHandler" ref="searchServiceBlackboardHandler" />
|
|
73 |
<!-- <property name="blackboardNotificationHandler" ref="searchServiceBlackboardHandler" /> -->
|
|
73 | 74 |
<property name="queryRules"> |
74 | 75 |
<list> |
75 | 76 |
<ref bean="prefixRule"/> |
... | ... | |
84 | 85 |
|
85 | 86 |
<!-- The web service bean --> |
86 | 87 |
<bean id="searchWebServiceImpl" |
87 |
class="eu.dnetlib.clients.data.search.ws.SearchWebServiceImpl"> |
|
88 |
class="eu.dnetlib.clients.data.search.ws.SearchWebServiceImpl">
|
|
88 | 89 |
<property name="service" ref="searchService" /> |
89 | 90 |
</bean> |
90 | 91 |
|
91 | 92 |
<!-- Service endpoint --> |
92 |
<jaxws:endpoint
|
|
93 |
id="searchWebService"
|
|
94 |
implementor="#searchWebServiceImpl" |
|
95 |
implementorClass="eu.dnetlib.clients.data.search.ws.SearchWebService" |
|
96 |
address="/searchWebService"/> |
|
93 |
<jaxws:endpoint |
|
94 |
id="searchWebService"
|
|
95 |
implementor="#searchWebServiceImpl"
|
|
96 |
implementorClass="eu.dnetlib.clients.data.search.ws.SearchWebService"
|
|
97 |
address="/searchWebService"/>
|
|
97 | 98 |
|
98 |
<template:instance name="nkua.serviceRegistrationManager"
|
|
99 |
t:name="searchServiceRegistrationManager"
|
|
100 |
t:service="searchService"
|
|
101 |
t:endpoint="searchWebService" |
|
102 |
t:serviceRegistrator="searchServiceRegistrator"/> |
|
99 |
<template:instance name="nkua.serviceRegistrationManager" |
|
100 |
t:name="searchServiceRegistrationManager"
|
|
101 |
t:service="searchService"
|
|
102 |
t:endpoint="searchWebService"
|
|
103 |
t:serviceRegistrator="searchServiceRegistrator"/>
|
|
103 | 104 |
|
104 | 105 |
<bean id="searchServiceRegistrator" parent="serviceRegistrator"> |
105 | 106 |
<property name="serviceProperties"> |
106 | 107 |
<map> |
107 | 108 |
<entry key="infrastructure" value="${services.search.infrastructure}" /> |
108 |
<entry key="mdformat" value="${services.search.mdFormat}" />
|
|
109 |
<entry key="mdformat" value="${services.search.mdFormat}" />
|
|
109 | 110 |
</map> |
110 | 111 |
</property> |
111 | 112 |
</bean> |
112 | 113 |
|
113 |
<bean id="searchServiceLocator"
|
|
114 |
class="gr.uoa.di.driver.util.StaticServiceLocator">
|
|
115 |
<property name="service" ref="searchService" />
|
|
116 |
</bean>
|
|
117 |
|
|
114 |
<bean id="searchServiceLocator" |
|
115 |
class="gr.uoa.di.driver.util.StaticServiceLocator">
|
|
116 |
<property name="service" ref="searchService" /> |
|
117 |
</bean> |
|
118 |
|
|
118 | 119 |
<bean id="maxResults" class="java.lang.String"> |
119 | 120 |
<constructor-arg value="${services.search.maxResults}"/> |
120 | 121 |
</bean> |
121 |
|
|
122 |
|
|
122 | 123 |
<bean id="maxSize" class="java.lang.String"> |
123 | 124 |
<constructor-arg value="${services.search.maxSize}"/> |
124 | 125 |
</bean> |
125 |
|
|
126 |
|
|
126 | 127 |
</beans> |
Also available in: Unified diff
basic structure for handling parameters and operators in publications only