Project

General

Profile

« Previous | Next » 

Revision 50308

repo UI fixing

View differences:

modules/dnet-openaire-datasource-manager/trunk/src/main/java/eu/dnetlib/enabling/datasources/LocalOpenaireDatasourceManager.java
1 1
package eu.dnetlib.enabling.datasources;
2 2

  
3
import java.io.StringWriter;
3 4
import java.util.ArrayList;
4 5
import java.util.Date;
5 6
import java.util.HashMap;
......
8 9
import java.util.Optional;
9 10
import java.util.stream.Collectors;
10 11

  
12
import org.apache.commons.io.IOUtils;
11 13
import org.apache.commons.lang.StringUtils;
12 14
import org.apache.commons.lang.math.NumberUtils;
13 15
import org.apache.commons.logging.Log;
......
68 70
	@Override
69 71
	public List<? extends SearchApisEntry> searchApis(final String field, final Object value) throws DsmException {
70 72
		try {
71
			final Map<String, Object> sqlParams = new HashMap<>();
73
			final StringWriter sql = new StringWriter();
72 74

  
73
			if (!field.equalsIgnoreCase("__search__")) {
74
				sqlParams.put("field", field);
75
				sqlParams.put("value", value);
75
			if (field.equalsIgnoreCase("__search__")) {
76
				sql.append(IOUtils.toString(searchApis.getInputStream()));
76 77
			} else {
77
				sqlParams.put("value", "%" + value + "%");
78
				sql.append(IOUtils.toString(searchApisUsingField.getInputStream()));
79
				sql.append(field);
80
				sql.append("::text = ");
81
				sql.append(":value");
78 82
			}
79 83

  
80
			return datasourceManagerClients.searchSQL(field.equalsIgnoreCase("__search__") ? searchApis : searchApisUsingField, sqlParams)
84
			return datasourceManagerClients
85
					.searchSQL(sql.toString(), ImmutableMap.of("value", field.equalsIgnoreCase("__search__") ? "%" + value + "%" : value))
81 86
					.stream()
82 87
					.map(DatasourceFunctions::mapToSearchApisEntry)
83 88
					.collect(Collectors.toList());
modules/dnet-openaire-datasource-manager/trunk/src/main/resources/eu/dnetlib/enabling/datasources/queries/searchApisNormal.sql
11 11
	ds.englishname                                                           AS "alternativeName",
12 12
	ds.namespaceprefix                                                       AS "prefix",
13 13
	ds.websiteurl                                                            AS "websiteUrl",
14
	(array_agg(o.country))[1]                                                AS "country",
14
	coalesce((array_agg(o.country))[1], '-')                                 AS "country",
15 15
    (array_agg(o.legalname))[1]                                              AS "organization"
16 16
FROM dsm_api a
17 17
	LEFT OUTER JOIN dsm_datasources ds ON (a.datasource = ds.id)
......
24 24
	OR ds.namespaceprefix ILIKE :value
25 25
	OR ds.websiteurl      ILIKE :value
26 26
	OR a.baseurl          ILIKE :value
27
	OR o.organization     ILIKE :value
27
	OR o.legalname        ILIKE :value
28 28
GROUP BY
29 29
	a.id,
30 30
	a.protocol,
modules/dnet-openaire-datasource-manager/trunk/src/main/resources/eu/dnetlib/enabling/datasources/queries/searchApisUsingField.sql
4 4
	coalesce(a.compatibility_override, a.compatibility)                      AS "compliance",
5 5
	a.active                                                                 AS "active",
6 6
	a.baseurl                                                                AS "baseUrl",
7
	a.typology                                                               AS "type",
7 8
	coalesce(a.last_aggregation_date::text, a.last_download_date::text, '')  AS "aggrDate",
8 9
	coalesce(a.last_aggregation_total, a.last_download_total, 0)             AS "aggrTotal",
9 10
	ds.id                                                                    AS "dsId",
......
11 12
	ds.englishname                                                           AS "alternativeName",
12 13
	ds.namespaceprefix                                                       AS "prefix",
13 14
	ds.websiteurl                                                            AS "websiteUrl",
14
	(array_agg(o.country))[1]                                                AS "country",
15
	coalesce((array_agg(o.country))[1], '-')                                 AS "country",
15 16
    (array_agg(o.legalname))[1]                                              AS "organization"
16 17
FROM dsm_api a
17 18
	LEFT OUTER JOIN dsm_datasources ds ON (a.datasource = ds.id)
......
32 33
	ds.englishname,
33 34
	ds.namespaceprefix,
34 35
	ds.websiteurl
35
) AS t WHERE :field = :value
36

  
37

  
36
) AS t WHERE

Also available in: Unified diff