[seam-commits] Seam SVN: r10526 - in seam-gen/trunk/src: template and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sun Apr 19 21:48:18 EDT 2009


Author: shane.bryzak at jboss.com
Date: 2009-04-19 21:48:17 -0400 (Sun, 19 Apr 2009)
New Revision: 10526

Added:
   seam-gen/trunk/src/template/Action.java
   seam-gen/trunk/src/template/ActionBean.java
   seam-gen/trunk/src/template/ActionJavaBean.java
   seam-gen/trunk/src/template/Authenticator.java
   seam-gen/trunk/src/template/AuthenticatorBean.java
   seam-gen/trunk/src/template/AuthenticatorLocal.java
   seam-gen/trunk/src/template/Conversation.java
   seam-gen/trunk/src/template/ConversationBean.java
   seam-gen/trunk/src/template/ConversationJavaBean.java
   seam-gen/trunk/src/template/Entity.java
   seam-gen/trunk/src/template/EntityHome.java
   seam-gen/trunk/src/template/EntityHome.java.ftl
   seam-gen/trunk/src/template/EntityList.java
   seam-gen/trunk/src/template/EntityList.java.ftl
   seam-gen/trunk/src/template/FormAction.java
   seam-gen/trunk/src/template/FormActionBean.java
   seam-gen/trunk/src/template/FormActionJavaBean.java
   seam-gen/trunk/src/template/Query.java
   seam-gen/trunk/src/template/UserAccount.java
   seam-gen/trunk/src/template/UserPermission.java
   seam-gen/trunk/src/template/UserRole.java
Removed:
   seam-gen/trunk/src/Action.java
   seam-gen/trunk/src/ActionBean.java
   seam-gen/trunk/src/ActionJavaBean.java
   seam-gen/trunk/src/Authenticator.java
   seam-gen/trunk/src/AuthenticatorBean.java
   seam-gen/trunk/src/AuthenticatorLocal.java
   seam-gen/trunk/src/Conversation.java
   seam-gen/trunk/src/ConversationBean.java
   seam-gen/trunk/src/ConversationJavaBean.java
   seam-gen/trunk/src/Entity.java
   seam-gen/trunk/src/EntityHome.java
   seam-gen/trunk/src/EntityHome.java.ftl
   seam-gen/trunk/src/EntityList.java
   seam-gen/trunk/src/EntityList.java.ftl
   seam-gen/trunk/src/FormAction.java
   seam-gen/trunk/src/FormActionBean.java
   seam-gen/trunk/src/FormActionJavaBean.java
   seam-gen/trunk/src/Query.java
   seam-gen/trunk/src/UserAccount.java
   seam-gen/trunk/src/UserPermission.java
   seam-gen/trunk/src/UserRole.java
Log:
restructure

Deleted: seam-gen/trunk/src/Action.java
===================================================================
--- seam-gen/trunk/src/Action.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/Action.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,13 +0,0 @@
-package @actionPackage@;
-
-import javax.ejb.Local;
-
- at Local
-public interface @interfaceName@
-{
-    // seam-gen method
-    public void @methodName@();
-
-    // add additional interface methods here
-
-}

Deleted: seam-gen/trunk/src/ActionBean.java
===================================================================
--- seam-gen/trunk/src/ActionBean.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/ActionBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,27 +0,0 @@
-package @actionPackage@;
-
-import javax.ejb.Stateless;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Logger;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.international.StatusMessages;
-
- at Stateless
- at Name("@componentName@")
-public class @beanName@ implements @interfaceName@
-{
-    @Logger private Log log;
-
-    @In StatusMessages statusMessages;
-
-    public void @methodName@()
-    {
-        // implement your business logic here
-        log.info("@componentName at .@methodName@() action called");
-        statusMessages.add("@methodName@");
-    }
-
-    // add additional action methods
-
-}

Deleted: seam-gen/trunk/src/ActionJavaBean.java
===================================================================
--- seam-gen/trunk/src/ActionJavaBean.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/ActionJavaBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,25 +0,0 @@
-package @actionPackage@;
-
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Logger;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.international.StatusMessages;
-
- at Name("@componentName@")
-public class @interfaceName@
-{
-    @Logger private Log log;
-
-    @In StatusMessages statusMessages;
-
-    public void @methodName@()
-    {
-        // implement your business logic here
-        log.info("@componentName at .@methodName@() action called");
-        statusMessages.add("@methodName@");
-    }
-
-    // add additional action methods
-
-}

Deleted: seam-gen/trunk/src/Authenticator.java
===================================================================
--- seam-gen/trunk/src/Authenticator.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/Authenticator.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,32 +0,0 @@
-package @actionPackage@;
-
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Logger;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.security.Credentials;
-import org.jboss.seam.security.Identity;
-
- at Name("authenticator")
-public class Authenticator
-{
-    @Logger private Log log;
-
-    @In Identity identity;
-    @In Credentials credentials;
-
-    public boolean authenticate()
-    {
-        log.info("authenticating {0}", credentials.getUsername());
-        //write your authentication logic here,
-        //return true if the authentication was
-        //successful, false otherwise
-        if ("admin".equals(credentials.getUsername()))
-        {
-            identity.addRole("admin");
-            return true;
-        }
-        return false;
-    }
-
-}

Deleted: seam-gen/trunk/src/AuthenticatorBean.java
===================================================================
--- seam-gen/trunk/src/AuthenticatorBean.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/AuthenticatorBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,34 +0,0 @@
-package @actionPackage@;
-
-import javax.ejb.Stateless;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Logger;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.security.Credentials;
-import org.jboss.seam.security.Identity;
-
- at Stateless
- at Name("authenticator")
-public class AuthenticatorBean implements Authenticator
-{
-    @Logger private Log log;
-
-    @In Identity identity;
-    @In Credentials credentials;
-
-    public boolean authenticate()
-    {
-        log.info("authenticating {0}", credentials.getUsername());
-        //write your authentication logic here,
-        //return true if the authentication was
-        //successful, false otherwise
-        if ("admin".equals(credentials.getUsername()))
-        {
-            identity.addRole("admin");
-            return true;
-        }
-        return false;
-    }
-
-}

Deleted: seam-gen/trunk/src/AuthenticatorLocal.java
===================================================================
--- seam-gen/trunk/src/AuthenticatorLocal.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/AuthenticatorLocal.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,10 +0,0 @@
-package @actionPackage@;
-
-import javax.ejb.Local;
-
- at Local
-public interface Authenticator {
-
-    boolean authenticate();
-
-}

Deleted: seam-gen/trunk/src/Conversation.java
===================================================================
--- seam-gen/trunk/src/Conversation.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/Conversation.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,16 +0,0 @@
-package @actionPackage@;
-
-import javax.ejb.Local;
-
- at Local
-public interface @interfaceName@
-{
-    public String begin();
-    public String increment();
-    public String end();
-    public int getValue();
-    public void destroy();
-  
-    // add additional interface methods here
-
-}

Deleted: seam-gen/trunk/src/ConversationBean.java
===================================================================
--- seam-gen/trunk/src/ConversationBean.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/ConversationBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,53 +0,0 @@
-package @actionPackage@;
-
-import java.io.Serializable;
-import javax.ejb.Remove;
-import javax.ejb.Stateful;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.End;
-import org.jboss.seam.annotations.Logger;
-import org.jboss.seam.log.Log;
-
- at Stateful
- at Name("@componentName@")
-public class @beanName@ implements @interfaceName@, Serializable
-{
-    @Logger private Log log;
-
-    private int value;
-
-    @Begin
-    public String begin()
-    {
-        // implement your begin conversation business logic
-        log.info("beginning conversation");
-        return "success";
-    }
-  
-    public String increment()
-    {
-        log.info("incrementing");
-        value++;
-        return "success";
-    }
-  
-    // add additional action methods that participate in this conversation
-  
-    @End
-    public String end()
-    {
-        // implement your end conversation business logic
-        log.info("ending conversation");
-        return "home";
-    }
-  
-    public int getValue()
-    {
-        return value;
-    }
-  
-    @Remove
-    public void destroy() {}
-
-}

Deleted: seam-gen/trunk/src/ConversationJavaBean.java
===================================================================
--- seam-gen/trunk/src/ConversationJavaBean.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/ConversationJavaBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,51 +0,0 @@
-package @actionPackage@;
-
-import static org.jboss.seam.ScopeType.CONVERSATION;
-
-import java.io.Serializable;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.End;
-import org.jboss.seam.annotations.Logger;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.log.Log;
-
- at Scope(CONVERSATION)
- at Name("@componentName@")
-public class @interfaceName@ implements Serializable
-{
-    @Logger private Log log;
-
-    private int value;
-
-    @Begin
-    public String begin()
-    {
-        // implement your begin conversation business logic
-        log.info("beginning conversation");
-        return "success";
-    }
-  
-    public String increment()
-    {
-        log.info("incrementing");
-        value++;
-        return "success";
-    }
-  
-    // add additional action methods that participate in this conversation
-  
-    @End
-    public String end()
-    {
-        // implement your end conversation business logic
-        log.info("ending conversation");
-        return "home";
-    }
-  
-    public int getValue()
-    {
-        return value;
-    }
-
-}

Deleted: seam-gen/trunk/src/Entity.java
===================================================================
--- seam-gen/trunk/src/Entity.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/Entity.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,49 +0,0 @@
-package @modelPackage@;
-
-import java.io.Serializable;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Version;
-import org.hibernate.validator.Length;
-
- at Entity
-public class @entityName@ implements Serializable
-{
-    // seam-gen attributes (you should probably edit these)
-    private Long id;
-    private Integer version;
-    private String name;
-
-    // add additional entity attributes
-
-    // seam-gen attribute getters/setters with annotations (you probably should edit)
-
-    @Id @GeneratedValue
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    @Version
-    public Integer getVersion() {
-        return version;
-    }
-
-    private void setVersion(Integer version) {
-        this.version = version;
-    }
-
-    @Length(max = 20)
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-}

Deleted: seam-gen/trunk/src/EntityHome.java
===================================================================
--- seam-gen/trunk/src/EntityHome.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/EntityHome.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,33 +0,0 @@
-package @actionPackage@;
-
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.web.RequestParameter;
-import org.jboss.seam.framework.EntityHome;
-
-import @modelPackage at .@entityName@;
-
- at Name("@homeName@")
-public class @entityName at Home extends EntityHome<@entityName@>
-{
-    @RequestParameter Long @componentName at Id;
-
-    @Override
-    public Object getId()
-    {
-        if (@componentName at Id == null)
-        {
-            return super.getId();
-        }
-        else
-        {
-            return @componentName at Id;
-        }
-    }
-
-    @Override @Begin
-    public void create() {
-        super.create();
-    }
-
-}

Deleted: seam-gen/trunk/src/EntityHome.java.ftl
===================================================================
--- seam-gen/trunk/src/EntityHome.java.ftl	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/EntityHome.java.ftl	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,134 +0,0 @@
-<#include "../util/TypeInfo.ftl">
-package ${actionPackage};
-<#assign classbody>
-<#assign entityName = pojo.shortName>
-<#assign componentName = entityName?uncap_first>
-<#assign homeName = componentName + "Home">
-@${pojo.importType("org.jboss.seam.annotations.Name")}("${homeName}")
-public class ${entityName}Home extends ${pojo.importType("org.jboss.seam.framework.EntityHome")}<${entityName}>
-{
-
-<#assign parentHomeNames = []>
-<#foreach property in pojo.allPropertiesIterator>
-<#if isToOne(property)>
-<#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
-<#assign parentHomeName = parentPojo.shortName?uncap_first + "Home">
-<#if !parentHomeNames?seq_contains(parentHomeName)><#-- This doesn't fix the functionality, just allows compilation to work -->
-<#assign parentHomeNames = parentHomeNames + [parentHomeName]>
-    @${pojo.importType("org.jboss.seam.annotations.In")}(create=true)
-    <#if parentPojo.packageName!="">${pojo.importType("${parentPojo.packageName}.${parentPojo.shortName}")}<#else>${parentPojo.shortName}</#if>Home ${parentHomeName};
-</#if>
-</#if>
-</#foreach>
-
-<#assign idName = entityName + pojo.identifierProperty.name?cap_first>
-<#if c2j.isComponent(pojo.identifierProperty)>
-<#assign idType = entityName + "Id">
-<#else>
-<#assign idType = pojo.importType(pojo.identifierProperty.type.returnedClass.name)>
-</#if>
-    public void set${idName}(${idType} id)
-    {
-        setId(id);
-    }
-
-    public ${idType} get${idName}()
-    {
-        return (${idType}) getId();
-    }
-
-<#if pojo.isComponent(pojo.identifierProperty)>
-    public ${entityName}Home()
-    {
-        set${idName}( new ${entityName}Id() );
-    }
-
-    @Override
-    public boolean isIdDefined()
-    {
-<#foreach property in pojo.identifierProperty.value.propertyIterator>
-<#assign getter = pojo.getGetterSignature(property)>
-<#if property.value.typeName == "string" || property.value.typeName == "java.lang.String" >
-        if ( get${idName}().${getter}()==null || "".equals( get${idName}().${getter}() ) ) return false;
-<#elseif !c2j.isPrimitive( pojo.getJavaTypeName(property, true) )>
-        if ( get${idName}().${getter}()==null ) return false;
-<#else>
-        if ( get${idName}().${getter}()==0 ) return false;
-</#if>
-</#foreach>
-        return true;
-    }
-
-</#if>
-    @Override
-    protected ${entityName} createInstance()
-    {
-        ${entityName} ${componentName} = new ${entityName}();
-<#if pojo.isComponent(pojo.identifierProperty)>
-        ${componentName}.setId( new ${entityName}Id() );
-</#if>
-        return ${componentName};
-    }
-
-    public void load()
-    {
-        if (isIdDefined())
-        {
-            wire();
-        }
-    }
-
-    public void wire()
-    {
-        getInstance();
-<#foreach property in pojo.allPropertiesIterator>
-<#if isToOne(property)>
-<#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
-<#if parentPojo.shortName!=pojo.shortName>
-<#assign parentHomeName = parentPojo.shortName?uncap_first + "Home">
-<#assign setter = "set" + pojo.getPropertyName(property)>
-        ${parentPojo.shortName} ${property.name}=${parentHomeName}.getDefinedInstance();
-        if ( ${property.name}!=null )
-        {
-           getInstance().${setter}(${property.name});
-        }
-</#if>
-</#if>
-</#foreach>
-    }
-
-    public boolean isWired()
-    {
-<#foreach property in pojo.allPropertiesIterator>
-<#if (isToOne(property) && !property.optional)>
-<#assign getter = pojo.getGetterSignature(property)>
-        if ( getInstance().${getter}()==null ) return false;
-</#if>
-</#foreach>
-        return true;
-    }
-
-    public ${entityName} getDefinedInstance()
-    {
-        return isIdDefined() ? getInstance() : null;
-    }
-
-<#foreach property in pojo.allPropertiesIterator>
-<#assign getter = pojo.getGetterSignature(property)>
-<#if c2h.isOneToManyCollection(property)>
-<#assign childPojo = c2j.getPOJOClass(property.value.element.associatedClass)>
-    public ${pojo.importType("java.util.List")}<<#if childPojo.packageName!="">${pojo.importType("${childPojo.packageName}.${childPojo.shortName}")}<#else>${childPojo.shortName}</#if>> ${getter}() {
-        return getInstance() == null ?
-            null : new ${pojo.importType("java.util.ArrayList")}<${childPojo.shortName}>( getInstance().${getter}() );
-    }
-</#if>
-</#foreach>
-
-}
-</#assign>
-
-<#if pojo.packageName != "">
-import ${pojo.packageName}.*;<#-- This import is necessary because we're using a different package than Hibernate Tools expects -->
-</#if>
-${pojo.generateImports()}
-${classbody}

Deleted: seam-gen/trunk/src/EntityList.java
===================================================================
--- seam-gen/trunk/src/EntityList.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/EntityList.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,14 +0,0 @@
-package @actionPackage@;
-
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.framework.EntityQuery;
-import @modelPackage at .@entityName@;
-
- at Name("@listName@")
-public class @entityName at List extends EntityQuery<@entityName@>
-{
-    public @entityName at List()
-    {
-        setEjbql("select @componentName@ from @entityName@ @componentName@");
-    }
-}

Deleted: seam-gen/trunk/src/EntityList.java.ftl
===================================================================
--- seam-gen/trunk/src/EntityList.java.ftl	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/EntityList.java.ftl	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,59 +0,0 @@
-<#include "../util/TypeInfo.ftl">
-<#assign entityName = pojo.shortName>
-<#assign componentName = entityName?uncap_first>
-<#assign listName = componentName + "List">
-package ${actionPackage};
-
-<#if pojo.packageName != "">
-import ${pojo.packageName}.*;<#-- This import is necessary because we're using a different package than Hibernate Tools expects -->
-</#if>
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.framework.EntityQuery;
-import java.util.Arrays;
-
- at Name("${listName}")
-public class ${entityName}List extends EntityQuery<${entityName}>
-{
-
-    private static final String EJBQL = "select ${componentName} from ${entityName} ${componentName}";
-
-    private static final String[] RESTRICTIONS = {
-<#foreach property in pojo.allPropertiesIterator>
-<#if !c2h.isCollection(property) && !isToOne(property)>
-<#if c2j.isComponent(property)>
-<#foreach componentProperty in property.value.propertyIterator>
-<#if isString(componentProperty)>
-        "lower(${componentName}.${property.name}.${componentProperty.name}) like lower(concat(${'#'}{${listName}.${componentName}.${property.name}.${componentProperty.name}},'%'))",
-</#if>
-</#foreach>
-<#else>
-<#if isString(property)>
-        "lower(${componentName}.${property.name}) like lower(concat(${'#'}{${listName}.${componentName}.${property.name}},'%'))",
-</#if>
-</#if>
-</#if>
-</#foreach>
-    };
-
-<#if pojo.isComponent(pojo.identifierProperty)>
-    private ${entityName} ${componentName};
-<#else>
-    private ${entityName} ${componentName} = new ${entityName}();
-</#if>
-
-    public ${entityName}List()
-    {
-<#if pojo.isComponent(pojo.identifierProperty)>
-        ${componentName} = new ${entityName}();
-        ${componentName}.setId( new ${entityName}Id() );
-</#if>
-        setEjbql(EJBQL);
-        setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
-        setMaxResults(25);
-    }
-
-    public ${entityName} get${entityName}()
-    {
-        return ${componentName};
-    }
-}

Deleted: seam-gen/trunk/src/FormAction.java
===================================================================
--- seam-gen/trunk/src/FormAction.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/FormAction.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,15 +0,0 @@
-package @actionPackage@;
-
-import javax.ejb.Local;
-
- at Local
-public interface @interfaceName@
-{
-    public void @methodName@();
-    public String getValue();
-    public void setValue(String value);
-    public void destroy();
-
-    // add additional interface methods here
-
-}

Deleted: seam-gen/trunk/src/FormActionBean.java
===================================================================
--- seam-gen/trunk/src/FormActionBean.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/FormActionBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,45 +0,0 @@
-package @actionPackage@;
-
-import javax.ejb.Remove;
-import javax.ejb.Stateful;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Logger;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.international.StatusMessages;
-import org.hibernate.validator.Length;
-
- at Stateful
- at Name("@componentName@")
-public class @beanName@ implements @interfaceName@
-{
-    @Logger private Log log;
-
-    @In StatusMessages statusMessages;
-
-    private String value;
-
-    public void @methodName@()
-    {
-        // implement your business logic here
-        log.info("@componentName at .@methodName@() action called with: #{@componentName at .value}");
-        statusMessages.add("@methodName@ #{@componentName at .value}");
-    }
-
-    // add additional action methods
-
-    @Length(max = 10)
-    public String getValue()
-    {
-        return value;
-    }
-
-    public void setValue(String value)
-    {
-        this.value = value;
-    }
-
-    @Remove
-    public void destroy() {}
-
-}

Deleted: seam-gen/trunk/src/FormActionJavaBean.java
===================================================================
--- seam-gen/trunk/src/FormActionJavaBean.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/FormActionJavaBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,39 +0,0 @@
-package @actionPackage@;
-
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Logger;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.international.StatusMessages;
-import org.hibernate.validator.Length;
-
- at Name("@componentName@")
-public class @interfaceName@
-{
-    @Logger private Log log;
-
-    @In StatusMessages statusMessages;
-
-    private String value;
-
-    public void @methodName@()
-    {
-        // implement your business logic here
-        log.info("@componentName at .@methodName@() action called with: #{@componentName at .value}");
-        statusMessages.add("@methodName@ #{@componentName at .value}");
-    }
-
-    // add additional action methods
-  
-    @Length(max = 10)
-    public String getValue()
-    {
-        return value;
-    }
-  
-    public void setValue(String value)
-    {
-        this.value = value;
-    }
-  
-}

Deleted: seam-gen/trunk/src/Query.java
===================================================================
--- seam-gen/trunk/src/Query.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/Query.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,28 +0,0 @@
-package @actionPackage@;
-
-import @modelPackage at .@entityName@;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.web.RequestParameter;
-import org.jboss.seam.framework.EntityQuery;
-import java.util.Arrays;
-
- at Name("@componentName@")
-public class @beanName@ extends EntityQuery<@entityName@>
-{
-    private static final String EJBQL = "@query@";
-    private static final String[] RESTRICTIONS = {};
-
-    public @beanName@()
-    {
-        setEjbql(EJBQL);
-        setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
-        setMaxResults(25);
-    }
-
-    // FIXME this causes the query to run over and over again
-    @RequestParameter
-    @Override
-    public void setFirstResult(Integer firstResult) {
-        super.setFirstResult(firstResult);
-    }
-}

Deleted: seam-gen/trunk/src/UserAccount.java
===================================================================
--- seam-gen/trunk/src/UserAccount.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/UserAccount.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,83 +0,0 @@
-package @modelPackage@;
-
-import java.io.Serializable;
-import java.util.Set;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
-
-import org.hibernate.validator.NotNull;
-import org.jboss.seam.annotations.security.management.UserEnabled;
-import org.jboss.seam.annotations.security.management.UserPassword;
-import org.jboss.seam.annotations.security.management.UserPrincipal;
-import org.jboss.seam.annotations.security.management.UserRoles;
-
- at Entity
- at Table(uniqueConstraints = @UniqueConstraint(columnNames = "username"), name = "user_account")
-public class UserAccount implements Serializable {
-	private static final long serialVersionUID = 6368734442192368866L;
-
-	private Long id;
-	private String username;
-	private String passwordHash;
-	private boolean enabled;
-
-	private Set<UserRole> roles;
-
-	@Id
-	@GeneratedValue
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	@NotNull
-	@UserPrincipal
-	public String getUsername() {
-		return username;
-	}
-
-	public void setUsername(String username) {
-		this.username = username;
-	}
-
-	@UserPassword(hash = "SHA")
-	@Column(name = "password_hash")
-	public String getPasswordHash() {
-		return passwordHash;
-	}
-
-	public void setPasswordHash(String passwordHash) {
-		this.passwordHash = passwordHash;
-	}
-
-	@UserEnabled
-	public boolean isEnabled() {
-		return enabled;
-	}
-
-	public void setEnabled(boolean enabled) {
-		this.enabled = enabled;
-	}
-
-	@UserRoles
-	@ManyToMany
-	@JoinTable(name = "user_account_role", joinColumns = @JoinColumn(name = "account_id"), inverseJoinColumns = @JoinColumn(name = "member_of_role"))
-	public Set<UserRole> getRoles() {
-		return roles;
-	}
-
-	public void setRoles(Set<UserRole> roles) {
-		this.roles = roles;
-	}
-}

Deleted: seam-gen/trunk/src/UserPermission.java
===================================================================
--- seam-gen/trunk/src/UserPermission.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/UserPermission.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,84 +0,0 @@
-package @modelPackage@;
-
-import java.io.Serializable;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-import org.jboss.seam.annotations.security.permission.PermissionAction;
-import org.jboss.seam.annotations.security.permission.PermissionDiscriminator;
-import org.jboss.seam.annotations.security.permission.PermissionRole;
-import org.jboss.seam.annotations.security.permission.PermissionTarget;
-import org.jboss.seam.annotations.security.permission.PermissionUser;
-
- at Entity
- at Table(name = "user_permission")
-public class UserPermission implements Serializable
-{
-   private static final long serialVersionUID = -5628863031792429938L;
-   
-   private Long id;
-   private String recipient;
-   private String target;
-   private String action;
-   private String discriminator;
-   
-   @Id @GeneratedValue
-   public Long getId()
-   {
-      return id;
-   }
-   
-   public void setId(Long id)
-   {
-      this.id = id;
-   }
-   
-   @PermissionUser 
-   @PermissionRole
-   public String getRecipient()
-   {
-      return recipient;
-   }
-   
-   public void setRecipient(String recipient)
-   {
-      this.recipient = recipient;
-   }
-   
-   @PermissionTarget
-   public String getTarget()
-   {
-      return target;
-   }
-   
-   public void setTarget(String target)
-   {
-      this.target = target;
-   }
-   
-   @PermissionAction
-   public String getAction()
-   {
-      return action;
-   }
-   
-   public void setAction(String action)
-   {
-      this.action = action;
-   }
-   
-   @PermissionDiscriminator
-   public String getDiscriminator()
-   {
-      return discriminator;
-   }
-   
-   public void setDiscriminator(String discriminator)
-   {
-      this.discriminator = discriminator;
-   }
-
-}

Deleted: seam-gen/trunk/src/UserRole.java
===================================================================
--- seam-gen/trunk/src/UserRole.java	2009-04-20 01:47:14 UTC (rev 10525)
+++ seam-gen/trunk/src/UserRole.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -1,69 +0,0 @@
-package @modelPackage@;
-
-import java.io.Serializable;
-import java.util.Set;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.Table;
-
-import org.hibernate.validator.NotNull;
-import org.jboss.seam.annotations.security.management.RoleConditional;
-import org.jboss.seam.annotations.security.management.RoleGroups;
-import org.jboss.seam.annotations.security.management.RoleName;
-
- at Entity
- at Table(name = "user_role")
-public class UserRole implements Serializable {
-	private static final long serialVersionUID = 9177366120789064801L;
-
-	private Long id;
-	private String name;
-	private boolean conditional;
-
-	private Set<UserRole> groups;
-
-	@Id
-	@GeneratedValue
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	@RoleName
-	@NotNull
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	@RoleGroups
-	@ManyToMany
-	@JoinTable(name = "user_role_group", joinColumns = @JoinColumn(name = "role_id"), inverseJoinColumns = @JoinColumn(name = "member_of_role"))
-	public Set<UserRole> getGroups() {
-		return groups;
-	}
-
-	public void setGroups(Set<UserRole> groups) {
-		this.groups = groups;
-	}
-
-	@RoleConditional
-	public boolean isConditional() {
-		return conditional;
-	}
-
-	public void setConditional(boolean conditional) {
-		this.conditional = conditional;
-	}
-}

Copied: seam-gen/trunk/src/template/Action.java (from rev 10523, seam-gen/trunk/src/Action.java)
===================================================================
--- seam-gen/trunk/src/template/Action.java	                        (rev 0)
+++ seam-gen/trunk/src/template/Action.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,13 @@
+package @actionPackage@;
+
+import javax.ejb.Local;
+
+ at Local
+public interface @interfaceName@
+{
+    // seam-gen method
+    public void @methodName@();
+
+    // add additional interface methods here
+
+}

Copied: seam-gen/trunk/src/template/ActionBean.java (from rev 10523, seam-gen/trunk/src/ActionBean.java)
===================================================================
--- seam-gen/trunk/src/template/ActionBean.java	                        (rev 0)
+++ seam-gen/trunk/src/template/ActionBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,27 @@
+package @actionPackage@;
+
+import javax.ejb.Stateless;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.international.StatusMessages;
+
+ at Stateless
+ at Name("@componentName@")
+public class @beanName@ implements @interfaceName@
+{
+    @Logger private Log log;
+
+    @In StatusMessages statusMessages;
+
+    public void @methodName@()
+    {
+        // implement your business logic here
+        log.info("@componentName at .@methodName@() action called");
+        statusMessages.add("@methodName@");
+    }
+
+    // add additional action methods
+
+}

Copied: seam-gen/trunk/src/template/ActionJavaBean.java (from rev 10523, seam-gen/trunk/src/ActionJavaBean.java)
===================================================================
--- seam-gen/trunk/src/template/ActionJavaBean.java	                        (rev 0)
+++ seam-gen/trunk/src/template/ActionJavaBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,25 @@
+package @actionPackage@;
+
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.international.StatusMessages;
+
+ at Name("@componentName@")
+public class @interfaceName@
+{
+    @Logger private Log log;
+
+    @In StatusMessages statusMessages;
+
+    public void @methodName@()
+    {
+        // implement your business logic here
+        log.info("@componentName at .@methodName@() action called");
+        statusMessages.add("@methodName@");
+    }
+
+    // add additional action methods
+
+}

Copied: seam-gen/trunk/src/template/Authenticator.java (from rev 10523, seam-gen/trunk/src/Authenticator.java)
===================================================================
--- seam-gen/trunk/src/template/Authenticator.java	                        (rev 0)
+++ seam-gen/trunk/src/template/Authenticator.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,32 @@
+package @actionPackage@;
+
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.security.Credentials;
+import org.jboss.seam.security.Identity;
+
+ at Name("authenticator")
+public class Authenticator
+{
+    @Logger private Log log;
+
+    @In Identity identity;
+    @In Credentials credentials;
+
+    public boolean authenticate()
+    {
+        log.info("authenticating {0}", credentials.getUsername());
+        //write your authentication logic here,
+        //return true if the authentication was
+        //successful, false otherwise
+        if ("admin".equals(credentials.getUsername()))
+        {
+            identity.addRole("admin");
+            return true;
+        }
+        return false;
+    }
+
+}

Copied: seam-gen/trunk/src/template/AuthenticatorBean.java (from rev 10523, seam-gen/trunk/src/AuthenticatorBean.java)
===================================================================
--- seam-gen/trunk/src/template/AuthenticatorBean.java	                        (rev 0)
+++ seam-gen/trunk/src/template/AuthenticatorBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,34 @@
+package @actionPackage@;
+
+import javax.ejb.Stateless;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.security.Credentials;
+import org.jboss.seam.security.Identity;
+
+ at Stateless
+ at Name("authenticator")
+public class AuthenticatorBean implements Authenticator
+{
+    @Logger private Log log;
+
+    @In Identity identity;
+    @In Credentials credentials;
+
+    public boolean authenticate()
+    {
+        log.info("authenticating {0}", credentials.getUsername());
+        //write your authentication logic here,
+        //return true if the authentication was
+        //successful, false otherwise
+        if ("admin".equals(credentials.getUsername()))
+        {
+            identity.addRole("admin");
+            return true;
+        }
+        return false;
+    }
+
+}

Copied: seam-gen/trunk/src/template/AuthenticatorLocal.java (from rev 10523, seam-gen/trunk/src/AuthenticatorLocal.java)
===================================================================
--- seam-gen/trunk/src/template/AuthenticatorLocal.java	                        (rev 0)
+++ seam-gen/trunk/src/template/AuthenticatorLocal.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,10 @@
+package @actionPackage@;
+
+import javax.ejb.Local;
+
+ at Local
+public interface Authenticator {
+
+    boolean authenticate();
+
+}

Copied: seam-gen/trunk/src/template/Conversation.java (from rev 10523, seam-gen/trunk/src/Conversation.java)
===================================================================
--- seam-gen/trunk/src/template/Conversation.java	                        (rev 0)
+++ seam-gen/trunk/src/template/Conversation.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,16 @@
+package @actionPackage@;
+
+import javax.ejb.Local;
+
+ at Local
+public interface @interfaceName@
+{
+    public String begin();
+    public String increment();
+    public String end();
+    public int getValue();
+    public void destroy();
+  
+    // add additional interface methods here
+
+}

Copied: seam-gen/trunk/src/template/ConversationBean.java (from rev 10523, seam-gen/trunk/src/ConversationBean.java)
===================================================================
--- seam-gen/trunk/src/template/ConversationBean.java	                        (rev 0)
+++ seam-gen/trunk/src/template/ConversationBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,53 @@
+package @actionPackage@;
+
+import java.io.Serializable;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.End;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.log.Log;
+
+ at Stateful
+ at Name("@componentName@")
+public class @beanName@ implements @interfaceName@, Serializable
+{
+    @Logger private Log log;
+
+    private int value;
+
+    @Begin
+    public String begin()
+    {
+        // implement your begin conversation business logic
+        log.info("beginning conversation");
+        return "success";
+    }
+  
+    public String increment()
+    {
+        log.info("incrementing");
+        value++;
+        return "success";
+    }
+  
+    // add additional action methods that participate in this conversation
+  
+    @End
+    public String end()
+    {
+        // implement your end conversation business logic
+        log.info("ending conversation");
+        return "home";
+    }
+  
+    public int getValue()
+    {
+        return value;
+    }
+  
+    @Remove
+    public void destroy() {}
+
+}

Copied: seam-gen/trunk/src/template/ConversationJavaBean.java (from rev 10523, seam-gen/trunk/src/ConversationJavaBean.java)
===================================================================
--- seam-gen/trunk/src/template/ConversationJavaBean.java	                        (rev 0)
+++ seam-gen/trunk/src/template/ConversationJavaBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,51 @@
+package @actionPackage@;
+
+import static org.jboss.seam.ScopeType.CONVERSATION;
+
+import java.io.Serializable;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.End;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.log.Log;
+
+ at Scope(CONVERSATION)
+ at Name("@componentName@")
+public class @interfaceName@ implements Serializable
+{
+    @Logger private Log log;
+
+    private int value;
+
+    @Begin
+    public String begin()
+    {
+        // implement your begin conversation business logic
+        log.info("beginning conversation");
+        return "success";
+    }
+  
+    public String increment()
+    {
+        log.info("incrementing");
+        value++;
+        return "success";
+    }
+  
+    // add additional action methods that participate in this conversation
+  
+    @End
+    public String end()
+    {
+        // implement your end conversation business logic
+        log.info("ending conversation");
+        return "home";
+    }
+  
+    public int getValue()
+    {
+        return value;
+    }
+
+}

Copied: seam-gen/trunk/src/template/Entity.java (from rev 10523, seam-gen/trunk/src/Entity.java)
===================================================================
--- seam-gen/trunk/src/template/Entity.java	                        (rev 0)
+++ seam-gen/trunk/src/template/Entity.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,49 @@
+package @modelPackage@;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Version;
+import org.hibernate.validator.Length;
+
+ at Entity
+public class @entityName@ implements Serializable
+{
+    // seam-gen attributes (you should probably edit these)
+    private Long id;
+    private Integer version;
+    private String name;
+
+    // add additional entity attributes
+
+    // seam-gen attribute getters/setters with annotations (you probably should edit)
+
+    @Id @GeneratedValue
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    @Version
+    public Integer getVersion() {
+        return version;
+    }
+
+    private void setVersion(Integer version) {
+        this.version = version;
+    }
+
+    @Length(max = 20)
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+}

Copied: seam-gen/trunk/src/template/EntityHome.java (from rev 10523, seam-gen/trunk/src/EntityHome.java)
===================================================================
--- seam-gen/trunk/src/template/EntityHome.java	                        (rev 0)
+++ seam-gen/trunk/src/template/EntityHome.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,33 @@
+package @actionPackage@;
+
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.web.RequestParameter;
+import org.jboss.seam.framework.EntityHome;
+
+import @modelPackage at .@entityName@;
+
+ at Name("@homeName@")
+public class @entityName at Home extends EntityHome<@entityName@>
+{
+    @RequestParameter Long @componentName at Id;
+
+    @Override
+    public Object getId()
+    {
+        if (@componentName at Id == null)
+        {
+            return super.getId();
+        }
+        else
+        {
+            return @componentName at Id;
+        }
+    }
+
+    @Override @Begin
+    public void create() {
+        super.create();
+    }
+
+}

Copied: seam-gen/trunk/src/template/EntityHome.java.ftl (from rev 10523, seam-gen/trunk/src/EntityHome.java.ftl)
===================================================================
--- seam-gen/trunk/src/template/EntityHome.java.ftl	                        (rev 0)
+++ seam-gen/trunk/src/template/EntityHome.java.ftl	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,134 @@
+<#include "../util/TypeInfo.ftl">
+package ${actionPackage};
+<#assign classbody>
+<#assign entityName = pojo.shortName>
+<#assign componentName = entityName?uncap_first>
+<#assign homeName = componentName + "Home">
+@${pojo.importType("org.jboss.seam.annotations.Name")}("${homeName}")
+public class ${entityName}Home extends ${pojo.importType("org.jboss.seam.framework.EntityHome")}<${entityName}>
+{
+
+<#assign parentHomeNames = []>
+<#foreach property in pojo.allPropertiesIterator>
+<#if isToOne(property)>
+<#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
+<#assign parentHomeName = parentPojo.shortName?uncap_first + "Home">
+<#if !parentHomeNames?seq_contains(parentHomeName)><#-- This doesn't fix the functionality, just allows compilation to work -->
+<#assign parentHomeNames = parentHomeNames + [parentHomeName]>
+    @${pojo.importType("org.jboss.seam.annotations.In")}(create=true)
+    <#if parentPojo.packageName!="">${pojo.importType("${parentPojo.packageName}.${parentPojo.shortName}")}<#else>${parentPojo.shortName}</#if>Home ${parentHomeName};
+</#if>
+</#if>
+</#foreach>
+
+<#assign idName = entityName + pojo.identifierProperty.name?cap_first>
+<#if c2j.isComponent(pojo.identifierProperty)>
+<#assign idType = entityName + "Id">
+<#else>
+<#assign idType = pojo.importType(pojo.identifierProperty.type.returnedClass.name)>
+</#if>
+    public void set${idName}(${idType} id)
+    {
+        setId(id);
+    }
+
+    public ${idType} get${idName}()
+    {
+        return (${idType}) getId();
+    }
+
+<#if pojo.isComponent(pojo.identifierProperty)>
+    public ${entityName}Home()
+    {
+        set${idName}( new ${entityName}Id() );
+    }
+
+    @Override
+    public boolean isIdDefined()
+    {
+<#foreach property in pojo.identifierProperty.value.propertyIterator>
+<#assign getter = pojo.getGetterSignature(property)>
+<#if property.value.typeName == "string" || property.value.typeName == "java.lang.String" >
+        if ( get${idName}().${getter}()==null || "".equals( get${idName}().${getter}() ) ) return false;
+<#elseif !c2j.isPrimitive( pojo.getJavaTypeName(property, true) )>
+        if ( get${idName}().${getter}()==null ) return false;
+<#else>
+        if ( get${idName}().${getter}()==0 ) return false;
+</#if>
+</#foreach>
+        return true;
+    }
+
+</#if>
+    @Override
+    protected ${entityName} createInstance()
+    {
+        ${entityName} ${componentName} = new ${entityName}();
+<#if pojo.isComponent(pojo.identifierProperty)>
+        ${componentName}.setId( new ${entityName}Id() );
+</#if>
+        return ${componentName};
+    }
+
+    public void load()
+    {
+        if (isIdDefined())
+        {
+            wire();
+        }
+    }
+
+    public void wire()
+    {
+        getInstance();
+<#foreach property in pojo.allPropertiesIterator>
+<#if isToOne(property)>
+<#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
+<#if parentPojo.shortName!=pojo.shortName>
+<#assign parentHomeName = parentPojo.shortName?uncap_first + "Home">
+<#assign setter = "set" + pojo.getPropertyName(property)>
+        ${parentPojo.shortName} ${property.name}=${parentHomeName}.getDefinedInstance();
+        if ( ${property.name}!=null )
+        {
+           getInstance().${setter}(${property.name});
+        }
+</#if>
+</#if>
+</#foreach>
+    }
+
+    public boolean isWired()
+    {
+<#foreach property in pojo.allPropertiesIterator>
+<#if (isToOne(property) && !property.optional)>
+<#assign getter = pojo.getGetterSignature(property)>
+        if ( getInstance().${getter}()==null ) return false;
+</#if>
+</#foreach>
+        return true;
+    }
+
+    public ${entityName} getDefinedInstance()
+    {
+        return isIdDefined() ? getInstance() : null;
+    }
+
+<#foreach property in pojo.allPropertiesIterator>
+<#assign getter = pojo.getGetterSignature(property)>
+<#if c2h.isOneToManyCollection(property)>
+<#assign childPojo = c2j.getPOJOClass(property.value.element.associatedClass)>
+    public ${pojo.importType("java.util.List")}<<#if childPojo.packageName!="">${pojo.importType("${childPojo.packageName}.${childPojo.shortName}")}<#else>${childPojo.shortName}</#if>> ${getter}() {
+        return getInstance() == null ?
+            null : new ${pojo.importType("java.util.ArrayList")}<${childPojo.shortName}>( getInstance().${getter}() );
+    }
+</#if>
+</#foreach>
+
+}
+</#assign>
+
+<#if pojo.packageName != "">
+import ${pojo.packageName}.*;<#-- This import is necessary because we're using a different package than Hibernate Tools expects -->
+</#if>
+${pojo.generateImports()}
+${classbody}

Copied: seam-gen/trunk/src/template/EntityList.java (from rev 10523, seam-gen/trunk/src/EntityList.java)
===================================================================
--- seam-gen/trunk/src/template/EntityList.java	                        (rev 0)
+++ seam-gen/trunk/src/template/EntityList.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,14 @@
+package @actionPackage@;
+
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.framework.EntityQuery;
+import @modelPackage at .@entityName@;
+
+ at Name("@listName@")
+public class @entityName at List extends EntityQuery<@entityName@>
+{
+    public @entityName at List()
+    {
+        setEjbql("select @componentName@ from @entityName@ @componentName@");
+    }
+}

Copied: seam-gen/trunk/src/template/EntityList.java.ftl (from rev 10523, seam-gen/trunk/src/EntityList.java.ftl)
===================================================================
--- seam-gen/trunk/src/template/EntityList.java.ftl	                        (rev 0)
+++ seam-gen/trunk/src/template/EntityList.java.ftl	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,59 @@
+<#include "../util/TypeInfo.ftl">
+<#assign entityName = pojo.shortName>
+<#assign componentName = entityName?uncap_first>
+<#assign listName = componentName + "List">
+package ${actionPackage};
+
+<#if pojo.packageName != "">
+import ${pojo.packageName}.*;<#-- This import is necessary because we're using a different package than Hibernate Tools expects -->
+</#if>
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.framework.EntityQuery;
+import java.util.Arrays;
+
+ at Name("${listName}")
+public class ${entityName}List extends EntityQuery<${entityName}>
+{
+
+    private static final String EJBQL = "select ${componentName} from ${entityName} ${componentName}";
+
+    private static final String[] RESTRICTIONS = {
+<#foreach property in pojo.allPropertiesIterator>
+<#if !c2h.isCollection(property) && !isToOne(property)>
+<#if c2j.isComponent(property)>
+<#foreach componentProperty in property.value.propertyIterator>
+<#if isString(componentProperty)>
+        "lower(${componentName}.${property.name}.${componentProperty.name}) like lower(concat(${'#'}{${listName}.${componentName}.${property.name}.${componentProperty.name}},'%'))",
+</#if>
+</#foreach>
+<#else>
+<#if isString(property)>
+        "lower(${componentName}.${property.name}) like lower(concat(${'#'}{${listName}.${componentName}.${property.name}},'%'))",
+</#if>
+</#if>
+</#if>
+</#foreach>
+    };
+
+<#if pojo.isComponent(pojo.identifierProperty)>
+    private ${entityName} ${componentName};
+<#else>
+    private ${entityName} ${componentName} = new ${entityName}();
+</#if>
+
+    public ${entityName}List()
+    {
+<#if pojo.isComponent(pojo.identifierProperty)>
+        ${componentName} = new ${entityName}();
+        ${componentName}.setId( new ${entityName}Id() );
+</#if>
+        setEjbql(EJBQL);
+        setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
+        setMaxResults(25);
+    }
+
+    public ${entityName} get${entityName}()
+    {
+        return ${componentName};
+    }
+}

Copied: seam-gen/trunk/src/template/FormAction.java (from rev 10523, seam-gen/trunk/src/FormAction.java)
===================================================================
--- seam-gen/trunk/src/template/FormAction.java	                        (rev 0)
+++ seam-gen/trunk/src/template/FormAction.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,15 @@
+package @actionPackage@;
+
+import javax.ejb.Local;
+
+ at Local
+public interface @interfaceName@
+{
+    public void @methodName@();
+    public String getValue();
+    public void setValue(String value);
+    public void destroy();
+
+    // add additional interface methods here
+
+}

Copied: seam-gen/trunk/src/template/FormActionBean.java (from rev 10523, seam-gen/trunk/src/FormActionBean.java)
===================================================================
--- seam-gen/trunk/src/template/FormActionBean.java	                        (rev 0)
+++ seam-gen/trunk/src/template/FormActionBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,45 @@
+package @actionPackage@;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.international.StatusMessages;
+import org.hibernate.validator.Length;
+
+ at Stateful
+ at Name("@componentName@")
+public class @beanName@ implements @interfaceName@
+{
+    @Logger private Log log;
+
+    @In StatusMessages statusMessages;
+
+    private String value;
+
+    public void @methodName@()
+    {
+        // implement your business logic here
+        log.info("@componentName at .@methodName@() action called with: #{@componentName at .value}");
+        statusMessages.add("@methodName@ #{@componentName at .value}");
+    }
+
+    // add additional action methods
+
+    @Length(max = 10)
+    public String getValue()
+    {
+        return value;
+    }
+
+    public void setValue(String value)
+    {
+        this.value = value;
+    }
+
+    @Remove
+    public void destroy() {}
+
+}

Copied: seam-gen/trunk/src/template/FormActionJavaBean.java (from rev 10523, seam-gen/trunk/src/FormActionJavaBean.java)
===================================================================
--- seam-gen/trunk/src/template/FormActionJavaBean.java	                        (rev 0)
+++ seam-gen/trunk/src/template/FormActionJavaBean.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,39 @@
+package @actionPackage@;
+
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.international.StatusMessages;
+import org.hibernate.validator.Length;
+
+ at Name("@componentName@")
+public class @interfaceName@
+{
+    @Logger private Log log;
+
+    @In StatusMessages statusMessages;
+
+    private String value;
+
+    public void @methodName@()
+    {
+        // implement your business logic here
+        log.info("@componentName at .@methodName@() action called with: #{@componentName at .value}");
+        statusMessages.add("@methodName@ #{@componentName at .value}");
+    }
+
+    // add additional action methods
+  
+    @Length(max = 10)
+    public String getValue()
+    {
+        return value;
+    }
+  
+    public void setValue(String value)
+    {
+        this.value = value;
+    }
+  
+}

Copied: seam-gen/trunk/src/template/Query.java (from rev 10523, seam-gen/trunk/src/Query.java)
===================================================================
--- seam-gen/trunk/src/template/Query.java	                        (rev 0)
+++ seam-gen/trunk/src/template/Query.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,28 @@
+package @actionPackage@;
+
+import @modelPackage at .@entityName@;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.web.RequestParameter;
+import org.jboss.seam.framework.EntityQuery;
+import java.util.Arrays;
+
+ at Name("@componentName@")
+public class @beanName@ extends EntityQuery<@entityName@>
+{
+    private static final String EJBQL = "@query@";
+    private static final String[] RESTRICTIONS = {};
+
+    public @beanName@()
+    {
+        setEjbql(EJBQL);
+        setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
+        setMaxResults(25);
+    }
+
+    // FIXME this causes the query to run over and over again
+    @RequestParameter
+    @Override
+    public void setFirstResult(Integer firstResult) {
+        super.setFirstResult(firstResult);
+    }
+}

Copied: seam-gen/trunk/src/template/UserAccount.java (from rev 10523, seam-gen/trunk/src/UserAccount.java)
===================================================================
--- seam-gen/trunk/src/template/UserAccount.java	                        (rev 0)
+++ seam-gen/trunk/src/template/UserAccount.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,83 @@
+package @modelPackage@;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+import org.hibernate.validator.NotNull;
+import org.jboss.seam.annotations.security.management.UserEnabled;
+import org.jboss.seam.annotations.security.management.UserPassword;
+import org.jboss.seam.annotations.security.management.UserPrincipal;
+import org.jboss.seam.annotations.security.management.UserRoles;
+
+ at Entity
+ at Table(uniqueConstraints = @UniqueConstraint(columnNames = "username"), name = "user_account")
+public class UserAccount implements Serializable {
+	private static final long serialVersionUID = 6368734442192368866L;
+
+	private Long id;
+	private String username;
+	private String passwordHash;
+	private boolean enabled;
+
+	private Set<UserRole> roles;
+
+	@Id
+	@GeneratedValue
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	@NotNull
+	@UserPrincipal
+	public String getUsername() {
+		return username;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
+	@UserPassword(hash = "SHA")
+	@Column(name = "password_hash")
+	public String getPasswordHash() {
+		return passwordHash;
+	}
+
+	public void setPasswordHash(String passwordHash) {
+		this.passwordHash = passwordHash;
+	}
+
+	@UserEnabled
+	public boolean isEnabled() {
+		return enabled;
+	}
+
+	public void setEnabled(boolean enabled) {
+		this.enabled = enabled;
+	}
+
+	@UserRoles
+	@ManyToMany
+	@JoinTable(name = "user_account_role", joinColumns = @JoinColumn(name = "account_id"), inverseJoinColumns = @JoinColumn(name = "member_of_role"))
+	public Set<UserRole> getRoles() {
+		return roles;
+	}
+
+	public void setRoles(Set<UserRole> roles) {
+		this.roles = roles;
+	}
+}

Copied: seam-gen/trunk/src/template/UserPermission.java (from rev 10523, seam-gen/trunk/src/UserPermission.java)
===================================================================
--- seam-gen/trunk/src/template/UserPermission.java	                        (rev 0)
+++ seam-gen/trunk/src/template/UserPermission.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,84 @@
+package @modelPackage@;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.jboss.seam.annotations.security.permission.PermissionAction;
+import org.jboss.seam.annotations.security.permission.PermissionDiscriminator;
+import org.jboss.seam.annotations.security.permission.PermissionRole;
+import org.jboss.seam.annotations.security.permission.PermissionTarget;
+import org.jboss.seam.annotations.security.permission.PermissionUser;
+
+ at Entity
+ at Table(name = "user_permission")
+public class UserPermission implements Serializable
+{
+   private static final long serialVersionUID = -5628863031792429938L;
+   
+   private Long id;
+   private String recipient;
+   private String target;
+   private String action;
+   private String discriminator;
+   
+   @Id @GeneratedValue
+   public Long getId()
+   {
+      return id;
+   }
+   
+   public void setId(Long id)
+   {
+      this.id = id;
+   }
+   
+   @PermissionUser 
+   @PermissionRole
+   public String getRecipient()
+   {
+      return recipient;
+   }
+   
+   public void setRecipient(String recipient)
+   {
+      this.recipient = recipient;
+   }
+   
+   @PermissionTarget
+   public String getTarget()
+   {
+      return target;
+   }
+   
+   public void setTarget(String target)
+   {
+      this.target = target;
+   }
+   
+   @PermissionAction
+   public String getAction()
+   {
+      return action;
+   }
+   
+   public void setAction(String action)
+   {
+      this.action = action;
+   }
+   
+   @PermissionDiscriminator
+   public String getDiscriminator()
+   {
+      return discriminator;
+   }
+   
+   public void setDiscriminator(String discriminator)
+   {
+      this.discriminator = discriminator;
+   }
+
+}

Copied: seam-gen/trunk/src/template/UserRole.java (from rev 10523, seam-gen/trunk/src/UserRole.java)
===================================================================
--- seam-gen/trunk/src/template/UserRole.java	                        (rev 0)
+++ seam-gen/trunk/src/template/UserRole.java	2009-04-20 01:48:17 UTC (rev 10526)
@@ -0,0 +1,69 @@
+package @modelPackage@;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+
+import org.hibernate.validator.NotNull;
+import org.jboss.seam.annotations.security.management.RoleConditional;
+import org.jboss.seam.annotations.security.management.RoleGroups;
+import org.jboss.seam.annotations.security.management.RoleName;
+
+ at Entity
+ at Table(name = "user_role")
+public class UserRole implements Serializable {
+	private static final long serialVersionUID = 9177366120789064801L;
+
+	private Long id;
+	private String name;
+	private boolean conditional;
+
+	private Set<UserRole> groups;
+
+	@Id
+	@GeneratedValue
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	@RoleName
+	@NotNull
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	@RoleGroups
+	@ManyToMany
+	@JoinTable(name = "user_role_group", joinColumns = @JoinColumn(name = "role_id"), inverseJoinColumns = @JoinColumn(name = "member_of_role"))
+	public Set<UserRole> getGroups() {
+		return groups;
+	}
+
+	public void setGroups(Set<UserRole> groups) {
+		this.groups = groups;
+	}
+
+	@RoleConditional
+	public boolean isConditional() {
+		return conditional;
+	}
+
+	public void setConditional(boolean conditional) {
+		this.conditional = conditional;
+	}
+}




More information about the seam-commits mailing list