You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/11/29 00:08:18 UTC

svn commit: r1414982 [3/5] - in /archiva/redback/redback-components/trunk/modello-plugins: ./ modello-db-keywords/ modello-db-keywords/src/ modello-db-keywords/src/main/ modello-db-keywords/src/main/java/ modello-db-keywords/src/main/java/org/ modello-...

Added: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/metadata/JPoxMetadataPlugin.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/metadata/JPoxMetadataPlugin.java?rev=1414982&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/metadata/JPoxMetadataPlugin.java (added)
+++ archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/metadata/JPoxMetadataPlugin.java Wed Nov 28 23:08:08 2012
@@ -0,0 +1,385 @@
+package org.codehaus.modello.plugin.jpox.metadata;
+
+/*
+ * Copyright (c) 2005, Codehaus.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import org.codehaus.modello.ModelloException;
+import org.codehaus.modello.metadata.AbstractMetadataPlugin;
+import org.codehaus.modello.metadata.AssociationMetadata;
+import org.codehaus.modello.metadata.ClassMetadata;
+import org.codehaus.modello.metadata.FieldMetadata;
+import org.codehaus.modello.metadata.ModelMetadata;
+import org.codehaus.modello.model.Model;
+import org.codehaus.modello.model.ModelAssociation;
+import org.codehaus.modello.model.ModelClass;
+import org.codehaus.modello.model.ModelField;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
+ * @version $Id: JPoxMetadataPlugin.java 829 2007-03-22 14:32:42Z joakime $
+ */
+public class JPoxMetadataPlugin extends AbstractMetadataPlugin
+{
+    public static final String ENABLED = "jpox.enabled";
+
+    public static final String DEPENDENT = "jpox.dependent";
+
+    public static final String DETACHABLE = "jpox.detachable";
+
+    public static final String FETCH_GROUPS = "jpox.fetch-groups";
+
+    public static final String NOT_PERSISTED_FIELDS = "jpox.not-persisted-fields";
+
+    public static final String JOIN = "jpox.join";
+
+    public static final String MAPPED_BY = "jpox.mapped-by";
+
+    public static final String NULL_VALUE = "jpox.null-value";
+
+    public static final String TABLE = "jpox.table";
+
+    public static final String TABLE_PREFIX = "jpox.table-prefix";
+
+    public static final String COLUMN = "jpox.column";
+
+    public static final String COLUMN_PREFIX = "jpox.column-prefix";
+
+    public static final String RESERVED_WORD_STRICTNESS = "jpox.reserved-word-strictness";
+
+    public static final String MAPPING_IN_PACKAGE = "jpox.mapping-in-package";
+
+    public static final String JOIN_TABLE = "jpox.join-table";
+
+    public static final String INDEXED = "jpox.indexed";
+
+    public static final String PRIMARY_KEY = "jpox.primary-key";
+
+    public static final String UNIQUE = "jpox.unique";
+
+    public static final String FOREIGN_KEY_DEFERRED = "jpox.foreign-key-deferred";
+
+    public static final String FOREIGN_KEY_DELETE_ACTION = "jpox.foreign-key-delete-action";
+
+    public static final String FOREIGN_KEY_UPDATE_ACTION = "jpox.foreign-key-update-action";
+
+    public static final String VALUE_STRATEGY = "jpox.value-strategy";
+
+    public static final String PERSISTENCE_MODIFIER = "jpox.persistence-modifier";
+
+    public static final String IDENTITY_TYPE = "jpox.identity-type";
+
+    public static final String IDENTITY_CLASS = "jpox.identity-class";
+
+    public static final String USE_IDENTIFIERS = "jpox.use-identifiers-as-primary-key";
+
+    // ----------------------------------------------------------------------
+    // Map to Metadata
+    // ----------------------------------------------------------------------
+
+    public ModelMetadata getModelMetadata( Model model, Map data )
+    {
+        JPoxModelMetadata metadata = new JPoxModelMetadata();
+
+        String columnPrefix = (String) data.get( COLUMN_PREFIX );
+
+        if ( StringUtils.isNotEmpty( columnPrefix ) )
+        {
+            metadata.setColumnPrefix( columnPrefix );
+        }
+
+        String tablePrefix = (String) data.get( TABLE_PREFIX );
+
+        if ( StringUtils.isNotEmpty( tablePrefix ) )
+        {
+            metadata.setTablePrefix( tablePrefix );
+        }
+
+        metadata.setMappingInPackage( getBoolean( data, MAPPING_IN_PACKAGE, false ) );
+
+        String reservedWordStrictness = (String) data.get( RESERVED_WORD_STRICTNESS );
+
+        // Set default.
+        metadata.setReservedWordStrictness( JPoxModelMetadata.WARNING );
+
+        // Set based on provided.
+        if ( StringUtils.isNotEmpty( reservedWordStrictness ) )
+        {
+            if ( JPoxModelMetadata.ERROR.equalsIgnoreCase( reservedWordStrictness ) )
+            {
+                metadata.setReservedWordStrictness( JPoxModelMetadata.ERROR );
+            }
+            else if ( JPoxModelMetadata.WARNING.equalsIgnoreCase( reservedWordStrictness ) )
+            {
+                metadata.setReservedWordStrictness( JPoxModelMetadata.WARNING );
+            }
+            else
+            {
+                getLogger().warn(
+                                  "Unknown reserved word strictness value: '" + reservedWordStrictness + "'.  "
+                                                  + "Only '" + JPoxModelMetadata.ERROR + "' and '"
+                                                  + JPoxModelMetadata.WARNING
+                                                  + "' are acceptable inputs.  Defaulting to 'warning'." );
+            }
+        }
+
+        return metadata;
+    }
+
+    public ClassMetadata getClassMetadata( ModelClass clazz, Map data ) throws ModelloException
+    {
+        JPoxClassMetadata metadata = new JPoxClassMetadata();
+
+        metadata.setEnabled( getBoolean( data, ENABLED, true ) );
+        metadata.setDetachable( getBoolean( data, DETACHABLE, true ) );
+
+        String notPersistedFields = (String) data.get( NOT_PERSISTED_FIELDS );
+
+        if ( !StringUtils.isEmpty( notPersistedFields ) )
+        {
+            List ignoredFields = Arrays.asList( StringUtils.split( notPersistedFields ) );
+
+            metadata.setNotPersisted( ignoredFields );
+        }
+
+        String table = (String) data.get( TABLE );
+
+        if ( !StringUtils.isEmpty( table ) )
+        {
+            metadata.setTable( table );
+        }
+
+        String columnPrefix = (String) data.get( COLUMN_PREFIX );
+
+        if ( !StringUtils.isEmpty( columnPrefix ) )
+        {
+            metadata.setColumnPrefix( columnPrefix );
+        }
+
+        String identityType = (String) data.get( IDENTITY_TYPE );
+
+        if ( StringUtils.isNotEmpty( identityType ) )
+        {
+            metadata.setIdentityType( identityType );
+        }
+
+        String identityClass = (String) data.get( IDENTITY_CLASS );
+
+        if ( StringUtils.isNotEmpty( identityClass ) )
+        {
+            metadata.setIdentityClass( identityClass );
+        }
+
+        metadata.setUseIdentifiersAsPrimaryKey( getBoolean( data, USE_IDENTIFIERS, true ) );
+
+        return metadata;
+    }
+
+    public FieldMetadata getFieldMetadata( ModelField field, Map data ) throws ModelloException
+    {
+        JPoxFieldMetadata metadata = new JPoxFieldMetadata();
+
+        JPoxClassMetadata classMetadata = (JPoxClassMetadata) field.getModelClass().getMetadata( JPoxClassMetadata.ID );
+
+        boolean useIdentifiersAsPrimaryKey = classMetadata.useIdentifiersAsPrimaryKey();
+
+        metadata.setPrimaryKey( getBoolean( data, PRIMARY_KEY, ( field.isIdentifier() && useIdentifiersAsPrimaryKey ) ) );
+
+        // Backwards Compatibility Syntax.
+        String fetchGroupNames = (String) data.get( "jpox.fetchGroupNames" );
+
+        if ( fetchGroupNames != null )
+        {
+            getLogger().warn(
+                              "You are using the <field jpox.fetchGroupNames=\"\"> attribute syntax.  "
+                                              + "It has been deprecated in favor of the <field jpox.fetch-groups=\"\"> syntax instead." );
+        }
+        else
+        {
+            // Correct Syntax.
+            fetchGroupNames = (String) data.get( FETCH_GROUPS );
+        }
+
+        if ( !StringUtils.isEmpty( fetchGroupNames ) )
+        {
+            List fetchGroups = Arrays.asList( StringUtils.split( fetchGroupNames ) );
+
+            metadata.setFetchGroupNames( fetchGroups );
+        }
+
+        // Backwards Compatibility Syntax.
+        String mappedBy = (String) data.get( "jpox.mappedBy" );
+
+        if ( mappedBy != null )
+        {
+            getLogger().warn(
+                              "You are using the <field jpox.mappedBy=\"\"> attribute syntax.  "
+                                              + "It has been deprecated in favor of the <field jpox.mapped-by=\"\"> syntax instead." );
+        }
+        else
+        {
+            // Correct Syntax.
+            mappedBy = (String) data.get( MAPPED_BY );
+        }
+
+        if ( !StringUtils.isEmpty( mappedBy ) )
+        {
+            metadata.setMappedBy( mappedBy );
+        }
+
+        // Backwards Compatibility Syntax.
+        String nullValue = (String) data.get( "jpox.nullValue" );
+
+        if ( nullValue != null )
+        {
+            getLogger().warn(
+                              "You are using the <field jpox.nullValue=\"\"> attribute syntax.  "
+                                              + "It has been deprecated in favor of the <field jpox.null-value=\"\"> syntax instead." );
+        }
+        else
+        {
+            // Correct Syntax.
+            nullValue = (String) data.get( NULL_VALUE );
+        }
+
+        if ( !StringUtils.isEmpty( nullValue ) )
+        {
+            metadata.setNullValue( nullValue );
+        }
+
+        String column = (String) data.get( COLUMN );
+
+        if ( StringUtils.isNotEmpty( column ) )
+        {
+            metadata.setColumnName( column );
+        }
+
+        String joinTable = (String) data.get( JOIN_TABLE );
+
+        if ( StringUtils.isNotEmpty( joinTable ) )
+        {
+            metadata.setJoinTableName( joinTable );
+        }
+
+        String indexed = (String) data.get( INDEXED );
+
+        if ( StringUtils.isNotEmpty( indexed ) )
+        {
+            metadata.setIndexed( indexed );
+        }
+
+        String persistenceModifier = (String) data.get( PERSISTENCE_MODIFIER );
+
+        if ( StringUtils.isNotEmpty( persistenceModifier ) )
+        {
+            metadata.setPersistenceModifier( persistenceModifier );
+        }
+
+        // According to http://www.jpox.org/docs/1_1/identity_generation.html the default value for
+        // this should be 'native', however this is untrue in jpox-1.1.1
+        metadata.setValueStrategy( "native" );
+
+        if ( StringUtils.isNotEmpty( (String) data.get( VALUE_STRATEGY ) ) )
+        {
+            String valueStrategy = (String) data.get( VALUE_STRATEGY );
+
+            if ( StringUtils.equals( valueStrategy, "off" ) )
+            {
+                metadata.setValueStrategy( null );
+            }
+            else
+            {
+                metadata.setValueStrategy( valueStrategy );
+            }
+        }
+
+        metadata.setUnique( getBoolean( data, UNIQUE, false ) );
+        metadata.setForeignKey( getBoolean( data, FOREIGN_KEY_DEFERRED, false ) );
+        metadata.setForeignKeyDeferred( getEnumString( data, FOREIGN_KEY_DEFERRED, JPoxFieldMetadata.BOOLEANS, null ) );
+        metadata.setForeignKeyDeleteAction( getEnumString( data, FOREIGN_KEY_DELETE_ACTION,
+                                                           JPoxFieldMetadata.FOREIGN_KEY_ACTIONS, null ) );
+        metadata.setForeignKeyUpdateAction( getEnumString( data, FOREIGN_KEY_UPDATE_ACTION,
+                                                           JPoxFieldMetadata.FOREIGN_KEY_ACTIONS, null ) );
+
+        return metadata;
+    }
+
+    public AssociationMetadata getAssociationMetadata( ModelAssociation association, Map data ) throws ModelloException
+    {
+        JPoxAssociationMetadata metadata = new JPoxAssociationMetadata();
+
+        metadata.setDependent( getBoolean( data, DEPENDENT, true ) );
+
+        metadata.setJoin( getBoolean( data, JOIN, true ) );
+
+        return metadata;
+    }
+
+    protected String getString( Map data, String key, String defaultValue )
+    {
+        String value = (String) data.get( key );
+
+        if ( StringUtils.isEmpty( value ) )
+        {
+            return defaultValue;
+        }
+
+        return value;
+    }
+
+    protected String getEnumString( Map data, String key, String[] legalValues, String defaultValue )
+        throws ModelloException
+    {
+        String value = (String) data.get( key );
+
+        if ( StringUtils.isEmpty( value ) )
+        {
+            return defaultValue;
+        }
+
+        for ( int i = 0; i < legalValues.length; i++ )
+        {
+            String enumString = legalValues[i];
+            if ( StringUtils.equals( enumString, value ) )
+            {
+                return value;
+            }
+        }
+
+        String emsg = "Unknown " + key + " value: '" + value + "'.  " + "(Allowed values: " + legalValues + ")";
+        throw new ModelloException( emsg );
+    }
+
+    // ----------------------------------------------------------------------
+    // Metadata to Map
+    // ----------------------------------------------------------------------
+
+    public Map getFieldMap( ModelField field, FieldMetadata metadata )
+    {
+        return Collections.EMPTY_MAP;
+    }
+}

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/metadata/JPoxMetadataPlugin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/metadata/JPoxMetadataPlugin.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/metadata/JPoxModelMetadata.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/metadata/JPoxModelMetadata.java?rev=1414982&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/metadata/JPoxModelMetadata.java (added)
+++ archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/metadata/JPoxModelMetadata.java Wed Nov 28 23:08:08 2012
@@ -0,0 +1,86 @@
+package org.codehaus.modello.plugin.jpox.metadata;
+
+/*
+ * Copyright (c) 2005, Codehaus.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import org.codehaus.modello.metadata.ModelMetadata;
+
+/**
+ * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
+ * @version $Id: JPoxModelMetadata.java 827 2007-03-21 19:31:37Z joakime $
+ */
+public class JPoxModelMetadata implements ModelMetadata
+{
+    public static final String ID = JPoxModelMetadata.class.getName();
+    
+    public static final String ERROR = "error";
+    
+    public static final String WARNING = "warning";
+
+    private String columnPrefix;
+
+    private String tablePrefix;
+    
+    private String reservedWordStrictness;
+    
+    private boolean mappingInPackage = false;
+    
+    public String getColumnPrefix()
+    {
+        return columnPrefix;
+    }
+
+    public void setColumnPrefix( String columnPrefix )
+    {
+        this.columnPrefix = columnPrefix;
+    }
+
+    public String getTablePrefix()
+    {
+        return tablePrefix;
+    }
+
+    public void setTablePrefix( String tablePrefix )
+    {
+        this.tablePrefix = tablePrefix;
+    }
+
+    public String getReservedWordStrictness()
+    {
+        return reservedWordStrictness;
+    }
+
+    public void setReservedWordStrictness( String reservedWordStrictness )
+    {
+        this.reservedWordStrictness = reservedWordStrictness;
+    }
+
+    public boolean isMappingInPackage()
+    {
+        return mappingInPackage;
+    }
+
+    public void setMappingInPackage( boolean mappingInPackage )
+    {
+        this.mappingInPackage = mappingInPackage;
+    }
+}

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/metadata/JPoxModelMetadata.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/java/org/codehaus/modello/plugin/jpox/metadata/JPoxModelMetadata.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/META-INF/plexus/components.xml?rev=1414982&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/META-INF/plexus/components.xml (added)
+++ archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/META-INF/plexus/components.xml Wed Nov 28 23:08:08 2012
@@ -0,0 +1,44 @@
+<component-set>
+  <components>
+
+    <component>
+      <role>org.codehaus.modello.plugin.ModelloGenerator</role>
+      <role-hint>jpox-store</role-hint>
+      <implementation>org.codehaus.modello.plugin.jpox.JPoxStoreModelloGenerator</implementation>
+      <requirements>
+        <requirement>
+          <role>org.codehaus.plexus.velocity.VelocityComponent</role>
+        </requirement>
+      </requirements>
+    </component>
+
+    <component>
+      <role>org.codehaus.modello.plugin.ModelloGenerator</role>
+      <role-hint>jpox-jdo-mapping</role-hint>
+      <implementation>org.codehaus.modello.plugin.jpox.JPoxJdoMappingModelloGenerator</implementation>
+      <requirements>
+        <requirement>
+          <role>org.codehaus.modello.db.SQLReservedWords</role>
+        </requirement>
+      </requirements>
+    </component>
+
+    <component>
+      <role>org.codehaus.modello.plugin.ModelloGenerator</role>
+      <role-hint>jpox-metadata-class</role-hint>
+      <implementation>org.codehaus.modello.plugin.jpox.JPoxMetadataClassModelloGenerator</implementation>
+      <requirements>
+        <requirement>
+          <role>org.codehaus.plexus.velocity.VelocityComponent</role>
+        </requirement>
+      </requirements>
+    </component>
+
+    <component>
+      <role>org.codehaus.modello.metadata.MetadataPlugin</role>
+      <role-hint>jpox</role-hint>
+      <implementation>org.codehaus.modello.plugin.jpox.metadata.JPoxMetadataPlugin</implementation>
+    </component>
+
+  </components>
+</component-set>

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/org/codehaus/modello/plugin/jpox/templates/JPoxStore.java.vm
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/org/codehaus/modello/plugin/jpox/templates/JPoxStore.java.vm?rev=1414982&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/org/codehaus/modello/plugin/jpox/templates/JPoxStore.java.vm (added)
+++ archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/org/codehaus/modello/plugin/jpox/templates/JPoxStore.java.vm Wed Nov 28 23:08:08 2012
@@ -0,0 +1,472 @@
+package ${package};
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.jdo.Extent;
+import javax.jdo.FetchPlan;
+import javax.jdo.Query;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.JDOUserException;
+import javax.jdo.Transaction;
+
+// Model class imports
+#foreach ( $class in $classes )
+#if ( $class.getMetadata( $storeClassMetadataId ).storable && ${class.packageName} != ${package} )
+import ${class.packageName}.${class.name};
+#end
+#end
+
+/**
+ * Generated JPox storage mechanism for ${model.name}.
+ *
+ * @author Mr Modello
+ */
+public class ${model.name}JPoxStore
+{
+#foreach ( $class in $classes )
+#if ( $class.getMetadata( $storeClassMetadataId ).storable )
+        public final static String ${class.name}_DETAIL_FETCH_GROUP = "${class.name}_detail";
+#end
+#end
+    private static ThreadLocal threadState = new ThreadLocal();
+
+    private PersistenceManagerFactory pmf;
+
+    public ${model.name}JPoxStore( PersistenceManagerFactory pmf )
+    {
+        this.pmf = pmf;
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    public static class ThreadState
+    {
+        private PersistenceManager pm;
+
+        private Transaction tx;
+
+        private int depth;
+
+        public PersistenceManager getPersistenceManager()
+        {
+            return pm;
+        }
+
+        public Transaction getTransaction()
+        {
+            return tx;
+        }
+
+        public int getDepth()
+        {
+            return depth;
+        }
+    }
+
+    // ----------------------------------------------------------------------
+    // Transaction Management Methods
+    // ----------------------------------------------------------------------
+
+    public ThreadState getThreadState()
+    {
+        return (ThreadState) threadState.get();
+    }
+
+    public PersistenceManager begin()
+    {
+        ThreadState state = (ThreadState) threadState.get();
+
+        if ( state == null )
+        {
+            state = new ThreadState();
+
+            state.pm = pmf.getPersistenceManager();
+
+            state.tx = state.pm.currentTransaction();
+
+            state.tx.begin();
+
+            threadState.set( state );
+
+            return state.pm;
+        }
+        else
+        {
+            state.depth++;
+
+            return state.pm;
+        }
+    }
+
+    public void commit()
+    {
+        ThreadState state = (ThreadState) threadState.get();
+
+        if ( state == null )
+        {
+            throw new IllegalStateException( "commit() must only be called after begin()." );
+        }
+
+        if ( state.depth > 0 )
+        {
+            state.depth--;
+
+            return;
+        }
+
+        threadState.set( null );
+
+        try
+        {
+            state.tx.commit();
+        }
+        finally
+        {
+            if ( state.tx.isActive() )
+            {
+                state.tx.rollback();
+            }
+
+            closePersistenceManager( state.pm );
+        }
+    }
+
+    public void rollback()
+    {
+        ThreadState state = (ThreadState) threadState.get();
+
+        if ( state == null )
+        {
+            // The tx is not active because it has already been committed or rolled back
+
+            return;
+        }
+
+        threadState.set( null );
+
+        try
+        {
+            if ( state.tx.isActive() )
+            {
+                state.tx.rollback();
+            }
+        }
+        finally
+        {
+            closePersistenceManager( state.pm );
+        }
+    }
+
+#foreach ( $class in $classes )
+#if ( $class.getMetadata( $storeClassMetadataId ).storable )
+    // ----------------------------------------------------------------------
+    // ${class.name} CRUD
+    // ----------------------------------------------------------------------
+
+    public Object add${class.name}( $class.name o )
+    {
+        try
+        {
+            PersistenceManager pm = begin();
+
+            pm.makePersistent( o );
+
+            Object id = pm.getObjectId( o );
+
+            commit();
+
+            return id;
+        }
+        finally
+        {
+            rollback();
+        }
+    }
+
+#if ( $class.getIdentifierFields( $version ).size() > 0 )
+    public Object store${class.name}( $class.name o )
+    {
+        try
+        {
+            PersistenceManager pm = begin();
+
+            pm.makePersistent( o );
+
+            Object id = pm.getObjectId( o );
+
+            commit();
+
+            return id;
+        }
+        finally
+        {
+            rollback();
+        }
+    }
+#end
+
+    public void delete${class.name}( String id )
+    {
+        try
+        {
+            PersistenceManager pm = begin();
+
+            Query query = pm.newQuery( ${class.name}.class );
+
+            query.setIgnoreCache( true );
+
+            // TODO: Use all known identifier fields in this filter
+            query.setFilter( "this.id == \"" + id + "\"" );
+
+            Collection result = (Collection) query.execute();
+
+            if ( result.isEmpty() )
+            {
+                throw new RuntimeException( "No such object of type \"${class.name}\" with id: \"" + id + "\"." );
+            }
+
+            pm.deletePersistentAll( result );
+
+            commit();
+        }
+        finally
+        {
+            rollback();
+        }
+    }
+
+#if ( $class.getIdentifierFields( $version ).size() == 1 )
+    public ${class.name} get${class.name}( String id, boolean detach )
+        throws Exception
+    {
+        try
+        {
+            PersistenceManager pm = begin();
+
+            pm.getFetchPlan().setGroup( FetchPlan.DEFAULT );
+
+            pm.getFetchPlan().addGroup( "${class.name}_detail" );
+
+            Query query = pm.newQuery( ${class.name}.class );
+
+            query.setIgnoreCache( true );
+
+            #foreach ( $idField in $class.getIdentifierFields( $version ) )
+            query.setFilter( "this.${idField.name} == \"" + id + "\"" );
+            #end
+
+            Collection result = (Collection) query.execute();
+
+            if ( result.isEmpty() )
+            {
+                throw new RuntimeException( "No such object of type \"${class.name}\" with id: \"" + id + "\"." );
+            }
+
+            ${class.name} object = (${class.name}) result.iterator().next();
+
+            if ( detach )
+            {
+                object = (${class.name}) pm.detachCopy( object );
+            }
+
+            commit();
+
+            return object;
+        }
+        finally
+        {
+            rollback();
+        }
+    }
+#end
+
+    public ${class.name} get${class.name}ByJdoId( Object id, boolean detach )
+    {
+        try
+        {
+            PersistenceManager pm = begin();
+
+            pm.getFetchPlan().setGroup( FetchPlan.DEFAULT );
+
+            pm.getFetchPlan().addGroup( "${class.name}_detail" );
+
+            ${class.name} object = (${class.name}) pm.getObjectById( id, true );
+
+            if ( detach )
+            {
+                object = (${class.name}) pm.detachCopy( object );
+            }
+
+            commit();
+
+            return object;
+        }
+        finally
+        {
+            rollback();
+        }
+    }
+
+    public Collection get${class.name}Collection( boolean detach, String filter, String ordering )
+    {
+        try
+        {
+            PersistenceManager pm = begin();
+
+            Extent extent = pm.getExtent( ${class.name}.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            if ( ordering != null )
+            {
+                query.setOrdering( ordering );
+            }
+
+            if ( filter != null )
+            {
+                query.setFilter( filter );
+            }
+
+            Collection result = ((Collection) query.execute() );
+
+            Collection collection;
+
+            // TODO: Why did was this done with a iterator and not makeTransientAll()? -- trygve
+            //       I would guess I had to do it this way to make sure JPOX fetched all fields
+            //       so this should probably go away now if detach works like expected.
+            //       Also; why refresh()?
+            if ( detach )
+            {
+                collection = new ArrayList();
+
+                for ( Iterator it = result.iterator(); it.hasNext(); )
+                {
+                    Object object = it.next();
+
+                    pm.refresh( object );
+
+                    object = pm.detachCopy( object );
+
+                    collection.add( object );
+                }
+            }
+            else
+            {
+                collection = result;
+            }
+
+            commit();
+
+            return collection;
+        }
+        finally
+        {
+            rollback();
+        }
+    }
+#end
+
+#end
+
+    public ${model.name}ModelloMetadata get${model.name}ModelloMetadata( boolean detach )
+    {
+        try
+        {
+            PersistenceManager pm = begin();
+
+            pm.getFetchPlan().setGroup( FetchPlan.DEFAULT );
+
+            Query query = pm.newQuery( ${model.name}ModelloMetadata.class );
+
+            query.setIgnoreCache( true );
+
+            Collection result = (Collection) query.execute();
+
+            if ( result.isEmpty() )
+            {
+                return null;
+            }
+
+            ${model.name}ModelloMetadata object = (${model.name}ModelloMetadata) result.iterator().next();
+
+            if ( detach )
+            {
+                object = (${model.name}ModelloMetadata) pm.detachCopy( object );
+            }
+
+            commit();
+
+            return object;
+        }
+        finally
+        {
+            rollback();
+        }
+    }
+
+    public void store${model.name}ModelloMetadata( ${model.name}ModelloMetadata o )
+    {
+        try
+        {
+            PersistenceManager pm = begin();
+
+            pm.makePersistent( o );
+
+            commit();
+        }
+        finally
+        {
+            rollback();
+        }
+    }
+
+    public void eraseModelFromDatabase()
+    {
+        try
+        {
+            PersistenceManager pm = begin();
+
+            Query query = pm.newQuery( ${model.name}ModelloMetadata.class );
+
+            query.setIgnoreCache( true );
+
+            query.deletePersistentAll();
+
+            #foreach ($class in $classes)
+            query = pm.newQuery( ${class.name}.class );
+
+            query.setIgnoreCache( true );
+
+            query.deletePersistentAll();
+            #end
+
+
+            commit();
+        }
+        finally
+        {
+            rollback();
+        }
+    }
+
+    // ----------------------------------------------------------------------
+    // Utility Methods
+    // ----------------------------------------------------------------------
+
+    private void closePersistenceManager( PersistenceManager pm )
+    {
+        try
+        {
+            pm.close();
+        }
+        catch( JDOUserException ex )
+        {
+            ex.printStackTrace();
+        }
+    }
+}

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/org/codehaus/modello/plugin/jpox/templates/JPoxStore.java.vm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/org/codehaus/modello/plugin/jpox/templates/JPoxStore.java.vm
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/org/codehaus/modello/plugin/jpox/templates/ModelloMetadata.java.vm
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/org/codehaus/modello/plugin/jpox/templates/ModelloMetadata.java.vm?rev=1414982&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/org/codehaus/modello/plugin/jpox/templates/ModelloMetadata.java.vm (added)
+++ archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/org/codehaus/modello/plugin/jpox/templates/ModelloMetadata.java.vm Wed Nov 28 23:08:08 2012
@@ -0,0 +1,28 @@
+package ${package};
+
+// Model class imports
+#foreach ( $class in $classes )
+#if ( $class.getMetadata( $storeClassMetadataId ).isStorable() && ${class.packageName} != ${package} )
+import ${class.packageName}.${class.name};
+#end
+#end
+
+/**
+ * Generated ModelloMetadata class for ${model.name}.
+ *
+ * @author Mr Modello
+ */
+public class ${model.name}ModelloMetadata
+{
+    private String modelVersion;
+
+    public String getModelVersion()
+    {
+        return modelVersion;
+    }
+
+    public void setModelVersion( String modelVersion )
+    {
+        this.modelVersion = modelVersion;
+    }
+}

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/org/codehaus/modello/plugin/jpox/templates/ModelloMetadata.java.vm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/main/resources/org/codehaus/modello/plugin/jpox/templates/ModelloMetadata.java.vm
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/apt/index.apt?rev=1414982&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/apt/index.apt (added)
+++ archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/apt/index.apt Wed Nov 28 23:08:08 2012
@@ -0,0 +1,25 @@
+ -----
+ Modello JPOX Plugin
+ -----
+ Joakim Erdfelt
+ -----
+ 14 March 2007
+ -----
+
+Welcome to Modello JPOX Plugin
+
+  The Modello JPOX Plugin is responsibile for providing various modello model transformations useful for the JPOX/JDO developer.
+
+    * jpox-jdo-mapping: Produces a package.jdo file describing the model.
+
+    * jpox-store: Produces a java source file that provides a basic DAO / Store for the objects within the model.
+
+    * jpox-metadata-class: Produces a java source file that can supply the basic model version object suitable for tracking the model version vs table schema version.
+
+  We welcome developers to the modello community who are interested in contributing. If you'd like to discuss modello, subscribe and post to
+  {{{mail-lists.html} the development mailing list}}, <<<...@modello.codehaus.org>>>.
+
+  If you'd like to obtain the code, you can get it from Subversion. See {{{source-repository.html} SCM details}} for more information.
+
+  Bugs, issues and new ideas should be reported in the issue tracker - see {{{issue-tracking.html} this page}}.
+

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/apt/index.apt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/apt/index.apt
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/site.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/site.xml?rev=1414982&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/site.xml (added)
+++ archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/site.xml Wed Nov 28 23:08:08 2012
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+
+<project name="Modello JPOX Plugin">
+  <bannerLeft>
+    <name>Modello</name>
+  </bannerLeft>
+
+  <body>
+
+    <menu ref="parent" />
+
+    <menu name="Maven 2.0">
+      <item name="Introduction" href="index.html"/>
+      <item name="Model Syntax" href="jpox-model-syntax.html"/>
+    </menu>
+
+    <menu ref="reports"/>
+
+  </body>
+</project>

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/site.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/site.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/xdoc/jpox-model-syntax.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/xdoc/jpox-model-syntax.xml?rev=1414982&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/xdoc/jpox-model-syntax.xml (added)
+++ archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/xdoc/jpox-model-syntax.xml Wed Nov 28 23:08:08 2012
@@ -0,0 +1,334 @@
+<?xml version="1.0" ?>
+
+<document>
+  <properties>
+    <author email="joakime@codehaus.org">Joakim Erdfelt</author>
+    <title>jpox-jdo-mapping model syntax</title>
+  </properties>
+
+  <head>
+    <style type="text/css">
+      pre.model-xml {
+        background-color: #f3f3ff;
+        border: 1px dashed #aaaaff;
+        padding: 15px;
+      }
+
+      pre.model-xml a {
+        font-style: normal;
+        color: #000088;
+      }
+
+      pre.model-xml a em {
+        color: #7777ff;
+      }
+    </style>
+  </head>
+
+  <body>
+    <section name="Modello JPOX Model Syntax">
+<pre class="model-xml">
+&lt;model <a href="#model-reserved-word-strictness">jpox.reserved-word-strictness="<em>(enum)</em>"</a>
+       <a href="#model-table-prefix">jpox.table-prefix="<em>(String)</em>"</a>
+       <a href="#model-column-prefix">jpox.column-prefix="<em>(String)</em>"</a>&gt;
+  &lt;name&gt;ExampleModel&lt;/name&gt;
+  &lt;classes&gt;
+    &lt;class <a href="#class-enabled">jpox.enabled="<em>(boolean)</em>"</a>
+           <a href="#class-detachable">jpox.detachable="<em>(boolean)</em>"</a>
+           <a href="#class-not-persisted-fields">jpox.not-persisted-fields="<em>(List)</em>"</a>
+           <a href="#class-table">jpox.table="<em>(String)</em>"</a>
+           <a href="#class-column-prefix">jpox.column-prefix="<em>(String)</em>"</a>
+           <a href="#class-identity-type">jpox.identity-type="<em>(enum)</em>"</a>
+           <a href="#class-identity-class">jpox.identity-class="<em>(String)</em>"</a>
+           <a href="#class-use-identifiers-as-primary-key">jpox.use-identifiers-as-primary-key="<em>(boolean)</em>"</a>&gt;
+      &lt;name&gt;SimpleClass&lt;/name&gt;
+      &lt;fields&gt;
+        &lt;field <a href="#field-fetch-groups">jpox.fetch-groups="<em>(List)</em>"</a>
+               <a href="#field-mapped-by">jpox.mapped-by="<em>(String)</em>"</a>
+               <a href="#field-null-value">jpox.null-value="<em>(String)</em>"</a>
+               <a href="#field-column">jpox.column="<em>(String)</em>"</a>
+               <a href="#field-join-table">jpox.join-table="<em>(String)</em>"</a>
+               <a href="#field-indexed">jpox.indexed="<em>(enum)</em>"</a>
+               <a href="#field-persistence-modifier">jpox.persistence-modifier="<em>(enum)</em>"</a>
+               <a href="#field-value-strategy">jpox.value-strategy="<em>(enum)</em>"</a>&gt;
+          &lt;name&gt;simple&lt;/name&gt;
+          &lt;type&gt;String&lt;/type&gt;
+          &lt;required&gt;true&lt;/required&gt;
+        &lt;/field&gt;
+        &lt;field&gt;
+          &lt;name&gt;associative&lt;/name&gt;
+          &lt;required&gt;false&lt;/required&gt;
+          &lt;association <a href="#association-dependent">jpox.dependent="<em>(boolean)</em>"</a>
+                       <a href="#association-join">jpox.join="<em>(boolean)</em>"</a>&gt;
+            &lt;type&gt;AnotherClass&lt;/type&gt;
+            &lt;multiplicity&gt;*&lt;/multiplicity&gt;
+          &lt;/association&gt;
+        &lt;/field&gt;
+      &lt;/fields&gt;
+    &lt;/class&gt;
+  &lt;/classes&gt;
+&lt;/model&gt;
+</pre>
+
+  <table>
+    <tr>
+      <th>Context</th>
+      <th>Attribute</th>
+      <th>Values</th>
+      <th>Description</th>
+    </tr>
+    <tr>
+      <td>Model</td>
+      <td><a name="model-reserved-word-strictness">jpox.reserved-word-strictness</a></td>
+      <td>"warning" or "error" (default: warning)</td>
+      <td>
+        <p>
+          This allows you to set the level of strictness on the reserved
+          word violations within the TABLE / COLUMN / JOIN-TABLE names.
+        </p>
+        <p>
+          A setting of "error" will only throw an exception if a reserved
+          word violation severity level of ERROR is encountered.
+        </p>
+        <p>
+          An attempt to use a reserved word found within the core SQL92 /
+          SQL99 / or SQL2003 set of reserved words are considered an ERROR.
+          Use of a reserved word found within a vendor specific SQL
+          implementation is considered a WARNING.
+        </p>
+        <p>
+          You are encouraged to fix all reserved word violations to make
+          your code as portable across multiple SQL implementations as
+          possible.
+        </p>
+      </td>
+    </tr>
+    <tr>
+      <td>Model</td>
+      <td><a name="model-table-prefix">jpox.table-prefix</a></td>
+      <td>
+        Any non-empty String.
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Model</td>
+      <td><a name="model-column-prefix">jpox.column-prefix</a></td>
+      <td>
+        Any non-empty String.
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Class</td>
+      <td><a name="class-enabled">jpox.enabled</a></td>
+      <td>
+        true or false.
+        <br/>(Default: true)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Class</td>
+      <td><a name="class-detachable">jpox.detachable</a></td>
+      <td>
+        true or false
+        <br/>(Default: true)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Class</td>
+      <td><a name="class-not-persisted-fields">jpox.not-persisted-fields</a></td>
+      <td>
+        List of fields that are not persisted (seperated by spaces)
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Class</td>
+      <td><a name="class-table">jpox.table</a></td>
+      <td>
+        Any non-empty String.
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Class</td>
+      <td><a name="class-column-prefix">jpox.column-prefix</a></td>
+      <td>
+        Any non-empty String.
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Class</td>
+      <td><a name="class-identity-type">jpox.identity-type</a></td>
+      <td>
+        "application", "datastore", or "nondurable"
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Class</td>
+      <td><a name="class-identity-class">jpox.identity-class</a></td>
+      <td>
+        Any non-empty String.
+        Refers to a Java Class name in the same package as
+        the model.
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Class</td>
+      <td><a name="class-use-identifiers-as-primary-key">jpox.use-identifiers-as-primary-key</a></td>
+      <td>
+        true or false
+        <br/>(Default: true)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Field</td>
+      <td><a name="field-fetch-groups">jpox.fetch-groups</a></td>
+      <td>
+        List of fetch-group names (seperated by space).
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Field</td>
+      <td><a name="field-mapped-by">jpox.mapped-by</a></td>
+      <td>
+        Any non-empty String.
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Field</td>
+      <td><a name="field-null-value">jpox.null-value</a></td>
+      <td>
+        Any non-empty String.
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Field</td>
+      <td><a name="field-column">jpox.column</a></td>
+      <td>
+        Any non-empty String.
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Field</td>
+      <td><a name="field-join-table">jpox.join-table</a></td>
+      <td>
+        Any non-empty String.
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Field</td>
+      <td><a name="field-indexed">jpox.indexed</a></td>
+      <td>
+        'true', 'false', or 'unique'
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Field</td>
+      <td><a name="field-persistence-modifier">jpox.persistence-modifier</a></td>
+      <td>
+        'persistent', 'transactiona', or 'none'
+        <br/>(No Default)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Field</td>
+      <td><a name="field-value-strategy">jpox.value-strategy</a></td>
+      <td>
+        'off', 'native', 'sequence', 'identity', 'increment', 'uuid-string',
+        'uuid-hex', 'datastore-uuid-hex', 'max', or 'auid'
+        <br/>(Default: 'native')
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Association</td>
+      <td><a name="association-dependent">jpox.dependent</a></td>
+      <td>
+        true or false
+        <br/>(Default: true)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+    <tr>
+      <td>Association</td>
+      <td><a name="association-join">jpox.join</a></td>
+      <td>
+        true or false
+        <br/>(Default: true)
+      </td>
+      <td>
+        <!-- TODO: Description -->
+      </td>
+    </tr>
+  </table>
+
+    </section>
+  </body>
+</document>
+

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/xdoc/jpox-model-syntax.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/site/xdoc/jpox-model-syntax.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/AbstractJpoxGeneratorTestCase.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/AbstractJpoxGeneratorTestCase.java?rev=1414982&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/AbstractJpoxGeneratorTestCase.java (added)
+++ archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/AbstractJpoxGeneratorTestCase.java Wed Nov 28 23:08:08 2012
@@ -0,0 +1,375 @@
+package org.codehaus.modello.plugin.jpox;
+
+/*
+ * Copyright (c) 2006, Codehaus.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import org.codehaus.modello.AbstractModelloGeneratorTest;
+import org.codehaus.modello.ModelloException;
+import org.codehaus.modello.ModelloParameterConstants;
+import org.codehaus.modello.core.ModelloCore;
+import org.codehaus.modello.model.Model;
+import org.codehaus.plexus.compiler.CompilerException;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.dom4j.Attribute;
+import org.dom4j.Branch;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.XPath;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import junit.framework.AssertionFailedError;
+
+public abstract class AbstractJpoxGeneratorTestCase
+    extends AbstractModelloGeneratorTest
+{
+    protected ModelloCore modello;
+
+    protected AbstractJpoxGeneratorTestCase( String name )
+    {
+        super( name );
+    }
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        modello = (ModelloCore) container.lookup( ModelloCore.ROLE );
+    }
+
+    protected void verifyModel( Model model, String className )
+        throws IOException, ModelloException, CompilerException, CommandLineException
+    {
+        verifyModel( model, className, null );
+    }
+
+    protected void verifyModel( Model model, String className, String[] versions )
+        throws IOException, ModelloException, CompilerException, CommandLineException
+    {
+        File generatedSources = new File( getTestPath( "target/" + getName() + "/sources" ) );
+
+        File classes = new File( getTestPath( "target/" + getName() + "/classes" ) );
+
+        FileUtils.deleteDirectory( generatedSources );
+
+        FileUtils.deleteDirectory( classes );
+
+        generatedSources.mkdirs();
+
+        classes.mkdirs();
+
+        Properties parameters = new Properties();
+
+        parameters.setProperty( ModelloParameterConstants.OUTPUT_DIRECTORY, generatedSources.getAbsolutePath() );
+
+        parameters.setProperty( ModelloParameterConstants.VERSION, "1.0.0" );
+
+        parameters.setProperty( ModelloParameterConstants.PACKAGE_WITH_VERSION, Boolean.toString( false ) );
+
+        modello.generate( model, "java", parameters );
+
+        modello.generate( model, "jpox-store", parameters );
+
+        modello.generate( model, "jpox-metadata-class", parameters );
+
+        parameters.setProperty( ModelloParameterConstants.OUTPUT_DIRECTORY, classes.getAbsolutePath() );
+        modello.generate( model, "jpox-jdo-mapping", parameters );
+
+        if ( versions != null && versions.length > 0 )
+        {
+            parameters.setProperty( ModelloParameterConstants.ALL_VERSIONS, StringUtils.join( versions, "," ) );
+
+            for ( int i = 0; i < versions.length; i++ )
+            {
+                parameters.setProperty( ModelloParameterConstants.VERSION, versions[i] );
+
+                parameters.setProperty( ModelloParameterConstants.OUTPUT_DIRECTORY,
+                                        generatedSources.getAbsolutePath() );
+
+                parameters.setProperty( ModelloParameterConstants.PACKAGE_WITH_VERSION, Boolean.toString( true ) );
+
+                modello.generate( model, "java", parameters );
+
+                modello.generate( model, "jpox-store", parameters );
+
+                parameters.setProperty( ModelloParameterConstants.OUTPUT_DIRECTORY, classes.getAbsolutePath() );
+                modello.generate( model, "jpox-jdo-mapping", parameters );
+            }
+        }
+
+        addDependency( "org.codehaus.modello", "modello-core", getModelloVersion() );
+
+        addDependency( "jpox", "jpox", "1.1.1" );
+        addDependency( "javax.jdo", "jdo2-api", "2.0" );
+        addDependency( "org.apache.derby", "derby", "10.1.3.1" );
+        addDependency( "log4j", "log4j", "1.2.8" );
+
+        compile( generatedSources, classes );
+
+        enhance( classes );
+        
+        verify( className, getName() );
+    }
+
+    private void enhance( File classes )
+        throws CommandLineException, ModelloException, IOException
+    {
+        Properties loggingProperties = new Properties();
+        loggingProperties.setProperty( "log4j.appender.root", "org.apache.log4j.ConsoleAppender" );
+        loggingProperties.setProperty( "log4j.appender.root.layout", "org.apache.log4j.PatternLayout" );
+        loggingProperties.setProperty( "log4j.appender.root.layout.ConversionPattern", "%-5p [%c] - %m%n" );
+        loggingProperties.setProperty( "log4j.category.JPOX", "INFO, root" );
+        File logFile = new File( classes, "log4j.properties" );
+        loggingProperties.store( new FileOutputStream( logFile ), "logging" );
+
+        Commandline cl = new Commandline();
+
+        cl.setExecutable( "java" );
+
+        StringBuffer cpBuffer = new StringBuffer();
+
+        cpBuffer.append( classes.getAbsolutePath() );
+
+        for ( Iterator it = getClassPathElements().iterator(); it.hasNext(); )
+        {
+            cpBuffer.append( File.pathSeparator );
+
+            cpBuffer.append( it.next() );
+        }
+
+        File enhancerJar = getDepedencyFile( "jpox", "jpox-enhancer", "1.1.1" );
+        cpBuffer.append( File.pathSeparator + enhancerJar.getAbsolutePath() );
+        File bcelJar = getDepedencyFile( "org.apache.bcel", "bcel", "5.2" );
+        cpBuffer.append( File.pathSeparator + bcelJar.getAbsolutePath() );
+
+        cl.createArgument().setValue( "-cp" );
+
+        cl.createArgument().setValue( cpBuffer.toString() );
+
+        cl.createArgument().setValue( "-Dlog4j.configuration=" + logFile.toURL() );
+
+        cl.createArgument().setValue( "org.jpox.enhancer.JPOXEnhancer" );
+
+        cl.createArgument().setValue( "-v" );
+
+        for ( Iterator i = FileUtils.getFiles( classes, "**/*.jdo", null ).iterator(); i.hasNext(); )
+        {
+            cl.createArgument().setFile( (File) i.next() );
+        }
+
+        CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
+
+        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
+
+        System.out.println( cl );
+        int exitCode = CommandLineUtils.executeCommandLine( cl, stdout, stderr );
+
+        String stream = stderr.getOutput();
+
+        if ( stream.trim().length() > 0 )
+        {
+            System.err.println( stderr.getOutput() );
+        }
+
+        stream = stdout.getOutput();
+
+        if ( stream.trim().length() > 0 )
+        {
+            System.out.println( stdout.getOutput() );
+        }
+
+        if ( exitCode != 0 )
+        {
+            throw new ModelloException( "The JPox enhancer tool exited with a non-null exit code." );
+        }
+    }
+    
+    protected void assertAttributeEquals( Document doc, String xpathToNode, String attributeKey, String expectedValue )
+    {
+        if ( expectedValue == null )
+        {
+            throw new AssertionFailedError( "Unable to assert an attribute using a null expected value." );
+        }
+    
+        Attribute attribute = findAttribute( doc, xpathToNode, attributeKey );
+    
+        if ( attribute == null )
+        {
+            throw new AssertionFailedError( "Element at '" + xpathToNode + "' is missing the '" + attributeKey
+                            + "' attribute." );
+        }
+    
+        assertEquals( "Attribute value for '" + xpathToNode + "'", expectedValue, attribute.getValue() );
+    }
+
+    protected void assertElementExists( Document doc, String xpathToNode )
+    {
+        findElement( doc, xpathToNode );
+    }
+
+    protected void assertElementNotExists( Document doc, String xpathToNode )
+    {
+        if ( StringUtils.isEmpty( xpathToNode ) )
+        {
+            throw new AssertionFailedError( "Unable to assert an attribute using an empty xpath." );
+        }
+    
+        if ( doc == null )
+        {
+            throw new AssertionFailedError( "Unable to assert an attribute using a null document." );
+        }
+    
+        XPath xpath = doc.createXPath( xpathToNode );
+    
+        Node node = xpath.selectSingleNode( doc );
+    
+        if ( node != null )
+        {
+            throw new AssertionFailedError( "Element at '" + xpathToNode + "' should not exist." );
+        }
+    
+        // In case node returns something other than an element.
+    }
+
+    private Element findElement( Document doc, String xpathToNode )
+    {
+        if ( StringUtils.isEmpty( xpathToNode ) )
+        {
+            throw new AssertionFailedError( "Unable to assert an attribute using an empty xpath." );
+        }
+    
+        if ( doc == null )
+        {
+            throw new AssertionFailedError( "Unable to assert an attribute using a null document." );
+        }
+    
+        XPath xpath = doc.createXPath( xpathToNode );
+    
+        Node node = xpath.selectSingleNode( doc );
+    
+        if ( node == null )
+        {
+            throw new AssertionFailedError( "Expected Node at '" + xpathToNode + "', but was not found." );
+        }
+    
+        if ( node.getNodeType() != Node.ELEMENT_NODE )
+        {
+            throw new AssertionFailedError( "Node at '" + xpathToNode + "' is not an xml element." );
+        }
+    
+        return (Element) node;
+    }
+
+    private Attribute findAttribute( Document doc, String xpathToNode, String attributeKey ) throws AssertionFailedError
+    {
+        if ( StringUtils.isEmpty( attributeKey ) )
+        {
+            throw new AssertionFailedError( "Unable to assert an attribute using an empty attribute key." );
+        }
+    
+        Element elem = findElement( doc, xpathToNode );
+    
+        Attribute attribute = elem.attribute( attributeKey );
+        return attribute;
+    }
+
+    protected void assertAttributeMissing( Document doc, String xpathToNode, String attributeKey )
+    {
+        Attribute attribute = findAttribute( doc, xpathToNode, attributeKey );
+    
+        if ( attribute != null )
+        {
+            throw new AssertionFailedError( "Node at '" + xpathToNode + "' should not have the attribute named '"
+                            + attributeKey + "'." );
+        }
+    }
+
+    protected void assertNoTextNodes( Document doc, String xpathToParentNode, boolean recursive )
+    {
+        if ( StringUtils.isEmpty( xpathToParentNode ) )
+        {
+            throw new AssertionFailedError( "Unable to assert an attribute using an empty xpath." );
+        }
+    
+        if ( doc == null )
+        {
+            throw new AssertionFailedError( "Unable to assert an attribute using a null document." );
+        }
+    
+        XPath xpath = doc.createXPath( xpathToParentNode );
+    
+        List nodes = xpath.selectNodes( doc );
+    
+        if ( ( nodes == null ) || nodes.isEmpty() )
+        {
+            throw new AssertionFailedError( "Expected Node(s) at '" + xpathToParentNode + "', but was not found." );
+        }
+    
+        Iterator it = nodes.iterator();
+        while ( it.hasNext() )
+        {
+            Node node = (Node) it.next();
+    
+            assertNoTextNode( "No Text should exist in '" + xpathToParentNode + "'", node, recursive );
+        }
+    }
+
+    private boolean assertNoTextNode( String message, Node node, boolean recursive )
+    {
+        if ( node.getNodeType() == Node.TEXT_NODE || node.getNodeType() == Node.CDATA_SECTION_NODE )
+        {
+            // Double check that it isn't just whitespace.
+            String text = StringUtils.trim( node.getText() );
+    
+            if ( StringUtils.isNotEmpty( text ) )
+            {
+                throw new AssertionFailedError( message + " found <" + text + ">" );
+            }
+        }
+    
+        if ( recursive )
+        {
+            if ( node instanceof Branch )
+            {
+                Iterator it = ( (Branch) node ).nodeIterator();
+                while ( it.hasNext() )
+                {
+                    Node child = (Node) it.next();
+                    assertNoTextNode( message, child, recursive );
+                }
+            }
+        }
+    
+        return false;
+    }
+}

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/AbstractJpoxGeneratorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/AbstractJpoxGeneratorTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGeneratorPrefixedTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGeneratorPrefixedTest.java?rev=1414982&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGeneratorPrefixedTest.java (added)
+++ archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGeneratorPrefixedTest.java Wed Nov 28 23:08:08 2012
@@ -0,0 +1,110 @@
+package org.codehaus.modello.plugin.jpox;
+
+/*
+ * Copyright (c) 2005, Codehaus.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import org.codehaus.modello.ModelloParameterConstants;
+import org.codehaus.modello.core.ModelloCore;
+import org.codehaus.modello.model.Model;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.dom4j.Document;
+import org.dom4j.io.SAXReader;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id: JPoxJdoMappingModelloGeneratorPrefixedTest.java 840 2007-07-17 18:50:39Z hboutemy $
+ */
+public class JPoxJdoMappingModelloGeneratorPrefixedTest extends AbstractJpoxGeneratorTestCase
+{
+    public JPoxJdoMappingModelloGeneratorPrefixedTest()
+    {
+        super( "jpox-jdo-mapping" );
+    }
+
+    public void testInvocationWithPrefixes() throws Exception
+    {
+        ModelloCore core = (ModelloCore) lookup( ModelloCore.ROLE );
+
+        Model model = core.loadModel( ReaderFactory.newXmlReader( getTestFile( "src/test/resources/test-with-prefixes.mdo" ) ) );
+
+        // ----------------------------------------------------------------------
+        // Generate the code
+        // ----------------------------------------------------------------------
+
+        Properties parameters = new Properties();
+
+        parameters.setProperty( ModelloParameterConstants.OUTPUT_DIRECTORY, getGeneratedSources().getAbsolutePath() );
+
+        parameters.setProperty( ModelloParameterConstants.VERSION, "1.0.0" );
+
+        parameters.setProperty( ModelloParameterConstants.PACKAGE_WITH_VERSION, Boolean.FALSE.toString() );
+
+        core.generate( model, "jpox-jdo-mapping", parameters );
+
+        // ----------------------------------------------------------------------
+        // Assert
+        // ----------------------------------------------------------------------
+
+        assertGeneratedFileExists( "package.jdo" );
+
+        SAXReader reader = new SAXReader();
+        reader.setEntityResolver( new JdoEntityResolver() );
+        Document jdoDocument = reader.read( new File( "target/" + getName() + "/package.jdo" ) );
+
+        assertNotNull( jdoDocument );
+
+        // Tree should consist of only elements with attributes. NO TEXT.
+        assertNoTextNodes( jdoDocument, "//jdo", true );
+
+        assertAttributeEquals( jdoDocument,
+                               "//class[@name='RbacJdoModelModelloMetadata']/field[@name='modelVersion']/column",
+                               "default-value", "1.0.0" );
+
+        assertAttributeEquals( jdoDocument, "//class[@name='JdoResource']/field[@name='modelEncoding']", "persistence-modifier",
+                               "none" );
+
+        // -----------------------------------------------------------------------
+        // Association Tests.
+
+        //   mdo/association/jpox.dependent-element == false (only on association with "*" multiplicity (default type)
+        assertAttributeEquals( jdoDocument, "//class[@name='JdoRole']/field[@name='permissions']/collection",
+                               "dependent-element", "false" );
+
+        //   mdo/association (default type) with "1" multiplicity.
+        assertElementNotExists( jdoDocument, "//class[@name='JdoPermission']/field[@name='operation']/collection" );
+
+        // -----------------------------------------------------------------------
+        // Fetch Group Tests
+        assertAttributeMissing( jdoDocument, "//class[@name='JdoRole']/field[@name='assignable']", "default-fetch-group" );
+        assertAttributeEquals( jdoDocument, "//class[@name='JdoRole']/field[@name='childRoleNames']",
+                               "default-fetch-group", "true" );
+
+        // -----------------------------------------------------------------------
+        // Alternate Table and Column Names Tests.
+        assertAttributeEquals( jdoDocument, "//class[@name='JdoPermission']", "table", "SECURITY_PERMISSIONS" );
+        assertAttributeEquals( jdoDocument, "//class[@name='JdoOperation']/field[@name='name']/column", "name", "OPERATION_NAME" );
+        assertAttributeEquals( jdoDocument, "//class[@name='JdoRole']/field[@name='permissions']", "table", "SECURITY_ROLE_PERMISSION_MAP" );
+    }
+}

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGeneratorPrefixedTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGeneratorPrefixedTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGeneratorTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGeneratorTest.java?rev=1414982&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGeneratorTest.java (added)
+++ archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGeneratorTest.java Wed Nov 28 23:08:08 2012
@@ -0,0 +1,147 @@
+package org.codehaus.modello.plugin.jpox;
+
+/*
+ * Copyright (c) 2005, Codehaus.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import org.codehaus.modello.ModelloParameterConstants;
+import org.codehaus.modello.core.ModelloCore;
+import org.codehaus.modello.model.Model;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.dom4j.Document;
+import org.dom4j.io.SAXReader;
+
+import java.io.File;
+import java.util.Properties;
+
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id: JPoxJdoMappingModelloGeneratorTest.java 840 2007-07-17 18:50:39Z hboutemy $
+ */
+public class JPoxJdoMappingModelloGeneratorTest extends AbstractJpoxGeneratorTestCase
+{
+    public JPoxJdoMappingModelloGeneratorTest()
+    {
+        super( "jpox-jdo-mapping" );
+    }
+
+    public void testSimpleInvocation() throws Exception
+    {
+        ModelloCore core = (ModelloCore) lookup( ModelloCore.ROLE );
+
+        Model model = core.loadModel( ReaderFactory.newXmlReader( getTestFile( "src/test/resources/mergere-tissue.mdo" ) ) );
+
+        // ----------------------------------------------------------------------
+        // Generate the code
+        // ----------------------------------------------------------------------
+
+        Properties parameters = new Properties();
+
+        parameters.setProperty( ModelloParameterConstants.OUTPUT_DIRECTORY, getGeneratedSources().getAbsolutePath() );
+
+        parameters.setProperty( ModelloParameterConstants.VERSION, "1.0.0" );
+
+        parameters.setProperty( ModelloParameterConstants.PACKAGE_WITH_VERSION, Boolean.FALSE.toString() );
+
+        core.generate( model, "jpox-jdo-mapping", parameters );
+
+        // ----------------------------------------------------------------------
+        // Assert
+        // ----------------------------------------------------------------------
+
+        assertGeneratedFileExists( "package.jdo" );
+
+        SAXReader reader = new SAXReader();
+        reader.setEntityResolver( new JdoEntityResolver() );
+        Document jdoDocument = reader.read( new File( "target/" + getName() + "/package.jdo" ) );
+
+        assertNotNull( jdoDocument );
+
+        // Tree should consist of only elements with attributes. NO TEXT.
+        assertNoTextNodes( jdoDocument, "//jdo", true );
+
+        assertAttributeEquals( jdoDocument,
+                               "//class[@name='TissueModelloMetadata']/field[@name='modelVersion']/column",
+                               "default-value", "1.0.0" );
+
+        assertAttributeEquals( jdoDocument, "//class[@name='Issue']/field[@name='summary']", "persistence-modifier",
+                               "none" );
+
+        // -----------------------------------------------------------------------
+        // Association Tests.
+
+        //   mdo/association/jpox.dependent-element == false (only on association with "*" multiplicity (default type)
+        assertAttributeEquals( jdoDocument, "//class[@name='Issue']/field[@name='friends']/collection",
+                               "dependent-element", "false" );
+
+        //   mdo/association (default type) with "1" multiplicity.
+        assertElementNotExists( jdoDocument, "//class[@name='Issue']/field[@name='assignee']/collection" );
+
+        //   mdo/association (map) with "*" multiplicity.
+        assertElementExists( jdoDocument, "//class[@name='Issue']/field[@name='configuration']/map" );
+
+        // -----------------------------------------------------------------------
+        // Fetch Group Tests
+        assertAttributeMissing( jdoDocument, "//class[@name='Issue']/field[@name='reporter']", "default-fetch-group" );
+        assertAttributeEquals( jdoDocument, "//class[@name='Issue']/field[@name='configuration']",
+                               "default-fetch-group", "true" );
+        assertAttributeEquals( jdoDocument, "//class[@name='Issue']/field[@name='assignee']", "default-fetch-group",
+                               "false" );
+
+        // -----------------------------------------------------------------------
+        // Value Strategy Tests
+        //   defaulted
+        assertAttributeEquals( jdoDocument, "//class[@name='ComplexIdentity']/field[@name='id']", "value-strategy",
+                               "native" );
+        assertAttributeEquals( jdoDocument, "//class[@name='Issue']/field[@name='accountId']", "value-strategy",
+                               "native" );
+        //   intentionally unset
+        assertAttributeMissing( jdoDocument, "//class[@name='User']/field[@name='id']", "value-strategy" );
+
+        // -----------------------------------------------------------------------
+        // Superclass Tests
+        assertAttributeEquals( jdoDocument, "//class[@name='User']", "persistence-capable-superclass",
+                               "org.mergere.user.AbstractUser" );
+
+        // -----------------------------------------------------------------------
+        // Primary Key Tests
+        assertAttributeEquals( jdoDocument, "//class[@name='Issue']/field[@name='accountId']", "primary-key", "true" );
+        assertAttributeEquals( jdoDocument, "//class[@name='Issue']/field[@name='summary']", "primary-key", "false" );
+
+        assertAttributeEquals( jdoDocument, "//class[@name='ComplexIdentity']/field[@name='id']", "primary-key", "true" );
+        assertAttributeEquals( jdoDocument, "//class[@name='ComplexIdentity']/field[@name='username']", "primary-key",
+                               "false" );
+        assertAttributeEquals( jdoDocument, "//class[@name='ComplexIdentity']/field[@name='fullName']", "primary-key",
+                               "false" );
+        assertAttributeEquals( jdoDocument, "//class[@name='ComplexIdentity']/field[@name='email']", "primary-key",
+                               "false" );
+        assertAttributeEquals( jdoDocument, "//class[@name='ComplexIdentity']/field[@name='locked']", "primary-key",
+                               "false" );
+        assertAttributeEquals( jdoDocument, "//class[@name='ComplexIdentity']/field[@name='lastLoginDate']",
+                               "primary-key", "false" );
+
+        // -----------------------------------------------------------------------
+        // Alternate Table and Column Names Tests.
+        assertAttributeEquals( jdoDocument, "//class[@name='DifferentTable']", "table", "MyTable" );
+        assertAttributeEquals( jdoDocument, "//class[@name='Issue']/field[@name='accountId']/column", "name", "id" );
+    }
+}

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxJdoMappingModelloGeneratorTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxMetadataClassModelloGeneratorTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxMetadataClassModelloGeneratorTest.java?rev=1414982&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxMetadataClassModelloGeneratorTest.java (added)
+++ archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxMetadataClassModelloGeneratorTest.java Wed Nov 28 23:08:08 2012
@@ -0,0 +1,72 @@
+package org.codehaus.modello.plugin.jpox;
+
+/*
+ * Copyright (c) 2006, Codehaus.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import org.codehaus.modello.AbstractModelloGeneratorTest;
+import org.codehaus.modello.ModelloParameterConstants;
+import org.codehaus.modello.core.ModelloCore;
+import org.codehaus.modello.model.Model;
+import org.codehaus.plexus.util.ReaderFactory;
+
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id: JPoxStoreModelloGeneratorTest.java 699 2006-11-23 03:37:55Z brett $
+ */
+public class JPoxMetadataClassModelloGeneratorTest
+    extends AbstractModelloGeneratorTest
+{
+    public JPoxMetadataClassModelloGeneratorTest()
+    {
+        super( "jpox-metadata-class" );
+    }
+
+    public void testSimpleInvocation()
+        throws Exception
+    {
+        ModelloCore core = (ModelloCore) lookup( ModelloCore.ROLE );
+
+        Model model = core.loadModel( ReaderFactory.newXmlReader( getTestFile( "src/test/resources/mergere-tissue.mdo" ) ) );
+
+        // ----------------------------------------------------------------------
+        // Generate the code
+        // ----------------------------------------------------------------------
+
+        Properties parameters = new Properties();
+
+        parameters.setProperty( ModelloParameterConstants.OUTPUT_DIRECTORY, getGeneratedSources().getAbsolutePath() );
+
+        parameters.setProperty( ModelloParameterConstants.VERSION, "1.0.0" );
+
+        parameters.setProperty( ModelloParameterConstants.PACKAGE_WITH_VERSION, Boolean.FALSE.toString() );
+
+        core.generate( model, "jpox-metadata-class", parameters );
+
+        // ----------------------------------------------------------------------
+        // Assert
+        // ----------------------------------------------------------------------
+
+        assertGeneratedFileExists( "org/mergere/tissue/TissueModelloMetadata.java" );
+    }
+}

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxMetadataClassModelloGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-jpox/src/test/java/org/codehaus/modello/plugin/jpox/JPoxMetadataClassModelloGeneratorTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision