Merge pull request 'Align Solr JSON records to the explore portal requirements' (#38) from solr_json_model into master

Reviewed-on: #38
This commit is contained in:
Claudio Atzori 2024-06-24 14:51:49 +02:00
commit c46c235c83
9 changed files with 171 additions and 36 deletions

View File

@ -10,23 +10,34 @@ public class AccessRight implements Serializable {
private static final long serialVersionUID = 7995566912611238604L;
private String value;
private String code;
private String label;
private OpenAccessRoute openAccessRoute;
public static AccessRight newInstance(String value, OpenAccessRoute openAccessRoute) {
public static AccessRight newInstance(String code, String label, OpenAccessRoute openAccessRoute) {
AccessRight accessRight = new AccessRight();
accessRight.setValue(value);
accessRight.setCode(code);
accessRight.setLabel(label);
accessRight.setOpenAccessRoute(openAccessRoute);
return accessRight;
}
public String getValue() {
return value;
public String getCode() {
return code;
}
public void setValue(String value) {
this.value = value;
public void setCode(String code) {
this.code = code;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public OpenAccessRoute getOpenAccessRoute() {

View File

@ -1,10 +1,36 @@
package eu.dnetlib.dhp.schema.solr;
import java.io.Serializable;
import java.util.List;
public class Measure implements Serializable {
private static final long serialVersionUID = 57939927121851504L;
//TODO define me!
private String id;
private List<CodeLabel> unit;
public static Measure newInstance(String id, List<CodeLabel> unit) {
Measure m = new Measure();
m.setId(id);
m.setUnit(unit);
return m;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public List<CodeLabel> getUnit() {
return unit;
}
public void setUnit(List<CodeLabel> unit) {
this.unit = unit;
}
}

View File

@ -6,25 +6,20 @@ public class Pid implements Serializable {
private static final long serialVersionUID = -943684282582228545L;
private String type;
private String value;
public static Pid newInstance(String type, String value) {
private String typeCode;
private String typeLabel;
public static Pid newInstance(String value, String typeCode, String typeLabel) {
Pid p = new Pid();
p.setType(type);
p.setValue(value);
p.setTypeCode(typeCode);
p.setTypeLabel(typeLabel);
return p;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getValue() {
return value;
}
@ -32,4 +27,20 @@ public class Pid implements Serializable {
public void setValue(String value) {
this.value = value;
}
public String getTypeCode() {
return typeCode;
}
public void setTypeCode(String typeCode) {
this.typeCode = typeCode;
}
public String getTypeLabel() {
return typeLabel;
}
public void setTypeLabel(String typeLabel) {
this.typeLabel = typeLabel;
}
}

View File

@ -39,6 +39,7 @@ public class RelatedRecord implements Serializable {
private String acronym;
private CodeLabel contracttype;
private Funding funding;
private String validationDate;
public RelatedRecordHeader getHeader() {
return header;
@ -215,4 +216,12 @@ public class RelatedRecord implements Serializable {
public void setFunding(Funding funding) {
this.funding = funding;
}
public String getValidationDate() {
return validationDate;
}
public void setValidationDate(String validationDate) {
this.validationDate = validationDate;
}
}

View File

@ -14,12 +14,18 @@ public class RelatedRecordHeader implements Serializable {
private RecordType relatedRecordType;
public static RelatedRecordHeader newInstance(String relationType, String relationClass, String relatedIdentifier, RecordType relatedRecordType) {
private String relationProvenance;
private String trust;
public static RelatedRecordHeader newInstance(String relationType, String relationClass, String relatedIdentifier, RecordType relatedRecordType, String relationProvenance, String trust) {
RelatedRecordHeader header = new RelatedRecordHeader();
header.setRelationType(relationType);
header.setRelationClass(relationClass);
header.setRelatedIdentifier(relatedIdentifier);
header.setRelatedRecordType(relatedRecordType);
header.setRelationProvenance(relationProvenance);
header.setTrust(trust);
return header;
}
@ -54,4 +60,20 @@ public class RelatedRecordHeader implements Serializable {
public void setRelatedRecordType(RecordType relatedRecordType) {
this.relatedRecordType = relatedRecordType;
}
public String getRelationProvenance() {
return relationProvenance;
}
public void setRelationProvenance(String relationProvenance) {
this.relationProvenance = relationProvenance;
}
public String getTrust() {
return trust;
}
public void setTrust(String trust) {
this.trust = trust;
}
}

View File

@ -3,8 +3,6 @@ package eu.dnetlib.dhp.schema.solr;
import java.io.Serializable;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Result implements Serializable {
private static final long serialVersionUID = -9121038426985022737L;
@ -147,12 +145,10 @@ public class Result implements Serializable {
*/
private List<EoscIfGuidelines> eoscifguidelines;
@JsonProperty("isGreen")
private Boolean isGreen;
private OpenAccessColor openAccessColor;
@JsonProperty("isInDiamondJournal")
private Boolean isInDiamondJournal;
private Boolean publiclyFunded;
@ -381,11 +377,11 @@ public class Result implements Serializable {
this.eoscifguidelines = eoscifguidelines;
}
public Boolean getGreen() {
public Boolean getIsGreen() {
return isGreen;
}
public void setGreen(Boolean green) {
public void setIsGreen(Boolean green) {
isGreen = green;
}
@ -397,11 +393,11 @@ public class Result implements Serializable {
this.openAccessColor = openAccessColor;
}
public Boolean getInDiamondJournal() {
public Boolean getIsInDiamondJournal() {
return isInDiamondJournal;
}
public void setInDiamondJournal(Boolean inDiamondJournal) {
public void setIsInDiamondJournal(Boolean inDiamondJournal) {
isInDiamondJournal = inDiamondJournal;
}

View File

@ -7,6 +7,8 @@ public class SolrRecordHeader implements Serializable {
private static final long serialVersionUID = -6052397109220149426L;
public enum Status { UNDER_CURATION }
/**
* The OpenAIRE identifiers for this record
*/
@ -19,13 +21,20 @@ public class SolrRecordHeader implements Serializable {
private RecordType recordType;
private Status status = null;
private Boolean deletedbyinference;
public static SolrRecordHeader newInstance(String id, List<String> originalId, RecordType recordType, Boolean deletedbyinference) {
return newInstance(id, originalId, recordType, null, deletedbyinference);
}
public static SolrRecordHeader newInstance(String id, List<String> originalId, RecordType recordType, Status status, Boolean deletedbyinference) {
SolrRecordHeader header = new SolrRecordHeader();
header.setId(id);
header.setOriginalId(originalId);
header.setRecordType(recordType);
header.setStatus(status);
header.setDeletedbyinference(deletedbyinference);
return header;
}
@ -58,6 +67,14 @@ public class SolrRecordHeader implements Serializable {
return deletedbyinference;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public void setDeletedbyinference(Boolean deletedbyinference) {
this.deletedbyinference = deletedbyinference;
}

View File

@ -8,12 +8,15 @@ public class Subject implements Serializable {
private String value;
private String type;
private String typeCode;
public static Subject newInstance(String value, String type) {
private String typeLabel;
public static Subject newInstance(String value, String typeCode, String typeLabel) {
Subject s = new Subject();
s.setValue(value);
s.setType(type);
s.setTypeCode(typeCode);
s.setTypeLabel(typeLabel);
return s;
}
@ -25,11 +28,19 @@ public class Subject implements Serializable {
this.value = value;
}
public String getType() {
return type;
public String getTypeCode() {
return typeCode;
}
public void setType(String type) {
this.type = type;
public void setTypeCode(String typeCode) {
this.typeCode = typeCode;
}
public String getTypeLabel() {
return typeLabel;
}
public void setTypeLabel(String typeLabel) {
this.typeLabel = typeLabel;
}
}

View File

@ -0,0 +1,32 @@
package eu.dnetlib.dhp.schema.solr;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.*;
public class TestJsonSerialization {
private static ObjectMapper MAPPER = new ObjectMapper();
@Test
void testSerialiseJsonPayload() throws IOException {
Result r = new Result();
r.setIsGreen(true);
r.setIsInDiamondJournal(false);
final String json = MAPPER.writeValueAsString(r);
assertNotNull(json);
System.out.println("json = " + json);
Result r1 = MAPPER.readValue(json, Result.class);
assertTrue(r1.getIsGreen());
assertFalse(r1.getIsInDiamondJournal());
}
}