/[volute]/trunk/projects/theory/snapdm/res/jpa.xsl
ViewVC logotype

Diff of /trunk/projects/theory/snapdm/res/jpa.xsl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 359 by gerard.lemson, Fri May 2 06:20:01 2008 UTC revision 360 by bourges.laurent, Mon May 5 18:18:10 2008 UTC
# Line 7  Line 7 
7  ]>  ]>
8    
9  <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
10      
11    <!--    <!--
12      Common templates used by XSLT scripts      Common templates used by XSLT scripts
13    -->    -->
14    <xsl:import href="common-ddl.xsl"/>    <xsl:import href="common-ddl.xsl"/>
15        
16    <xsl:output name="persistenceInfo" method="xml" encoding="UTF-8" indent="yes" />    <xsl:output name="persistenceInfo" method="xml" encoding="UTF-8" indent="yes"  />
17    
18  <!-- Configuraiton parameters, set in build.properties -->  
19    <xsl:param name="eclipseLink.jdbc.url"/>  <!-- Configuraiton parameters, set in build.properties -->
20      <xsl:param name="eclipseLink.jdbc.url"/>
21    <xsl:param name="eclipseLink.jdbc.user"/>  
22    <xsl:param name="eclipseLink.jdbc.password"/>    <xsl:param name="eclipseLink.jdbc.user"/>
23      <xsl:param name="eclipseLink.jdbc.password"/>
24    <xsl:param name="eclipseLink.jdbc.driver"/>  
25    <xsl:param name="eclipseLink.jdbc.read-connections.min"/>    <xsl:param name="eclipseLink.jdbc.driver"/>
26    <xsl:param name="eclipseLink.jdbc.read-connections.max"/>    <xsl:param name="eclipseLink.jdbc.read-connections.min"/>
27    <xsl:param name="eclipseLink.jdbc.write-connections.min"/>    <xsl:param name="eclipseLink.jdbc.read-connections.max"/>
28    <xsl:param name="eclipseLink.jdbc.write-connections.max"/>    <xsl:param name="eclipseLink.jdbc.write-connections.min"/>
29      <xsl:param name="eclipseLink.jdbc.write-connections.max"/>
30    
31    
32    
33    <xsl:key name="element" match="*//*" use="@xmiid"/>    <xsl:key name="element" match="*//*" use="@xmiid"/>
34    
# Line 112  Line 113 
113    
114    
115    <xsl:template match="reference" mode="JPAAnnotation">    <xsl:template match="reference" mode="JPAAnnotation">
116      @ManyToOne      @Transient
117  <!--    @Column(name="<xsl:apply-templates select="." mode="columnName"/>") -->  <!--    @Column(name="<xsl:apply-templates select="." mode="columnName"/>") -->
118    </xsl:template>    </xsl:template>
119        
# Line 173  Line 174 
174    
175    
176    
   
177        
178        
179        
# Line 182  Line 182 
182        
183    <xsl:template match="model" mode="jpaConfig">    <xsl:template match="model" mode="jpaConfig">
184      <xsl:variable name="file" select="'META-INF/persistence.xml'"/>      <xsl:variable name="file" select="'META-INF/persistence.xml'"/>
185        
186        <!-- reading persistence-template.xml file : -->
187        
188        <xsl:variable name="jpaConf" select="document('./persistence.xml')"/>
189        
190      <!-- open file for global jpa configuration -->      <!-- open file for global jpa configuration -->
191      <xsl:message >Opening file <xsl:value-of select="$file"/></xsl:message>      <xsl:message >Opening file <xsl:value-of select="$file"/></xsl:message>
192      <xsl:result-document href="{$file}" format="persistenceInfo">      <xsl:result-document href="{$file}" format="persistenceInfo">
193  <persistence version="1.0"  
194               xmlns="http://java.sun.com/xml/ns/persistence"  <xsl:apply-templates select="$jpaConf" mode="otherXml">
195               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    <xsl:with-param name="model" select="."/>
196               xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">  </xsl:apply-templates>
197  &cr;  
198        </xsl:result-document>
199      </xsl:template>
200    
201    
202    
203    
204      <xsl:template match="@*|node()" mode="otherXml">
205        <xsl:param name="model"/>
206    
207        <xsl:choose>
208          <xsl:when test="name() = 'properties'">
209  &cr;  &cr;
   <persistence-unit name="SnapDbPU" transaction-type="RESOURCE_LOCAL">  
     <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>  
210  &cr;  &cr;
211    <xsl:comment>generated JPA entities</xsl:comment>
212  &cr;  &cr;
     <xsl:comment>generated JPA entities</xsl:comment>  
213  &cr;  &cr;
214    <xsl:for-each select="$model/package">
215      <xsl:call-template name="packageJpaConfig">
216        <xsl:with-param name="package" select="."/>
217        <xsl:with-param name="path" select="$root_package"/>
218      </xsl:call-template>
219    </xsl:for-each>
220  &cr;  &cr;
     <xsl:for-each select="package">  
       <xsl:call-template name="packageJpaConfig">  
         <xsl:with-param name="path" select="$root_package"/>  
       </xsl:call-template>  
     </xsl:for-each>  
221  &cr;  &cr;
222      <xsl:comment>JPA Properties</xsl:comment>  <xsl:comment>JPA Properties</xsl:comment>
223  &cr;  &cr;
224  &cr;  &cr;
225      <properties>  <xsl:element name="properties" namespace="http://java.sun.com/xml/ns/persistence">
226            
227  <!--    <xsl:apply-templates select="child::*"  mode="otherXml"/>
228        <property name="eclipselink.ddl-generation" value="create-tables"/>    
  -->        
       <!-- local -->  
       <property name="eclipseLink.jdbc.url">  
         <xsl:attribute name="value" select="$eclipseLink.jdbc.url"/>  
       </property>  
       <property name="eclipseLink.jdbc.user">  
         <xsl:attribute name="value" select="$eclipseLink.jdbc.user"/>  
       </property>  
       <property name="eclipseLink.jdbc.password">  
         <xsl:attribute name="value" select="$eclipseLink.jdbc.password"/>  
       </property>  
       <property name="eclipseLink.jdbc.driver">  
         <xsl:attribute name="value" select="$eclipseLink.jdbc.driver"/>  
       </property>  
       <property name="eclipseLink.jdbc.read-connections.min">  
         <xsl:attribute name="value" select="$eclipseLink.jdbc.read-connections.min"/>  
       </property>  
       <property name="eclipseLink.jdbc.read-connections.max">  
         <xsl:attribute name="value" select="$eclipseLink.jdbc.read-connections.max"/>  
       </property>  
       <property name="eclipseLink.jdbc.write-connections.min">  
         <xsl:attribute name="value" select="$eclipseLink.jdbc.write-connections.min"/>  
       </property>  
       <property name="eclipseLink.jdbc.write-connections.max">  
         <xsl:attribute name="value" select="$eclipseLink.jdbc.write-connections.max"/>  
       </property>  
229  &cr;  &cr;
230  &cr;  &cr;
231  <xsl:comment>  <xsl:comment>
232          SQL Log :    &lt;property name="eclipseLink.cache.type.Cardinality" value="Full"/&gt;
233            OFF - disable logging    &lt;property name="eclipseLink.cache.type.DataType" value="Full"/&gt;
           SEVERE - Logs exceptions indicating eclipseLink cannot continue, as well as any exceptions generated during login. This includes a stack trace.  
           WARNING - Logs exceptions that do not force eclipseLink to stop, including all exceptions not logged with severe level. This does not include a stack trace.  
           INFO - Logs the login/logout per sever session, including the user name. After acquiring the session, detailed information is logged.  
           CONFIG - Logs only login, JDBC connection, and database information.  
           FINE - Logs SQL.  
           FINER - Similar to warning. Includes stack trace.  
           FINEST - Includes additional low level information.  
234  </xsl:comment>  </xsl:comment>
 &cr;  
 &cr;  
       <property name="eclipseLink.logging.level" value="INFO"/>  
 &cr;  
 &cr;  
       <xsl:comment> cache : NONE, Full, HardWeak, SoftWeak, Weak : </xsl:comment>  
 &cr;  
 &cr;  
       <property name="eclipseLink.cache.size.default" value="5000"/>  
       <property name="eclipseLink.cache.type.default" value="HardWeak"/>  
       <property name="eclipseLink.cache.shared.default" value="true"/>  
 &cr;  
 &cr;  
       <xsl:comment> entity cache : NONE, Full, HardWeak, SoftWeak, Weak : </xsl:comment>  
 &cr;  
 &cr;  
       <property name="eclipseLink.cache.type.Cardinality" value="Full"/>  
       <property name="eclipseLink.cache.type.DataType" value="Full"/>  
     </properties>  
   </persistence-unit>  
 </persistence>  
     </xsl:result-document>  
   </xsl:template>  
   
   
235    
236    </xsl:element>
237    
238          </xsl:when>
239          <xsl:otherwise>
240            <xsl:copy>
241              <xsl:apply-templates select="@*|node()"  mode="otherXml">
242                <xsl:with-param name="model" select="$model"/>
243              </xsl:apply-templates>        
244            </xsl:copy>    
245            </xsl:otherwise>
246        </xsl:choose>
247        
248      </xsl:template>
249      
250      
251      
252      
253    <xsl:template name="packageJpaConfig">    <xsl:template name="packageJpaConfig">
254        <xsl:param name="package"/>
255      <xsl:param name="path"/>      <xsl:param name="path"/>
256            
257      <xsl:variable name="newpath">      <xsl:variable name="newpath">
258        <xsl:choose>        <xsl:choose>
259          <xsl:when test="$path">          <xsl:when test="$path">
260            <xsl:value-of select="concat($path,'.',name)"/>            <xsl:value-of select="concat($path,'.',$package/name)"/>
261          </xsl:when>          </xsl:when>
262          <xsl:otherwise>          <xsl:otherwise>
263            <xsl:value-of select="name"/>            <xsl:value-of select="$package/name"/>
264          </xsl:otherwise>          </xsl:otherwise>
265        </xsl:choose>        </xsl:choose>
266      </xsl:variable>      </xsl:variable>
267            
268      <xsl:message>package = <xsl:value-of select="$newpath"></xsl:value-of></xsl:message>      <xsl:message>package = <xsl:value-of select="$newpath"></xsl:value-of></xsl:message>
269            
270      <xsl:for-each select="objectType|dataType">      <xsl:for-each select="$package/objectType|$package/dataType">
271        <xsl:element name="class" namespace="http://java.sun.com/xml/ns/persistence">        <xsl:element name="class" namespace="http://java.sun.com/xml/ns/persistence">
272          <xsl:value-of select="$newpath"/><xsl:text>.</xsl:text><xsl:value-of select="name"/>          <xsl:value-of select="$newpath"/><xsl:text>.</xsl:text><xsl:value-of select="name"/>
273        </xsl:element>        </xsl:element>
274      </xsl:for-each>      </xsl:for-each>
275            
276      <xsl:for-each select="package">      <xsl:for-each select="$package/package">
277        <xsl:call-template name="packageJpaConfig">        <xsl:call-template name="packageJpaConfig">
278            <xsl:with-param name="package" select="."/>
279          <xsl:with-param name="path" select="$newpath"/>          <xsl:with-param name="path" select="$newpath"/>
280        </xsl:call-template>        </xsl:call-template>
281      </xsl:for-each>      </xsl:for-each>

Legend:
Removed from v.359  
changed lines
  Added in v.360

msdemlei@ari.uni-heidelberg.de
ViewVC Help
Powered by ViewVC 1.1.26