Added:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/StoreModelloGenerator.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/StoreModelloGenerator.java?rev=1414982&view=auto
==============================================================================
---
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/StoreModelloGenerator.java
(added)
+++
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/StoreModelloGenerator.java
Wed Nov 28 23:08:08 2012
@@ -0,0 +1,120 @@
+package org.codehaus.modello.plugin.store;
+
+/*
+ * 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.apache.velocity.VelocityContext;
+import org.apache.velocity.context.Context;
+import org.codehaus.modello.ModelloException;
+import org.codehaus.modello.model.Model;
+import org.codehaus.modello.plugin.AbstractModelloGenerator;
+import org.codehaus.modello.plugin.store.metadata.StoreClassMetadata;
+import org.codehaus.plexus.util.WriterFactory;
+import org.codehaus.plexus.velocity.VelocityComponent;
+
+import java.io.File;
+import java.io.Writer;
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:[email protected]">Trygve Laugstøl</a>
+ * @version $Id: StoreModelloGenerator.java 895 2008-05-24 22:31:50Z hboutemy $
+ */
+public class StoreModelloGenerator
+ extends AbstractModelloGenerator
+{
+ /** @requirement */
+ private VelocityComponent velocity;
+
+ public void generate( Model model, Properties properties )
+ throws ModelloException
+ {
+ initialize( model, properties );
+
+
+ //
----------------------------------------------------------------------
+ // Initialize the Velocity context
+ //
----------------------------------------------------------------------
+
+ Context context = new VelocityContext();
+
+ context.put( "version", getGeneratedVersion() );
+
+ context.put( "package", model.getDefaultPackageName( false,
getGeneratedVersion() ) );
+
+ context.put( "metadataId", StoreClassMetadata.ID );
+
+ context.put( "model", model );
+
+ //
----------------------------------------------------------------------
+ // Generate the code
+ //
----------------------------------------------------------------------
+
+ String packageName = model.getDefaultPackageName( false,
getGeneratedVersion() );
+
+ File packageFile = new File( getOutputDirectory(),
packageName.replace( '.', File.separatorChar ) );
+
+ File interfaceFile = new File( packageFile, model.getName() +
"Store.java" );
+
+ File exceptionFile = new File( packageFile, model.getName() +
"StoreException.java" );
+
+ if ( !interfaceFile.getParentFile().exists() )
+ {
+ if ( !interfaceFile.getParentFile().mkdirs() )
+ {
+ throw new ModelloException( "Error while creating parent
directories for '" + interfaceFile.getAbsolutePath() + "'." );
+ }
+ }
+
+ String interfaceTemplate =
"org/codehaus/modello/plugin/store/templates/Store.vm";
+
+ String exceptionTemplate =
"org/codehaus/modello/plugin/store/templates/StoreException.vm";
+
+ writeTemplate( interfaceTemplate, interfaceFile, context );
+
+ writeTemplate( exceptionTemplate, exceptionFile, context );
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ private void writeTemplate( String template, File file, Context context )
+ throws ModelloException
+ {
+ try
+ {
+ Writer writer = getEncoding() == null ?
WriterFactory.newPlatformWriter( file )
+ : WriterFactory.newWriter( file, getEncoding()
);
+
+ velocity.getEngine().mergeTemplate( template, context, writer );
+
+ writer.flush();
+
+ writer.close();
+ }
+ catch ( Exception e )
+ {
+ throw new ModelloException( "Error while generating code.", e );
+ }
+ }
+}
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/StoreModelloGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/StoreModelloGenerator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreAssociationMetadata.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreAssociationMetadata.java?rev=1414982&view=auto
==============================================================================
---
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreAssociationMetadata.java
(added)
+++
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreAssociationMetadata.java
Wed Nov 28 23:08:08 2012
@@ -0,0 +1,71 @@
+package org.codehaus.modello.plugin.store.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.AssociationMetadata;
+
+/**
+ * @author <a href="mailto:[email protected]">Jason van Zyl</a>
+ * @version $Id: StoreAssociationMetadata.java 378 2005-06-19 21:04:43Z
trygvis $
+ */
+public class StoreAssociationMetadata
+ implements AssociationMetadata
+{
+ public static final String ID = StoreAssociationMetadata.class.getName();
+
+ private boolean storable;
+
+ private Boolean part;
+
+ private String keyType;
+
+ public void setStorable( boolean storable )
+ {
+ this.storable = storable;
+ }
+
+ public boolean isStorable()
+ {
+ return storable;
+ }
+
+ public Boolean isPart()
+ {
+ return part;
+ }
+
+ public void setPart( Boolean part )
+ {
+ this.part = part;
+ }
+
+ public String getKeyType()
+ {
+ return keyType;
+ }
+
+ public void setKeyType( String keyType )
+ {
+ this.keyType = keyType;
+ }
+}
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreAssociationMetadata.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreAssociationMetadata.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreClassMetadata.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreClassMetadata.java?rev=1414982&view=auto
==============================================================================
---
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreClassMetadata.java
(added)
+++
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreClassMetadata.java
Wed Nov 28 23:08:08 2012
@@ -0,0 +1,47 @@
+package org.codehaus.modello.plugin.store.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.ClassMetadata;
+
+/**
+ * @author <a href="mailto:[email protected]">Jason van Zyl</a>
+ * @version $Id: StoreClassMetadata.java 240 2005-02-24 21:00:54Z trygvis $
+ */
+public class StoreClassMetadata
+ implements ClassMetadata
+{
+ public static final String ID = StoreClassMetadata.class.getName();
+
+ private boolean storable;
+
+ public void setStorable( boolean storable )
+ {
+ this.storable = storable;
+ }
+
+ public boolean isStorable()
+ {
+ return storable;
+ }
+}
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreClassMetadata.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreClassMetadata.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreFieldMetadata.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreFieldMetadata.java?rev=1414982&view=auto
==============================================================================
---
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreFieldMetadata.java
(added)
+++
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreFieldMetadata.java
Wed Nov 28 23:08:08 2012
@@ -0,0 +1,59 @@
+package org.codehaus.modello.plugin.store.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.FieldMetadata;
+
+/**
+ * @author <a href="mailto:[email protected]">Jason van Zyl</a>
+ * @version $Id: StoreFieldMetadata.java 243 2005-02-28 13:51:51Z trygvis $
+ */
+public class StoreFieldMetadata
+ implements FieldMetadata
+{
+ public static final String ID = StoreFieldMetadata.class.getName();
+
+ private boolean storable;
+
+ private int maxSize;
+
+ public void setStorable( boolean storable )
+ {
+ this.storable = storable;
+ }
+
+ public boolean isStorable()
+ {
+ return storable;
+ }
+
+ public int getMaxSize()
+ {
+ return maxSize;
+ }
+
+ public void setMaxSize( int maxSize )
+ {
+ this.maxSize = maxSize;
+ }
+}
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreFieldMetadata.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreFieldMetadata.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreMetadataPlugin.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreMetadataPlugin.java?rev=1414982&view=auto
==============================================================================
---
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreMetadataPlugin.java
(added)
+++
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreMetadataPlugin.java
Wed Nov 28 23:08:08 2012
@@ -0,0 +1,163 @@
+package org.codehaus.modello.plugin.store.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.Collections;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:[email protected]">Trygve Laugstøl</a>
+ * @version $Id: StoreMetadataPlugin.java 796 2007-02-09 00:10:59Z brett $
+ */
+public class StoreMetadataPlugin
+ extends AbstractMetadataPlugin
+{
+ public final static String PART = "stash.part";
+
+ public final static String KEY_TYPE = "stash.keyType";
+
+ // ----------------------------------------------------------------------
+ // Map to Metadata
+ // ----------------------------------------------------------------------
+
+ public ModelMetadata getModelMetadata( Model model, Map data )
+ {
+ return new StoreModelMetadata();
+ }
+
+ public ClassMetadata getClassMetadata( ModelClass clazz, Map data )
+ throws ModelloException
+ {
+ StoreClassMetadata metadata = new StoreClassMetadata();
+
+ String storable = (String) data.get( "stash.storable" );
+
+ if ( storable != null && storable.equals( "true" ) )
+ {
+// JavaClassMetadata jcm = (JavaClassMetadata) clazz.getMetadata(
JavaClassMetadata.ID );
+//
+// if ( jcm.isAbstract() )
+// {
+// throw new ModelloException( "A storable class can't be
abstract. " +
+// "Class name '" + clazz.getName()
+ "'." );
+// }
+//
+ metadata.setStorable( true );
+ }
+
+ return metadata;
+ }
+
+ public FieldMetadata getFieldMetadata( ModelField field, Map data )
+ throws ModelloException
+ {
+ StoreFieldMetadata metadata = new StoreFieldMetadata();
+
+ //
----------------------------------------------------------------------
+ // Fields are per default storable as the fields can't be persisted
+ // unless the class itself is storable.
+ //
----------------------------------------------------------------------
+
+ metadata.setStorable( getBoolean( data, "stash.storable", true ) );
+
+ String maxSize = (String) data.get( "stash.maxSize" );
+
+ if ( !StringUtils.isEmpty( maxSize ) )
+ {
+ if ( !field.getType().equals( "String" ) )
+ {
+ throw new ModelloException( "When specifying max size on a
field the type must be String. " +
+ "Class: '" +
field.getModelClass().getName() + "', " +
+ "field : '" + field.getName() +
"'." );
+ }
+
+ try
+ {
+ metadata.setMaxSize( Integer.parseInt( maxSize ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new ModelloException( "Max size on a field the type must
be String. " +
+ "Class: '" +
field.getModelClass().getName() + "', " +
+ "field : '" + field.getName() +
"'." );
+ }
+ }
+
+ return metadata;
+ }
+
+ public AssociationMetadata getAssociationMetadata( ModelAssociation
association, Map data )
+ throws ModelloException
+ {
+ StoreAssociationMetadata metadata = new StoreAssociationMetadata();
+
+ //
----------------------------------------------------------------------
+ // Associations are per default storable as the fields can't be
persisted
+ // unless the class itself is storable.
+ //
----------------------------------------------------------------------
+
+ metadata.setStorable( getBoolean( data, "stash.storable", true ) );
+
+ if ( data.containsKey( PART ) )
+ {
+ metadata.setPart( Boolean.valueOf( (String) data.get( PART ) ) );
+ }
+
+ String keyType = (String) data.get( KEY_TYPE );
+
+ if ( association.getType() != null && association.getType().equals(
"Map" ) )
+ {
+ if ( StringUtils.isEmpty( keyType ) )
+ {
+ keyType = "String";
+ }
+
+ // TODO: assert the key type
+
+ metadata.setKeyType( keyType );
+ }
+
+ return metadata;
+ }
+
+ // ----------------------------------------------------------------------
+ // Metadata to Map
+ // ----------------------------------------------------------------------
+
+ public Map getFieldMap( ModelField field, FieldMetadata metadata )
+ {
+ return Collections.EMPTY_MAP;
+ }
+}
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreMetadataPlugin.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreMetadataPlugin.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreModelMetadata.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreModelMetadata.java?rev=1414982&view=auto
==============================================================================
---
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreModelMetadata.java
(added)
+++
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreModelMetadata.java
Wed Nov 28 23:08:08 2012
@@ -0,0 +1,34 @@
+package org.codehaus.modello.plugin.store.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:[email protected]">Jason van Zyl</a>
+ * @version $Id: StoreModelMetadata.java 215 2005-02-11 02:16:49Z trygvis $
+ */
+public class StoreModelMetadata
+ implements ModelMetadata
+{
+}
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreModelMetadata.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/metadata/StoreModelMetadata.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/tool/JavaTool.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/tool/JavaTool.java?rev=1414982&view=auto
==============================================================================
---
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/tool/JavaTool.java
(added)
+++
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/tool/JavaTool.java
Wed Nov 28 23:08:08 2012
@@ -0,0 +1,82 @@
+package org.codehaus.modello.plugin.store.tool;
+
+/*
+ * 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.model.ModelField;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * @author <a href="mailto:[email protected]">Trygve Laugstøl</a>
+ * @version $Id: JavaTool.java 803 2007-02-09 11:12:55Z brett $
+ */
+public class JavaTool
+{
+ public String makeGetter( ModelField field )
+ {
+ if ( field.getType().equals( "boolean" ) )
+ {
+ return "is" + field.getName().substring( 0, 1 ).toUpperCase() +
field.getName().substring( 1 );
+ }
+
+ return "get" + field.getName().substring( 0, 1 ).toUpperCase() +
field.getName().substring( 1 );
+ }
+
+ public String makeSetter( ModelField field )
+ {
+ return "set" + field.getName().substring( 0, 1 ).toUpperCase() +
field.getName().substring( 1 );
+ }
+
+ public void fail( String message )
+ throws Exception
+ {
+ throw new Exception( message );
+ }
+
+ public String uncapitalise( String s )
+ {
+ return StringUtils.uncapitalise( s );
+ }
+
+ public String capitalise( String s )
+ {
+ return StringUtils.capitalise( s );
+ }
+
+ public String singular( String name )
+ {
+ if ( name.endsWith( "ies" ) )
+ {
+ return name.substring( 0, name.length() - 3 ) + "y";
+ }
+ else if ( name.endsWith( "es" ) && name.endsWith( "ches" ) )
+ {
+ return name.substring( 0, name.length() - 2 );
+ }
+ else if ( name.endsWith( "s" ) )
+ {
+ return name.substring( 0, name.length() - 1 );
+ }
+
+ return name;
+ }
+}
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/tool/JavaTool.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/java/org/codehaus/modello/plugin/store/tool/JavaTool.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/META-INF/plexus/components.xml
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/META-INF/plexus/components.xml?rev=1414982&view=auto
==============================================================================
---
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/META-INF/plexus/components.xml
(added)
+++
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/META-INF/plexus/components.xml
Wed Nov 28 23:08:08 2012
@@ -0,0 +1,22 @@
+<component-set>
+ <components>
+
+ <component>
+ <role>org.codehaus.modello.plugin.ModelloGenerator</role>
+ <role-hint>store</role-hint>
+
<implementation>org.codehaus.modello.plugin.store.StoreModelloGenerator</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.velocity.VelocityComponent</role>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>org.codehaus.modello.metadata.MetadataPlugin</role>
+ <role-hint>store</role-hint>
+
<implementation>org.codehaus.modello.plugin.store.metadata.StoreMetadataPlugin</implementation>
+ </component>
+
+ </components>
+</component-set>
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/org/codehaus/modello/plugin/store/templates/Store.vm
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/org/codehaus/modello/plugin/store/templates/Store.vm?rev=1414982&view=auto
==============================================================================
---
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/org/codehaus/modello/plugin/store/templates/Store.vm
(added)
+++
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/org/codehaus/modello/plugin/store/templates/Store.vm
Wed Nov 28 23:08:08 2012
@@ -0,0 +1,27 @@
+package ${package};
+
+/**
+ * Generated storage mechanism for the $model.name model.
+ *
+ * @author Mr Modello
+ */
+public interface ${model.name}Store
+{
+#foreach ( $class in $model.allClasses )
+ // ----------------------------------------------------------------------
+ // $class.name storage methods
+ // ----------------------------------------------------------------------
+
+#if ( $class.getMetadata( $metadataId ).isStorable() )
+ public void add${class.name}( $class.name entity )
+ throws ${model.name}StoreException;
+
+ public void delete${class.name}( String id )
+ throws ${model.name}StoreException;
+
+ public void update${class.name}( String id, $class.name entity )
+ throws ${model.name}StoreException;
+#end
+
+#end
+}
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/org/codehaus/modello/plugin/store/templates/Store.vm
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/org/codehaus/modello/plugin/store/templates/Store.vm
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/org/codehaus/modello/plugin/store/templates/StoreException.vm
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/org/codehaus/modello/plugin/store/templates/StoreException.vm?rev=1414982&view=auto
==============================================================================
---
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/org/codehaus/modello/plugin/store/templates/StoreException.vm
(added)
+++
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/org/codehaus/modello/plugin/store/templates/StoreException.vm
Wed Nov 28 23:08:08 2012
@@ -0,0 +1,20 @@
+package ${package};
+
+/**
+ * Generated exception for the store for the $model.name model.
+ *
+ * @author Mr Modello
+ */
+public class ${model.name}Exception
+ extends Exception
+{
+ public ${model.name}Exception( String message )
+ {
+ super( message );
+ }
+
+ public ${model.name}Exception( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/org/codehaus/modello/plugin/store/templates/StoreException.vm
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/main/resources/org/codehaus/modello/plugin/store/templates/StoreException.vm
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/test/java/org/codehaus/modello/plugin/store/StoreModelloGeneratorTest.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/test/java/org/codehaus/modello/plugin/store/StoreModelloGeneratorTest.java?rev=1414982&view=auto
==============================================================================
---
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/test/java/org/codehaus/modello/plugin/store/StoreModelloGeneratorTest.java
(added)
+++
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/test/java/org/codehaus/modello/plugin/store/StoreModelloGeneratorTest.java
Wed Nov 28 23:08:08 2012
@@ -0,0 +1,62 @@
+package org.codehaus.modello.plugin.store;
+
+/*
+ * 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.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:[email protected]">Trygve Laugstøl</a>
+ * @version $Id: StoreModelloGeneratorTest.java 840 2007-07-17 18:50:39Z
hboutemy $
+ */
+public class StoreModelloGeneratorTest
+ extends AbstractModelloGeneratorTest
+{
+ public StoreModelloGeneratorTest()
+ {
+ super( "store" );
+ }
+
+ public void testSimpleInvocation()
+ throws Exception
+ {
+ ModelloCore core = (ModelloCore) lookup( ModelloCore.ROLE );
+
+ Model model = core.loadModel( ReaderFactory.newXmlReader( getTestFile(
"src/test/resources/mergere-tissue.mdo" ) ) );
+
+ Properties parameters = new Properties();
+
+ parameters.setProperty( ModelloParameterConstants.OUTPUT_DIRECTORY,
getGeneratedSources().getAbsolutePath() );
+
+ parameters.setProperty( ModelloParameterConstants.VERSION, "4.0.0" );
+
+ parameters.setProperty(
ModelloParameterConstants.PACKAGE_WITH_VERSION, Boolean.toString( false ) );
+
+ core.generate( model, "store", parameters );
+ }
+}
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/test/java/org/codehaus/modello/plugin/store/StoreModelloGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/test/java/org/codehaus/modello/plugin/store/StoreModelloGeneratorTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/test/resources/mergere-tissue.mdo
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/test/resources/mergere-tissue.mdo?rev=1414982&view=auto
==============================================================================
---
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/test/resources/mergere-tissue.mdo
(added)
+++
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/test/resources/mergere-tissue.mdo
Wed Nov 28 23:08:08 2012
@@ -0,0 +1,115 @@
+<model>
+ <id>tissue</id>
+ <name>Tissue</name>
+ <description>Tissue's entity model.></description>
+ <defaults>
+ <default>
+ <key>package</key>
+ <value>org.mergere.tissue</value>
+ </default>
+ </defaults>
+ <classes>
+ <class stash.storable="true">
+ <name>Issue</name>
+ <version>1.0.0</version>
+ <fields>
+ <field>
+ <name>id</name>
+ <required>true</required>
+ <version>1.0.0</version>
+ <type>String</type>
+ </field>
+ <field>
+ <name>summary</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ </field>
+ <field>
+ <name>assignee</name>
+ <version>1.0.0</version>
+ <association>
+ <type>User</type>
+ </association>
+ </field>
+ <field>
+ <name>reporter</name>
+ <version>1.0.0</version>
+ <association>
+ <type>User</type>
+ </association>
+ </field>
+ <field>
+ <name>status</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ </field>
+ <field>
+ <name>project</name>
+ <version>1.0.0</version>
+ <association>
+ <type>Project</type>
+ </association>
+ </field>
+ </fields>
+ </class>
+ <class stash.storable="true">
+ <name>Project</name>
+ <version>1.0.0</version>
+ <fields>
+ <field>
+ <name>id</name>
+ <version>1.0.0</version>
+ <description><![CDATA[
+ ]]></description>
+ <type>String</type>
+ </field>
+ <field>
+ <name>name</name>
+ <version>1.0.0</version>
+ <description><![CDATA[
+ ]]></description>
+ <type>String</type>
+ </field>
+ <field>
+ <name>url</name>
+ <version>1.0.0</version>
+ <description><![CDATA[
+ ]]></description>
+ <type>String</type>
+ </field>
+ <field>
+ <name>lead</name>
+ <version>1.0.0</version>
+ <description><![CDATA[
+ ]]></description>
+ <type>String</type>
+ </field>
+ </fields>
+ </class>
+ <!--
+ |
+ |
+ |
+ -->
+ <class stash.storable="true">
+ <name>User</name>
+ <version>1.0.0</version>
+ <fields>
+ <field>
+ <name>id</name>
+ <version>1.0.0</version>
+ <description><![CDATA[
+ ]]></description>
+ <type>String</type>
+ </field>
+ <field>
+ <name>name</name>
+ <version>1.0.0</version>
+ <description><![CDATA[
+ ]]></description>
+ <type>String</type>
+ </field>
+ </fields>
+ </class>
+ </classes>
+</model>
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/test/resources/mergere-tissue.mdo
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
archiva/redback/redback-components/trunk/modello-plugins/modello-plugin-store/src/test/resources/mergere-tissue.mdo
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/modello-plugins/pom.xml
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins/pom.xml?rev=1414982&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/modello-plugins/pom.xml (added)
+++ archiva/redback/redback-components/trunk/modello-plugins/pom.xml Wed Nov 28
23:08:08 2012
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.archiva.redback.components</groupId>
+ <artifactId>redback-components</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ <relativePath>../redback-components-parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.archiva.redback.components.modello</groupId>
+ <artifactId>modello-plugins</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>Expression Evaluator Components</name>
+
+ <url>http://archiva.apache.org/redback/components/${project.artifactId}</url>
+
+ <distributionManagement>
+ <site>
+ <id>apache.website</id>
+
<url>file://${user.home}/redback-components-site-deploy/${project.artifactId}</url>
+ </site>
+ </distributionManagement>
+
+ <scm>
+
<connection>scm:svn:http://svn.apache.org/repos/asf/archiva/redback/redback-components/trunk/modello-plugins</connection>
+
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/archiva/redback/redback-components/trunk/modello-plugins</developerConnection>
+
<url>http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins</url>
+ </scm>
+
+ <modules>
+ <module>modello-db-keywords</module>
+ <module>modello-plugin-store</module>
+ <module>modello-plugin-jpox</module>
+ </modules>
+
+</project>
Propchange: archiva/redback/redback-components/trunk/modello-plugins/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/modello-plugins/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision