Project

General

Profile

« Previous | Next » 

Revision 57474

fix a problem with scholexplorer

View differences:

EnrichDatasetsPlugin.java
16 16

  
17 17
import eu.dnetlib.data.mdstore.plugins.objects.Dataset;
18 18
import eu.dnetlib.data.mdstore.plugins.objects.MdRecord;
19
import eu.dnetlib.data.mdstore.plugins.objects.dli.DliEntity;
19 20
import eu.dnetlib.data.mdstore.plugins.objects.dli.DliIdentifier;
20 21
import eu.dnetlib.data.mdstore.plugins.objects.dli.DliRelation;
21 22

  
......
56 57
		final List<DliRelation> rels = gson.fromJson(response, new TypeToken<List<DliRelation>>() {}.getType());
57 58

  
58 59
		for (final DliRelation rel : rels) {
59
			final String title = rel.getTarget().getTitle();
60
			for (final DliIdentifier id : rel.getTarget().getIdentifiers()) {
61
				if (id.getSchema().equalsIgnoreCase("doi") && StringUtils.isNoneBlank(id.getIdentifier()) && StringUtils.isNotBlank(title)) {
62
					datasets.add(new Dataset(id.getIdentifier(), title));
63
				}
64
			}
60
			datasets.addAll(findRelatedDatasets(rel.getSource()));
61
			datasets.addAll(findRelatedDatasets(rel.getTarget()));
65 62
		}
66 63

  
67 64
		if (datasets.isEmpty()) {
......
73 70
		}
74 71
	}
75 72

  
73
	private List<Dataset> findRelatedDatasets(final DliEntity entity) {
74
		final List<Dataset> res = new ArrayList<>();
75
		if (entity.getObjectType().equalsIgnoreCase("dataset")) {
76
			final String title = entity.getTitle();
77
			for (final DliIdentifier id : entity.getIdentifiers()) {
78
				if (id.getSchema().equalsIgnoreCase("doi") && StringUtils.isNoneBlank(id.getIdentifier()) && StringUtils.isNotBlank(title)) {
79
					res.add(new Dataset(id.getIdentifier(), title));
80
				}
81
			}
82
		}
83
		return res;
84
	}
85

  
76 86
}

Also available in: Unified diff