forked from D-Net/dnet-hadoop
[graph provision] person serialisation
This commit is contained in:
parent
23e0ab3a7c
commit
5f86c93be6
|
@ -231,6 +231,14 @@ public class CreateRelatedEntitiesJob_phase1 {
|
||||||
if (!f.isEmpty()) {
|
if (!f.isEmpty()) {
|
||||||
re.setFundingtree(f.stream().map(Field::getValue).collect(Collectors.toList()));
|
re.setFundingtree(f.stream().map(Field::getValue).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case person:
|
||||||
|
final Person person = (Person) entity;
|
||||||
|
|
||||||
|
re.setGivenName(person.getGivenName());
|
||||||
|
re.setFamilyName(person.getFamilyName());
|
||||||
|
re.setAlternativeNames(person.getAlternativeNames());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return re;
|
return re;
|
||||||
|
|
|
@ -5,7 +5,6 @@ import java.io.StringReader;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import eu.dnetlib.dhp.schema.solr.Person;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dom4j.Document;
|
import org.dom4j.Document;
|
||||||
import org.dom4j.DocumentException;
|
import org.dom4j.DocumentException;
|
||||||
|
@ -38,6 +37,8 @@ import eu.dnetlib.dhp.schema.solr.Measure;
|
||||||
import eu.dnetlib.dhp.schema.solr.OpenAccessColor;
|
import eu.dnetlib.dhp.schema.solr.OpenAccessColor;
|
||||||
import eu.dnetlib.dhp.schema.solr.OpenAccessRoute;
|
import eu.dnetlib.dhp.schema.solr.OpenAccessRoute;
|
||||||
import eu.dnetlib.dhp.schema.solr.Organization;
|
import eu.dnetlib.dhp.schema.solr.Organization;
|
||||||
|
import eu.dnetlib.dhp.schema.solr.Person;
|
||||||
|
import eu.dnetlib.dhp.schema.solr.PersonTopic;
|
||||||
import eu.dnetlib.dhp.schema.solr.Pid;
|
import eu.dnetlib.dhp.schema.solr.Pid;
|
||||||
import eu.dnetlib.dhp.schema.solr.Project;
|
import eu.dnetlib.dhp.schema.solr.Project;
|
||||||
import eu.dnetlib.dhp.schema.solr.Result;
|
import eu.dnetlib.dhp.schema.solr.Result;
|
||||||
|
@ -193,6 +194,10 @@ public class ProvisionModelSupport {
|
||||||
ps.setFamilyName(p.getFamilyName());
|
ps.setFamilyName(p.getFamilyName());
|
||||||
ps.setGivenName(p.getGivenName());
|
ps.setGivenName(p.getGivenName());
|
||||||
ps.setAlternativeNames(p.getAlternativeNames());
|
ps.setAlternativeNames(p.getAlternativeNames());
|
||||||
|
ps.setBiography(p.getBiography());
|
||||||
|
ps.setConsent(p.getConsent());
|
||||||
|
// ps.setSubject(...));
|
||||||
|
|
||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,11 @@ public class RelatedEntity implements Serializable {
|
||||||
private Qualifier contracttype;
|
private Qualifier contracttype;
|
||||||
private List<String> fundingtree;
|
private List<String> fundingtree;
|
||||||
|
|
||||||
|
// person
|
||||||
|
private String givenName;
|
||||||
|
private String familyName;
|
||||||
|
private List<String> alternativeNames;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -251,6 +256,30 @@ public class RelatedEntity implements Serializable {
|
||||||
this.fundingtree = fundingtree;
|
this.fundingtree = fundingtree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getGivenName() {
|
||||||
|
return givenName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGivenName(String givenName) {
|
||||||
|
this.givenName = givenName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFamilyName() {
|
||||||
|
return familyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFamilyName(String familyName) {
|
||||||
|
this.familyName = familyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getAlternativeNames() {
|
||||||
|
return alternativeNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlternativeNames(List<String> alternativeNames) {
|
||||||
|
this.alternativeNames = alternativeNames;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o)
|
if (this == o)
|
||||||
|
@ -280,7 +309,10 @@ public class RelatedEntity implements Serializable {
|
||||||
&& Objects.equal(code, that.code)
|
&& Objects.equal(code, that.code)
|
||||||
&& Objects.equal(acronym, that.acronym)
|
&& Objects.equal(acronym, that.acronym)
|
||||||
&& Objects.equal(contracttype, that.contracttype)
|
&& Objects.equal(contracttype, that.contracttype)
|
||||||
&& Objects.equal(fundingtree, that.fundingtree);
|
&& Objects.equal(fundingtree, that.fundingtree)
|
||||||
|
&& Objects.equal(givenName, that.givenName)
|
||||||
|
&& Objects.equal(familyName, that.familyName)
|
||||||
|
&& Objects.equal(alternativeNames, that.alternativeNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -309,6 +341,9 @@ public class RelatedEntity implements Serializable {
|
||||||
code,
|
code,
|
||||||
acronym,
|
acronym,
|
||||||
contracttype,
|
contracttype,
|
||||||
fundingtree);
|
fundingtree,
|
||||||
|
familyName,
|
||||||
|
givenName,
|
||||||
|
alternativeNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import javax.xml.transform.*;
|
||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
import eu.dnetlib.dhp.oa.provision.model.*;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
@ -42,6 +41,7 @@ import com.google.common.collect.Sets;
|
||||||
import com.mycila.xmltool.XMLDoc;
|
import com.mycila.xmltool.XMLDoc;
|
||||||
import com.mycila.xmltool.XMLTag;
|
import com.mycila.xmltool.XMLTag;
|
||||||
|
|
||||||
|
import eu.dnetlib.dhp.oa.provision.model.*;
|
||||||
import eu.dnetlib.dhp.schema.common.*;
|
import eu.dnetlib.dhp.schema.common.*;
|
||||||
import eu.dnetlib.dhp.schema.oaf.*;
|
import eu.dnetlib.dhp.schema.oaf.*;
|
||||||
import eu.dnetlib.dhp.schema.oaf.Result;
|
import eu.dnetlib.dhp.schema.oaf.Result;
|
||||||
|
@ -1035,6 +1035,42 @@ public class XmlRecordFactory implements Serializable {
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case person:
|
||||||
|
final Person person = (Person) entity;
|
||||||
|
|
||||||
|
if (person.getGivenName() != null) {
|
||||||
|
metadata.add(XmlSerializationUtils.asXmlElement("givenname", person.getGivenName()));
|
||||||
|
}
|
||||||
|
if (person.getFamilyName() != null) {
|
||||||
|
metadata.add(XmlSerializationUtils.asXmlElement("familyname", person.getFamilyName()));
|
||||||
|
}
|
||||||
|
if (person.getAlternativeNames() != null) {
|
||||||
|
metadata.addAll(person.getAlternativeNames());
|
||||||
|
}
|
||||||
|
if (person.getBiography() != null) {
|
||||||
|
metadata.add(XmlSerializationUtils.asXmlElement("biography", person.getBiography()));
|
||||||
|
}
|
||||||
|
if (person.getSubject() != null) {
|
||||||
|
metadata
|
||||||
|
.addAll(
|
||||||
|
person
|
||||||
|
.getSubject()
|
||||||
|
.stream()
|
||||||
|
.map(pt -> {
|
||||||
|
List<Tuple2<String, String>> attrs = Lists.newArrayList();
|
||||||
|
attrs.add(new Tuple2<>("schema", pt.getSchema()));
|
||||||
|
attrs.add(new Tuple2<>("value", pt.getValue()));
|
||||||
|
attrs.add(new Tuple2<>("fromYear", String.valueOf(pt.getFromYear())));
|
||||||
|
attrs.add(new Tuple2<>("toYear", String.valueOf(pt.getToYear())));
|
||||||
|
return XmlSerializationUtils.asXmlElement("subject", attrs);
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
if (person.getConsent() != null) {
|
||||||
|
metadata.add(XmlSerializationUtils.asXmlElement("consent", String.valueOf(person.getConsent())));
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("invalid entity type: " + type);
|
throw new IllegalArgumentException("invalid entity type: " + type);
|
||||||
|
@ -1240,6 +1276,25 @@ public class XmlRecordFactory implements Serializable {
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case person:
|
||||||
|
|
||||||
|
if (isNotBlank(re.getGivenName())) {
|
||||||
|
metadata.add(XmlSerializationUtils.asXmlElement("givenname", re.getGivenName()));
|
||||||
|
}
|
||||||
|
if (isNotBlank(re.getFamilyName())) {
|
||||||
|
metadata.add(XmlSerializationUtils.asXmlElement("familyname", re.getFamilyName()));
|
||||||
|
}
|
||||||
|
if (re.getAlternativeNames() != null && !re.getAlternativeNames().isEmpty()) {
|
||||||
|
metadata
|
||||||
|
.addAll(
|
||||||
|
re
|
||||||
|
.getAlternativeNames()
|
||||||
|
.stream()
|
||||||
|
.map(name -> XmlSerializationUtils.asXmlElement("alternativename", name))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("invalid target type: " + targetType);
|
throw new IllegalArgumentException("invalid target type: " + targetType);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue