Revision 50143
Added by Claudio Atzori over 6 years ago
MappingUtils.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.StringReader; |
4 | 4 |
import java.util.List; |
5 |
import java.util.Map; |
|
5 | 6 |
import java.util.Queue; |
6 | 7 |
import java.util.stream.Collectors; |
7 | 8 |
|
8 | 9 |
import com.google.common.collect.Lists; |
10 |
import eu.dnetlib.openaire.exporter.funders.model.ExtendedFunderDetails; |
|
9 | 11 |
import eu.dnetlib.openaire.exporter.funders.model.FunderDetails; |
10 | 12 |
import eu.dnetlib.openaire.exporter.funders.model.FundingStream; |
11 | 13 |
import org.apache.commons.lang3.BooleanUtils; |
... | ... | |
54 | 56 |
|
55 | 57 |
private static List<Concept> parseConcepts(final Element eCategory) { |
56 | 58 |
final List<Element> eConcepts = (List<Element>) eCategory.selectNodes("./concept"); |
57 |
|
|
58 |
//TODO check stop condition |
|
59 | 59 |
return eConcepts.stream() |
60 | 60 |
.map(eCon -> new Concept() |
61 | 61 |
.setClaim(BooleanUtils.toBooleanObject(eCon.attributeValue("claim"))) |
... | ... | |
80 | 80 |
return new FunderDetails() |
81 | 81 |
.setId(c.getId()) |
82 | 82 |
.setName(c.getLabel()) |
83 |
.setShortname(c.getId()) |
|
83 |
.setShortname(c.getId()); |
|
84 |
} |
|
85 |
|
|
86 |
public static ExtendedFunderDetails asExtendedFunderDetails(final Context c) { |
|
87 |
final Map<String, String> pMap = hashByParamName(c.getParams()); |
|
88 |
final ExtendedFunderDetails details = new ExtendedFunderDetails() |
|
84 | 89 |
.setFundingStreams(asFundingStreams(c.getCategories())); |
90 |
details.setId(c.getId()); |
|
91 |
details.setName(c.getLabel()); |
|
92 |
details.setShortname(c.getId()); |
|
93 |
details.setJurisdiction(pMap.get("jurisdiction")); |
|
94 |
details.setFundrefId(pMap.get("fundrefId")); |
|
95 |
details.setCollectedFromId(pMap.get("collectedFromId")); |
|
96 |
details.setCollectedFromName(pMap.get("collectedFromName")); |
|
97 |
|
|
98 |
return details; |
|
85 | 99 |
} |
86 | 100 |
|
101 |
private static Map<String, String> hashByParamName(final List<Param> params) { |
|
102 |
return params.stream() |
|
103 |
.collect(Collectors.toMap( |
|
104 |
Param::getName, |
|
105 |
Param::getValue |
|
106 |
)); |
|
107 |
} |
|
108 |
|
|
87 | 109 |
private static List<FundingStream> asFundingStreams(final List<? extends Object> list) { |
88 | 110 |
final List<FundingStream> fundingStreams = Lists.newArrayList(); |
89 | 111 |
if (list != null && !list.isEmpty()) { |
Also available in: Unified diff
huge update: swagger documentation, alignment of methods with the service trunk