Project

General

Profile

« Previous | Next » 

Revision 52220

introduced xquery to read all type of context profiles and expose them via the Context API

View differences:

modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/OpenaireExporterConfig.java
23 23
	private ClassPathResource findObjectStore;
24 24
	private ClassPathResource findFunderContexts;
25 25
	private ClassPathResource findCommunityContexts;
26
	private ClassPathResource findContextProfiles;
26 27
	private ClassPathResource getRepoProfile;
27 28

  
28 29
	@Value("${openaire.exporter.oaf2HBaseWfId}")
......
372 373
		return findCommunityContexts;
373 374
	}
374 375

  
376
	public ClassPathResource getFindContextProfiles() {
377
		return findContextProfiles;
378
	}
379

  
380
	public void setFindContextProfiles(final ClassPathResource findContextProfiles) {
381
		this.findContextProfiles = findContextProfiles;
382
	}
383

  
375 384
	public void setFindCommunityContexts(final ClassPathResource findCommunityContexts) {
376 385
		this.findCommunityContexts = findCommunityContexts;
377 386
	}
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/context/ContextApiCore.java
86 86

  
87 87
	private Map<String, Context> getContextMap() throws ContextException {
88 88
		try {
89
			return isClient.getCommunityContextMap();
89
			return isClient.getContextMap();
90 90
		} catch (IOException e) {
91 91
			throw new ContextException(e);
92 92
		}
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/common/ISClient.java
21 21

  
22 22
	Map<String, Context> getCommunityContextMap() throws IOException;
23 23

  
24
	Map<String, Context> getContextMap() throws IOException;
25

  
24 26
	void updateContextParam(String id, String name, String value);
25 27

  
26 28
	void updateContextAttribute(String id, String name, String value);
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/common/ISClientImpl.java
90 90
	@Override
91 91
	@Cacheable("context-cache")
92 92
	public Map<String, Context> getFunderContextMap() throws IOException {
93
		return _processContext(
94
				new LinkedBlockingQueue<>(),
95
				_getQuery(config.getFindFunderContexts()));
93
		return _processContext(_getQuery(config.getFindFunderContexts()));
96 94
	}
97 95

  
98 96
	@Override
99 97
	@Cacheable("context-cache")
100 98
	public Map<String, Context> getCommunityContextMap() throws IOException {
101
		return _processContext(
102
				new LinkedBlockingQueue<>(),
103
				_getQuery(config.getFindCommunityContexts()));
99
		return _processContext(_getQuery(config.getFindCommunityContexts()));
104 100
	}
105 101

  
106 102
	@Override
103
	@Cacheable("context-cache")
104
	public Map<String, Context> getContextMap() throws IOException {
105
		return _processContext(_getQuery(config.getFindContextProfiles()));
106
	}
107

  
108
	@Override
107 109
	@CacheEvict(value = "context-cache", allEntries = true)
108 110
	public void updateContextParam(final String id, final String name, final String value) {
109 111
		final Queue<Throwable> errors = Lists.newLinkedList();
......
308 310
		}
309 311
	}
310 312

  
313
	private Map<String, Context> _processContext(final String xquery) throws IOException {
314
		return _processContext(new LinkedBlockingQueue<>(), xquery);
315
	}
316

  
311 317
	private Map<String, Context> _processContext(final Queue<Throwable> errors, final String xquery) throws IOException {
312 318
		try {
313 319
			return getContextProfiles(errors, xquery).stream()
......
315 321
					.map(s -> ContextMappingUtils.parseContext(s, errors))
316 322
					.collect(Collectors.toMap(
317 323
							Context::getId,
318
							Function.identity()));
324
							Function.identity(),
325
							(c1, c2) -> {
326
								log.warn(String.format("found duplicate context profile '%s'", c1.getId()));
327
								return c1;
328
							}));
319 329
		} finally {
320 330
			if (!errors.isEmpty()) {
321 331
				log.error(errors);
modules/dnet-openaire-exporter/trunk/src/main/resources/eu/dnetlib/openaire/xquery/findContextProfiles.xquery
1
for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')
2
return $x
modules/dnet-openaire-exporter/trunk/src/main/resources/global.properties
41 41
openaire.exporter.findObjectStore           =   /eu/dnetlib/openaire/xquery/findObjectStore.xquery
42 42
openaire.exporter.findFunderContexts        =   /eu/dnetlib/openaire/xquery/findFunderContexts.xquery
43 43
openaire.exporter.findCommunityContexts     =   /eu/dnetlib/openaire/xquery/findCommunityContexts.xquery
44
openaire.exporter.findContextProfiles       =   /eu/dnetlib/openaire/xquery/findContextProfiles.xquery
44 45
openaire.exporter.getRepoProfile            =   /eu/dnetlib/openaire/xquery/getRepoProfile.xquery
45 46

  
46 47
openaire.exporter.oaf2HBaseWfId             =   c7d7d775-2db3-474d-85ab-5173a582d515_V29ya2Zsb3dEU1Jlc291cmNlcy9Xb3JrZmxvd0RTUmVzb3VyY2VUeXBl

Also available in: Unified diff