Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into base_update
Browse files Browse the repository at this point in the history
  • Loading branch information
pahjbo committed Nov 19, 2024
2 parents f3fdbd2 + bd71b44 commit c95f17d
Show file tree
Hide file tree
Showing 26 changed files with 201 additions and 209 deletions.
47 changes: 22 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,34 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Build java runtime with Gradle
- name: Setup gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-disabled: false
arguments: |
:java:publishToMavenLocal
-PskipSigning=True

- name: Build the Runtime
run: |
./gradlew :java:publishToMavenLocal -PskipSigning=True
- name: Build ivoa model with Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-disabled: false
arguments: |
:ivoa:publishToMavenLocal
-PskipSigning=True
run : |
./gradlew :ivoa:publishToMavenLocal -PskipSigning=True
- name: Test sample model with Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-disabled: false
arguments: |
:sample:test
-PskipSigning=True
run: |
./gradlew :sample:test -PskipSigning=True
- name: Validate sample model with Gradle
uses: gradle/actions/setup-gradle@v3
run : |
./gradlew :sample:vodmlValidate -PskipSigning=True
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
cache-disabled: false
arguments: |
:sample:vodmlValidate
-PskipSigning=True
files: |
./**/reports/**/test/*.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ tools/gradletooling/gradle-plugin/bin/
/tools/gradletooling/sample/mkdocs.yml
__pycache__/
/runtime/java/bin/
/tools/gradletooling/sample/tmp/
48 changes: 35 additions & 13 deletions doc/guide/Serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,31 @@ The schema for the serializations can be created with the `gradle vodmlSchema` c
For the [small example model](https://github.com/ivoa/vo-dml/tree/master/models/sample/test/serializationExample.vodsl), the overall model object will produce xml like

```xml
<ser:myModelModel xmlns:ser="http://ivoa.net/vodml/sample/serialization" >
<ser:myModelModel xmlns:ser="http://ivoa.net/vodml/sample/serialization" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<refs>
<refa _id="id_0">
<refa _id="MyModel-Refa_1000">
<val>a value</val>
</refa>
<refb>
<name>a name</name>
<name>naturalkey</name>
<val>another val</val>
</refb>
</refs>
<SomeContent>
<zval>a z val</zval>
<ref1>id_0</ref1>
<ref2>a name</ref2>
</SomeContent>
<someContent>
<zval>some</zval>
<zval>z</zval>
<zval>values</zval>
<con xsi:type="ser:Dcont" >
<bname>dval</bname>
<dval>a D</dval>
</con>
<con xsi:type="ser:Econt" >
<bname>eval</bname>
<evalue>cube</evalue>
</con>
<ref1>MyModel-Refa_1000</ref1>
<ref2>naturalkey</ref2>
</someContent>
</ser:myModelModel>
```
Note that because the integer parts of the id might have come from database indices, which
Expand All @@ -61,19 +71,31 @@ as a reference to the object if the data model is known. An `_id` property is ad
"MyModelModel" : {
"refs" : {
"MyModel:Refa" : [ {
"_id" : 0,
"_id" : 1000,
"val" : "a value"
} ],
"MyModel:Refb" : [ {
"name" : "a name",
"name" : "naturalkey",
"val" : "another val"
} ]
},
"content" : [ {
"@type" : "MyModel:SomeContent",
"zval" : "a z val",
"ref1" : 0,
"ref2" : "a name"
"_id" : 0,
"zval" : [ "some", "z", "values" ],
"con" : [ {
"@type" : "MyModel:Dcont",
"_id" : 0,
"bname" : "dval",
"dval" : "a D"
}, {
"@type" : "MyModel:Econt",
"_id" : 0,
"bname" : "eval",
"evalue" : "cube"
} ],
"ref1" : 1000,
"ref2" : "naturalkey"
} ]
}
}
Expand Down
2 changes: 1 addition & 1 deletion doc/guide/modelling/VODSL.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## VODSL support in the gradle tools

There is a `vodslToVodml` task that will convert models authored in [vodsl](https://github.com/pahjbo/vodsl) into standard VO-DML.
There is a `vodslToVodml` task that will convert models authored in [vodsl](https://www.ivoa.net/documents/Notes/VODSL/) into standard VO-DML.

the configurable properties within the vodml extension are;

Expand Down
2 changes: 1 addition & 1 deletion doc/std/ivoatex
2 changes: 1 addition & 1 deletion models/ivoa/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("net.ivoa.vo-dml.vodmltools") version "0.5.10"
id("net.ivoa.vo-dml.vodmltools") version "0.5.11"
// id ("com.diffplug.spotless") version "5.17.1"
`maven-publish`
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
Expand Down
6 changes: 3 additions & 3 deletions runtime/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ plugins {
signing
}
group = "org.javastro.ivoa.vo-dml"
version = "0.8.0"
version = "0.8.2"


dependencies {
// xjcPlugins("net.codesup.util:jaxb2-rich-contract-plugin:2.1.0")
implementation("org.xmlresolver:xmlresolver:6.0.4") // for xml catalogues - note that the apache xml-commons resolver is out of date
implementation("org.xmlresolver:xmlresolver:6.0.9") // for xml catalogues - note that the apache xml-commons resolver is out of date
implementation("jakarta.xml.bind:jakarta.xml.bind-api:4.0.0")
// implementation("org.glassfish.jaxb:jaxb-runtime:2.3.6")
implementation("jakarta.persistence:jakarta.persistence-api:3.1.0")
implementation("com.fasterxml.jackson.core:jackson-databind:2.17.0")
implementation("com.networknt:json-schema-validator:1.5.3")
implementation("org.hibernate.orm:hibernate-core:6.2.7.Final")

implementation("org.slf4j:slf4j-api:1.7.36")
api("org.javastro:jaxbjpa-utils:0.2.3")
compileOnly("org.junit.jupiter:junit-jupiter-api:5.9.2")// have put the base test classes in the runtime main - naughty, but easier to make everything work without changing dependencies


Expand Down
17 changes: 8 additions & 9 deletions runtime/java/src/main/java/org/ivoa/vodml/ModelManagement.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,7 @@ public interface ModelManagement <T>{
* @return the name
*/
String pu_name();
/**
* Write XML schema for the model.
* Note that these schema are internally generated by JAXB, and as such should not be regarded as the definitive schema to be published -
* they are used mainly in automated testing.
* @deprecated - should only use the schema generated by the top level tooling.
*/
void writeXMLSchema();


/**
* The context factory that can be used for full XML serialization.
* @return the context factory.
Expand Down Expand Up @@ -84,6 +77,12 @@ public interface ModelManagement <T>{
* @return the objectmapper.
*/
ObjectMapper jsonMapper();
}

/**
* Return the model description.
* @return the model description.
*/
ModelDescription description();

}

6 changes: 1 addition & 5 deletions runtime/java/src/main/java/org/ivoa/vodml/VodmlModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ public interface VodmlModel <T> extends org.ivoa.vodml.jaxb.JaxbManagement {
* @return the management infterface.
*/
ModelManagement<T> management();
/**
* get the description.
* @return the description interface.
*/
ModelDescription descriptor();

}


Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import jakarta.xml.bind.JAXBException;

import org.ivoa.vodml.VodmlModel;
import org.ivoa.vodml.validation.ModelValidator.ValidationResult;
import org.ivoa.vodml.validation.XMLValidator.ValidationResult;
import org.junit.jupiter.api.Test;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Created on 03/05/2023 by Paul Harrison ([email protected]).
*/

import java.io.File;
import java.io.StringReader;
import java.io.StringWriter;
import java.sql.PreparedStatement;
Expand Down Expand Up @@ -37,7 +36,7 @@
import org.ivoa.vodml.ModelManagement;
import org.ivoa.vodml.VodmlModel;
import org.ivoa.vodml.jpa.JPAManipulationsForObjectType;
import org.ivoa.vodml.validation.ModelValidator.ValidationResult;
import org.ivoa.vodml.validation.XMLValidator.ValidationResult;

/**
* Base Class for doing validating tests.
Expand Down Expand Up @@ -123,20 +122,27 @@ protected <T extends VodmlModel<T>> RoundTripResult<T> roundtripXML(VodmlModel<T
StreamResult result = new StreamResult(sw2);

trans.transform(new StreamSource(new StringReader(sw.toString())), result);
System.out.println(sw2.toString());
final String xmlOutput = sw2.toString();
System.out.println(xmlOutput);
XMLValidator xmlValidator = new XMLValidator(vodmlModel.management());
ValidationResult validation = xmlValidator.validate(xmlOutput);
if(!validation.isOk)
{
validation.printValidationErrors(System.err);
}

//try to read in again
Unmarshaller um = jc.createUnmarshaller();
ValidationEventCollector vc = new jakarta.xml.bind.util.ValidationEventCollector();
um.setEventHandler(vc);
JAXBElement<T> el = um.unmarshal(new StreamSource(new StringReader(sw2.toString())),clazz);
JAXBElement<T> el = um.unmarshal(new StreamSource(new StringReader(xmlOutput)),clazz);
if (vc.hasEvents()) {
for (ValidationEvent err : vc.getEvents()) {
System.err.println(err.getMessage());
}
}
T modelin = el.getValue();
return new RoundTripResult<T>(!vc.hasEvents(), modelin);
return new RoundTripResult<T>(!vc.hasEvents() & validation.isOk, modelin);
}

/**
Expand Down Expand Up @@ -227,11 +233,9 @@ protected EntityManager setupH2Db(String puname){
* @throws JAXBException exception when there is a JAXB problem.
*/
protected <T> ValidationResult validateModel(VodmlModel<T> m) throws JAXBException {

final ModelDescription desc = m.descriptor();
File schemaFile = new File(desc.schemaMap().get(desc.xmlNamespace()));
ModelValidator v = new ModelValidator(m);
return v.validate(m);

XMLValidator v = new XMLValidator(m.management());
return v.validateObject(m.management().theModel());

}

Expand Down
Loading

0 comments on commit c95f17d

Please sign in to comment.