Skip to content

Commit

Permalink
start towards making jpa optional
Browse files Browse the repository at this point in the history
this is the beginnings of implementing #47 - but decided not to progress further for this release.
  • Loading branch information
pahjbo committed Jun 27, 2024
1 parent da4d6ad commit b567370
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions tools/xslt/vo-dml2java.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
<xsl:param name="output_root" />
<xsl:param name="vo-dml_package" select="'org.ivoa.vodml.model'"/>
<xsl:param name="binding"/>
<xsl:param name="isMain"/>

<xsl:param name="do_jpa" select="true()"/>
<xsl:param name="write_persistence_xml" select="false()"/>


<xsl:include href="binding_setup.xsl"/>
<xsl:param name="isMain"/>
<xsl:include href="binding_setup.xsl"/>

<!-- main pattern : processes for root node model -->
<xsl:template match="/">
Expand Down Expand Up @@ -98,7 +98,9 @@
<xsl:with-param name="path" select="$root_package"/>
</xsl:apply-templates>
<xsl:if test="$isMain eq 'True'">
<xsl:if test="$do_jpa">
<xsl:apply-templates select="." mode="jpaConfig" />
</xsl:if>
</xsl:if>
</xsl:template>

Expand Down Expand Up @@ -599,7 +601,7 @@
*
* <xsl:value-of select="$vodmlauthor"/>
*/
<xsl:apply-templates select="." mode="JPAAnnotation"/>
<xsl:if test="$do_jpa"><xsl:apply-templates select="." mode="JPAAnnotation"/></xsl:if>
<xsl:apply-templates select="." mode="JAXBAnnotation"/>
<xsl:call-template name="vodmlAnnotation"/>
<xsl:apply-templates select="." mode="openapiAnnotation"/>
Expand Down Expand Up @@ -821,7 +823,7 @@ package <xsl:value-of select="$path"/>;
*/
<xsl:call-template name="vodmlAnnotation"/>
<xsl:apply-templates select="." mode="openapiAnnotation"/>
<xsl:apply-templates select="." mode="JPAAnnotation"/>
<xsl:if test="$do_jpa"><xsl:apply-templates select="." mode="JPAAnnotation"/></xsl:if>
<xsl:apply-templates select="." mode="JAXBAnnotation"/>
public class&bl;<xsl:if test="@abstract='true'">abstract</xsl:if>&bl;<xsl:value-of select="vf:capitalize(name)"/>&bl;
implements java.io.Serializable {
Expand Down Expand Up @@ -897,7 +899,7 @@ package <xsl:value-of select="$path"/>;
@jakarta.persistence.Transient
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="JPAAnnotation"/>
<xsl:if test="$do_jpa"><xsl:apply-templates select="." mode="JPAAnnotation"/></xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
Expand Down Expand Up @@ -936,13 +938,16 @@ package <xsl:value-of select="$path"/>;
<xsl:variable name="name" select="tokenize(role/vodml-ref/text(),'[.]')[last()]"/>
<xsl:if test="name($subsetted)='attribute' and datatype/vodml-ref != $subsetted/datatype/vodml-ref"> <!-- only do this if types are different (subsetting can change just the semantic stuff)-->

<xsl:if test="$do_jpa">
<xsl:call-template name="doEmbeddedJPA">
<xsl:with-param name="name" select="$name"/>
<xsl:with-param name="type" select="$models/key('ellookup',current()/datatype/vodml-ref)"/>
<xsl:with-param name="nillable" >true</xsl:with-param><!--TODO think if it is possible to do better with nillable value-->
</xsl:call-template>

@jakarta.persistence.Access(jakarta.persistence.AccessType.PROPERTY)
</xsl:if>
</xsl:if>
<xsl:call-template name="doGetSet">
<xsl:with-param name="name" select="$name"/>
<xsl:with-param name="mult" select="$models/key('ellookup',current()/role/vodml-ref)/multiplicity"/>
Expand Down Expand Up @@ -1053,7 +1058,7 @@ package <xsl:value-of select="$path"/>;
* )
*/
<xsl:apply-templates select="." mode="JAXBAnnotation"/>
<xsl:apply-templates select="." mode="JPAAnnotation"/>
<xsl:if test="$do_jpa"><xsl:apply-templates select="." mode="JPAAnnotation"/></xsl:if>
<xsl:call-template name="vodmlAnnotation"/>
<xsl:apply-templates select="." mode="openapiAnnotation"/>
<xsl:choose>
Expand All @@ -1077,7 +1082,7 @@ package <xsl:value-of select="$path"/>;
* )
*/
<xsl:apply-templates select="." mode="JAXBAnnotation"/>
<xsl:apply-templates select="." mode="JPAAnnotation"/>
<xsl:if test="$do_jpa"><xsl:apply-templates select="." mode="JPAAnnotation"/></xsl:if>
<xsl:call-template name="vodmlAnnotation"/>
<xsl:apply-templates select="." mode="openapiAnnotation"/>
protected <xsl:value-of select="$type"/>&bl;<xsl:value-of select="vf:javaMemberName(name)"/> = null;
Expand Down Expand Up @@ -1282,7 +1287,7 @@ package <xsl:value-of select="$path"/>;
* Multiplicity : <xsl:apply-templates select="multiplicity" mode="tostring"/>
* )
*/
<xsl:apply-templates select="." mode="JPAAnnotation"/>
<xsl:if test="$do_jpa"><xsl:apply-templates select="." mode="JPAAnnotation"/></xsl:if>
<xsl:apply-templates select="." mode="JAXBAnnotation"/>
<xsl:call-template name="vodmlAnnotation"/>
<xsl:apply-templates select="." mode="openapiAnnotation"/>
Expand Down Expand Up @@ -1420,7 +1425,7 @@ package <xsl:value-of select="$path"/>;

<!-- specific documents -->

<!-- ModelVersion.java -->
<!-- ModelVersion.java - deprecated -->
<xsl:template match="vo-dml:model" mode="modelFactory">
<xsl:param name="root_package"/>
<xsl:param name="root_package_dir"/>
Expand Down

0 comments on commit b567370

Please sign in to comment.