EOSC Services - added Service-specific fields in the XML record serialization
This commit is contained in:
parent
f5f532d134
commit
05c1ea92e9
|
@ -75,6 +75,12 @@ public class MigrateDbEntitiesApplicationTest {
|
||||||
.stream()
|
.stream()
|
||||||
.map(KeyValue::getKey)
|
.map(KeyValue::getKey)
|
||||||
.forEach(dsId -> assertValidId(dsId));
|
.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("officialname", fields), ds.getOfficialname().getValue());
|
||||||
assertEquals(getValueAsString("englishname", fields), ds.getEnglishname().getValue());
|
assertEquals(getValueAsString("englishname", fields), ds.getEnglishname().getValue());
|
||||||
assertEquals(getValueAsString("websiteurl", fields), ds.getWebsiteurl().getValue());
|
assertEquals(getValueAsString("websiteurl", fields), ds.getWebsiteurl().getValue());
|
||||||
|
|
|
@ -535,6 +535,12 @@ public class XmlRecordFactory implements Serializable {
|
||||||
if (ds.getDatasourcetypeui() != null) {
|
if (ds.getDatasourcetypeui() != null) {
|
||||||
metadata.add(XmlSerializationUtils.mapQualifier("datasourcetypeui", ds.getDatasourcetypeui()));
|
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) {
|
if (ds.getOpenairecompatibility() != null) {
|
||||||
metadata
|
metadata
|
||||||
.add(
|
.add(
|
||||||
|
@ -583,6 +589,16 @@ public class XmlRecordFactory implements Serializable {
|
||||||
metadata
|
metadata
|
||||||
.add(XmlSerializationUtils.asXmlElement("description", ds.getDescription().getValue()));
|
.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) {
|
if (ds.getOdnumberofitems() != null) {
|
||||||
metadata
|
metadata
|
||||||
.add(
|
.add(
|
||||||
|
@ -609,6 +625,16 @@ public class XmlRecordFactory implements Serializable {
|
||||||
.map(c -> XmlSerializationUtils.asXmlElement("odlanguages", c.getValue()))
|
.map(c -> XmlSerializationUtils.asXmlElement("odlanguages", c.getValue()))
|
||||||
.collect(Collectors.toList()));
|
.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) {
|
if (ds.getOdcontenttypes() != null) {
|
||||||
metadata
|
metadata
|
||||||
.addAll(
|
.addAll(
|
||||||
|
@ -689,6 +715,12 @@ public class XmlRecordFactory implements Serializable {
|
||||||
XmlSerializationUtils
|
XmlSerializationUtils
|
||||||
.asXmlElement("versioning", ds.getVersioning().getValue().toString()));
|
.asXmlElement("versioning", ds.getVersioning().getValue().toString()));
|
||||||
}
|
}
|
||||||
|
if (ds.getVersioncontrol() != null) {
|
||||||
|
metadata
|
||||||
|
.add(
|
||||||
|
XmlSerializationUtils
|
||||||
|
.asXmlElement("versioncontrol", ds.getVersioncontrol().toString()));
|
||||||
|
}
|
||||||
if (ds.getCitationguidelineurl() != null) {
|
if (ds.getCitationguidelineurl() != null) {
|
||||||
metadata
|
metadata
|
||||||
.add(
|
.add(
|
||||||
|
@ -716,17 +748,24 @@ public class XmlRecordFactory implements Serializable {
|
||||||
if (ds.getJournal() != null) {
|
if (ds.getJournal() != null) {
|
||||||
metadata.add(XmlSerializationUtils.mapJournal(ds.getJournal()));
|
metadata.add(XmlSerializationUtils.mapJournal(ds.getJournal()));
|
||||||
}
|
}
|
||||||
if (ds.getSubjects() != null) {
|
if (ds.getResearchentitytypes() != null) {
|
||||||
metadata
|
metadata
|
||||||
.addAll(
|
.addAll(
|
||||||
ds
|
ds
|
||||||
.getSubjects()
|
.getResearchentitytypes()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(Objects::nonNull)
|
.map(c -> XmlSerializationUtils.asXmlElement("researchentitytypes", c))
|
||||||
.map(sp -> XmlSerializationUtils.mapStructuredProperty("subjects", sp))
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
if (ds.getProvidedproducttypes() != null) {
|
||||||
|
metadata
|
||||||
|
.addAll(
|
||||||
|
ds
|
||||||
|
.getProvidedproducttypes()
|
||||||
|
.stream()
|
||||||
|
.map(c -> XmlSerializationUtils.asXmlElement("providedproducttypes", c))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ds.getJurisdiction() != null) {
|
if (ds.getJurisdiction() != null) {
|
||||||
metadata.add(XmlSerializationUtils.mapQualifier("jurisdiction", ds.getJurisdiction()));
|
metadata.add(XmlSerializationUtils.mapQualifier("jurisdiction", ds.getJurisdiction()));
|
||||||
}
|
}
|
||||||
|
@ -750,7 +789,34 @@ public class XmlRecordFactory implements Serializable {
|
||||||
.map(q -> XmlSerializationUtils.mapQualifier("contentpolicy", q))
|
.map(q -> XmlSerializationUtils.mapQualifier("contentpolicy", q))
|
||||||
.collect(Collectors.toList()));
|
.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;
|
break;
|
||||||
case organization:
|
case organization:
|
||||||
final Organization o = (Organization) entity;
|
final Organization o = (Organization) entity;
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.dom4j.Document;
|
import org.dom4j.Document;
|
||||||
import org.dom4j.DocumentException;
|
import org.dom4j.DocumentException;
|
||||||
|
import org.dom4j.Element;
|
||||||
import org.dom4j.io.SAXReader;
|
import org.dom4j.io.SAXReader;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -142,7 +143,7 @@ public class XmlRecordFactoryTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDatasource() throws IOException, DocumentException {
|
public void testService() throws IOException, DocumentException {
|
||||||
final ContextMapper contextMapper = new ContextMapper();
|
final ContextMapper contextMapper = new ContextMapper();
|
||||||
|
|
||||||
final XmlRecordFactory xmlRecordFactory = new XmlRecordFactory(contextMapper, false,
|
final XmlRecordFactory xmlRecordFactory = new XmlRecordFactory(contextMapper, false,
|
||||||
|
@ -167,6 +168,14 @@ public class XmlRecordFactoryTest {
|
||||||
assertEquals("true", doc.valueOf("//thematic"));
|
assertEquals("true", doc.valueOf("//thematic"));
|
||||||
assertEquals("Journal article", doc.valueOf("//contentpolicy/@classname"));
|
assertEquals("Journal article", doc.valueOf("//contentpolicy/@classname"));
|
||||||
assertEquals("Journal archive", doc.valueOf("//datasourcetypeui/@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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue