Skip to content

Commit

Permalink
feat(schemas): introduce schema generation submodule #5889
Browse files Browse the repository at this point in the history
- Generate model classes for DataCite 4.5 Metadata Schema
- Add a simple test to demonstrate usage and basic validity.
  • Loading branch information
poikilotherm committed Apr 10, 2024
1 parent 21538d6 commit cfe5378
Show file tree
Hide file tree
Showing 16 changed files with 1,668 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/dataverse-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<module>../../scripts/zipdownload</module>
<module>../container-base</module>
<module>../dataverse-spi</module>
<module>../dataverse-schemas</module>
</modules>

<!-- Transitive dependencies, bigger library "bill of materials" (BOM) and
Expand Down
326 changes: 326 additions & 0 deletions modules/dataverse-schemas/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,326 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>edu.harvard.iq</groupId>
<artifactId>dataverse-parent</artifactId>
<version>${revision}</version>
<relativePath>../dataverse-parent</relativePath>
</parent>

<groupId>io.gdcc</groupId>
<artifactId>dataverse-schemas</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Dataverse Schema Model Classes</name>
<url>https://dataverse.org</url>
<description>
This package provides model classes compiled from diverse metadata schemas like DataCite and others.
</description>

<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<developer>
<name>Dataverse Core Team</name>
<email>support@dataverse.org</email>
</developer>
</developers>

<issueManagement>
<url>https://github.com/IQSS/dataverse/issues</url>
<system>GitHub Issues</system>
</issueManagement>

<scm>
<connection>scm:git:git@github.com:IQSS/dataverse.git</connection>
<developerConnection>scm:git:git@github.com:IQSS/dataverse.git</developerConnection>
<url>git@github.com:IQSS/dataverse.git</url>
<tag>HEAD</tag>
</scm>

<ciManagement>
<url>https://github.com/IQSS/dataverse/actions</url>
<system>github</system>
<notifiers>
<notifier>
<address>dataversebot@gdcc.io</address>
</notifier>
</notifiers>
</ciManagement>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<properties>
<javadoc.lint>none</javadoc.lint>
<skipDeploy>false</skipDeploy>

<jaxb-plugin.version>4.0.6</jaxb-plugin.version>
</properties>

<dependencies>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<scope>provided</scope>
<!-- no version here as managed by parent -->
</dependency>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<scope>provided</scope>
<!-- no version here as managed by parent -->
</dependency>

<!-- Necessary for functionality of generated code -->
<dependency>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-plugins-runtime</artifactId>
<version>${jaxb-plugin.version}</version>
</dependency>

<!-- TESTING -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-osgi</artifactId>
<scope>test</scope>
<!-- no version here as managed by parent / Payara BOM -->
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<version>2.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-matchers</artifactId>
<version>2.9.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>${target.java.version}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>

<!-- SCHEMA TO CLASS GENERATION -->
<plugin>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-maven-plugin</artifactId>
<version>${jaxb-plugin.version}</version>
<executions>
<execution>
<id>datacite-4.5</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemas>
<schema>
<fileset>
<directory>${basedir}/src/main/resources/datacite-4.5</directory>
</fileset>
</schema>
</schemas>
<bindings>
<binding>
<fileset>
<directory>${basedir}/src/main/resources/datacite-4.5</directory>
</fileset>
</binding>
</bindings>
<markGenerated>false</markGenerated>
<locale>en</locale>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-plugins</artifactId>
<version>${jaxb-plugin.version}</version>
</plugin>
</plugins>
<!-- See https://github.com/highsource/jaxb-tools/wiki/JAXB2-Basic for more -->
<args>
<!-- Must be set and executed first to make the other plugins create compatible code -->
<arg>-XelementWrapper</arg>
<!--<arg>-XelementWrapper:delete</arg>-->

<arg>-Xfluent-api</arg>
<arg>-Xvalue-constructor</arg>
<arg>-XtoString</arg>
<arg>-XsimpleEquals</arg>
<arg>-XsimpleHashCode</arg>
<arg>-Xdefault-value</arg>
<arg>-XfixJAXB1058</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>

<!-- RELEASING -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<autoVersionSubmodules>true</autoVersionSubmodules>
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>oss</flattenMode>
<pomElements>
<distributionManagement>remove</distributionManagement>
<repositories>remove</repositories>
</pomElements>
</configuration>
<executions>
<!-- enable flattening -->
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<!-- ensure proper cleanup -->
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>${skipDeploy}</skip>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.kordamp.maven</groupId>
<artifactId>pomchecker-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>check-maven-central</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<source>${target.java.version}</source>
<detectJavaApiLink>false</detectJavaApiLink>
<doclint>${javadoc.lint}</doclint>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>ct</id>
<properties>
<skipDeploy>true</skipDeploy>
</properties>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
jaxb:version="3.0">

<jaxb:bindings schemaLocation="schema.xsd">
<jaxb:schemaBindings>
<!-- Define the target name of the package -->
<jaxb:package name="io.gdcc.schemas.datacite45"/>
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxb:bindings>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany
2013-05 v3.0: Addition of ID to simpleType element, added values "ResearchGroup" & "Other"
2014-08-20 v3.1: Addition of value "DataCurator"
2015-05-14 v4.0 dropped value "Funder", use new "funderReference" -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-4" targetNamespace="http://datacite.org/schema/kernel-4" elementFormDefault="qualified">
<xs:simpleType name="contributorType" id="contributorType">
<xs:annotation>
<xs:documentation>The type of contributor of the resource.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="ContactPerson" />
<xs:enumeration value="DataCollector" />
<xs:enumeration value="DataCurator" />
<xs:enumeration value="DataManager" />
<xs:enumeration value="Distributor" />
<xs:enumeration value="Editor" />
<xs:enumeration value="HostingInstitution" />
<xs:enumeration value="Other" />
<xs:enumeration value="Producer" />
<xs:enumeration value="ProjectLeader" />
<xs:enumeration value="ProjectManager" />
<xs:enumeration value="ProjectMember" />
<xs:enumeration value="RegistrationAgency" />
<xs:enumeration value="RegistrationAuthority" />
<xs:enumeration value="RelatedPerson" />
<xs:enumeration value="ResearchGroup" />
<xs:enumeration value="RightsHolder" />
<xs:enumeration value="Researcher" />
<xs:enumeration value="Sponsor" />
<xs:enumeration value="Supervisor" />
<xs:enumeration value="WorkPackageLeader" />
</xs:restriction>
</xs:simpleType>
</xs:schema>

0 comments on commit cfe5378

Please sign in to comment.