Revision 55639
Added by Katerina Iatropoulou almost 5 years ago
modules/uoa-search/branches/solr7/src/main/java/eu/dnetlib/data/search/solr/SolrResultSetFactory.java | ||
---|---|---|
17 | 17 |
public class SolrResultSetFactory implements ResultSetFactory { |
18 | 18 |
|
19 | 19 |
private Logger logger = Logger.getLogger(getClass()); |
20 |
private Map<String, CloudSolrClient> clients = new HashMap<String, CloudSolrClient>(); |
|
20 | 21 |
|
21 | 22 |
@Override |
22 | 23 |
public ResultSet<String> createResultSet(EPR epr) { |
23 | 24 |
try { |
24 | 25 |
|
25 | 26 |
String[] zkservers= epr.getAddress().split(","); |
26 |
CloudSolrClient solrClient = new CloudSolrClient.Builder().withZkHost(Arrays.asList(zkservers)).build(); |
|
27 | 27 |
|
28 |
CloudSolrClient solrClient; |
|
29 |
|
|
30 |
synchronized (clients) { |
|
31 |
solrClient = clients.get(epr.getAddress()); |
|
32 |
} |
|
33 |
if (solrClient == null) { |
|
34 |
solrClient = new CloudSolrClient.Builder().withZkHost(Arrays.asList(zkservers)).build(); |
|
35 |
|
|
36 |
clients.put(epr.getAddress(), solrClient); |
|
37 |
} |
|
38 |
|
|
28 | 39 |
ResultSet<String> solrResultSets = new SolrResultSet(epr, solrClient); |
29 | 40 |
|
30 | 41 |
return solrResultSets; |
modules/uoa-search/branches/solr7/src/main/java/eu/dnetlib/data/search/solr/SolrResultSet.java | ||
---|---|---|
23 | 23 |
import javax.ws.rs.core.MediaType; |
24 | 24 |
import java.io.IOException; |
25 | 25 |
import java.io.OutputStream; |
26 |
import java.util.ArrayList; |
|
27 |
import java.util.HashMap; |
|
28 |
import java.util.List; |
|
29 |
import java.util.Map; |
|
26 |
import java.util.*; |
|
30 | 27 |
|
31 | 28 |
/** |
32 | 29 |
* Created by antleb on 2/4/14. |
... | ... | |
67 | 64 |
|
68 | 65 |
@Override |
69 | 66 |
public void close() { |
70 |
//solrClient.shutdown(); |
|
67 |
/* |
|
68 |
try { |
|
69 |
logger.debug("!!!!!!!!! !!!!!!! CLOSING !!!!!!!!! !!!!!!!!!! "); |
|
70 |
solrClient.close(); |
|
71 |
|
|
72 |
} catch (IOException e) { |
|
73 |
logger.error("Error closing result set.", e); |
|
74 |
} |
|
75 |
*/ |
|
71 | 76 |
} |
72 | 77 |
|
73 | 78 |
@Override |
... | ... | |
191 | 196 |
bf.setId(field.getValues().get(i).getName()); |
192 | 197 |
String[] facetedValues = field.getValues().get(i).getName().split("\\|\\|",2); |
193 | 198 |
|
199 |
|
|
200 |
logger.debug("faceted values " + Arrays.toString(facetedValues)); |
|
201 |
|
|
194 | 202 |
if (facetedValues.length > 1) { |
195 | 203 |
//bf.setName(org.apache.commons.lang3.StringEscapeUtils.escapeJson(facetedValues[1])); |
196 | 204 |
bf.setName(facetedValues[1]); |
205 |
logger.debug("faceted values [1] " + facetedValues[1]); |
|
197 | 206 |
|
198 | 207 |
} else if (field.getValues().get(i).getName().split("_\\:\\:",2).length > 1) { |
199 | 208 |
//bf.setName(org.apache.commons.lang3.StringEscapeUtils.escapeJson(field.getValues().get(i).getName().split("\\:\\:",2)[1]).replaceAll("\\:\\:", "\\|")); |
modules/uoa-search/branches/solr7/src/main/java/eu/dnetlib/data/search/app/SearchServiceImpl.java | ||
---|---|---|
119 | 119 |
} catch (Exception e) { |
120 | 120 |
logger.error("Fail to load search service profile with id " + serviceId + " from IS.", e); |
121 | 121 |
} |
122 |
|
|
122 | 123 |
} |
123 | 124 |
|
124 | 125 |
@Override |
... | ... | |
279 | 280 |
|
280 | 281 |
String query = rewrite(text); |
281 | 282 |
enhanceFieldQueries(fieldQueries); |
283 |
logger.info("Performing cursor query " + query + "' and fields " + fieldQueries + " and refine " + refinefields); |
|
282 | 284 |
logger.debug("Performing cursor query " + query + "' and fields " + fieldQueries + " and refine " + refinefields); |
283 | 285 |
|
284 | 286 |
|
... | ... | |
379 | 381 |
return queryBuffer.append(facetsBuffer.toString()).append(fqBuffer.toString()).toString(); |
380 | 382 |
} |
381 | 383 |
|
384 |
|
|
385 |
//TODO: I wish to remove this. This was only made (quick and dirty - only the enhanceFieldQueries(fieldQueries) is missing |
|
386 |
//from newSearch() after a last time request for the portal to show all the publications and the deletedbyinference ones. |
|
387 |
//I did not want to pass a parameter since I do not know if we are going to keep it. This is for a tech meeting showcase. |
|
388 |
//If we want to keep this I need to redesign. |
|
389 |
|
|
390 |
public SearchResult newSearchWithoutFieldQueries (String text, String locale, List<String> refinefields, List<String> fieldQueries, |
|
391 |
int from, int to, String format, Transformer transformer, Transformer oldRefineTransformer, |
|
392 |
boolean oldPaging) throws SearchServiceException { |
|
393 |
logger.info("non filtered search for... > from: " + from + " to:" + to); |
|
394 |
long startTime = System.nanoTime(); |
|
395 |
|
|
396 |
IndexService index = getIndexLocator().getService(); |
|
397 |
|
|
398 |
EPR epr = null; |
|
399 |
ResultSet<String> rs = null; |
|
400 |
|
|
401 |
List<String> browseResults = null; |
|
402 |
List<String> searchResults = null; |
|
403 |
|
|
404 |
String query = rewrite(text); |
|
405 |
logger.info("Performing query " + query + "' and fields " + fieldQueries + " and refine " + refinefields); |
|
406 |
|
|
407 |
try { |
|
408 |
//TODO see parser and maybe delete! |
|
409 |
//query = new CQLParser().parse(query).toCQL(); |
|
410 |
String eprQuery = createEprQuery(query, refinefields, fieldQueries); |
|
411 |
|
|
412 |
epr = index.getBrowsingStatistics(eprQuery, "all", mdFormat, indexLayout); |
|
413 |
|
|
414 |
if (epr == null) { |
|
415 |
throw new SearchServiceException("Something really strange happened there! Index returned null result set id."); |
|
416 |
} |
|
417 |
|
|
418 |
//get the locale TODO do we need this? |
|
419 |
//String correctLocale = getCorrectLocale(locale); |
|
420 |
//StringTokenizer tokenizer = new StringTokenizer(correctLocale, "_"); |
|
421 |
//Locale requestLocale = new Locale(tokenizer.nextToken(), tokenizer.nextToken()); |
|
422 |
|
|
423 |
rs = rsFactory.createResultSet(epr); |
|
424 |
|
|
425 |
Map<String, List<String>> list = null; |
|
426 |
if (oldPaging) { |
|
427 |
list = ((SolrResultSet)rs).newGet(from-1, to, format, transformer, oldRefineTransformer); |
|
428 |
|
|
429 |
} else { |
|
430 |
list = ((SolrResultSet)rs).newGet(from, to, format, transformer, oldRefineTransformer); |
|
431 |
} |
|
432 |
|
|
433 |
|
|
434 |
searchResults = list.get("search"); |
|
435 |
browseResults = list.get("refine"); |
|
436 |
|
|
437 |
} catch (IndexServiceException ise) { |
|
438 |
logger.error("Error getting refine results.", ise); |
|
439 |
throw new SearchServiceException("Error getting refine results.", ise); |
|
440 |
|
|
441 |
} |
|
442 |
|
|
443 |
long estimatedTime = System.nanoTime() - startTime; |
|
444 |
logger.debug("Search time " + estimatedTime/1000000 + " milliseconds for query " + query + |
|
445 |
" and fields " + fieldQueries + " and refine " + refinefields + " from: "+ from + " and size " + to); |
|
446 |
|
|
447 |
//logger.info("Returned results for NEW search query '" + query + "' and fields " + fieldQueries + " and refine " + refinefields);; |
|
448 |
rs.close(); |
|
449 |
return new SearchResult(query, Locale.getDefault().toString(), rs.size(), from, to, searchResults, browseResults, refinefields); |
|
450 |
} |
|
451 |
|
|
452 |
|
|
382 | 453 |
public String getMdFormat() { |
383 | 454 |
return mdFormat; |
384 | 455 |
} |
modules/uoa-search/branches/solr7/src/main/java/eu/dnetlib/data/search/utils/cql/ParameterQueryEnhancer.java | ||
---|---|---|
105 | 105 |
addBooleanQueryTerm("contextid", hasWTFunding, "WT", queryBuilder); |
106 | 106 |
} |
107 | 107 |
|
108 |
public static void enhanceQueryWithCommunityParams(StringBuilder queryBuilder, HttpServletRequest request) { |
|
109 |
String community = request.getParameter("community"); |
|
110 |
|
|
111 |
if (community!= null) { |
|
112 |
addExactQueryTerm("communityId", community, queryBuilder); |
|
113 |
} |
|
114 |
|
|
115 |
} |
|
116 |
|
|
108 | 117 |
public static void enhanceQueryWithProjectFundingParams(StringBuilder queryBuilder, HttpServletRequest request) { |
109 | 118 |
String hasECFunding = request.getParameter("hasECFunding"); |
110 | 119 |
String hasWTFunding = request.getParameter("hasWTFunding"); |
... | ... | |
300 | 309 |
String[] openairePublicationIDs = request.getParameterValues("openairePublicationID"); |
301 | 310 |
String[] openaireDatasetIDs = request.getParameterValues("openaireDatasetID"); |
302 | 311 |
String[] openaireSoftwareIDs = request.getParameterValues("openaireSoftwareID"); |
312 |
String[] openaireOtherIDs = request.getParameterValues("openaireOtherID"); |
|
303 | 313 |
String[] openaireProviderIDs = request.getParameterValues("openaireProviderID"); |
304 | 314 |
String[] openaireProjectIDs = request.getParameterValues("openaireProjectID"); |
305 | 315 |
|
306 | 316 |
enhanceQueryWithIds("objidentifier", openairePublicationIDs, queryBuilder); |
307 | 317 |
enhanceQueryWithIds("objidentifier", openaireDatasetIDs, queryBuilder); |
308 | 318 |
enhanceQueryWithIds("objidentifier", openaireSoftwareIDs, queryBuilder); |
319 |
enhanceQueryWithIds("objidentifier", openaireOtherIDs, queryBuilder); |
|
309 | 320 |
enhanceQueryWithIds("resulthostingdatasourceid", openaireProviderIDs, queryBuilder); |
310 | 321 |
enhanceQueryWithIds("relprojectid", openaireProjectIDs, queryBuilder); |
311 | 322 |
} |
... | ... | |
317 | 328 |
|
318 | 329 |
addMetadataQueryTerm(null, keywords, queryBuilder); |
319 | 330 |
addMetadataQueryTerm("resulttitle", title, queryBuilder); |
320 |
addMetadataQueryTerm("relperson", author, queryBuilder);
|
|
331 |
addMetadataQueryTerm("resultauthor", author, queryBuilder);
|
|
321 | 332 |
} |
322 | 333 |
|
323 | 334 |
public static void enhanceQueryWithProjectMetadataKeywords(StringBuilder queryBuilder, HttpServletRequest request) { |
modules/uoa-search/branches/solr7/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/branches/solr7/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, |
... | ... | |
478 | 543 |
return getCount(request, fullQuery,format, fieldQueries); |
479 | 544 |
} |
480 | 545 |
|
546 |
/* |
|
481 | 547 |
|
482 |
|
|
483 | 548 |
@GET |
484 | 549 |
@Path("/api/people") |
485 | 550 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
... | ... | |
567 | 632 |
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.DATASET, "relpersonid", personid, fieldQueries); |
568 | 633 |
return getCount(request, fullQuery, format, fieldQueries); |
569 | 634 |
} |
570 |
|
|
635 |
*/ |
|
571 | 636 |
@GET |
572 |
@Path("/reports") |
|
637 |
@Path("/api/reports")
|
|
573 | 638 |
@Produces(MediaType.TEXT_PLAIN) |
574 |
public Response fetchReport(@QueryParam("query") String query,
|
|
639 |
public Response fetchReport(@QueryParam("q") String keywords,
|
|
575 | 640 |
@QueryParam("refine") @DefaultValue("false") boolean refine, |
576 | 641 |
@QueryParam("fields") final List<String> fields, |
577 | 642 |
@QueryParam("fq") final List<String> fieldQueries, |
... | ... | |
592 | 657 |
final boolean special = isSpecialFormat(format); |
593 | 658 |
String responseType = extractResponseFormat(format); |
594 | 659 |
|
595 |
final String fullQuery = buildSearchRequest(entity,"", fieldQueries); |
|
660 |
final String fullQuery = buildSearchRequest(entity, keywords, fieldQueries); |
|
661 |
logger.debug("fullquery " + fullQuery); |
|
662 |
logger.debug("fieldQueries " + fieldQueries); |
|
596 | 663 |
|
597 | 664 |
try { |
598 | 665 |
SearchResult sr = searchService.newSearch(fullQuery, Locale.getDefault().toString(), fields, fieldQueries,0, 0, format, transformer,null,false); |
... | ... | |
890 | 957 |
} else if (type.equalsIgnoreCase(RequestResponseHandler.Entity.SOFTWARE.getPlural())) { |
891 | 958 |
return RequestResponseHandler.Entity.SOFTWARE; |
892 | 959 |
|
960 |
} else if (type.equalsIgnoreCase(RequestResponseHandler.Entity.OTHER.getPlural())) { |
|
961 |
return RequestResponseHandler.Entity.OTHER; |
|
962 |
|
|
893 | 963 |
} else if (type.equalsIgnoreCase(RequestResponseHandler.Entity.PROJECT.getPlural())) { |
894 | 964 |
return RequestResponseHandler.Entity.PROJECT; |
895 | 965 |
|
... | ... | |
907 | 977 |
} |
908 | 978 |
|
909 | 979 |
|
980 |
//This follows the newSearchWithoutFieldQueries comment. I wish to remove it!!! This was only made |
|
981 |
// (quick and dirty - only the getResponseByEntity version with newSearchWithoutFieldQueries is used |
|
982 |
// after a last time request for the portal to show all the publications and the deletedbyinference ones. |
|
983 |
// I did not want to pass a parameter since I do not know if we are going to keep it. This is for a tech meeting showcase. |
|
984 |
// If we want to keep this I need to redesign. |
|
985 |
@GET |
|
986 |
@Path("/api/deletedByInferencePublications/{publicationid}") |
|
987 |
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
|
988 |
public Response fetchDeletedByInferencePublicationsById(@PathParam("publicationid") String publicationid, |
|
989 |
@QueryParam("format") final String format, |
|
990 |
@QueryParam("fq") final List<String> fieldQueries, |
|
991 |
@Context final HttpServletRequest request) { |
|
992 |
return getDeletedByInferenceResponseByEntityId(request, RequestResponseHandler.Entity.PUBLICATION, publicationid, format, fieldQueries); |
|
993 |
} |
|
994 |
|
|
995 |
//Please see comment above. I wish to remove it. |
|
996 |
private Response getDeletedByInferenceResponseByEntityId(HttpServletRequest request, RequestResponseHandler.Entity entity, String entityId, String format, List<String> fieldQueries) { |
|
997 |
String responseType = extractResponseFormat(format); |
|
998 |
|
|
999 |
try { |
|
1000 |
StringBuilder queryBuilder = new StringBuilder(); |
|
1001 |
builtEntityIdQuery(queryBuilder, entity, entityId, fieldQueries); |
|
1002 |
String fullQuery = queryBuilder.toString(); |
|
1003 |
|
|
1004 |
if(fullQuery == null || fullQuery.isEmpty()) { |
|
1005 |
return Response.status(Response.Status.BAD_REQUEST). |
|
1006 |
entity(APIResponseFormatter.compose400Message(format, "The 'query' parameter is required")). |
|
1007 |
type(responseType).build(); |
|
1008 |
} |
|
1009 |
|
|
1010 |
SearchResult searchResult = searchService.newSearchWithoutFieldQueries(fullQuery, Locale.getDefault().toString(), null, fieldQueries, 0, 1, responseType, null, null, false); |
|
1011 |
|
|
1012 |
if (searchResult.getSearchResults() == null || searchResult.getSearchResults().isEmpty() || |
|
1013 |
searchResult.getSearchResults().size() == 0 || searchResult.getSearchResults().get(0) == null) { |
|
1014 |
return Response.status(Response.Status.NOT_FOUND).entity(APIResponseFormatter.compose404Message(responseType, "404 - " + entity +" with id " |
|
1015 |
+ entityId + " not found.")).type(responseType).build(); |
|
1016 |
} |
|
1017 |
|
|
1018 |
return Response.status(Response.Status.OK).entity(APIResponseFormatter.createEntityResponse(request, entity, searchResult.getSearchResults().get(0).toString(), responseType)).type(responseType).build(); |
|
1019 |
|
|
1020 |
} catch (SearchServiceException sse) { |
|
1021 |
logger.error("Fail to fetch "+ entity + " with id " + entityId, sse); |
|
1022 |
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(APIResponseFormatter.compose500Message(responseType, "Fail to fetch " + entity + " with id " + entityId, sse.getMessage())).build(); |
|
1023 |
} |
|
1024 |
} |
|
1025 |
|
|
910 | 1026 |
/* |
911 | 1027 |
public static void main(String[] args) { |
912 | 1028 |
String json = " {\"result\":{\"xmlns:oaf\":\"http://namespace.openaire.eu/oaf\",\"xmlns:xsi\":\"http://www.w3.o" + |
modules/uoa-search/branches/solr7/src/main/java/eu/dnetlib/data/search/web/api/SearchRequestController.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.search.web.api; |
2 | 2 |
|
3 | 3 |
import com.google.common.collect.Iterables; |
4 |
import eu.dnetlib.api.data.SearchServiceException; |
|
4 | 5 |
import eu.dnetlib.data.search.app.SearchServiceImpl; |
5 | 6 |
import eu.dnetlib.data.search.utils.cql.ParameterQueryEnhancer; |
6 | 7 |
import eu.dnetlib.data.search.utils.vocabulary.VocabularyManager; |
... | ... | |
11 | 12 |
import org.apache.commons.lang.StringEscapeUtils; |
12 | 13 |
import org.apache.log4j.Logger; |
13 | 14 |
import org.springframework.beans.factory.annotation.Autowired; |
15 |
import org.springframework.http.*; |
|
14 | 16 |
import org.springframework.stereotype.Controller; |
15 | 17 |
import org.springframework.ui.ModelMap; |
18 |
import org.springframework.web.bind.annotation.ExceptionHandler; |
|
16 | 19 |
import org.springframework.web.bind.annotation.RequestMapping; |
17 | 20 |
import org.springframework.web.bind.annotation.RequestMethod; |
21 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
18 | 22 |
|
19 | 23 |
import javax.annotation.Resource; |
20 | 24 |
import javax.servlet.http.HttpServletRequest; |
21 | 25 |
import javax.servlet.http.HttpServletResponse; |
26 |
import java.io.IOException; |
|
22 | 27 |
import java.io.PrintWriter; |
23 | 28 |
import java.text.SimpleDateFormat; |
24 | 29 |
import java.util.*; |
... | ... | |
48 | 53 |
private static final String PUBLICATION_BASIC_QUERY = "(oaftype exact result) and (resulttypeid exact publication)"; |
49 | 54 |
private static final String DATASET_BASIC_QUERY = "(oaftype exact result) and (resulttypeid exact dataset)"; |
50 | 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)"; |
|
51 | 57 |
private static final String PROJECT_BASIC_QUERY = "(oaftype exact project)"; |
52 | 58 |
|
53 | 59 |
private static final List<String> GLOBAL_PARAMETERS = Arrays.asList("page", "size", "format", "sortBy"); |
54 | 60 |
|
55 |
private static final List<String> PUB_N_DATA_COMMON_PARAMETERS = Arrays.asList("author", "doi", "FP7ProjectID", "FP7scientificArea", |
|
61 |
private static final List<String> PUB_N_DATA_COMMON_PARAMETERS = Arrays.asList("author", "doi", "community", "FP7ProjectID", "FP7scientificArea",
|
|
56 | 62 |
"fromDateAccepted", "funder", "fundingStream", "hasECFunding", "hasProject", "hasWTFunding", "keywords", |
57 | 63 |
"model", "OA", "openaireProjectID", "openaireProviderID", "projectID", "title", "toDateAccepted"); |
58 | 64 |
|
59 | 65 |
private static final List<String> PUB_PARAMETERS = Arrays.asList("openairePublicationID"); |
60 | 66 |
private static final List<String> DATA_PARAMETERS = Arrays.asList("openaireDatasetID"); |
61 | 67 |
private static final List<String> SOFTWARE_PARAMETERS = Arrays.asList("openaireSoftwareID"); |
68 |
private static final List<String> OTHER_PARAMETERS = Arrays.asList("openaireOtherID"); |
|
62 | 69 |
|
63 | 70 |
private static final List<String> PUB_N_DATASET_MODELS = Arrays.asList("dc", "openaire", "sygma"); |
64 | 71 |
private static final List<String> PUB_N_DATASET_FORMATS = Arrays.asList("json", "rss", "xml", "csv", "tsv", "html"); |
... | ... | |
68 | 75 |
"participantAcronyms", "participantCountries", "startYear", "sc39", "openaireParticipantID", "openaireProjectID"); |
69 | 76 |
private static final List<String> PROJECT_FORMATS = Arrays.asList("xml", "json", "csv", "tsv", "html"); |
70 | 77 |
|
78 |
//TODO this is for joomla - to be removed soon |
|
71 | 79 |
@RequestMapping(value = "/search", method = RequestMethod.GET) |
72 | 80 |
public void search(HttpServletRequest request, HttpServletResponse response) { |
73 | 81 |
PrintWriter writer = null; |
... | ... | |
185 | 193 |
return "openSearchDescriptor"; |
186 | 194 |
} |
187 | 195 |
|
188 |
@RequestMapping(value = "/api/publications", method = RequestMethod.GET) |
|
189 |
public void searchPublications(HttpServletRequest request, HttpServletResponse response) { |
|
196 |
@RequestMapping(value = "/api/publications", method = RequestMethod.GET, produces = {MediaType.APPLICATION_XML_VALUE,MediaType.APPLICATION_JSON_VALUE})
|
|
197 |
public void searchPublications(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
190 | 198 |
|
191 | 199 |
long time = System.currentTimeMillis(); |
200 |
checkParameters(ListUtils.union(PUB_N_DATA_COMMON_PARAMETERS, PUB_PARAMETERS),request.getParameterMap()); |
|
192 | 201 |
|
193 |
PrintWriter writer = null; |
|
194 |
|
|
195 |
try { |
|
196 |
writer = response.getWriter(); |
|
197 |
|
|
198 |
checkParameters(ListUtils.union(PUB_N_DATA_COMMON_PARAMETERS, PUB_PARAMETERS),request.getParameterMap()); |
|
199 |
|
|
200 | 202 |
int page = readParameter(request, "page", 1); |
201 | 203 |
int size = readParameter(request, "size", 10); |
202 | 204 |
checkRequestSize(page, size); |
... | ... | |
221 | 223 |
ParameterQueryEnhancer.enhanceQueryWithOpenAIREIds(queryBuilder, request); |
222 | 224 |
ParameterQueryEnhancer.enhanceQueryWithMetadataKeywords(queryBuilder, request); |
223 | 225 |
ParameterQueryEnhancer.enhanceQueryWithFundingParams(queryBuilder, request); |
226 |
ParameterQueryEnhancer.enhanceQueryWithCommunityParams(queryBuilder, request); |
|
224 | 227 |
ParameterQueryEnhancer.enhanceQueryWithRelProjectParams(queryBuilder, request); |
225 | 228 |
ParameterQueryEnhancer.enhanceQueryWithAccessRights(queryBuilder, request); |
226 | 229 |
ParameterQueryEnhancer.enhanceQueryWithDate(queryBuilder, request); |
227 | 230 |
ParameterQueryEnhancer.enhanceQueryWithDoi(queryBuilder, request); |
228 | 231 |
|
229 | 232 |
ParameterQueryEnhancer.enhanceQueryWithResultsSortParameters(queryBuilder, request); |
233 |
FormattedSearchResult formattedSearchResult = null; |
|
230 | 234 |
|
231 |
FormattedSearchResult formattedSearchResult = searchService.search(queryBuilder.toString(),sTransformer, (newFormat!=null)?newFormat:format, locale, page, size);
|
|
232 |
writer.append(formattedSearchResult.getFormattedResult());
|
|
235 |
try {
|
|
236 |
formattedSearchResult = searchService.search(queryBuilder.toString(),sTransformer, (newFormat!=null)?newFormat:format, locale, page, size);
|
|
233 | 237 |
|
234 | 238 |
} catch (Exception e) { |
235 | 239 |
logger.error("Fail to execute search.", e); |
236 |
createXmlErrorPage(writer, e);
|
|
240 |
throw new Exception("Fail to execute search", e);
|
|
237 | 241 |
|
238 |
} finally { |
|
239 |
if (writer != null) { |
|
240 |
IOUtils.closeQuietly(writer); |
|
241 |
} |
|
242 | 242 |
} |
243 | 243 |
|
244 |
PrintWriter writer = response.getWriter(); |
|
245 |
writer.append(formattedSearchResult.getFormattedResult()); |
|
246 |
writer.close(); |
|
247 |
|
|
244 | 248 |
time = System.currentTimeMillis() - time; |
245 | 249 |
logger.debug("Answer old time " + time); |
246 | 250 |
} |
247 | 251 |
|
248 |
@RequestMapping(value = "/api/datasets", method = RequestMethod.GET) |
|
249 |
public void searchData(HttpServletRequest request, HttpServletResponse response) { |
|
252 |
@RequestMapping(value = "/api/datasets", method = RequestMethod.GET, produces = {MediaType.APPLICATION_XML_VALUE,MediaType.APPLICATION_JSON_VALUE})
|
|
253 |
public void searchData(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
250 | 254 |
|
251 |
PrintWriter writer = null; |
|
252 |
|
|
253 |
try { |
|
254 |
writer = response.getWriter(); |
|
255 |
|
|
256 | 255 |
checkParameters(ListUtils.union(PUB_N_DATA_COMMON_PARAMETERS, DATA_PARAMETERS),request.getParameterMap()); |
257 | 256 |
|
258 | 257 |
int page = readParameter(request, "page", 1); |
... | ... | |
287 | 286 |
|
288 | 287 |
ParameterQueryEnhancer.enhanceQueryWithResultsSortParameters(queryBuilder, request); |
289 | 288 |
|
290 |
FormattedSearchResult formattedSearchResult = searchService.search(queryBuilder.toString(),sTransformer, (newFormat!=null)?newFormat:format, locale, page, size); |
|
291 |
writer.append(formattedSearchResult.getFormattedResult()); |
|
289 |
FormattedSearchResult formattedSearchResult = null; |
|
290 |
try { |
|
291 |
formattedSearchResult = searchService.search(queryBuilder.toString(),sTransformer, (newFormat!=null)?newFormat:format, locale, page, size); |
|
292 | 292 |
|
293 | 293 |
} catch (Exception e) { |
294 | 294 |
logger.error("Fail to execute search.", e); |
295 |
createXmlErrorPage(writer, e); |
|
296 |
|
|
297 |
} finally { |
|
298 |
if (writer != null) { |
|
299 |
IOUtils.closeQuietly(writer); |
|
295 |
throw new Exception("Fail to execute search.", e); |
|
300 | 296 |
} |
301 |
} |
|
302 | 297 |
|
298 |
PrintWriter writer = response.getWriter(); |
|
299 |
writer.append(formattedSearchResult.getFormattedResult()); |
|
300 |
writer.close(); |
|
301 |
|
|
303 | 302 |
} |
304 | 303 |
|
305 |
@RequestMapping(value = "/api/software", method = RequestMethod.GET) |
|
306 |
public void searchSoftware(HttpServletRequest request, HttpServletResponse response) { |
|
304 |
@RequestMapping(value = "/api/software", method = RequestMethod.GET, produces = {MediaType.APPLICATION_XML_VALUE,MediaType.APPLICATION_JSON_VALUE})
|
|
305 |
public void searchSoftware(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
307 | 306 |
|
308 |
PrintWriter writer = null; |
|
309 |
|
|
310 |
try { |
|
311 |
writer = response.getWriter(); |
|
312 |
|
|
313 | 307 |
checkParameters(ListUtils.union(PUB_N_DATA_COMMON_PARAMETERS, SOFTWARE_PARAMETERS),request.getParameterMap()); |
314 | 308 |
|
315 | 309 |
int page = readParameter(request, "page", 1); |
... | ... | |
344 | 338 |
|
345 | 339 |
ParameterQueryEnhancer.enhanceQueryWithResultsSortParameters(queryBuilder, request); |
346 | 340 |
|
347 |
FormattedSearchResult formattedSearchResult = searchService.search(queryBuilder.toString(),sTransformer, (newFormat!=null)?newFormat:format, locale, page, size); |
|
348 |
writer.append(formattedSearchResult.getFormattedResult()); |
|
341 |
FormattedSearchResult formattedSearchResult = null; |
|
349 | 342 |
|
343 |
try { |
|
344 |
formattedSearchResult = searchService.search(queryBuilder.toString(),sTransformer, (newFormat!=null)?newFormat:format, locale, page, size); |
|
345 |
|
|
350 | 346 |
} catch (Exception e) { |
351 | 347 |
logger.error("Fail to execute search.", e); |
352 |
createXmlErrorPage(writer, e); |
|
353 |
|
|
354 |
} finally { |
|
355 |
if (writer != null) { |
|
356 |
IOUtils.closeQuietly(writer); |
|
348 |
throw new Exception("Fail to execute search", e); |
|
357 | 349 |
} |
358 |
} |
|
359 | 350 |
|
351 |
PrintWriter writer = response.getWriter(); |
|
352 |
writer.append(formattedSearchResult.getFormattedResult()); |
|
353 |
|
|
360 | 354 |
} |
361 | 355 |
|
362 |
@RequestMapping(value = "/api/projects", method = RequestMethod.GET)
|
|
363 |
public void searchProjects(HttpServletRequest request, HttpServletResponse response) {
|
|
356 |
@RequestMapping(value = "/api/other", method = RequestMethod.GET, produces = {MediaType.APPLICATION_XML_VALUE,MediaType.APPLICATION_JSON_VALUE})
|
|
357 |
public void searchOther(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
364 | 358 |
|
365 |
PrintWriter writer = null;
|
|
359 |
checkParameters(ListUtils.union(PUB_N_DATA_COMMON_PARAMETERS, OTHER_PARAMETERS),request.getParameterMap());
|
|
366 | 360 |
|
361 |
int page = readParameter(request, "page", 1); |
|
362 |
int size = readParameter(request, "size", 10); |
|
363 |
checkRequestSize(page, size); |
|
364 |
|
|
365 |
String format = (request.getParameter("format") != null) ? request.getParameter("format") : "xml"; |
|
366 |
createResponseMeta(response, format); |
|
367 |
|
|
368 |
checkFormatParameter(PUB_N_DATASET_FORMATS, format); |
|
369 |
|
|
370 |
String model = request.getParameter("model"); |
|
371 |
checkModelParameter(PUB_N_DATASET_MODELS, model); |
|
372 |
String sTransformer = defineTransformer(model,format); |
|
373 |
|
|
374 |
Collection<String> referrers = readParameter(request,"referrer"); |
|
375 |
String newFormat = defineFormatter(model, format, false, referrers); |
|
376 |
|
|
377 |
String locale = request.getParameter("locale"); |
|
378 |
|
|
379 |
StringBuilder queryBuilder = new StringBuilder(); |
|
380 |
queryBuilder.append(OTHER_BASIC_QUERY); |
|
381 |
|
|
382 |
ParameterQueryEnhancer.enhanceQueryWithFundingLevelParams(queryBuilder, request, vocabularyManager, isModelSygma(model)); |
|
383 |
ParameterQueryEnhancer.enhanceQueryWithOpenAIREIds(queryBuilder, request); |
|
384 |
ParameterQueryEnhancer.enhanceQueryWithMetadataKeywords(queryBuilder, request); |
|
385 |
ParameterQueryEnhancer.enhanceQueryWithFundingParams(queryBuilder, request); |
|
386 |
ParameterQueryEnhancer.enhanceQueryWithCommunityParams(queryBuilder, request); |
|
387 |
ParameterQueryEnhancer.enhanceQueryWithRelProjectParams(queryBuilder, request); |
|
388 |
ParameterQueryEnhancer.enhanceQueryWithAccessRights(queryBuilder, request); |
|
389 |
ParameterQueryEnhancer.enhanceQueryWithDate(queryBuilder, request); |
|
390 |
ParameterQueryEnhancer.enhanceQueryWithDoi(queryBuilder, request); |
|
391 |
|
|
392 |
ParameterQueryEnhancer.enhanceQueryWithResultsSortParameters(queryBuilder, request); |
|
393 |
|
|
394 |
FormattedSearchResult formattedSearchResult = null; |
|
395 |
|
|
367 | 396 |
try { |
368 |
writer = response.getWriter();
|
|
397 |
formattedSearchResult = searchService.search(queryBuilder.toString(),sTransformer, (newFormat!=null)?newFormat:format, locale, page, size);
|
|
369 | 398 |
|
399 |
} catch (Exception e) { |
|
400 |
logger.error("Fail to execute search.", e); |
|
401 |
throw new Exception("Fail to execute search", e); |
|
402 |
} |
|
403 |
|
|
404 |
PrintWriter writer = response.getWriter(); |
|
405 |
writer.append(formattedSearchResult.getFormattedResult()); |
|
406 |
|
|
407 |
} |
|
408 |
|
|
409 |
@RequestMapping(value = "/api/projects", method = RequestMethod.GET, produces = {MediaType.APPLICATION_XML_VALUE,MediaType.APPLICATION_JSON_VALUE}) |
|
410 |
public void searchProjects(HttpServletRequest request, HttpServletResponse response) throws Exception { |
|
411 |
|
|
370 | 412 |
checkParameters(PROJECT_PARAMETERS, request.getParameterMap()); |
371 | 413 |
|
372 | 414 |
int page = readParameter(request, "page", 1); |
... | ... | |
383 | 425 |
|
384 | 426 |
format = finalFormat(format); |
385 | 427 |
|
386 |
|
|
387 | 428 |
String sTransformer = request.getParameter("sTransformer"); |
388 | 429 |
|
389 |
FormattedSearchResult formattedSearchResult = null; |
|
390 |
|
|
391 | 430 |
ParameterQueryEnhancer.enhanceProjectQueryWithOpenAIREIds(queryBuilder, request); |
392 | 431 |
ParameterQueryEnhancer.enhanceQueryWithProjectMetadataKeywords(queryBuilder, request); |
393 | 432 |
ParameterQueryEnhancer.enhanceQueryWithProjectFundingParams(queryBuilder, request); |
... | ... | |
398 | 437 |
|
399 | 438 |
ParameterQueryEnhancer.enhanceQueryWithProjectSortParameters(queryBuilder, request); |
400 | 439 |
|
440 |
FormattedSearchResult formattedSearchResult = null; |
|
441 |
try { |
|
401 | 442 |
formattedSearchResult = searchService.search(queryBuilder.toString(),sTransformer, format, locale, page, size); |
402 |
writer.append(formattedSearchResult.getFormattedResult()); |
|
403 | 443 |
|
404 |
} catch (Exception e) {
|
|
405 |
logger.error("Fail to execute search.", e);
|
|
406 |
createXmlErrorPage(writer, e);
|
|
444 |
} catch (SearchServiceException e) {
|
|
445 |
throw new Exception("Fail to execute search");
|
|
446 |
}
|
|
407 | 447 |
|
408 |
} finally { |
|
409 |
if (writer != null) { |
|
410 |
IOUtils.closeQuietly(writer); |
|
411 |
} |
|
412 |
} |
|
448 |
PrintWriter writer = response.getWriter(); |
|
449 |
writer.append(formattedSearchResult.getFormattedResult()); |
|
450 |
writer.close(); |
|
413 | 451 |
} |
414 | 452 |
|
453 |
|
|
454 |
@ExceptionHandler(IllegalArgumentException.class) |
|
455 |
public @ResponseBody ResponseEntity<Error> invalidInput(HttpServletRequest request, HttpServletResponse httpServletResponse, Exception ex) { |
|
456 |
Error response = new Error(); |
|
457 |
response.setStatus("error"); |
|
458 |
response.setCode("400"); |
|
459 |
response.setMessage("400 - Illegal argument exception."); |
|
460 |
response.setException(ex.getMessage()); |
|
461 |
|
|
462 |
String format = (request.getParameter("format") == null)? "xml": request.getParameter("format").toLowerCase(); |
|
463 |
|
|
464 |
return new ResponseEntity<Error>(response, HttpStatus.BAD_REQUEST); |
|
465 |
} |
|
466 |
|
|
415 | 467 |
private String finalFormat(String format) { |
416 | 468 |
if (format.equals("tsv")){ |
417 | 469 |
return "project_tsv"; |
... | ... | |
468 | 520 |
|
469 | 521 |
//TODO: check if needed |
470 | 522 |
private String defineTransformer(String model, String format) { |
471 |
if (model!=null && !model.trim().isEmpty()) {
|
|
523 |
if (model != null && !model.trim().isEmpty() && format != null && (format.equals("json")||format.equals("xml"))) {
|
|
472 | 524 |
if (model.equals("openaire")) { |
473 | 525 |
return null; |
474 | 526 |
|
... | ... | |
510 | 562 |
return null; |
511 | 563 |
} |
512 | 564 |
|
565 |
@Deprecated |
|
513 | 566 |
private void createXmlErrorPage(PrintWriter writer, Exception e) { |
514 | 567 |
writer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); |
515 | 568 |
writer.append("<error>"); |
... | ... | |
648 | 701 |
} |
649 | 702 |
} |
650 | 703 |
|
704 |
|
|
705 |
/* TODO: enable if we decide to use ACCEPT Header as a priority to format parameter |
|
706 |
private String getFormat(HttpServletRequest request) { |
|
707 |
if (request.getParameter("format") == null && request.getHeader("Accept")!=null) { |
|
708 |
if (request.getHeader("Accept").equals(MediaType.APPLICATION_XML_VALUE) || |
|
709 |
request.getHeader("Accept").contains(MediaType.APPLICATION_XML_VALUE)){ |
|
710 |
return "xml"; |
|
711 |
} |
|
712 |
|
|
713 |
if (request.getHeader("Accept").equals(MediaType.APPLICATION_JSON_VALUE)){ |
|
714 |
return "json"; |
|
715 |
} |
|
716 |
} |
|
717 |
|
|
718 |
if (request.getParameter("format") == null && (request.getHeader("Accept")== null || |
|
719 |
request.getHeader("Accept").equals(MediaType.ALL_VALUE))) { |
|
720 |
return "xml"; |
|
721 |
} |
|
722 |
|
|
723 |
return request.getParameter("format"); |
|
724 |
} */ |
|
725 |
|
|
651 | 726 |
/*public void test(HttpServletRequest request, HttpServletResponse response) throws IOException, SolrServerException { |
652 | 727 |
|
653 | 728 |
long time = System.currentTimeMillis(); |
modules/uoa-search/branches/solr7/src/main/resources/csv_publication.xsl | ||
---|---|---|
28 | 28 |
<xsl:text>",</xsl:text> |
29 | 29 |
|
30 | 30 |
<!-- Authors --> |
31 |
<xsl:text>"</xsl:text> |
|
31 | 32 |
<xsl:for-each select="creator"> |
32 | 33 |
<xsl:sort select="@rank"/> |
33 |
<xsl:text>"</xsl:text> |
|
34 | 34 |
<xsl:value-of select="."/> |
35 |
<xsl:text>"</xsl:text> |
|
36 | 35 |
<xsl:if test="not(position()=last())"> |
37 | 36 |
<xsl:text>;</xsl:text> |
38 | 37 |
</xsl:if> |
39 | 38 |
</xsl:for-each> |
39 |
<xsl:text>"</xsl:text> |
|
40 | 40 |
<xsl:text>,</xsl:text> |
41 | 41 |
|
42 | 42 |
<!-- Publication Year --> |
modules/uoa-search/branches/solr7/src/main/resources/csv_publication_special.xsl | ||
---|---|---|
32 | 32 |
<xsl:text>",</xsl:text> |
33 | 33 |
|
34 | 34 |
<!-- Authors --> |
35 |
<xsl:text>"</xsl:text> |
|
35 | 36 |
<xsl:for-each select="../../../creator"> |
36 | 37 |
<xsl:sort select="@rank"/> |
37 |
<xsl:text>"</xsl:text> |
|
38 | 38 |
<xsl:value-of select="."/> |
39 |
<xsl:text>"</xsl:text> |
|
40 | 39 |
<xsl:if test="not(position()=last())"> |
41 | 40 |
<xsl:text>;</xsl:text> |
42 | 41 |
</xsl:if> |
43 | 42 |
</xsl:for-each> |
43 |
<xsl:text>"</xsl:text> |
|
44 | 44 |
<xsl:text>,</xsl:text> |
45 | 45 |
|
46 | 46 |
<!-- Publication Year --> |
modules/uoa-search/branches/solr7/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> |
modules/uoa-search/branches/solr7/src/main/resources/json.xsl | ||
---|---|---|
106 | 106 |
<xsl:value-of select="name()"/> |
107 | 107 |
<xsl:text>" : [ </xsl:text> |
108 | 108 |
</xsl:when> |
109 |
<xsl:when test="$kctr = 1"> |
|
109 |
<xsl:when test="$kctr = 1 and name()!='result'">
|
|
110 | 110 |
<xsl:text>"</xsl:text> |
111 | 111 |
<xsl:value-of select="name()"/> |
112 | 112 |
<xsl:text>" : </xsl:text> |
113 | 113 |
</xsl:when> |
114 |
<xsl:when test="$kctr = 1 and name()='result'"> |
|
115 |
<xsl:text>"</xsl:text> |
|
116 |
<xsl:value-of select="name()"/> |
|
117 |
<xsl:text>" : [</xsl:text> |
|
118 |
</xsl:when> |
|
114 | 119 |
</xsl:choose> |
115 | 120 |
<!-- count number of elements, text nodes and attribute nodes --> |
116 | 121 |
<xsl:variable name="nctr" select="count(*|text()|@*)"/> |
... | ... | |
167 | 172 |
</xsl:otherwise> |
168 | 173 |
</xsl:choose> |
169 | 174 |
</xsl:if> |
175 |
<xsl:if test="$kctr = 1 and name()='result'"> |
|
176 |
<xsl:text> ]</xsl:text> |
|
177 |
</xsl:if> |
|
170 | 178 |
</xsl:for-each> |
171 | 179 |
<xsl:if test="position() != last()"> |
172 | 180 |
<xsl:text>, </xsl:text> |
... | ... | |
178 | 186 |
<xsl:variable name="t" select="." /> |
179 | 187 |
<xsl:choose> |
180 | 188 |
<!-- test to see if it is a number --> |
181 |
<xsl:when test="string(number($t)) != 'NaN' and not(starts-with($t,'+')) and not(local-name(..)='code') ">
|
|
189 |
<xsl:when test="string(number($t)) != 'NaN' and not(starts-with($t,'+')) and (not(local-name(..)='code') and not(local-name(..)='subject'))">
|
|
182 | 190 |
<xsl:value-of select="$t"/> |
183 | 191 |
</xsl:when> |
184 | 192 |
<!-- deal with any case booleans --> |
Also available in: Unified diff
Latest for solr7 + deletedByInferencePublications method added #4216