/**
* Copyright 1999-2001 by Nordija <www.nordija.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
**/
package com.nordija.portal.entity;
import com.nordija.midtier.ejb.BaseEntityBean;
import com.nordija.midtier.ejb.EntityVersionException;
// TODO move into separate class
import com.nordija.midtier.utilitybeans.sequence.sessionbean.SequenceServiceHome;
import com.nordija.midtier.utilitybeans.sequence.sessionbean.SequenceService;
import com.nordija.midtier.utilitybeans.sequence.entitybean.Range;
import javax.naming.*;
import javax.ejb.*;
/**
* Core bean code for the User bean.
*
* Entity Bean - Container Managed Persistence
*
* Generated by Nordija BeanBuilder - www.nordija.com
*
* @author Nordija ApS
*/
public class UserBean extends BaseEntityBean implements UserBusiness
{
/** Unique id of the user - Persisted by container */
public long id;
/** Name of user - Persisted by container */
public String name;
/** E-mail address of user - Persisted by container */
public String email;
/**
* This method corresponds to a create method in the home interface
*
*/
public UserPK ejbCreate() throws java.rmi.RemoteException
{
try {
// TODO: Reuse at central point
Context ctx = new InitialContext();
SequenceServiceHome home = (SequenceServiceHome)ctx.lookup("nordija.portal.sequence");
SequenceService seq = home.create();
Range range = seq.getSequenceRange("User",true,1);
// Init values
this.id = range.getNextUniqueNumber();
this.name = "No name";
this.email = "none@nowhere.com";
} catch(javax.naming.NamingException ne) {
throw new java.rmi.RemoteException("Error while looking up the Sequence service",ne);
} catch(javax.ejb.CreateException ce) {
throw new java.rmi.RemoteException("Error while trying to create new instance. Check the SequenceService is installed and running correctly",ce);
}
ejbCreateDone();
return new UserPK(id);
}
/**
* This method is required by the EJB Specification, but is not used here.
*
*/
public void ejbPostCreate()
{
}
/**
* Get the value of the id attribute.
* (Unique id of the user)
*
* @return Value of id attribute
*/
public long getId()
{
return id;
}
/**
* Get the value of the name attribute.
* (Name of user)
*
* @return Value of name attribute
*/
public String getName()
{
return name;
}
/**
* Get the value of the email attribute.
* (E-mail address of user)
*
* @return Value of email attribute
*/
public String getEmail()
{
return email;
}
/**
* Set id (Unique id of the user)
*
* @param id New value for id
*/
private void setId(long id)
{
this.id = id;
setModified(true);
}
/**
* Set name (Name of user)
*
* @param name New value for name
*/
public void setName(String name)
{
this.name = name;
setModified(true);
}
/**
* Set email (E-mail address of user)
*
* @param email New value for email
*/
public void setEmail(String email)
{
this.email = email;
setModified(true);
}
/**
* Get all attributes of the bean in a single data structure
*
* @return An instance of UserData
*/
public UserData getAll()
{
return new UserData(id, name, email);
}
// TODO:
public PortletInfo[] getPortletInfo() {
return null;
}
// This might be a good place to add methods that are more specific to
// your application. Don't forget to add methods to the UserBusiness
// class if you want them to be remotely accessible.
// Please also consider additional get/set method that operate on several
// attributes in a single method - in particular if you plan to use this
// bean across a network connection.
}