/**
* 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.portlet.poll;
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.*;
import java.util.*;
/**
* Core bean code for the PollDefQA bean.
*
* Entity Bean - Container Managed Persistence
*
* Generated by Nordija BeanBuilder - www.nordija.com
*
* @author Nordija ApS
*/
public class PollDefQABean extends BaseEntityBean implements PollDefQABusiness
{
/** Unique Identifier - Persisted by container */
public long ID;
/** PollQuestion ID - Persisted by container */
public long PollQuestionID;
/** PollDefAnswer ID - Persisted by container */
public long PollDefAnswerID;
/**
* This method corresponds to a create method in the home interface
*
* @param PollQuestionID PollQuestion ID
* @param PollDefAnswerID PollDefAnswer ID
*/
public void ejbCreate(long PollQuestionID, long PollDefAnswerID) 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
setID(range.getNextUniqueNumber());
} 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);
}
setPollQuestionID(PollQuestionID);
setPollDefAnswerID(PollDefAnswerID);
// FIXME ID = "Appropriate value for ID"
// finish the job in super class
ejbCreateDone();
}
/**
* This method is required by the EJB Specification. The EJB object identity is
* available during the ejbPostCreate(...) method. The instance may, for example,
* pass its own EJB object reference to another EJB object as a method argument.
* An ejbPostCreate(...) method executes in the proper transaction context (as
* opposed to ejbCreate(...).
*
* @param PollQuestionID PollQuestion ID
* @param PollDefAnswerID PollDefAnswer ID
*/
public void ejbPostCreate(long PollQuestionID, long PollDefAnswerID)
{
}
/**
* Get the value of the ID attribute.
* (Unique Identifier )
*
* @return Value of ID attribute
*/
public long getID()
{
return ID;
}
/**
* Get the value of the PollQuestionID attribute.
* (PollQuestion ID)
*
* @return Value of PollQuestionID attribute
*/
public long getPollQuestionID()
{
return PollQuestionID;
}
/**
* Get the value of the PollDefAnswerID attribute.
* (PollDefAnswer ID)
*
* @return Value of PollDefAnswerID attribute
*/
public long getPollDefAnswerID()
{
return PollDefAnswerID;
}
/**
* Set ID (Unique Identifier )
*
* @param ID New value for ID
*/
public void setID(long ID)
{
this.ID = ID;
setModified(true);
}
/**
* Set PollQuestionID (PollQuestion ID)
*
* @param PollQuestionID New value for PollQuestionID
*/
public void setPollQuestionID(long PollQuestionID)
{
this.PollQuestionID = PollQuestionID;
setModified(true);
}
/**
* Set PollDefAnswerID (PollDefAnswer ID)
*
* @param PollDefAnswerID New value for PollDefAnswerID
*/
public void setPollDefAnswerID(long PollDefAnswerID)
{
this.PollDefAnswerID = PollDefAnswerID;
setModified(true);
}
/**
* Get all 'public' attributes of the bean in a single data structure
*
* @return An instance of PollDefQAData
*/
public PollDefQAData getAll()
{
return new PollDefQAData(ID, PollQuestionID, PollDefAnswerID);
}
// This might be a good place to add methods that are more specific to
// your application. Don't forget to add methods to the PollDefQABusiness
// 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.
}