Project

General

Profile

« Previous | Next » 

Revision 58672

ensure we have the proper identifiers in the list of original source and target objects. They may, as it used to be, contain also representative identifiers. Asking for them should be enough to completely blacklist a relationship

View differences:

OpenaireIdResolver.java
2 2

  
3 3
import java.io.StringReader;
4 4
import java.util.List;
5
import java.util.Set;
5 6

  
6 7
import com.google.common.base.Function;
7 8
import com.google.common.collect.Iterables;
8 9
import com.google.common.collect.Lists;
10
import com.google.common.collect.Sets;
9 11
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
10 12
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
11 13
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
......
40 42
	@Autowired
41 43
	private SolrIndexClientFactory indexClientFactory;
42 44

  
43
	public List<String> resolveIdentifier(final String id) {
44
		if (StringUtils.isBlank(id)) return Lists.newArrayList();
45
	public Set<String> resolveIdentifier(final String id) {
46
		if (StringUtils.isBlank(id)) return  Sets.newHashSet();
45 47
		else {
46 48
			return findOriginalIds(id);
47 49
		}
48 50
	}
49 51

  
50
	protected List<String> findOriginalIds(final String id) {
52
	protected Set<String> findOriginalIds(final String id) {
51 53
		try(final SolrIndexClient client = (SolrIndexClient) indexClientFactory.getClient(getPublicIndexCollection()+SOLR_COLLECTION_POSTFIX)) {
52 54

  
53 55
			final String query = String.format("objidentifier:\"%s\"", id);
......
55 57
			final SolrDocumentList results = response.getResults();
56 58
			if (results.isEmpty()) {
57 59
				log.debug("Query " + query + " returned 0 documents");
58
				return Lists.newArrayList();
60
				return Sets.newHashSet();
59 61
			}
60 62
			// my results contain the document with the given identifier
61 63
			final SolrDocument solrDoc = results.get(0);
......
67 69
	}
68 70

  
69 71
	@SuppressWarnings("unchecked")
70
	protected List<String> extractMergedIdentifiers(final SolrDocument doc) throws DocumentException {
72
	protected Set<String> extractMergedIdentifiers(final SolrDocument doc) throws DocumentException {
71 73
		final String xmlRecord = (String) doc.getFirstValue(RESULT_FIELD);
72 74
		final Document xmlDoc = this.saxReader.read(new StringReader(xmlRecord));
73
		return Lists.newArrayList(Iterables.transform(xmlDoc.selectNodes(XPATH_TO_MERGED), (Function<Attribute, String>) a -> a.getStringValue()));
75
		return Sets.newHashSet(Iterables.transform(xmlDoc.selectNodes(XPATH_TO_MERGED), (Function<Attribute, String>) a -> a.getStringValue()));
74 76
	}
75 77

  
76 78
	protected String getIndexEndpoint() throws ISLookUpException {

Also available in: Unified diff