1
0
Fork 0
This commit is contained in:
Miriam Baglioni 2020-08-13 12:08:24 +02:00
parent 69bbb9592a
commit 90b54d3efb
1 changed files with 44 additions and 49 deletions

View File

@ -1,8 +1,3 @@
/**
* Dumps of entities in the model defined in eu.dnetlib.dhp.schema.dump.oaf.graph.
* Results are dumped using the same Mapper as for eu.dnetlib.dhp.schema.dump.oaf.community, while for
* the other entities the mapping is defined below
*/
package eu.dnetlib.dhp.oa.graph.dump.graph;
@ -31,6 +26,10 @@ import eu.dnetlib.dhp.schema.oaf.Field;
import eu.dnetlib.dhp.schema.oaf.Journal;
import eu.dnetlib.dhp.schema.oaf.OafEntity;
/**
* Dumps of entities in the model defined in eu.dnetlib.dhp.schema.dump.oaf.graph. Results are dumped using the same
* Mapper as for eu.dnetlib.dhp.schema.dump.oaf.community, while for the other entities the mapping is defined below
*/
public class DumpGraphEntities implements Serializable {
public void run(Boolean isSparkSessionManaged,
@ -285,7 +284,7 @@ public class DumpGraphEntities implements Serializable {
return c;
}
private static Project mapProject(eu.dnetlib.dhp.schema.oaf.Project p) {
private static Project mapProject(eu.dnetlib.dhp.schema.oaf.Project p) throws DocumentException {
Project project = new Project();
Optional
@ -383,24 +382,24 @@ public class DumpGraphEntities implements Serializable {
.collect(Collectors.toList()))
.orElse(new ArrayList<>()));
project
.setFunding(
Optional
.ofNullable(p.getFundingtree())
.map(
value -> value
.stream()
.map(fundingtree -> getFunder(fundingtree.getValue()))
.collect(Collectors.toList()))
.orElse(new ArrayList<>()));
Optional<List<Field<String>>> ofundTree = Optional
.ofNullable(p.getFundingtree());
List<Funder> funList = new ArrayList<>();
if (ofundTree.isPresent()) {
for (Field<String> fundingtree : ofundTree.get()) {
funList.add(getFunder(fundingtree.getValue()));
}
}
project.setFunding(funList);
return project;
}
public static Funder getFunder(String fundingtree) {
public static Funder getFunder(String fundingtree) throws DocumentException {
Funder f = new Funder();
final Document doc;
try {
doc = new SAXReader().read(new StringReader(fundingtree));
f.setShortName(((org.dom4j.Node) (doc.selectNodes("//funder/shortname").get(0))).getText());
f.setName(((org.dom4j.Node) (doc.selectNodes("//funder/name").get(0))).getText());
@ -435,10 +434,6 @@ public class DumpGraphEntities implements Serializable {
}
return f;
} catch (DocumentException e) {
e.printStackTrace();
}
return f;
}