forked from D-Net/dnet-hadoop
fixed NPE
This commit is contained in:
parent
a1a6fc8315
commit
071f5c3e52
|
@ -32,8 +32,8 @@ public class Scholix implements Serializable {
|
|||
ScholixSummary scholixSummary = mapper.readValue(sourceSummaryJson, ScholixSummary.class);
|
||||
Relation rel = mapper.readValue(relation, Relation.class);
|
||||
final Scholix s = new Scholix();
|
||||
if (scholixSummary.getDate() != null)
|
||||
s.setPublicationDate(scholixSummary.getDate().stream().findAny().orElse(null));
|
||||
if (scholixSummary.getDate() != null && scholixSummary.getDate().size()>0)
|
||||
s.setPublicationDate(scholixSummary.getDate().get(0));
|
||||
s.setLinkprovider(rel.getCollectedFrom().stream().map(cf ->
|
||||
new ScholixEntityId(cf.getValue(), Collections.singletonList(
|
||||
new ScholixIdentifier(cf.getKey(), "dnet_identifier")
|
||||
|
|
|
@ -35,8 +35,8 @@ public class ScholixResource implements Serializable {
|
|||
resource.setObjectType(summary.getTypology().toString());
|
||||
|
||||
|
||||
if (summary.getTitle() != null)
|
||||
resource.setTitle(summary.getTitle().stream().findAny().orElse(null));
|
||||
if (summary.getTitle() != null && summary.getTitle().size()>0)
|
||||
resource.setTitle(summary.getTitle().get(0));
|
||||
|
||||
if (summary.getAuthor() != null)
|
||||
resource.setCreator(summary.getAuthor().stream()
|
||||
|
@ -44,8 +44,8 @@ public class ScholixResource implements Serializable {
|
|||
.collect(Collectors.toList())
|
||||
);
|
||||
|
||||
if (summary.getDate() != null)
|
||||
resource.setPublicationDate(summary.getDate().stream().findAny().orElse(null));
|
||||
if (summary.getDate() != null && summary.getDate().size()>0)
|
||||
resource.setPublicationDate(summary.getDate().get(0));
|
||||
if (summary.getPublisher() != null)
|
||||
resource.setPublisher(summary.getPublisher().stream()
|
||||
.map(p -> new ScholixEntityId(p, null))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.dnetlib.dhp.provision;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.dhp.provision.scholix.Scholix;
|
||||
import eu.dnetlib.dhp.provision.scholix.summary.ScholixSummary;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Ignore;
|
||||
|
@ -31,6 +32,17 @@ public class ExtractInfoTest {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testScholix() throws Exception {
|
||||
final String jsonSummary = IOUtils.toString(getClass().getResourceAsStream("summary.json"));
|
||||
final String jsonRelation = IOUtils.toString(getClass().getResourceAsStream("relation.json"));
|
||||
|
||||
Scholix.generateScholixWithSource(jsonSummary, jsonRelation);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testIndex() throws Exception {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{"dataInfo":{"invisible":false,"inferred":null,"deletedbyinference":false,"trust":"0.9","inferenceprovenance":null,"provenanceaction":null},"lastupdatetimestamp":null,"relType":"cites","subRelType":null,"relClass":"datacite","source":"50|4916f842ad1567aed2ec220001081d22","target":"60|829a8bf6b014d9bab2d24e42ed395723","collectedFrom":[{"key":"dli_________::r3d100010255","value":"ICPSR","dataInfo":null}]}
|
|
@ -0,0 +1 @@
|
|||
{"id":"50|4916f842ad1567aed2ec220001081d22","localIdentifier":[{"id":"43379","type":"ICPSR"}],"typology":"publication","title":["Racial differences in patterns of wealth accumulation"],"author":["Gittleman, Maury","Wolff, Edward, N."],"date":[null],"subject":[],"publisher":null,"relatedPublications":0,"relatedDatasets":1,"relatedUnknown":0,"datasources":[{"datasourceName":"ICPSR","datasourceId":"dli_________::r3d100010255","completionStatus":"complete"}],"abstract":null}
|
Loading…
Reference in New Issue