Project

General

Profile

1
package eu.dnetlib.msro.openaireplus.workflows.nodes.index;
2

    
3
import java.util.List;
4

    
5
import javax.annotation.Resource;
6

    
7
import org.apache.commons.logging.Log;
8
import org.apache.commons.logging.LogFactory;
9
import org.springframework.beans.factory.annotation.Required;
10

    
11
import com.google.common.collect.Iterables;
12

    
13
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
14
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
15
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
16

    
17
public class EntityGrouperConfigurationLoader {
18

    
19
	/**
20
	 * logger.
21
	 */
22
	private static final Log log = LogFactory.getLog(EntityGrouperConfigurationLoader.class); // NOPMD by marko on 11/24/08 5:02 PM
23

    
24
	private String xquery;
25

    
26
	@Resource
27
	private UniqueServiceLocator serviceLocator;
28

    
29
	public String load() throws ISLookUpException {
30

    
31
		log.info("loading EntityGrouperConfigurationDSResourceType: " + getXquery());
32

    
33
		List<String> conf = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(getXquery());
34
		if (conf == null || conf.isEmpty()) { throw new IllegalStateException("unable to read entity grouper configuration profile"); }
35
		if (conf.size() > 1) { throw new IllegalStateException("found more than one EntityGrouperConfigurationDSResourceType"); }
36

    
37
		return Iterables.getOnlyElement(conf).replaceAll("\\s+", " ").trim();
38
	}
39

    
40
	public String getXquery() {
41
		return xquery;
42
	}
43

    
44
	@Required
45
	public void setXquery(final String xquery) {
46
		this.xquery = xquery;
47
	}
48

    
49
}
(2-2/6)