forked from D-Net/dnet-hadoop
fixed conflict
This commit is contained in:
commit
0902bac7dd
|
@ -10,54 +10,60 @@ public class DataInfo implements Serializable {
|
||||||
private Boolean deletedbyinference;
|
private Boolean deletedbyinference;
|
||||||
private String trust;
|
private String trust;
|
||||||
private String inferenceprovenance;
|
private String inferenceprovenance;
|
||||||
private List<Qualifier> provenanceaction;
|
private Qualifier provenanceaction;
|
||||||
|
|
||||||
|
|
||||||
public Boolean getInvisible() {
|
public Boolean getInvisible() {
|
||||||
return invisible;
|
return invisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInvisible(Boolean invisible) {
|
public DataInfo setInvisible(Boolean invisible) {
|
||||||
this.invisible = invisible;
|
this.invisible = invisible;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getInferred() {
|
public Boolean getInferred() {
|
||||||
return inferred;
|
return inferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInferred(Boolean inferred) {
|
public DataInfo setInferred(Boolean inferred) {
|
||||||
this.inferred = inferred;
|
this.inferred = inferred;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getDeletedbyinference() {
|
public Boolean getDeletedbyinference() {
|
||||||
return deletedbyinference;
|
return deletedbyinference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeletedbyinference(Boolean deletedbyinference) {
|
public DataInfo setDeletedbyinference(Boolean deletedbyinference) {
|
||||||
this.deletedbyinference = deletedbyinference;
|
this.deletedbyinference = deletedbyinference;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTrust() {
|
public String getTrust() {
|
||||||
return trust;
|
return trust;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTrust(String trust) {
|
public DataInfo setTrust(String trust) {
|
||||||
this.trust = trust;
|
this.trust = trust;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInferenceprovenance() {
|
public String getInferenceprovenance() {
|
||||||
return inferenceprovenance;
|
return inferenceprovenance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInferenceprovenance(String inferenceprovenance) {
|
public DataInfo setInferenceprovenance(String inferenceprovenance) {
|
||||||
this.inferenceprovenance = inferenceprovenance;
|
this.inferenceprovenance = inferenceprovenance;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Qualifier> getProvenanceaction() {
|
public Qualifier getProvenanceaction() {
|
||||||
return provenanceaction;
|
return provenanceaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProvenanceaction(List<Qualifier> provenanceaction) {
|
public DataInfo setProvenanceaction(Qualifier provenanceaction) {
|
||||||
this.provenanceaction = provenanceaction;
|
this.provenanceaction = provenanceaction;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,23 +14,26 @@ public class KeyValue implements Serializable {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKey(String key) {
|
public KeyValue setKey(String key) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(String value) {
|
public KeyValue setValue(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataInfo getDataInfo() {
|
public DataInfo getDataInfo() {
|
||||||
return dataInfo;
|
return dataInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataInfo(DataInfo dataInfo) {
|
public KeyValue setDataInfo(DataInfo dataInfo) {
|
||||||
this.dataInfo = dataInfo;
|
this.dataInfo = dataInfo;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,39 +15,44 @@ public class Qualifier implements Serializable {
|
||||||
return classid;
|
return classid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClassid(String classid) {
|
public Qualifier setClassid(String classid) {
|
||||||
this.classid = classid;
|
this.classid = classid;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClassname() {
|
public String getClassname() {
|
||||||
return classname;
|
return classname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClassname(String classname) {
|
public Qualifier setClassname(String classname) {
|
||||||
this.classname = classname;
|
this.classname = classname;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSchemeid() {
|
public String getSchemeid() {
|
||||||
return schemeid;
|
return schemeid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSchemeid(String schemeid) {
|
public Qualifier setSchemeid(String schemeid) {
|
||||||
this.schemeid = schemeid;
|
this.schemeid = schemeid;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSchemename() {
|
public String getSchemename() {
|
||||||
return schemename;
|
return schemename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSchemename(String schemename) {
|
public Qualifier setSchemename(String schemename) {
|
||||||
this.schemename = schemename;
|
this.schemename = schemename;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataInfo getDataInfo() {
|
public DataInfo getDataInfo() {
|
||||||
return dataInfo;
|
return dataInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataInfo(DataInfo dataInfo) {
|
public Qualifier setDataInfo(DataInfo dataInfo) {
|
||||||
this.dataInfo = dataInfo;
|
this.dataInfo = dataInfo;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,47 +20,53 @@ public class Relation extends Oaf {
|
||||||
return relType;
|
return relType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRelType(String relType) {
|
public Relation setRelType(String relType) {
|
||||||
this.relType = relType;
|
this.relType = relType;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSubRelType() {
|
public String getSubRelType() {
|
||||||
return subRelType;
|
return subRelType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubRelType(String subRelType) {
|
public Relation setSubRelType(String subRelType) {
|
||||||
this.subRelType = subRelType;
|
this.subRelType = subRelType;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRelClass() {
|
public String getRelClass() {
|
||||||
return relClass;
|
return relClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRelClass(String relClass) {
|
public Relation setRelClass(String relClass) {
|
||||||
this.relClass = relClass;
|
this.relClass = relClass;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSource() {
|
public String getSource() {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSource(String source) {
|
public Relation setSource(String source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTarget() {
|
public String getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTarget(String target) {
|
public Relation setTarget(String target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<KeyValue> getCollectedFrom() {
|
public List<KeyValue> getCollectedFrom() {
|
||||||
return collectedFrom;
|
return collectedFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCollectedFrom(List<KeyValue> collectedFrom) {
|
public Relation setCollectedFrom(List<KeyValue> collectedFrom) {
|
||||||
this.collectedFrom = collectedFrom;
|
this.collectedFrom = collectedFrom;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,28 +10,30 @@ public class StructuredProperty implements Serializable {
|
||||||
|
|
||||||
private DataInfo dataInfo;
|
private DataInfo dataInfo;
|
||||||
|
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(String value) {
|
public StructuredProperty setValue(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Qualifier getQualifier() {
|
public Qualifier getQualifier() {
|
||||||
return qualifier;
|
return qualifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setQualifier(Qualifier qualifier) {
|
public StructuredProperty setQualifier(Qualifier qualifier) {
|
||||||
this.qualifier = qualifier;
|
this.qualifier = qualifier;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataInfo getDataInfo() {
|
public DataInfo getDataInfo() {
|
||||||
return dataInfo;
|
return dataInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataInfo(DataInfo dataInfo) {
|
public StructuredProperty setDataInfo(DataInfo dataInfo) {
|
||||||
this.dataInfo = dataInfo;
|
this.dataInfo = dataInfo;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package eu.dnetlib.dhp.graph;
|
package eu.dnetlib.dhp.graph;
|
||||||
|
|
||||||
|
|
||||||
import com.googlecode.protobuf.format.JsonFormat;
|
|
||||||
import eu.dnetlib.data.proto.KindProtos;
|
import eu.dnetlib.data.proto.KindProtos;
|
||||||
import eu.dnetlib.data.proto.OafProtos;
|
import eu.dnetlib.data.proto.OafProtos;
|
||||||
import eu.dnetlib.dhp.schema.oaf.*;
|
import eu.dnetlib.dhp.schema.oaf.*;
|
||||||
|
@ -9,30 +7,39 @@ import eu.dnetlib.dhp.schema.oaf.*;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static eu.dnetlib.dhp.graph.ProtoUtils.mapKV;
|
||||||
|
|
||||||
public class ProtoConverter implements Serializable {
|
public class ProtoConverter implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
public static Oaf convert(String s) {
|
public static Oaf convert(String s) {
|
||||||
try {
|
try {
|
||||||
final OafProtos.Oaf.Builder builder = OafProtos.Oaf.newBuilder();
|
OafProtos.Oaf oaf = ProtoUtils.parse(s);
|
||||||
JsonFormat.merge(s, builder);
|
|
||||||
|
|
||||||
if (builder.getKind() == KindProtos.Kind.entity)
|
if (oaf.getKind() == KindProtos.Kind.entity)
|
||||||
return convertEntity(builder);
|
return convertEntity(oaf);
|
||||||
else {
|
else {
|
||||||
return convertRelation(builder);
|
return convertRelation(oaf);
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Relation convertRelation(OafProtos.Oaf.Builder oaf) {
|
private static Relation convertRelation(OafProtos.Oaf oaf) {
|
||||||
return new Relation();
|
final Relation rel = new Relation();
|
||||||
|
final OafProtos.OafRel r = oaf.getRel();
|
||||||
|
return rel
|
||||||
|
.setSource(r.getSource())
|
||||||
|
.setTarget(r.getTarget())
|
||||||
|
.setRelType(r.getRelType().toString())
|
||||||
|
.setSubRelType(r.getSubRelType().toString())
|
||||||
|
.setRelClass(r.getRelClass())
|
||||||
|
.setCollectedFrom(r.getCollectedfromList().stream()
|
||||||
|
.map(kv -> mapKV(kv))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static OafEntity convertEntity(OafProtos.Oaf.Builder oaf) {
|
private static OafEntity convertEntity(OafProtos.Oaf oaf) {
|
||||||
|
|
||||||
switch (oaf.getEntity().getType()) {
|
switch (oaf.getEntity().getType()) {
|
||||||
case result:
|
case result:
|
||||||
|
@ -48,11 +55,12 @@ public class ProtoConverter implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Organization convertOrganization(OafProtos.Oaf.Builder oaf) {
|
private static Organization convertOrganization(OafProtos.Oaf oaf) {
|
||||||
return new Organization();
|
return new Organization();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Datasource convertDataSource(OafProtos.Oaf.Builder oaf) {
|
|
||||||
|
private static Datasource convertDataSource(OafProtos.Oaf oaf) {
|
||||||
final Datasource result = new Datasource();
|
final Datasource result = new Datasource();
|
||||||
|
|
||||||
//setting oaf field
|
//setting oaf field
|
||||||
|
@ -75,11 +83,11 @@ public class ProtoConverter implements Serializable {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Project convertProject(OafProtos.Oaf.Builder oaf) {
|
private static Project convertProject(OafProtos.Oaf oaf) {
|
||||||
return new Project();
|
return new Project();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Result convertResult(OafProtos.Oaf.Builder oaf) {
|
private static Result convertResult(OafProtos.Oaf oaf) {
|
||||||
switch (oaf.getEntity().getResult().getMetadata().getResulttype().getClassid()) {
|
switch (oaf.getEntity().getResult().getMetadata().getResulttype().getClassid()) {
|
||||||
case "dataset":
|
case "dataset":
|
||||||
return createDataset(oaf);
|
return createDataset(oaf);
|
||||||
|
@ -94,19 +102,19 @@ public class ProtoConverter implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Software createSoftware(OafProtos.Oaf.Builder oaf) {
|
private static Software createSoftware(OafProtos.Oaf oaf) {
|
||||||
return new Software();
|
return new Software();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static OtherResearchProducts createORP(OafProtos.Oaf.Builder oaf) {
|
private static OtherResearchProducts createORP(OafProtos.Oaf oaf) {
|
||||||
return new OtherResearchProducts();
|
return new OtherResearchProducts();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Publication createPublication(OafProtos.Oaf.Builder oaf) {
|
private static Publication createPublication(OafProtos.Oaf oaf) {
|
||||||
return new Publication();
|
return new Publication();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dataset createDataset(OafProtos.Oaf.Builder oaf) {
|
private static Dataset createDataset(OafProtos.Oaf oaf) {
|
||||||
return new Dataset();
|
return new Dataset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package eu.dnetlib.dhp.graph;
|
||||||
|
|
||||||
|
import com.googlecode.protobuf.format.JsonFormat;
|
||||||
|
import eu.dnetlib.data.proto.FieldTypeProtos;
|
||||||
|
import eu.dnetlib.data.proto.OafProtos;
|
||||||
|
import eu.dnetlib.dhp.schema.oaf.DataInfo;
|
||||||
|
import eu.dnetlib.dhp.schema.oaf.KeyValue;
|
||||||
|
import eu.dnetlib.dhp.schema.oaf.Qualifier;
|
||||||
|
import eu.dnetlib.dhp.schema.oaf.StructuredProperty;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ProtoUtils {
|
||||||
|
|
||||||
|
public static OafProtos.Oaf parse(String json) throws JsonFormat.ParseException {
|
||||||
|
final OafProtos.Oaf.Builder builder = OafProtos.Oaf.newBuilder();
|
||||||
|
JsonFormat.merge(json, builder);
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static KeyValue mapKV(FieldTypeProtos.KeyValue kv) {
|
||||||
|
return new KeyValue()
|
||||||
|
.setKey(kv.getKey())
|
||||||
|
.setValue(kv.getValue())
|
||||||
|
.setDataInfo(mapDataInfo(kv.getDataInfo()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataInfo mapDataInfo(FieldTypeProtos.DataInfo d) {
|
||||||
|
return new DataInfo()
|
||||||
|
.setDeletedbyinference(d.getDeletedbyinference())
|
||||||
|
.setInferenceprovenance(d.getInferenceprovenance())
|
||||||
|
.setInferred(d.getInferred())
|
||||||
|
.setInvisible(d.getInvisible())
|
||||||
|
.setProvenanceaction(mapQualifier(d.getProvenanceaction()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Qualifier mapQualifier(FieldTypeProtos.Qualifier q) {
|
||||||
|
return new Qualifier()
|
||||||
|
.setClassid(q.getClassid())
|
||||||
|
.setClassname(q.getClassname())
|
||||||
|
.setSchemeid(q.getSchemeid())
|
||||||
|
.setSchemename(q.getSchemename())
|
||||||
|
.setDataInfo(q.hasDataInfo() ? mapDataInfo(q.getDataInfo()) : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StructuredProperty mapStructuredProperty(FieldTypeProtos.StructuredProperty sp) {
|
||||||
|
return new StructuredProperty()
|
||||||
|
.setValue(sp.getValue())
|
||||||
|
.setQualifier(mapQualifier(sp.getQualifier()))
|
||||||
|
.setDataInfo(sp.hasDataInfo() ? mapDataInfo(sp.getDataInfo()) : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue