EOSC Services - added Service-specific fields in the XML record serialization

This commit is contained in:
Claudio Atzori 2022-04-29 15:56:55 +02:00
parent f5f532d134
commit 05c1ea92e9
4 changed files with 495 additions and 8 deletions

View File

@ -75,6 +75,12 @@ public class MigrateDbEntitiesApplicationTest {
.stream()
.map(KeyValue::getKey)
.forEach(dsId -> assertValidId(dsId));
assertEquals(1, ds.getPid().size());
assertEquals("r3d100010218", ds.getPid().get(0).getValue());
assertEquals("re3data", ds.getPid().get(0).getQualifier().getClassid());
assertEquals("dnet:pid_types", ds.getPid().get(0).getQualifier().getSchemeid());
assertEquals(getValueAsString("officialname", fields), ds.getOfficialname().getValue());
assertEquals(getValueAsString("englishname", fields), ds.getEnglishname().getValue());
assertEquals(getValueAsString("websiteurl", fields), ds.getWebsiteurl().getValue());

View File

@ -535,6 +535,12 @@ public class XmlRecordFactory implements Serializable {
if (ds.getDatasourcetypeui() != null) {
metadata.add(XmlSerializationUtils.mapQualifier("datasourcetypeui", ds.getDatasourcetypeui()));
}
if (ds.getEosctype() != null) {
metadata.add(XmlSerializationUtils.mapQualifier("eosctype", ds.getEosctype()));
}
if (ds.getEoscdatasourcetype() != null) {
metadata.add(XmlSerializationUtils.mapQualifier("eoscdatasourcetype", ds.getEoscdatasourcetype()));
}
if (ds.getOpenairecompatibility() != null) {
metadata
.add(
@ -583,6 +589,16 @@ public class XmlRecordFactory implements Serializable {
metadata
.add(XmlSerializationUtils.asXmlElement("description", ds.getDescription().getValue()));
}
if (ds.getSubjects() != null) {
metadata
.addAll(
ds
.getSubjects()
.stream()
.filter(Objects::nonNull)
.map(sp -> XmlSerializationUtils.mapStructuredProperty("subjects", sp))
.collect(Collectors.toList()));
}
if (ds.getOdnumberofitems() != null) {
metadata
.add(
@ -609,6 +625,16 @@ public class XmlRecordFactory implements Serializable {
.map(c -> XmlSerializationUtils.asXmlElement("odlanguages", c.getValue()))
.collect(Collectors.toList()));
}
if (ds.getLanguages() != null) {
metadata
.addAll(
ds
.getLanguages()
.stream()
.filter(Objects::nonNull)
.map(c -> XmlSerializationUtils.asXmlElement("languages", c))
.collect(Collectors.toList()));
}
if (ds.getOdcontenttypes() != null) {
metadata
.addAll(
@ -689,6 +715,12 @@ public class XmlRecordFactory implements Serializable {
XmlSerializationUtils
.asXmlElement("versioning", ds.getVersioning().getValue().toString()));
}
if (ds.getVersioncontrol() != null) {
metadata
.add(
XmlSerializationUtils
.asXmlElement("versioncontrol", ds.getVersioncontrol().toString()));
}
if (ds.getCitationguidelineurl() != null) {
metadata
.add(
@ -716,17 +748,24 @@ public class XmlRecordFactory implements Serializable {
if (ds.getJournal() != null) {
metadata.add(XmlSerializationUtils.mapJournal(ds.getJournal()));
}
if (ds.getSubjects() != null) {
if (ds.getResearchentitytypes() != null) {
metadata
.addAll(
ds
.getSubjects()
.getResearchentitytypes()
.stream()
.filter(Objects::nonNull)
.map(sp -> XmlSerializationUtils.mapStructuredProperty("subjects", sp))
.map(c -> XmlSerializationUtils.asXmlElement("researchentitytypes", c))
.collect(Collectors.toList()));
}
if (ds.getProvidedproducttypes() != null) {
metadata
.addAll(
ds
.getProvidedproducttypes()
.stream()
.map(c -> XmlSerializationUtils.asXmlElement("providedproducttypes", c))
.collect(Collectors.toList()));
}
if (ds.getJurisdiction() != null) {
metadata.add(XmlSerializationUtils.mapQualifier("jurisdiction", ds.getJurisdiction()));
}
@ -750,7 +789,34 @@ public class XmlRecordFactory implements Serializable {
.map(q -> XmlSerializationUtils.mapQualifier("contentpolicy", q))
.collect(Collectors.toList()));
}
if (ds.getSubmissionpolicyurl() != null) {
metadata
.add(XmlSerializationUtils.asXmlElement("submissionpolicyurl", ds.getSubmissionpolicyurl()));
}
if (ds.getPreservationpolicyurl() != null) {
metadata
.add(
XmlSerializationUtils.asXmlElement("preservationpolicyurl", ds.getPreservationpolicyurl()));
}
if (ds.getResearchproductaccesspolicies() != null) {
metadata
.addAll(
ds
.getResearchproductaccesspolicies()
.stream()
.map(c -> XmlSerializationUtils.asXmlElement("researchproductaccesspolicies", c))
.collect(Collectors.toList()));
}
if (ds.getResearchproductmetadataaccesspolicies() != null) {
metadata
.addAll(
ds
.getResearchproductmetadataaccesspolicies()
.stream()
.map(
c -> XmlSerializationUtils.asXmlElement("researchproductmetadataaccesspolicies", c))
.collect(Collectors.toList()));
}
break;
case organization:
final Organization o = (Organization) entity;

View File

@ -11,6 +11,7 @@ import java.util.List;
import org.apache.commons.io.IOUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.junit.jupiter.api.Test;
@ -142,7 +143,7 @@ public class XmlRecordFactoryTest {
}
@Test
public void testDatasource() throws IOException, DocumentException {
public void testService() throws IOException, DocumentException {
final ContextMapper contextMapper = new ContextMapper();
final XmlRecordFactory xmlRecordFactory = new XmlRecordFactory(contextMapper, false,
@ -167,6 +168,14 @@ public class XmlRecordFactoryTest {
assertEquals("true", doc.valueOf("//thematic"));
assertEquals("Journal article", doc.valueOf("//contentpolicy/@classname"));
assertEquals("Journal archive", doc.valueOf("//datasourcetypeui/@classname"));
assertEquals("Data Source", doc.valueOf("//eosctype/@classname"));
final List pids = doc.selectNodes("//pid");
assertEquals(1, pids.size());
assertEquals("re3data", ((Element) pids.get(0)).attribute("classid").getValue());
assertEquals(
"Registry of research data repositories", ((Element) pids.get(0)).attribute("classname").getValue());
assertEquals("dnet:pid_types", ((Element) pids.get(0)).attribute("schemeid").getValue());
assertEquals("dnet:pid_types", ((Element) pids.get(0)).attribute("schemename").getValue());
}
}