Project

General

Profile

1
package eu.dnetlib.msro.workers.aggregation.collect.plugins.filesfrommetadata;
2

    
3
import java.util.ArrayList;
4
import java.util.List;
5
import java.util.Map;
6
import java.util.stream.Collectors;
7

    
8
import org.apache.commons.logging.Log;
9
import org.apache.commons.logging.LogFactory;
10
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.beans.factory.annotation.Value;
12

    
13
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
14
import eu.dnetlib.rmi.data.ProtocolParameterValue;
15
import eu.dnetlib.rmi.data.functions.ParamValuesFunction;
16
import eu.dnetlib.rmi.enabling.ISLookUpException;
17
import eu.dnetlib.rmi.enabling.ISLookUpService;
18

    
19
/**
20
 * Created by alessia on 17/12/15.
21
 */
22
// @Component
23
public class PopulateFileDownloadBasePath implements ParamValuesFunction {
24

    
25
	private static final Log log = LogFactory.getLog(PopulateFileDownloadBasePath.class);
26
	@Autowired
27
	private UniqueServiceLocator serviceLocator;
28

    
29
	@Value("${services.objectstore.basePathList.xquery}")
30
	private String xQueryForObjectStoreBasePath;
31

    
32
	@Override
33
	public List<ProtocolParameterValue> findValues(final String s, final Map<String, String> map) {
34
		try {
35
			return serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xQueryForObjectStoreBasePath)
36
					.stream()
37
					.map(it -> new ProtocolParameterValue(it, it))
38
					.collect(Collectors.toList());
39
		} catch (final ISLookUpException e) {
40
			log.error("Cannot read Object store service properties", e);
41
		}
42
		return new ArrayList<>();
43
	}
44

    
45
	public UniqueServiceLocator getServiceLocator() {
46
		return serviceLocator;
47
	}
48

    
49
	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
50
		this.serviceLocator = serviceLocator;
51
	}
52

    
53
	public String getxQueryForObjectStoreBasePath() {
54
		return xQueryForObjectStoreBasePath;
55
	}
56

    
57
	public void setxQueryForObjectStoreBasePath(final String xQueryForObjectStoreBasePath) {
58
		this.xQueryForObjectStoreBasePath = xQueryForObjectStoreBasePath;
59
	}
60
}
(2-2/2)