diff --git a/doc/guide/modelling/TransformingToVODML.md b/doc/guide/modelling/TransformingToVODML.md index 3c79f577..19112bc0 100644 --- a/doc/guide/modelling/TransformingToVODML.md +++ b/doc/guide/modelling/TransformingToVODML.md @@ -4,9 +4,12 @@ Creating VO-DML from other Data Models It is possible to start with an XML schema that can be transferred to VODSL with ```shell -gradle vodmlXsdToVodsl --xsd mymodel.xsd --dsl mymodel.vodsl +gradle vodmlXsdToVodsl --xsd `pwd`/mymodel.xsd --dsl mymodel.vodsl ``` +Note that it is necessary to use the full path for the input file. + + The transformation does not cope with all of the "styles" XML schema that are possible, so that it is likely that the generated VODSL will need further hand editing. diff --git a/models/sample/test/lifecycleTest.vo-dml.xml b/models/sample/test/lifecycleTest.vo-dml.xml index 05801853..01b3889e 100644 --- a/models/sample/test/lifecycleTest.vo-dml.xml +++ b/models/sample/test/lifecycleTest.vo-dml.xml @@ -9,7 +9,7 @@ pharriso 0.1 - 2024-10-19T13:44:44Z + 2024-11-21T13:44:44Z null IVOA-v1.0.vo-dml.xml @@ -196,7 +196,7 @@ lifecycleTest:ReferredLifeCycle - 1 + 0 1 diff --git a/models/sample/test/lifecycleTest.vodsl b/models/sample/test/lifecycleTest.vodsl index 24ddc308..b63728c9 100644 --- a/models/sample/test/lifecycleTest.vodsl +++ b/models/sample/test/lifecycleTest.vodsl @@ -43,7 +43,7 @@ otype ATest3 { /* fails the "unique composition rule" in schematron if the one * but this should be unlikely if a contained type instance is created at the same time as its container instance. */ contained : Contained @+ as composition ""; //vodsl tooling does not flag this- but the vodml schematron does. - refBad references ReferredLifeCycle ""; //this should be lifecycle warning + refBad @? references ReferredLifeCycle ""; //this should be lifecycle warning } otype ATest4 { diff --git a/runtime/java/build.gradle.kts b/runtime/java/build.gradle.kts index 37bd94f9..85488889 100644 --- a/runtime/java/build.gradle.kts +++ b/runtime/java/build.gradle.kts @@ -6,7 +6,7 @@ plugins { signing } group = "org.javastro.ivoa.vo-dml" -version = "0.8.2" +version = "0.8.3" dependencies { @@ -25,7 +25,7 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2") - testRuntimeOnly("ch.qos.logback:logback-classic:1.4.7") + testRuntimeOnly("ch.qos.logback:logback-classic:1.4.12") } diff --git a/runtime/java/src/main/java/org/ivoa/vodml/jpa/JPAManipulationsForObjectType.java b/runtime/java/src/main/java/org/ivoa/vodml/jpa/JPAManipulationsForObjectType.java index 18a76fa9..99387d84 100644 --- a/runtime/java/src/main/java/org/ivoa/vodml/jpa/JPAManipulationsForObjectType.java +++ b/runtime/java/src/main/java/org/ivoa/vodml/jpa/JPAManipulationsForObjectType.java @@ -3,8 +3,11 @@ * Created on 29/03/2022 by Paul Harrison (paul.harrison@manchester.ac.uk). */ +import jakarta.persistence.EntityManager; + /** * Interface to implement some common manipulations in JPA. + * This interface will be implemented on ObjectTypes. */ public interface JPAManipulationsForObjectType extends JPAManipulations { @@ -13,7 +16,13 @@ public interface JPAManipulationsForObjectType extends JPAManipulations { * @return the database ID. */ ID getId(); - - + + /** + * Delete the entity from the database. This will take into account any ordering necessary because of any contained references. + * If there are no contained references - then this will be equivalent to em.delete(this), however there might be some efficiency built in via bulk deletion. + * @param em the entity manager + */ + void delete(EntityManager em); + } diff --git a/tools/Developing.md b/tools/Developing.md index 9e58d98e..188088e0 100644 --- a/tools/Developing.md +++ b/tools/Developing.md @@ -18,6 +18,7 @@ of useful functions that can answer model questions such as "has subtypes" defin * There is a [sample](./gradletooling/sample) project that acts as a test bench for the plugin. +http://dh.obdurodon.org/xslt3.xhtml is a good summary of the new features in XSLT 3.0. ## Local testing diff --git a/tools/gradletooling/TODO.md b/tools/gradletooling/TODO.md index 8f5fab8f..bdca9b6b 100644 --- a/tools/gradletooling/TODO.md +++ b/tools/gradletooling/TODO.md @@ -127,4 +127,8 @@ VODML Tooling TODO * using dataclasses - need python 3.10 for the kw_only field specifier - might do better just generating multiple `__init__()` rather than relying on the dataclass generation. # Distribution - * need better directory structure on IVOA site.... \ No newline at end of file + * need better directory structure on IVOA site.... + + + + diff --git a/tools/gradletooling/gradle-plugin/src/main/kotlin/net/ivoa/vodml/gradle/plugin/VodmlGradlePlugin.kt b/tools/gradletooling/gradle-plugin/src/main/kotlin/net/ivoa/vodml/gradle/plugin/VodmlGradlePlugin.kt index 08331ff5..1ed7f31c 100644 --- a/tools/gradletooling/gradle-plugin/src/main/kotlin/net/ivoa/vodml/gradle/plugin/VodmlGradlePlugin.kt +++ b/tools/gradletooling/gradle-plugin/src/main/kotlin/net/ivoa/vodml/gradle/plugin/VodmlGradlePlugin.kt @@ -163,7 +163,7 @@ class VodmlGradlePlugin: Plugin { //add the dependencies for JAXB and JPA - using the hibernate implementation - listOf("org.javastro.ivoa.vo-dml:vodml-runtime:0.8.2", + listOf("org.javastro.ivoa.vo-dml:vodml-runtime:0.8.3", "jakarta.xml.bind:jakarta.xml.bind-api:4.0.0", "org.glassfish.jaxb:jaxb-runtime:4.0.2", // "org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.10", // supports JPA 2.2 diff --git a/tools/gradletooling/sample/build.gradle.kts b/tools/gradletooling/sample/build.gradle.kts index 65ff6182..037eaaaa 100644 --- a/tools/gradletooling/sample/build.gradle.kts +++ b/tools/gradletooling/sample/build.gradle.kts @@ -110,7 +110,7 @@ python { pip("pytest:7.3.1") pip("SQLAlchemy:2.0.30") pip("xsdata[lxml,cli]:24.5") - pip("pydantic:2.7.1") + pip("pydantic:2.9.2") pip("sqlmodel:0.0.22") pip("xsdata-pydantic:24.5") } diff --git a/tools/gradletooling/sample/src/test/java/org/ivoa/dm/lifecycle/LifeCycleDetailedTest.java b/tools/gradletooling/sample/src/test/java/org/ivoa/dm/lifecycle/LifeCycleDetailedTest.java index e88279fa..ae93cfa8 100644 --- a/tools/gradletooling/sample/src/test/java/org/ivoa/dm/lifecycle/LifeCycleDetailedTest.java +++ b/tools/gradletooling/sample/src/test/java/org/ivoa/dm/lifecycle/LifeCycleDetailedTest.java @@ -64,6 +64,8 @@ void setUp() throws Exception { model = new LifecycleTestModel(); // model.addContent(atest); model.addContent(atest2); + model.addContent(atest3); + } /** @@ -128,7 +130,29 @@ void copyTest() { // references assertEquals("rc1", atest2prime.refcont.test3); // should be pointing to above - // assertEquals("rc1" ,atest3.refBad.test3);//TODO not sure which way we want these to work. + // assertEquals("rc1" ,atest3.refBad.test3);//TODO not sure which way we want these to work - it is actually a failure of design + + } + + @Test + void deleteTest() { + jakarta.persistence.EntityManager em = + setupH2Db(SampleModel.pu_name()); // IMPL build means that everything is in one + // persistence unit. + em.getTransaction().begin(); + model.management().persistRefs(em); + em.persist(atest2); + em.getTransaction().commit(); + Long id = atest2.getId(); + // flush any existing entities + em.clear(); + em.getEntityManagerFactory().getCache().evictAll(); + ATest2 atest2in = em.createNamedQuery("ATest2.findById", ATest2.class).setParameter("id", id).getSingleResult(); + assertNotNull(atest2in); + em.getTransaction().begin(); + atest2in.delete(em); //IMPL + em.getTransaction().commit(); + } } diff --git a/tools/gradletooling/sample/src/test/java/org/ivoa/dm/serializationsample/SerializationExampleVocabTest.java b/tools/gradletooling/sample/src/test/java/org/ivoa/dm/serializationsample/SerializationExampleVocabTest.java index 72893bc6..85f79bd0 100644 --- a/tools/gradletooling/sample/src/test/java/org/ivoa/dm/serializationsample/SerializationExampleVocabTest.java +++ b/tools/gradletooling/sample/src/test/java/org/ivoa/dm/serializationsample/SerializationExampleVocabTest.java @@ -3,6 +3,8 @@ import static org.junit.jupiter.api.Assertions.fail; import org.junit.jupiter.api.Test; +import jakarta.persistence.EntityManager; + /* * Created on 16/05/2023 by Paul Harrison (paul.harrison@manchester.ac.uk). */ @@ -31,6 +33,13 @@ public BaseC copyMe() { "Type1728055728713.copyMe() not implemented"); } + + @Override + public void delete(EntityManager em) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("JPAManipulationsForObjectType.delete() not implemented"); + + } }, "eval"); fail("should have thown exception for value outside vocab"); } catch (Exception e) { diff --git a/tools/xslt/common-structure-functions.xsl b/tools/xslt/common-structure-functions.xsl index 923421af..67c0ea9a 100644 --- a/tools/xslt/common-structure-functions.xsl +++ b/tools/xslt/common-structure-functions.xsl @@ -308,11 +308,8 @@ note - only define functions in here as it is included in the schematron rules - - - - - + + @@ -544,15 +541,8 @@ note - only define functions in here as it is included in the schematron rules - - - - - - - - - + + diff --git a/tools/xslt/common.xsl b/tools/xslt/common.xsl index 49fcd4ca..8e7d8efe 100644 --- a/tools/xslt/common.xsl +++ b/tools/xslt/common.xsl @@ -161,7 +161,10 @@ - + + + + diff --git a/tools/xslt/jpa.xsl b/tools/xslt/jpa.xsl index 787fbb72..fe853fae 100644 --- a/tools/xslt/jpa.xsl +++ b/tools/xslt/jpa.xsl @@ -495,7 +495,46 @@ + + + + + /** + * {@inheritDoc} + */ + @Override + public void delete(jakarta.persistence.EntityManager em) { + + + + //has contained references + + //referred to by + + + + + + .stream().forEach(i -> em.remove(i)); + + + em.remove(); + + + + + em.remove(this); // finish up with itself. + + + em.remove(this); // nothing special to do + + + + } + + \ No newline at end of file diff --git a/tools/xslt/vo-dml2java.xsl b/tools/xslt/vo-dml2java.xsl index 7ea7d53e..739946dc 100644 --- a/tools/xslt/vo-dml2java.xsl +++ b/tools/xslt/vo-dml2java.xsl @@ -762,6 +762,7 @@ + diff --git a/tools/xslt/vo-dml2md.xsl b/tools/xslt/vo-dml2md.xsl index 94b861f5..36fd6b0f 100644 --- a/tools/xslt/vo-dml2md.xsl +++ b/tools/xslt/vo-dml2md.xsl @@ -397,7 +397,7 @@ classDiagram - + diff --git a/xsd/vo-dml-binding.xsd b/xsd/vo-dml-binding.xsd index a9eee633..32288334 100644 --- a/xsd/vo-dml-binding.xsd +++ b/xsd/vo-dml-binding.xsd @@ -77,7 +77,12 @@ targetNamespace="http://www.ivoa.net/xml/vodml-binding/v0.9.1" attributeFormDefa the list of type mappings for the model. - + + + the list of type detail the model. + + +