Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publishing 0.5.7 #58

Merged
merged 10 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
- name: Build java runtime with Gradle
uses: gradle/actions/setup-gradle@v3
Expand Down
4 changes: 2 additions & 2 deletions doc/guide/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Installation
============

The VO-DML tooling is based around [gradle](https://gradle.org) (currently version 8) which itself
is based on Java. It is recommended that a minimum of JDK 11 is installed
(JDK 17 has also been tested) using a package manager for your OS and
is based on Java. It is recommended that a minimum of JDK 17 is installed
using a package manager for your OS and
similarly use a package manager for gradle installation. Although if you are working
with a repository that already has a `gradelw` file at the top level, then that can be used
in place of the gradle command, and it will handle the downloading and running of the correct gradle version.
Expand Down
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.6"
id("net.ivoa.vo-dml.vodmltools") version "0.5.7"
// id ("com.diffplug.spotless") version "5.17.1"
`maven-publish`
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
Expand Down
4 changes: 2 additions & 2 deletions models/sample/sample/vo-dml/Sample.vo-dml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@
<maxOccurs>1</maxOccurs>
</multiplicity>
<semanticconcept>
<topConcept>http://purl.org/astronomy/vocab/DataObjectTypes/DataObjectType</topConcept>
<vocabularyURI>http://purl.org/astronomy/vocab/DataObjectTypes</vocabularyURI>
<topConcept>http://www.ivoa.net/rdf/object-type#DataObjectType</topConcept> <!--FIXME - this is probably not correct -->
<vocabularyURI>http://www.ivoa.net/rdf/object-type</vocabularyURI>
</semanticconcept>
</attribute>
</objectType>
Expand Down
7 changes: 5 additions & 2 deletions models/sample/test/serializationExample.vo-dml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<uri/>
<title></title>
<version>1.0</version>
<lastModified>2024-05-31T11:12:57Z</lastModified>
<lastModified>2024-10-07T08:26:18Z</lastModified>
<import>
<name>null</name><!--should not be needed in modern vo-dml -->
<url>IVOA-v1.0.vo-dml.xml</url>
Expand Down Expand Up @@ -127,6 +127,9 @@
<minOccurs>1</minOccurs>
<maxOccurs>1</maxOccurs>
</multiplicity>
<semanticconcept>
<vocabularyURI>http://www.ivoa.net/rdf/product-type</vocabularyURI>
</semanticconcept>
</attribute>
</objectType>
<objectType>
Expand Down Expand Up @@ -166,7 +169,7 @@
</datatype>
<multiplicity>
<minOccurs>1</minOccurs>
<maxOccurs>1</maxOccurs>
<maxOccurs>-1</maxOccurs>
</multiplicity>
</attribute>
<composition>
Expand Down
4 changes: 2 additions & 2 deletions models/sample/test/serializationExample.vodsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ otype Dcont -> BaseC {
}

otype Econt -> BaseC {
evalue: ivoa:string "";
evalue: ivoa:string "" semantic in "http://www.ivoa.net/rdf/product-type";
}
otype SomeContent "" {
ref1 references Refa "";
ref2 references Refb "";
zval : ivoa:string "";
zval : ivoa:string @+ "";
con: BaseC @+ as composition "";
}

Expand Down
15 changes: 11 additions & 4 deletions runtime/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
signing
}
group = "org.javastro.ivoa.vo-dml"
version = "0.7.1"
version = "0.7.2"


dependencies {
Expand All @@ -15,7 +15,7 @@ dependencies {
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.15.1")
implementation("com.fasterxml.jackson.core:jackson-databind:2.17.0")
implementation("org.hibernate.orm:hibernate-core:6.2.7.Final")

implementation("org.slf4j:slf4j-api:1.7.36")
Expand All @@ -40,12 +40,16 @@ dependencies {
//}

java {
// modularity.inferModulePath.set(false) // still can only build on java 1.8
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
languageVersion = JavaLanguageVersion.of(17)
}
withJavadocJar()
withSourcesJar()

}

tasks.javadoc {
(options as StandardJavadocDocletOptions).tags("TODO","IMPL")
}

tasks.test {
Expand Down Expand Up @@ -110,6 +114,9 @@ publishing.publications.withType(MavenPublication::class.java).forEach { publica
}
}
println ("java property skipSigning= " + project.hasProperty("skipSigning"))
repositories {
mavenCentral()
}


signing {
Expand Down
128 changes: 128 additions & 0 deletions runtime/java/src/main/java/org/ivoa/vodml/jpa/AttributeConverters.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* Created on 7 Oct 2024
* Copyright 2024 Paul Harrison ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License in file LICENSE
*/

package org.ivoa.vodml.jpa;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import jakarta.persistence.AttributeConverter;

/**
* Attribute converters to convert lists to comma separated strings.
* @author Paul Harrison ([email protected])
*/
public class AttributeConverters {

private static final String SPLIT_CHAR = ";";
public static class StringListConverter implements AttributeConverter<List<String>, String> {


/**
* {@inheritDoc}
* overrides @see jakarta.persistence.AttributeConverter#convertToDatabaseColumn(java.lang.Object)
*/
@Override
public String convertToDatabaseColumn(List<String> attribute) {
return attribute != null ? String.join(SPLIT_CHAR, attribute) : "";
}

/**
* {@inheritDoc}
* overrides @see jakarta.persistence.AttributeConverter#convertToEntityAttribute(java.lang.Object)
*/
@Override
public List<String> convertToEntityAttribute(String dbData) {
return dbData != null ? Arrays.asList(dbData.split(SPLIT_CHAR)) : new ArrayList<String>() ;
}

}

public static abstract class NumberListConverter <T> implements AttributeConverter<List<T>, String> {

/**
* {@inheritDoc}
* overrides @see jakarta.persistence.AttributeConverter#convertToDatabaseColumn(java.lang.Object)
*/
@Override
public String convertToDatabaseColumn(List<T> attribute) {

if(attribute!= null)
{
return attribute.stream().map(T::toString).collect(Collectors.joining (SPLIT_CHAR));
}
else
{
return "";
}
}


}
public static class IntListConverter extends NumberListConverter<Integer>
{

/**
* {@inheritDoc}
* overrides @see jakarta.persistence.AttributeConverter#convertToEntityAttribute(java.lang.Object)
*/
@Override
public List<Integer> convertToEntityAttribute(String dbData) {
if (dbData != null)
{
return Stream.of(dbData.split(SPLIT_CHAR)).map(Integer::parseInt).toList();
}
else return new ArrayList<>();

}

}
public static class DoubleListConverter extends NumberListConverter<Double>
{

/**
* {@inheritDoc}
* overrides @see jakarta.persistence.AttributeConverter#convertToEntityAttribute(java.lang.Object)
*/
@Override
public List<Double> convertToEntityAttribute(String dbData) {
if (dbData != null)
{
return Stream.of(dbData.split(SPLIT_CHAR)).map(Double::parseDouble).toList();
}
else return new ArrayList<>();

}

}
public static class BooleanListConverter extends NumberListConverter<Boolean>
{

/**
* {@inheritDoc}
* overrides @see jakarta.persistence.AttributeConverter#convertToEntityAttribute(java.lang.Object)
*/
@Override
public List<Boolean> convertToEntityAttribute(String dbData) {
if (dbData != null)
{
return Stream.of(dbData.split(SPLIT_CHAR)).map(Boolean::parseBoolean).toList();
}
else return new ArrayList<>();


}

}
}


Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class AutoDBRoundTripTest <M extends VodmlModel<M>, I, T extends
* @param e the entity to be tested.
*/
public abstract void testEntity(T e);

@Test
void testRDBRoundTrip()
{
Expand All @@ -46,7 +46,8 @@ void testRDBRoundTrip()
testEntity(result.retval);

}



}


Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@
import org.ivoa.vodml.jpa.JPAManipulationsForObjectType;
import org.ivoa.vodml.validation.ModelValidator.ValidationResult;

/**
* Base Class for doing validating tests.
*/
public abstract class AbstractBaseValidation {
/**
* Do a JSON round trip of a model instance.
* @param m A model instance.
* @return The result of the round trip test.
* @param <T> The Model class .
* @throws JsonProcessingException
*/
protected <T> RoundTripResult<T> roundTripJSON(VodmlModel<T> m) throws JsonProcessingException {
T model = m.management().theModel();
if(m.management().hasReferences())
Expand All @@ -57,6 +67,10 @@ protected <T> RoundTripResult<T> roundTripJSON(VodmlModel<T> m) throws JsonProc

}

/**
* The result of doing a round trip test.
* @param <T> the model class.
*/
public static class RoundTripResult <T> {
public final boolean isValid;
public final T retval;
Expand All @@ -66,6 +80,18 @@ public static class RoundTripResult <T> {
}
}

/**
* Do a XML round trip of a model instance.
* @param vodmlModel a model instance.
* @return the result of doing a round trip.
* @param <T> The model class.
* @throws ParserConfigurationException
* @throws JAXBException
* @throws PropertyException
* @throws TransformerFactoryConfigurationError
* @throws TransformerConfigurationException
* @throws TransformerException
*/
protected <T extends VodmlModel<T>> RoundTripResult<T> roundtripXML(VodmlModel<T> vodmlModel) throws ParserConfigurationException, JAXBException,
PropertyException, TransformerFactoryConfigurationError,
TransformerConfigurationException, TransformerException {
Expand Down Expand Up @@ -108,7 +134,16 @@ protected <T extends VodmlModel<T>> RoundTripResult<T> roundtripXML(VodmlModel<T
T modelin = el.getValue();
return new RoundTripResult<T>(!vc.hasEvents(), modelin);
}


/**
* Do an RDB round trip of a model instance.
* @param modelManagement Then model management
* @param entity The entity to round trip.
* @return
* @param <M> the model class.
* @param <I> The type of the identifier for the entity.
* @param <T> The type of the entity.
*/
protected <M, I, T extends JPAManipulationsForObjectType<I>> RoundTripResult<T> roundtripRDB(ModelManagement<M> modelManagement, T entity)
{

Expand All @@ -118,7 +153,8 @@ protected <M, I, T extends JPAManipulationsForObjectType<I>> RoundTripResult<T>
em.persist(entity);
em.getTransaction().commit();
I id = entity.getId();

String dumpfile = setDbDumpFile();
if(dumpfile!= null) dumpDbData(em, dumpfile);
//flush any existing entities
em.clear();
em.getEntityManagerFactory().getCache().evictAll();
Expand All @@ -131,7 +167,12 @@ protected <M, I, T extends JPAManipulationsForObjectType<I>> RoundTripResult<T>
return new RoundTripResult<T>(true, r);

}


/**
* Create an Entity manager for a memory-based test database;
* @param puname the persistence unit name of the JPA DB.
* @return the EntityManager for the database.
*/
protected EntityManager setupH2Db(String puname){
Map<String, String> props = new HashMap<>();

Expand Down Expand Up @@ -173,7 +214,14 @@ protected EntityManager setupH2Db(String puname){
return em;

}


/**
* Validate a model instance. This is done via JAXB.
* @param m the model instance.
* @return result of the validation.
* @param <T> the model class.
* @throws JAXBException exception when there is a JAXB problem.
*/
protected <T> ValidationResult validateModel(VodmlModel<T> m) throws JAXBException {

final ModelDescription desc = m.descriptor();
Expand All @@ -198,4 +246,12 @@ protected void dumpDbData(jakarta.persistence.EntityManager em, String filename)
});
}

/**
* set the name of the file to which the dbDump is written. The default is null so that no file is written.
* @return the filename.
*/
protected String setDbDumpFile() {
return null;
}

}
Loading
Loading