Project

General

Profile

« Previous | Next » 

Revision 50284

repo UI fixing

View differences:

modules/dnet-openaire-datasource-manager/trunk/src/main/java/eu/dnetlib/enabling/datasources/LocalOpenaireDatasourceManager.java
5 5
import java.util.HashMap;
6 6
import java.util.List;
7 7
import java.util.Map;
8
import java.util.Objects;
8
import java.util.Optional;
9 9
import java.util.stream.Collectors;
10 10

  
11 11
import org.apache.commons.lang.StringUtils;
......
238 238

  
239 239
	@Override
240 240
	public List<BrowseTerm> browseField(final String field) throws DsmException {
241
		return getBrowsableFields()
241
		final Optional<DbBrowsableField> bf = getBrowsableFields()
242 242
				.stream()
243 243
				.filter(f -> f.getId().equals(field))
244
				.map(f -> {
245
					try {
246
						return datasourceManagerClients.searchSQL(f.getSql(), new HashMap<>());
247
					} catch (final DsmException e) {
248
						return null;
249
					}
250
				})
251
				.filter(Objects::nonNull)
252
				.flatMap(List::stream)
253
				.map(m -> new BrowseTermImpl(
254
						m.get("term").toString(),
255
						NumberUtils.toInt(m.get("count").toString())))
256
				.collect(Collectors.toList());
244
				.findFirst();
245

  
246
		if (bf.isPresent()) {
247
			return datasourceManagerClients.searchSQL(bf.get().getSql(), new HashMap<>())
248
					.stream()
249
					.filter(m -> m.get("term") != null)
250
					.filter(m -> m.get("count") != null)
251
					.filter(m -> StringUtils.isNotBlank(m.get("term").toString()))
252
					.map(m -> new BrowseTermImpl(m.get("term").toString(), NumberUtils.toInt(m.get("count").toString(), 0)))
253
					.collect(Collectors.toList());
254
		} else {
255
			log.error("Not browsable field:" + field);
256
			throw new DsmException("Not browsable field:" + field);
257
		}
257 258
	}
258 259

  
259 260
	@Override
modules/dnet-openaire-datasource-manager/trunk/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-dnet-openaire-datasource-manager.properties
1 1
dnet.openaire.db.url      = jdbc:postgresql://localhost:5432/dnet_openaire
2
dnet.openaire.db.username =
2
dnet.openaire.db.username = dnet
3 3
dnet.openaire.db.password =
modules/dnet-modular-repositories-ui/branches/dsm/src/main/resources/eu/dnetlib/web/resources/js/repoControllers.js
14 14
				enableCellEditOnFocus: false,
15 15
				enableHighlighting: true,
16 16
				filterOptions: $scope.filterBrowseData,
17
				sortInfo: { fields: ['value'], directions: ['desc'] },
17
				sortInfo: { fields: ['term'], directions: ['desc'] },
18 18
				columnDefs: [
19
				             {field: 'name', displayName: 'Name', cellTemplate: '<div class="ngCellText"><a href="javascript:void(0)" ng-click="browseApis(repoBrowseData.id, row.getProperty(\'id\'))">{{row.getProperty(col.field)}}</a></div>' },
20
				             {field: 'value', displayName: '# datasources', width: '20%', headerClass: 'text-right', cellClass: 'text-right' }
19
				             {field: 'term', displayName: 'Name', cellTemplate: '<div class="ngCellText"><a href="javascript:void(0)" ng-click="browseApis(repoBrowseData.id, row.getProperty(\'term\'))">{{row.getProperty(col.field)}}</a></div>' },
20
				             {field: 'total', displayName: '# datasources', width: '20%', headerClass: 'text-right', cellClass: 'text-right' }
21 21
				             ]
22 22
		};
23 23
		

Also available in: Unified diff