From 54258abf5edf75ea4a615fb99bb55cf432655b61 Mon Sep 17 00:00:00 2001 From: Paul Harrison Date: Tue, 18 Jun 2024 14:56:58 +0100 Subject: [PATCH] allow references to be aggregated all unit-tests working - though perhaps there should be more functions generated to managed the aggregation in the instances. --- models/sample/test/lifecycleTest.vo-dml.xml | 4 +- models/sample/test/lifecycleTest.vodsl | 2 +- .../dm/lifecycle/LifeCycleDetailedTest.java | 14 ++++-- .../dm/lifecycle/LifecycleTestModelTest.java | 2 +- tools/xslt/common-structure-functions.xsl | 49 +++++++++++++------ tools/xslt/jpa.xsl | 16 ++++-- tools/xslt/vo-dml2java.xsl | 49 ++++++++++++++++--- 7 files changed, 101 insertions(+), 35 deletions(-) diff --git a/models/sample/test/lifecycleTest.vo-dml.xml b/models/sample/test/lifecycleTest.vo-dml.xml index 823680e8..d73d6484 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-05-16T19:27:45Z + 2024-06-13T14:50:55Z null IVOA-v1.0.vo-dml.xml @@ -120,7 +120,7 @@ 1 - 1 + -1 diff --git a/models/sample/test/lifecycleTest.vodsl b/models/sample/test/lifecycleTest.vodsl index 51829577..89da5fca 100644 --- a/models/sample/test/lifecycleTest.vodsl +++ b/models/sample/test/lifecycleTest.vodsl @@ -31,7 +31,7 @@ otype ATest2 { it is more a lifecycle matter really - as long as there is nothing that can * delete the referredTo otype */ - refagg references ReferredTo ""; + refagg @+ references ReferredTo ""; atest : ATest as composition ""; refcont references ReferredLifeCycle ""; // potentially not OK (should be an error if referenced by something outside the object tree) - here the referred otype is also contained, so the 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 d2643da0..8036e16f 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 @@ -54,7 +54,7 @@ void setUp() throws Exception { a.contained = contained; a.refandcontained = refcont; }); - atest2 = new ATest2(referredTo, atest, refcont.get(0)); + atest2 = new ATest2(Arrays.asList(referredTo), atest, refcont.get(0)); atest3 = new ATest3( contained, refcont.get(0)); // TODO this will create contradictions.... how best to test @@ -98,22 +98,26 @@ void MultiContainedJPATest() { @Test void copyTest() { + model.createContext(); ATest atestprime = new ATest(atest); - atest.ref1.test1 = 4; + atest.ref1.test1 = 4; //change the original assertEquals(4, atestprime.ref1.test1); // the reference should have changed + + //now just change one of the contained atest.contained.get(0).test2 = "changed"; assertEquals( "firstcontained", atestprime.contained.get(0) - .test2); // new objects created for the contained so changing original - // should not affect the prime + .test2); // new objects created for the contained so changing original should not affect the prime + //now clone something with "contained" references ATest2 atest2prime = new ATest2(atest2); atest2.atest.refandcontained.get(0).test3 = "changed2"; assertEquals("changed2", atest2.refcont.test3); // this is in atest3 - + + //TODO this API feels unnatural... atest2prime.updateClonedReferences(); assertEquals( "rc1", diff --git a/tools/gradletooling/sample/src/test/java/org/ivoa/dm/lifecycle/LifecycleTestModelTest.java b/tools/gradletooling/sample/src/test/java/org/ivoa/dm/lifecycle/LifecycleTestModelTest.java index 39a8b2a4..885d4f32 100644 --- a/tools/gradletooling/sample/src/test/java/org/ivoa/dm/lifecycle/LifecycleTestModelTest.java +++ b/tools/gradletooling/sample/src/test/java/org/ivoa/dm/lifecycle/LifecycleTestModelTest.java @@ -67,7 +67,7 @@ public LifecycleTestModel createModel() { a.contained = contained; a.refandcontained = refcont; }); - atest2 = new ATest2( referredTo, atest, refcont.get(0)); + atest2 = new ATest2( Arrays.asList(referredTo), atest, refcont.get(0)); LifecycleTestModel model = new LifecycleTestModel(); model.addContent(atest); diff --git a/tools/xslt/common-structure-functions.xsl b/tools/xslt/common-structure-functions.xsl index 5418f08b..17bc0ec0 100644 --- a/tools/xslt/common-structure-functions.xsl +++ b/tools/xslt/common-structure-functions.xsl @@ -159,9 +159,11 @@ note - only define functions in here as it is included in the schematron rules + + @@ -219,8 +221,16 @@ note - only define functions in here as it is included in the schematron rules + + + + + + + + + - @@ -231,13 +241,7 @@ note - only define functions in here as it is included in the schematron rules - - - - - - - + @@ -247,6 +251,27 @@ note - only define functions in here as it is included in the schematron rules + + + + + + + + + + + + + + + + type '' not in considered models + + + + + @@ -257,13 +282,7 @@ note - only define functions in here as it is included in the schematron rules - - - - - - - + diff --git a/tools/xslt/jpa.xsl b/tools/xslt/jpa.xsl index 84b39bf9..bf754489 100644 --- a/tools/xslt/jpa.xsl +++ b/tools/xslt/jpa.xsl @@ -353,9 +353,19 @@ // TODO [NOT_SUPPORTED_REFERENCE] - - @jakarta.persistence.ManyToOne( cascade = { jakarta.persistence.CascadeType.REFRESH } ) - @jakarta.persistence.JoinColumn( nullable = ) + + + + +@jakarta.persistence.ManyToMany( cascade = { jakarta.persistence.CascadeType.REFRESH } ) + + + +@jakarta.persistence.ManyToOne( cascade = { jakarta.persistence.CascadeType.REFRESH } ) +@jakarta.persistence.JoinColumn( nullable = ) + + + diff --git a/tools/xslt/vo-dml2java.xsl b/tools/xslt/vo-dml2java.xsl index 4a4edf27..17b68a8e 100644 --- a/tools/xslt/vo-dml2java.xsl +++ b/tools/xslt/vo-dml2java.xsl @@ -514,8 +514,10 @@ + - + + ; ; ; @@ -902,7 +904,7 @@ package ; protected ; - + protected ; @@ -1175,7 +1177,7 @@ package ; } - + for( c : ) { c.forceLoad(); } @@ -1271,7 +1273,7 @@ package ; - + /** * ReferenceObject : @@ -1284,13 +1286,21 @@ package ; - protected &bl; = null; + + + protected ; + + + protected &bl; = null; + + + - + @@ -1313,10 +1323,33 @@ package ; } + + + + + + + + /** + * Returns Reference
+ * @return Reference + */ + public List<>&bl;get() { + return this.; + } + /** + * Defines Reference + * @param p references to set + */ + public void set(final List<> p) { + this. = p; + } +
- + /**