Project

General

Profile

1 26600 sandro.lab
package eu.dnetlib.msro.openaireplus.workflows.nodes.index;
2
3
import java.util.List;
4
import javax.annotation.Resource;
5
6
import com.google.common.collect.Iterables;
7
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
8
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
9 32798 michele.ar
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
10 48139 alessia.ba
import org.apache.commons.logging.Log;
11
import org.apache.commons.logging.LogFactory;
12
import org.springframework.beans.factory.annotation.Required;
13 26600 sandro.lab
14
public class EntityGrouperConfigurationLoader {
15
16
	/**
17
	 * logger.
18
	 */
19
	private static final Log log = LogFactory.getLog(EntityGrouperConfigurationLoader.class); // NOPMD by marko on 11/24/08 5:02 PM
20
21
	private String xquery;
22
23 32798 michele.ar
	@Resource
24
	private UniqueServiceLocator serviceLocator;
25 26600 sandro.lab
26
	public String load() throws ISLookUpException {
27
28
		log.info("loading EntityGrouperConfigurationDSResourceType: " + getXquery());
29
30 32798 michele.ar
		List<String> conf = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(getXquery());
31 26600 sandro.lab
		if (conf == null || conf.isEmpty()) { throw new IllegalStateException("unable to read entity grouper configuration profile"); }
32
		if (conf.size() > 1) { throw new IllegalStateException("found more than one EntityGrouperConfigurationDSResourceType"); }
33
34
		return Iterables.getOnlyElement(conf).replaceAll("\\s+", " ").trim();
35
	}
36
37
	public String getXquery() {
38
		return xquery;
39
	}
40
41
	@Required
42
	public void setXquery(final String xquery) {
43
		this.xquery = xquery;
44
	}
45
46
}