Project

General

Profile

« Previous | Next » 

Revision 43189

Added DatasourceManager Core with backend Postgres

View differences:

CMRCollectorPlugin.java
1 1
package eu.dnetlib.wds.collector.plugins;
2 2

  
3
import java.io.IOException;
4

  
5
import eu.dnetlib.enabling.tools.DnetStreamSupport;
3 6
import eu.dnetlib.rmi.data.CollectorServiceException;
4 7
import eu.dnetlib.rmi.data.InterfaceDescriptor;
5 8
import eu.dnetlib.rmi.data.plugin.AbstractCollectorPlugin;
9
import org.antlr.stringtemplate.StringTemplate;
10
import org.apache.commons.io.IOUtils;
11
import org.springframework.beans.factory.annotation.Required;
12
import org.springframework.core.io.ClassPathResource;
6 13

  
7 14
/**
8 15
 * Created by sandro on 5/27/16.
9 16
 */
10 17
public class CMRCollectorPlugin extends AbstractCollectorPlugin {
11 18

  
19
	private StringTemplate xmlTemplate;
20

  
21
	private ClassPathResource classPathTemplate;
22

  
23

  
24

  
12 25
	@Override
13 26
	public Iterable<String> collect(final InterfaceDescriptor interfaceDescriptor, final String fromDate, final String untilDate)
14 27
			throws CollectorServiceException {
15
		return () -> new CMRIterator();
28

  
29
		try {
30
			xmlTemplate = new StringTemplate(IOUtils.toString(classPathTemplate.getInputStream()));
31
		} catch (IOException e) {
32
			throw new CollectorServiceException("Error on open resource ", e);
33
		}
34

  
35
		return () -> DnetStreamSupport.generateStreamFromIterator(new CMRIterator())
36
				.map(it -> {
37
					xmlTemplate.setAttribute("object", it);
38
					return xmlTemplate.toString();
39
				}).iterator();
40

  
16 41
	}
42

  
43
	public ClassPathResource getClassPathTemplate() {
44
		return classPathTemplate;
45
	}
46

  
47
	@Required
48
	public void setClassPathTemplate(final ClassPathResource classPathTemplate) {
49
		this.classPathTemplate = classPathTemplate;
50
	}
17 51
}

Also available in: Unified diff