Return-Path: X-Original-To: apmail-archiva-commits-archive@www.apache.org Delivered-To: apmail-archiva-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 52F50E39B for ; Wed, 28 Nov 2012 23:08:46 +0000 (UTC) Received: (qmail 20864 invoked by uid 500); 28 Nov 2012 23:08:46 -0000 Delivered-To: apmail-archiva-commits-archive@archiva.apache.org Received: (qmail 20831 invoked by uid 500); 28 Nov 2012 23:08:46 -0000 Mailing-List: contact commits-help@archiva.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@archiva.apache.org Delivered-To: mailing list commits@archiva.apache.org Received: (qmail 20822 invoked by uid 99); 28 Nov 2012 23:08:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Nov 2012 23:08:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Nov 2012 23:08:43 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 225B82388B45; Wed, 28 Nov 2012 23:08:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1414982 [5/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-... Date: Wed, 28 Nov 2012 23:08:18 -0000 To: commits@archiva.apache.org From: olamy@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121128230823.225B82388B45@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 Trygve Laugstøl + * @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 Jason van Zyl + * @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 Jason van Zyl + * @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 Jason van Zyl + * @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 Trygve Laugstøl + * @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 Jason van Zyl + * @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 Trygve Laugstøl + * @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 @@ + + + + + org.codehaus.modello.plugin.ModelloGenerator + store + org.codehaus.modello.plugin.store.StoreModelloGenerator + + + org.codehaus.plexus.velocity.VelocityComponent + + + + + + org.codehaus.modello.metadata.MetadataPlugin + store + org.codehaus.modello.plugin.store.metadata.StoreMetadataPlugin + + + + 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 Trygve Laugstøl + * @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 @@ + + tissue + Tissue + Tissue's entity model.> + + + package + org.mergere.tissue + + + + + Issue + 1.0.0 + + + id + true + 1.0.0 + String + + + summary + 1.0.0 + String + + + assignee + 1.0.0 + + User + + + + reporter + 1.0.0 + + User + + + + status + 1.0.0 + String + + + project + 1.0.0 + + Project + + + + + + Project + 1.0.0 + + + id + 1.0.0 + + String + + + name + 1.0.0 + + String + + + url + 1.0.0 + + String + + + lead + 1.0.0 + + String + + + + + + User + 1.0.0 + + + id + 1.0.0 + + String + + + name + 1.0.0 + + String + + + + + 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 @@ + + + + + 4.0.0 + + + org.apache.archiva.redback.components + redback-components + 2.1-SNAPSHOT + ../redback-components-parent/pom.xml + + + org.apache.archiva.redback.components.modello + modello-plugins + 1.0-SNAPSHOT + pom + Expression Evaluator Components + + http://archiva.apache.org/redback/components/${project.artifactId} + + + + apache.website + file://${user.home}/redback-components-site-deploy/${project.artifactId} + + + + + scm:svn:http://svn.apache.org/repos/asf/archiva/redback/redback-components/trunk/modello-plugins + scm:svn:https://svn.apache.org/repos/asf/archiva/redback/redback-components/trunk/modello-plugins + http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/modello-plugins + + + + modello-db-keywords + modello-plugin-store + modello-plugin-jpox + + + 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