package eric.share.ejb;

import java.util.Set;

import javax.ejb.CreateException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;


/**
 * The UserRoleBean.
 *
 * @ejb.bean
 *    type="CMP"
 *    cmp-version="${ejb.cmp.version}" 
 *    name="UserRole"
 *    view-type="local"
 *    local-jndi-name="${project.packages}.local.UserRole"
 *
 * @ejb.transaction
 *    type="Required"
 *
 *
 * @ejb.persistence
 *    table-name="chk_userRole"
 *
 * @ejb.home
 *    local-class="${project.packages}.interfaces.UserRoleHome"
 *
 * @ejb.interface
 *    local-class="${project.packages}.interfaces.UserRole"
 *
 * @ejb.pk
 *    class="${project.packages}.pk.UserRolePK"
 *
 * @ejb.finder
 *    signature="Collection findAll()"
 *    query="SELECT OBJECT(a) FROM UserRole AS a"
 *    transaction-type="Required"
 *    unchecked="true"
 *
 * @ejb.finder
 *    signature="UserRole findByPrimaryKey(eric.share.pk.UserRolePK pk)"
 *
 * @ejb.finder
 *    signature="UserRole findByRoleName(java.lang.String roleName)"
 *    query="SELECT OBJECT(a) FROM UserRole AS a WHERE a.roleName = ?1"
 *    methof-intf="LocalHome"
 *    result-type-mapping="Local"
 *
 * @jboss.query
 *    signature="UserRole findByRoleName(java.lang.String roleName)"
 *    query="SELECT OBJECT(a) FROM UserRole AS a WHERE a.roleName = ?1"
 *
 *
 * @jonas.bean
 *    ejb-name="UserRole"
 *    jndi-name="${project.packages}.local.UserRole"
 *
 * @jonas.jdbc-mapping
 *    jndi-name="${jonas.datasource}"
 *    jdbc-table-name="chk_userrole"
 * 
 *
 *
 * @jrun.jndi-name
 *    jndi-name="${project.packages}.local.UserRole"
 * 
 *
 * @author
 *    <a href="mailto:eric138@yahoo.com">Eric Chow</a>
 */
public abstract class UserRoleBean implements EntityBean {
	 protected EntityContext ctx;   


   /**
    * @ejb.create-method
    */
   public Object ejbCreate(long roleId, String roleName, String description) throws CreateException {
    	try {
    		setRoleId(roleId);
    		setRoleName(roleName);
    		setDescription(description);
    	} catch(Exception e) {
    		throw new CreateException(e.toString());
    	}
    		
      return null;
   }

   /**
    * Called when the object has been instantiated
    */
   public void ejbPostCreate(long roleId, String roleName, String description) { }   


   /**
    * @ejb.interface-method
    *
    */
   public abstract void setRoleId(long roleId);


   /**
    * @ejb.interface-method
    *
    * @ejb.transaction
    *      type="Supports"
    *
    * @ejb.pk-field
    *
    * @ejb.persistence
    *    column-name="roleId"
    *    
    * @jboss.persistence
    *    not-null="true"    
    *
    * @jonas.cmp-field-jdbc-mapping 
    *    field-name="roleId"
    *    jdbc-field-name="roleId"
    *    
    */	
   public abstract long getRoleId();

   /**
    * @ejb.interface-method
    *
    */
	public abstract void setRoleName(String roleName);
	
	
   /**
    * @ejb.interface-method
    *
    * @ejb.transaction
    *      type="Supports"
    *
    * @ejb.persistence
    *    column-name="roleName"
    *    
    *
    * @jboss.jdbc-type
    *    type="VARCHAR"
    *
    * @jboss.sql-type 
    *    type="VARCHAR(100)"
    *
    * @jboss.persistence
    *    not-null="true"    
    *
    * @jonas.cmp-field-jdbc-mapping 
    *    field-name="roleName"
    *    jdbc-field-name="roleName"
    *    
    */		
   public abstract String getRoleName();

   /**
    * @ejb.interface-method
    *
    */
   public abstract void setDescription(String description);

   /**
    * @ejb.interface-method
    *
    * @ejb.transaction
    *      type="Supports"
    *
    *
    * @ejb.persistence
    *    column-name="description"
    *    
    *
    * @jboss.persistence
    *    not-null="false"     
    *
    * @jonas.cmp-field-jdbc-mapping 
    *    field-name="description"
    *    jdbc-field-name="description"
    *    
    */	
   public abstract String getDescription();
   



   /**
    * Returns a Set of Users in the UserRole.
    * 
    * @ejb.interface-method
    *    view-type="local"
    *
    *
    * @ejb.relation
    *    name="user-userRole"
    *    role-name="userRole-has-users"
    *
    * @jboss.relation
    *    related-pk-field="userId"
    *    fk-column="userId"    
    *
    * @jboss.relation-table
    *    table-name="chk_user_role_link"    
    *
    *
    *
    * @weblogic.relation
    *    join-table-name="chk_user_role_link"
    *
    * @weblogic.column-map
    *    key-column="roleId"
    *    foreign-key-column="userId"    
    *
    *        
    */   
   public abstract Set getUsers();

   /**
    * Sets a Set of User to the UserRole.
    * 
    * @param Set of User.
    *
    * @ejb.interface-method
    *    view-type="local"
    *
    */   
   public abstract void setUsers(Set users);
   
   

   /**
    * Returns a Set of UserGroups in the UserRole.
    * 
    * @ejb.interface-method
    *    view-type="local"
    *
    *
    * @ejb.relation
    *    name="userGroup-userRole"
    *    role-name="userRole-belongs-to-userGroups"
    *
    * @jboss.relation
    *    related-pk-field="groupId"
    *    fk-column="groupId"
    *
    * @jboss.relation-table
    *    table-name="chk_group_role_link"
    *
    *
    *
    * @weblogic.relation
    *    join-table-name="chk_group_role_link"
    *
    * @weblogic.column-map
    *    key-column=roleId"
    *    foreign-key-column="groupId"    
    *
    *        
    */   
   public abstract Set getGroups();

   /**
    * Sets a Set of UserGroup to the UserRole.
    * 
    * @param Set of UserGroup.
    *
    * @ejb.interface-method
    *    view-type="local"
    *
    */   
   public abstract void setGroups(Set groups);
}

