-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of kiuma Sent: 25. mars 2003 09:43 To: [EMAIL PROTECTED] Subject: [Xdoclet-user] Urgent, please help with package substitution
Hi all, I was happily using xdoclet in my project. Now it give me some strange errors that I cannot decipher.
The "it" that gives you errors is javac - the java compiler. Maybe you could post some relevant parts of the generated code?
And oh, read this ;-)
http://www.catb.org/~esr/faqs/smart-questions.html#urgent
Cheers, Aslak
------------------------------------------------------- This SF.net email is sponsored by: The Definitive IT and Networking Event. Be There! NetWorld+Interop Las Vegas 2003 -- Register today! http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user .
I've just tryed the beta version and it works. I've also compiled the leatest cvs and it doesn't work
I attach the one of the generated file that is wrong
The problem is that in the cvs version xdoclet transform
createSpeciality( SpecialityData view )
in
createSpeciality( com.wingstech.webappointments.session.SpecialityData view )
instead of
createSpeciality( com.wingstech.webappointments.interfaces.SpecialityData view ) [at least]
So the bug is mine or it is a xdoclet' bug?
Thanks in advance. kiuma
/* * Generated by XDoclet - Do not edit! */ package com.wingstech.webappointments.interfaces;
/**
* Remote interface for ActivitySession.
*/
public interface ActivitySession
extends javax.ejb.EJBObject
{
/**
* Create new Speciality object
* @return Returns the Speciality' code.
* @throws RemoteException Idnicates that the creation process failed
*/
public java.lang.String createSpeciality(
com.wingstech.webappointments.session.SpecialityData view )
throws java.rmi.RemoteException;
/**
* Create new Activity object
* @return Returns the Activity' code.
* @throws RemoteException Idnicates that the creation process failed
*/
public java.lang.String createActivity(
com.wingstech.webappointments.session.ActivityData view,java.lang.String specCode )
throws java.rmi.RemoteException;
/**
* Modify a Speciality object
* @throws RemoteException Idnicates that the creation process failed
*/
public void editSpeciality( com.wingstech.webappointments.session.SpecialityData
view )
throws java.rmi.RemoteException;
/**
* Modify a Activity object
* @throws RemoteException Idnicates that the creation process failed
*/
public void editActivity( com.wingstech.webappointments.session.ActivityData view )
throws java.rmi.RemoteException;
/**
* Return a Speciality by its code
* @param pCode the code of this speciality
* @return Returns a SpecialityData
* @throws RemoteException Idnicates that the creation process failed
*/
public com.wingstech.webappointments.session.SpecialityData getSpecialityByCode(
java.lang.String pCode )
throws java.rmi.RemoteException;
/**
* Return a Speciality by its description
* @param pDescription The description of this speciality
* @return Returns a SpecialityData
* @throws RemoteException Idnicates that the creation process failed
*/
public com.wingstech.webappointments.session.SpecialityData
getSpecialityByDescription( java.lang.String pDescription )
throws java.rmi.RemoteException;
/**
* Return a ActivityCenter by its id
* @param pId the Id of the ActivityCenter to find
* @return Returns a ActivityCenterData
* @throws RemoteException Idnicates that the creation process failed
*/
public com.wingstech.webappointments.session.ActivityCenterData getActivCenterById(
int pId )
throws java.rmi.RemoteException;
/**
* Return a ActivityCenter by its description
* @param pDescription the Description of the ActivityCenter to find
* @return Returns a ActivityCenterData
* @throws RemoteException Idnicates that the creation process failed
*/
public com.wingstech.webappointments.session.ActivityCenterData
getActivCenterByDescription( java.lang.String pDescription )
throws java.rmi.RemoteException;
/**
* Return a Colection of ActivityCenter' CalendarData
* @param pId the Id of the ActivityCenter to find
* @return Returns a Collection of CalendarData
* @throws RemoteException Idnicates that the creation process failed
*/
public java.util.Collection getActivCenterCalendar( int pId )
throws java.rmi.RemoteException;
/**
* Return a Colection of ActivityCenter' CalendarData
* @param pId the Id of the ActivityCenter to find
* @param pDate the date we are intereste in
* @return Returns a CalendarData
* @throws RemoteException Idnicates that the creation process failed
*/
public com.wingstech.webappointments.session.CalendarData
getActivCenterCalendarInDate( int pId,java.util.Date pDate )
throws java.rmi.RemoteException;
/**
* Return a Activity by its code
* @return Returns a ActivityData
* @throws RemoteException Idnicates that the creation process failed
*/
public com.wingstech.webappointments.session.ActivityData getActivityByCode(
java.lang.String pCode )
throws java.rmi.RemoteException;
/**
* Return a Speciality Activity by its description
* @param pSpecialityCode the code of the relative speciality
* @param pActivityDescription The activity description
* @return Returns a ActivityData
* @throws RemoteException Idnicates that the creation process failed
*/
public com.wingstech.webappointments.session.ActivityData
getSpecialityActivityByDescription( java.lang.String pSpecialityCode,java.lang.String
pActivityDescription )
throws java.rmi.RemoteException;
/**
* Return a SorteActivityFull Collection given an ActivityCenter code
* @param pActivityCenterId the id of the ActivityCenter
* @return Returns a SorteActivityFull
* @throws RemoteException Idnicates that the creation process failed
*/
public java.util.Collection getActivCenterFullActivities( java.lang.String
pActivityCenterId )
throws java.rmi.RemoteException;
/**
* Return a SorteActivityFull Collection
* @return Returns a SorteActivityFull
* @throws RemoteException Idnicates that the creation process failed
*/
public java.util.Collection getFullActivities( )
throws java.rmi.RemoteException;
/**
* Return a Collection of Activity code given an ActivityCenter code sorted by
description
* @param pActivityCenterId the id of the ActivityCenter
* @return Returns a Collection of Activity id
* @throws RemoteException Idnicates that the creation process failed
*/
public java.util.Collection getActivCenterActivityCodes( java.lang.String
pActivityCenterId )
throws java.rmi.RemoteException;
/**
* Return a Collection of Activity code given an ActivityCenter code sorted by
description
* @param pActivityCode the code of the Activity
* @param pageNum page nuber
* @param pageSize Nuber of rows to display per page
* @return Returns a Collection of Activity id
* @throws RemoteException Idnicates that the creation process failed
*/
public java.util.Collection getActivityActivCenters( java.lang.String
pActivityCode,int pageNum,int pageSize )
throws java.rmi.RemoteException;
/**
* Return a Collection of Activity code given an ActivityCenter code sorted by
description
* @param pActivityCode the code of the Activity
* @param pageNum page nuber
* @param pageSize Nuber of rows to display per page
* @return Returns a Collection of Activity id
* @throws RemoteException Idnicates that the creation process failed
*/
public java.util.Collection getActivityActivCentersEnabled( java.lang.String
pActivityCode,int pageNum,int pageSize )
throws java.rmi.RemoteException;
/**
* Returns a Collection of Activities related to the given speciality
* @param pSpecCode The code of the speciality
* @return Returns a collaction of ActivityData
* @throws RemoteException Idnicates that the creation process failed
*/
public java.util.Collection getSpecialityActivities( java.lang.String pSpecCode )
throws java.rmi.RemoteException;
/**
* Get a collection (SpecialityData) of all a Speciality objects
* @return Returns the collection of all SpecialityData
* @throws RemoteException Idnicates that the creation process failed
*/
public java.util.Collection getAllSpecialities( )
throws java.rmi.RemoteException;
/**
* Get a collection (ActivityCenterData) of all a ActivityCenter objects
* @return Returns the collection of all ActivityCenterData
* @throws RemoteException Idnicates that the creation process failed
*/
public java.util.Collection getAllActivCenters( )
throws java.rmi.RemoteException;
/**
* Delete al the specialities whose code is expressed in the collection param
* @param pCode The list of the specialities I want to delete
* @throws RemoteException Idnicates that the creation process failed
*/
public void deleteSpecialitiesByCodes( java.util.Collection pCodes )
throws java.rmi.RemoteException;
/**
* Delete al the activities whose code is expressed in the collection param
* @param pCode The list of the activties I want to delete
* @throws RemoteException Idnicates that the creation process failed
*/
public void deleteActivitiesByCodes( java.util.Collection pCodes )
throws java.rmi.RemoteException;
/**
* Delete all the activitycenters whose code is expressed in the collection param
* @param pIds The list of the activties I want to delete
* @throws RemoteException Idnicates that the creation process failed
*/
public void deleteActivCenterByCodes( java.util.Collection pIds )
throws java.rmi.RemoteException;
/**
* Return a Update or insert an activity center Bean
* @param pVeiew the Activity center data
* @param pCalendarId the calendar id of
* @param pActivities all the activities (their id) of this center
* @return Returns the id of the bean inserted
* @throws RemoteException Idnicates that the creation process failed
*/
public java.lang.String updateActivityCenter(
com.wingstech.webappointments.session.ActivityCenterData pView,java.util.Collection
pCalendars,java.util.Collection pActivities )
throws java.rmi.RemoteException;
}
/*
* ActivitySessionBean.java
*
* Created on 15 novembre 2002, 16.49
*/
package com.wingstech.webappointments.session;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.FinderException;
import javax.ejb.RemoveException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import javax.security.auth.login.*;
import javax.security.auth.callback.*;
//--------Calendar Imports-------------------------------------------
import com.wingstech.webappointments.interfaces.*;
//--------Role Imports-------------------------------------------
import java.util.Collection;
import java.util.Vector;
import java.util.Iterator;
/**
* Session Bean Template
*
* ATTENTION: Some of the XDoclet tags are hidden from XDoclet by
* adding a "--" between @ and the namespace. Please remove
* this "--" to make it active or add a space to make an
* active tag inactive.
*
* @ejb.bean name="ActivitySession"
* display-name="Activity Session Bean"
* type="Stateless"
* transaction-type="Container"
* jndi-name="ejb/webappointments/ActivitySession"
*
* @ejb.ejb-ref ejb-name="Calendar"
* ref-name="ejb/mywebappointments/Calendar"
* view-type="local"
*
* @ejb.ejb-ref ejb-name="Activity"
* ref-name="ejb/mywebappointments/Activity"
* view-type="local"
*
* @ejb.ejb-ref ejb-name="ActivityCenter"
* ref-name="ejb/mywebappointments/ActivityCenter"
* view-type="local"
*
* @ejb.ejb-ref ejb-name="Speciality"
* ref-name="ejb/mywebappointments/Speciality"
* view-type="local"
*
* @ejb.security-role-ref role-name="ApplicationAdmin"
* role-link="Admin"
*
* @ejb.permission role-name="Admin"
*
* @ejb.security-identity
* run-as="Admin"
*
* @web.ejb-ref
* name="ejb/webappointments/ActivitySession"
* type="Session"
* home="com.wingstech.webappointments.interfaces.ActivitySessionHome"
* remote="com.wingstech.webappointments.interfaces.ActivitySession"
*
**/
public class ActivitySessionBean implements SessionBean {
// -------------------------------------------------------------------------
// Members
// -------------------------------------------------------------------------
private SessionContext mContext;
// -------------------------------------------------------------------------
// Methods
// -------------------------------------------------------------------------
/**
* Create new Speciality object
* @return Returns the Speciality' code.
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public String createSpeciality( SpecialityData view)
throws
RemoteException
{
SpecialityData cData;
String specialityCode = "";
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
SpecialityLocalHome lHome = (SpecialityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Speciality"
),
SpecialityLocalHome.class
);
SpecialityLocal cEntity = lHome.create( view );
specialityCode = cEntity.getValueObject().getCode() + "";
}
catch ( NamingException ne ) {
System.out.println("Speciality creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( CreateException ce ) {
System.out.println("Speciality creation error: " + ce.getMessage());
throw new EJBException( "Failure while creating a generator session bean: " +
ce.getMessage() );
}
catch ( Exception e ) {
System.out.println("Speciality error: " + e.getMessage());
}
return specialityCode;
}
/**
* Create new Activity object
* @return Returns the Activity' code.
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public String createActivity( ActivityData view, String specCode)
throws
RemoteException
{
ActivityData cData;
String activityCode = "";
SpecialityLocal lSpec;
try {
// Get Speciality Entity Remote Interface
Context lContext = new InitialContext();
SpecialityLocalHome lHome = (SpecialityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Speciality"
),
SpecialityLocalHome.class
);
lSpec = lHome.findByPrimaryKey( new SpecialityPK(specCode) );
}
catch ( NamingException ne ) {
System.out.println("Speciality creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( Exception e ) {
System.out.println("Speciality error: " + e.getMessage());
throw new EJBException( "Activity error: " + e.getMessage() );
}
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
ActivityLocalHome lHome = (ActivityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Activity"
),
ActivityLocalHome.class
);
ActivityLocal cEntity = lHome.create( view, lSpec );
activityCode = cEntity.getValueObject().getCode() + "";
}
catch ( NamingException ne ) {
System.out.println("Activity creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( CreateException ce ) {
System.out.println("Activity creation error: " + ce.getMessage());
throw new EJBException( "Failure while creating a generator session bean: "
+ ce.getMessage() );
}
catch ( Exception e ) {
System.out.println("Activity error: " + e.getMessage());
throw new EJBException( "Activity error: " + e.getMessage() );
}
return activityCode;
}
/**
* Modify a Speciality object
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public void editSpeciality( SpecialityData view)
throws
RemoteException
{
SpecialityData cData;
String specialityCode = "";
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
SpecialityLocalHome lHome = (SpecialityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Speciality"
),
SpecialityLocalHome.class
);
SpecialityLocal cEntity = lHome.findByPrimaryKey( new
SpecialityPK(view.getCode()) );
cEntity.setValueObject( view );
}
catch ( NamingException ne ) {
System.out.println("Speciality creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("Speciality creation error: " + ce.getMessage());
throw new EJBException( "Failure while creating a generator session bean: " +
ce.getMessage() );
}
catch ( Exception e ) {
System.out.println("Speciality error: " + e.getMessage());
}
}
/**
* Modify a Activity object
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public void editActivity( ActivityData view)
throws
RemoteException
{
try {
// Get Activity Entity Remote Interface
Context lContext = new InitialContext();
ActivityLocalHome lHome = (ActivityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Activity"
),
ActivityLocalHome.class
);
ActivityLocal cEntity = lHome.findByPrimaryKey( new
ActivityPK(view.getCode()) );
cEntity.setValueObject( view );
}
catch ( NamingException ne ) {
System.out.println("Activity creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("Activity creation error: " + ce.getMessage());
throw new EJBException( "Failure while creating a generator session bean: " +
ce.getMessage() );
}
catch ( Exception e ) {
System.out.println("Activity error: " + e.getMessage());
}
}
/**
* Return a Speciality by its code
* @param pCode the code of this speciality
* @return Returns a SpecialityData
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
* @ejb.permission role-name="Admin,PoweredUser,User"
*
**/
public SpecialityData getSpecialityByCode( String pCode)
throws
RemoteException
{
SpecialityData cData;
String specialityCode = "";
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
SpecialityLocalHome lHome = (SpecialityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Speciality"
),
SpecialityLocalHome.class
);
SpecialityLocal cEntity = lHome.findByPrimaryKey( new SpecialityPK(pCode) );
return cEntity.getValueObject();
}
catch ( NamingException ne ) {
System.out.println("Speciality creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("Speciality not found error: " + ce.getMessage());
throw new EJBException( "Failure while searching Speciality bean: " +
ce.getMessage() );
}
}
/**
* Return a Speciality by its description
* @param pDescription The description of this speciality
* @return Returns a SpecialityData
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public SpecialityData getSpecialityByDescription( String pDescription)
throws
RemoteException
{
SpecialityData cData;
String specialityCode = "";
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
SpecialityLocalHome lHome = (SpecialityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Speciality"
),
SpecialityLocalHome.class
);
SpecialityLocal cEntity = lHome.findByDescription( pDescription );
return cEntity.getValueObject();
}
catch ( NamingException ne ) {
System.out.println("Speciality creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("Speciality not found error: " + ce.getMessage());
throw new EJBException( "Failure while searching Speciality bean: " +
ce.getMessage() );
}
}
/**
* Return a ActivityCenter by its id
* @param pId the Id of the ActivityCenter to find
* @return Returns a ActivityCenterData
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public ActivityCenterData getActivCenterById( int pId )
throws
RemoteException
{
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
ActivityCenterLocalHome lHome = (ActivityCenterLocalHome)
PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/ActivityCenter"
),
ActivityCenterLocalHome.class
);
ActivityCenterLocal acEntity = lHome.findByPrimaryKey( new ActivityCenterPK(
pId ) );
return acEntity.getValueObject();
}
catch ( NamingException ne ) {
System.out.println("ActivityCenter creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("ActivityCenter not found error: " + ce.getMessage());
throw new EJBException( "Failure while searching ActivityCenter bean: " +
ce.getMessage() );
}
}
/**
* Return a ActivityCenter by its description
* @param pDescription the Description of the ActivityCenter to find
* @return Returns a ActivityCenterData
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public ActivityCenterData getActivCenterByDescription( String pDescription )
throws
RemoteException
{
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
ActivityCenterLocalHome lHome = (ActivityCenterLocalHome)
PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/ActivityCenter"
),
ActivityCenterLocalHome.class
);
ActivityCenterLocal acEntity = lHome.findByDescription( pDescription );
return acEntity.getValueObject();
}
catch ( NamingException ne ) {
System.out.println("ActivityCenter creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("ActivityCenter not found error: " + ce.getMessage());
throw new EJBException( "Failure while searching ActivityCenter bean: " +
ce.getMessage() );
}
}
/**
* Return a Colection of ActivityCenter' CalendarData
* @param pId the Id of the ActivityCenter to find
* @return Returns a Collection of CalendarData
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public Collection getActivCenterCalendar( int pId )
{
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
ActivityCenterLocalHome lHome = (ActivityCenterLocalHome)
PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/ActivityCenter"
),
ActivityCenterLocalHome.class
);
ActivityCenterLocal acEntity = lHome.findByPrimaryKey( new ActivityCenterPK(
pId ) );
try {
Collection calendarsLocal = acEntity.getCalendars();
Iterator iter = calendarsLocal.iterator();
Collection calendarsData = new Vector();
CalendarLocal cLocal;
while (iter.hasNext()) {
cLocal = (CalendarLocal)iter.next();
calendarsData.add( cLocal.getValueObject());
}
return calendarsData;
} catch (Exception e) {
return new Vector();
}
}
catch ( NamingException ne ) {
System.out.println("ActivityCenter creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("ActivityCenter not found error: " + ce.getMessage());
throw new EJBException( "Failure while searching ActivityCenter bean: " +
ce.getMessage() );
}
}
/**
* Return a Colection of ActivityCenter' CalendarData
* @param pId the Id of the ActivityCenter to find
* @param pDate the date we are intereste in
* @return Returns a CalendarData
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public CalendarData getActivCenterCalendarInDate( int pId, java.util.Date pDate )
{
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
ActivityCenterLocalHome lHome = (ActivityCenterLocalHome)
PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/ActivityCenter"
),
ActivityCenterLocalHome.class
);
ActivityCenterLocal acEntity = lHome.findByPrimaryKey( new ActivityCenterPK(
pId ) );
try {
Collection calendarsLocal = acEntity.getCalendars();
Iterator iter = calendarsLocal.iterator();
Collection calendarsData = new Vector();
CalendarData cData;
while (iter.hasNext()) {
cData = ((CalendarLocal)iter.next()).getValueObject();
if ( isValidCalendar(cData, pDate) )
{
System.out.println( "Valid calendar is: " + cData.getDescription()
);
return cData;
} else {
System.out.println( "This is a not valid calendar: " +
cData.getDescription() + " for date: " + pDate.toString());
}
}
throw new EJBException( "Not in period exception" + pDate.toString() );
} catch (Exception e) {
throw new EJBException( "Unexpected exception: " + e.getMessage() );
}
}
catch ( NamingException ne ) {
System.out.println("ActivityCenter creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("ActivityCenter not found error: " + ce.getMessage());
throw new EJBException( "Failure while searching ActivityCenter bean: " +
ce.getMessage() );
}
}
/**
* Return a Activity by its code
* @return Returns a ActivityData
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public ActivityData getActivityByCode( String pCode)
throws
RemoteException
{
SpecialityData cData;
String specialityCode = "";
try {
// Get Activity Entity Remote Interface
Context lContext = new InitialContext();
ActivityLocalHome lHome = (ActivityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Activity"
),
ActivityLocalHome.class
);
ActivityLocal cEntity = lHome.findByPrimaryKey( new ActivityPK(pCode) );
return cEntity.getValueObject();
}
catch ( NamingException ne ) {
System.out.println("Activity creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("Activity creation error: " + ce.getMessage());
throw new EJBException( "Failure element not found error: " + ce.getMessage()
);
}
}
/**
* Return a Speciality Activity by its description
* @param pSpecialityCode the code of the relative speciality
* @param pActivityDescription The activity description
* @return Returns a ActivityData
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public ActivityData getSpecialityActivityByDescription( String pSpecialityCode,
String pActivityDescription)
throws
RemoteException
{
SpecialityData cData;
String specialityCode = "";
try {
// Get Activity Entity Remote Interface
Context lContext = new InitialContext();
ActivityLocalHome lHome = (ActivityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Activity"
),
ActivityLocalHome.class
);
ActivityLocal cEntity = lHome.findInSpecialityByDescription( pSpecialityCode,
pActivityDescription );
return cEntity.getValueObject();
}
catch ( NamingException ne ) {
System.out.println("Activity creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("Activity creation error: " + ce.getMessage());
throw new EJBException( "Failure element not found error: " + ce.getMessage()
);
}
}
/**
* Return a SorteActivityFull Collection given an ActivityCenter code
* @param pActivityCenterId the id of the ActivityCenter
* @return Returns a SorteActivityFull
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public Collection getActivCenterFullActivities( String pActivityCenterId) {
SortedActivityFull result = new SortedActivityFull();
try {
Context lContext = new InitialContext();
ActivityCenterLocalHome lHome = (ActivityCenterLocalHome)
PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/ActivityCenter"
),
ActivityCenterLocalHome.class
);
ActivityCenterLocal acEntity = lHome.findByPrimaryKey( new
ActivityCenterPK(Integer.parseInt(pActivityCenterId)) );
Collection unsortedActivities = acEntity.getActivities();
Iterator iter = unsortedActivities.iterator();
ActivityLocal activity;
while (iter.hasNext()) {
activity = (ActivityLocal)iter.next();
result.add( new ActivityFullData(activity.getValueObject(),
activity.getSpeciality().getValueObject().getDescription()) );
}
}
catch ( NamingException ne ) {
System.out.println("ActivityCenter creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("ActivityCenter element not found error: " +
ce.getMessage());
throw new EJBException( "Failure element not found error: " +
ce.getMessage() );
}
return result;
}
/**
* Return a SorteActivityFull Collection
* @return Returns a SorteActivityFull
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public Collection getFullActivities( ) {
SortedActivityFull result = new SortedActivityFull();
try {
Context lContext = new InitialContext();
ActivityLocalHome lHome = (ActivityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Activity"
),
ActivityLocalHome.class
);
Collection unsortedActivities = lHome.findAll();
Iterator iter = unsortedActivities.iterator();
ActivityLocal activity;
while (iter.hasNext()) {
activity = (ActivityLocal)iter.next();
try {
ActivityData aData = activity.getValueObject();
SpecialityLocal lSpec= activity.getSpeciality();
SpecialityData sData= lSpec.getValueObject();
result.add( new ActivityFullData(aData, sData.getDescription()) );
} catch (Exception e) {
}
}
}
catch ( NamingException ne ) {
System.out.println("ActivityCenter creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("ActivityCenter element not found error: " +
ce.getMessage());
throw new EJBException( "Failure element not found error: " +
ce.getMessage() );
}
return result;
}
/**
* Return a Collection of Activity code given an ActivityCenter code sorted by
description
* @param pActivityCenterId the id of the ActivityCenter
* @return Returns a Collection of Activity id
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public Collection getActivCenterActivityCodes( String pActivityCenterId ) {
Collection result = new Vector();
try {
Context lContext = new InitialContext();
ActivityCenterLocalHome lHome = (ActivityCenterLocalHome)
PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/ActivityCenter"
),
ActivityCenterLocalHome.class
);
ActivityCenterLocal acEntity = lHome.findByPrimaryKey( new
ActivityCenterPK(Integer.parseInt(pActivityCenterId)) );
Collection unsortedActivities = acEntity.getActivities();
Iterator iter = unsortedActivities.iterator();
ActivityLocal activity;
while (iter.hasNext()) {
activity = (ActivityLocal)iter.next();
result.add( activity.getValueObject().getCode() );
}
return result;
}
catch ( NamingException ne ) {
System.out.println("ActivityCenter creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("ActivityCenter element not found error: " +
ce.getMessage());
throw new EJBException( "Failure element not found error: " +
ce.getMessage() );
}
}
/**
* Return a Collection of Activity code given an ActivityCenter code sorted by
description
* @param pActivityCode the code of the Activity
* @param pageNum page nuber
* @param pageSize Nuber of rows to display per page
* @return Returns a Collection of Activity id
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public Collection getActivityActivCenters( String pActivityCode, int pageNum, int
pageSize) {
Collection result = java.util.Collections.EMPTY_SET;
try {
Context lContext = new InitialContext();
ActivityCenterLocalHome lHome = (ActivityCenterLocalHome)
PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/ActivityCenter"
),
ActivityCenterLocalHome.class
);
Collection unsortedActivityCenters = lHome.findByActivity( pActivityCode
);
Iterator iter = unsortedActivityCenters.iterator();
ActivityCenterLocal activityCenter;
int elements = 0;
int i = 0;
while ( (iter.hasNext()) || (elements >= pageSize) ){
activityCenter = (ActivityCenterLocal)iter.next();
if ( (i % pageSize) == (pageNum - 1) )
{
result.add( activityCenter.getValueObject() );
elements++;
}
}
return result;
}
catch ( NamingException ne ) {
System.out.println("ActivityCenter creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("ActivityCenter element not found error: " +
ce.getMessage());
throw new EJBException( "Failure element not found error: " +
ce.getMessage() );
}
}
/**
* Return a Collection of Activity code given an ActivityCenter code sorted by
description
* @param pActivityCode the code of the Activity
* @param pageNum page nuber
* @param pageSize Nuber of rows to display per page
* @return Returns a Collection of Activity id
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
* @ejb.permission role-name="Admin,PoweredUser,User"
*
**/
public Collection getActivityActivCentersEnabled( String pActivityCode, int
pageNum, int pageSize) {
//Collection result = new SortedActivityCenter();
Collection result = java.util.Collections.EMPTY_SET;
try {
Context lContext = new InitialContext();
ActivityCenterLocalHome lHome = (ActivityCenterLocalHome)
PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/ActivityCenter"
),
ActivityCenterLocalHome.class
);
Collection unsortedActivityCenters = lHome.findByActivityEnabled(
pActivityCode );
Iterator iter = unsortedActivityCenters.iterator();
ActivityCenterLocal activityCenter;
int elements = 0;
int i = 0;
while ( (iter.hasNext()) || (elements >= pageSize) ){
activityCenter = (ActivityCenterLocal)iter.next();
if ( (i % pageSize) == (pageNum - 1) )
{
result.add( activityCenter.getValueObject() );
elements++;
}
}
return result;
}
catch ( NamingException ne ) {
System.out.println("ActivityCenter creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("ActivityCenter element not found error: " +
ce.getMessage());
throw new EJBException( "Failure element not found error: " +
ce.getMessage() );
}
}
/**
* Returns a Collection of Activities related to the given speciality
* @param pSpecCode The code of the speciality
* @return Returns a collaction of ActivityData
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.permission role-name="Admin,PoweredUser,User"
* @ejb.interface-method view-type="remote"
**/
public Collection getSpecialityActivities( String pSpecCode )
throws
RemoteException
{
SpecialityData cData;
String specialityCode = "";
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
ActivityLocalHome lHome = (ActivityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Activity"
),
ActivityLocalHome.class
);
Collection cActivities = lHome.findInSpeciality( pSpecCode );
Collection activitiesData = new Vector();
try {
Iterator iter = cActivities.iterator();
ActivityData aData;
while (iter.hasNext()) {
aData = ((ActivityLocal)iter.next()).getValueObject();
activitiesData.add( aData );
}
} catch (Exception e) {}
return activitiesData;
}
catch ( NamingException ne ) {
System.out.println("Speciality creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("Speciality creation error: " + ce.getMessage());
throw new EJBException( "Failure while creating a generator session bean: " +
ce.getMessage() );
}
}
/**
* Get a collection (SpecialityData) of all a Speciality objects
* @return Returns the collection of all SpecialityData
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.permission role-name="Admin,PoweredUser,User"
*
* @ejb.interface-method view-type="remote"
**/
public Collection getAllSpecialities()
throws
RemoteException
{
Collection result = new Vector();
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
SpecialityLocalHome lHome = (SpecialityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Speciality"
),
SpecialityLocalHome.class
);
Collection cSpecLocal = lHome.findAll();
Iterator iter = cSpecLocal.iterator();
while (iter.hasNext())
result.add( ((SpecialityLocal)iter.next()).getValueObject() );
}
catch ( NamingException ne ) {
System.out.println("Speciality creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("Speciality creation error: " + ce.getMessage());
throw new EJBException( "Failure Failure findig Speciality bean: " +
ce.getMessage() );
}
catch ( Exception e ) {
System.out.println("Speciality error: " + e.getMessage());
}
return result;
}
/**
* Get a collection (ActivityCenterData) of all a ActivityCenter objects
* @return Returns the collection of all ActivityCenterData
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public Collection getAllActivCenters()
throws
RemoteException
{
Collection result = new Vector();
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
ActivityCenterLocalHome lHome = (ActivityCenterLocalHome)
PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/ActivityCenter"
),
ActivityCenterLocalHome.class
);
Collection cSpecLocal = lHome.findAll();
Iterator iter = cSpecLocal.iterator();
while (iter.hasNext())
result.add( ((ActivityCenterLocal)iter.next()).getValueObject() );
}
catch ( NamingException ne ) {
System.out.println("ActivityCenter creation error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("ActivityCenter creation error: " + ce.getMessage());
throw new EJBException( "Failure findig ActivityCenter bean: " +
ce.getMessage() );
}
catch ( Exception e ) {
System.out.println("Speciality error: " + e.getMessage());
}
return result;
}
/**
* Delete al the specialities whose code is expressed in the collection param
* @param pCode The list of the specialities I want to delete
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public void deleteSpecialitiesByCodes( Collection pCodes)
throws
RemoteException
{
SpecialityData cData;
String specialityCode = "";
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
SpecialityLocalHome lHome = (SpecialityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Speciality"
),
SpecialityLocalHome.class
);
Iterator iter = pCodes.iterator();
SpecialityLocal itemToDelete;
while (iter.hasNext()) {
itemToDelete = lHome.findByPrimaryKey( new
SpecialityPK((String)iter.next()) );
itemToDelete.remove();
}
}
catch ( NamingException ne ) {
System.out.println("Speciality naming error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("Speciality findByCodes error: " + ce.getMessage());
throw new EJBException( "Failure while creating a generator session bean: " +
ce.getMessage() );
}
catch ( Exception e ) {
System.out.println("Speciality error: " + e.getMessage());
}
}
/**
* Delete al the activities whose code is expressed in the collection param
* @param pCode The list of the activties I want to delete
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public void deleteActivitiesByCodes( Collection pCodes)
throws
RemoteException
{
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
ActivityLocalHome lHome = (ActivityLocalHome) PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Activity"
),
ActivityLocalHome.class
);
Iterator iter = pCodes.iterator();
ActivityLocal itemToDelete;
while (iter.hasNext()) {
itemToDelete = lHome.findByPrimaryKey( new ActivityPK((String)iter.next())
);
itemToDelete.remove();
}
}
catch ( NamingException ne ) {
System.out.println("Activity naming error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("Activity findByCodes error: " + ce.getMessage());
throw new EJBException( "Failure while creating a generator session bean: " +
ce.getMessage() );
}
catch ( Exception e ) {
System.out.println("Activity error: " + e.getMessage());
}
}
/**
* Delete all the activitycenters whose code is expressed in the collection param
* @param pIds The list of the activties I want to delete
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public void deleteActivCenterByCodes( Collection pIds)
throws
RemoteException
{
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
ActivityCenterLocalHome lHome = (ActivityCenterLocalHome)
PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/ActivityCenter"
),
ActivityCenterLocalHome.class
);
System.out.println("Deleting " + pIds.size() + " AC");
Iterator iter = pIds.iterator();
ActivityCenterLocal itemToDelete;
int id;
while (iter.hasNext()) {
id = Integer.parseInt( ((String)iter.next()) );
System.out.println( "Deleting AC: " + id );
itemToDelete = lHome.findByPrimaryKey( new ActivityCenterPK(id) );
itemToDelete.remove();
}
}
catch ( NamingException ne ) {
System.out.println("ActivityCenter naming error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("ActivityCenter findByCodes error: " + ce.getMessage());
throw new EJBException( "Failure while creating a generator session bean: " +
ce.getMessage() );
}
catch ( Exception e ) {
System.out.println("ActivityCenter unknown error: " + e.getMessage());
}
}
/**
* Return a Update or insert an activity center Bean
* @param pVeiew the Activity center data
* @param pCalendarId the calendar id of
* @param pActivities all the activities (their id) of this center
* @return Returns the id of the bean inserted
* @throws RemoteException Idnicates that the creation process failed
*
* @ejb.interface-method view-type="remote"
**/
public String updateActivityCenter( ActivityCenterData pView, Collection
pCalendars, Collection pActivities)
throws
RemoteException
{
try {
// Get Calendar Entity Remote Interface
Context lContext = new InitialContext();
ActivityCenterLocal acLocal;
ActivityCenterLocalHome lHome = (ActivityCenterLocalHome)
PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/ActivityCenter"
),
ActivityCenterLocalHome.class
);
if (pView.getId() == 0) {
acLocal = lHome.create(pView);
} else {
acLocal = lHome.findByPrimaryKey( new ActivityCenterPK(pView.getId())
);
acLocal.setValueObject( pView );
}
//-------------------------------------
Iterator calIter = pCalendars.iterator(); //their codes
Collection calendars = new Vector();
int currCalId;
CalendarLocal currCalendar;
CalendarLocalHome calHome = (CalendarLocalHome)
PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Calendar"
),
CalendarLocalHome.class
);
try {
while (calIter.hasNext()) {
currCalId = Integer.parseInt((String)calIter.next());
currCalendar = calHome.findByPrimaryKey( new CalendarPK(currCalId)
);
System.out.println("Calendar Local: " + currCalId);
calendars.add(currCalendar);
}
System.out.println("Calendars are: " + calendars.size());
acLocal.setCalendars( calendars );
} catch (Exception e) {
System.out.println( "Exception occurred setting activities" +
e.getMessage() );
throw new RemoteException( "Exception occurred setting activities" +
e.getMessage() );
}
//-------------------------------------
Iterator iter = pActivities.iterator(); //their codes
Collection activities = new Vector();
String currCode;
ActivityLocal currActivity;
ActivityLocalHome actHome = (ActivityLocalHome)
PortableRemoteObject.narrow(
lContext.lookup(
"java:comp/env/ejb/mywebappointments/Activity"
),
ActivityLocalHome.class
);
try {
while (iter.hasNext()) {
currCode = (String)iter.next();
currActivity = actHome.findByPrimaryKey( new ActivityPK(currCode)
);
activities.add(currActivity);
}
acLocal.setActivities( activities );
} catch (Exception e) {
System.out.println( "Exception occurred setting activities" +
e.getMessage() );
throw new RemoteException( "Exception occurred setting activities" +
e.getMessage() );
}
return acLocal.getValueObject().getId() + "";
}
catch ( NamingException ne ) {
System.out.println("ActivityCenter naming error: " + ne.getMessage());
throw new EJBException( "Naming lookup failure: " + ne.getMessage() );
}
catch ( FinderException ce ) {
System.out.println("ActivityCenter findByCodes error: " + ce.getMessage());
throw new EJBException( "Bean not found exception: " + ce.getMessage() );
}
catch ( Exception e ) {
System.out.println("ActivityCenter error: " + e.getMessage());
throw new EJBException( "ActivityCenter failure: " + e.getMessage() );
}
}
/**
*
* @ejb.create-method view-type="remote"
*
* @ejb.permission role-name="Admin,PoweredUser,User"
*
**/
public void ejbCreate()
throws
CreateException
{
System.out.println( "ActivitySessionBean.ejbCreate()" );
}
/**
* Describes the instance and its content for debugging purpose
*
* @return Debugging information about the instance and its content
**/
public String toString()
{
return "ActivitySessionBean [ " + " ]";
}
// ------------------------------------------------------------------------
// Helpers
private boolean isValidCalendar(CalendarData calendarData, java.util.Date
pCompareDate)
{
boolean result = false;
Calendar period = new GregorianCalendar();
period.setTime( pCompareDate );
Calendar sCal = new GregorianCalendar(2002, 0, 1, 0, 0);
sCal.setTimeInMillis( calendarData.getValidityStart().getTime() );
sCal.set(Calendar.HOUR, 0);
sCal.set(Calendar.MINUTE, -1); //1 minute before midnight
Calendar eCal = new GregorianCalendar(2002, 0, 1, 0, 0);
eCal.setTimeInMillis( calendarData.getValidityEnd().getTime() );
eCal.set(Calendar.HOUR, 23);
eCal.set(Calendar.MINUTE, 60); //1 minute after midnight
if ( (sCal.getTimeInMillis() < period.getTimeInMillis()) &&
(eCal.getTimeInMillis() > period.getTimeInMillis()) )
result = true;
return result;
}
// -------------------------------------------------------------------------
// Framework Callbacks
// -------------------------------------------------------------------------
public void setSessionContext( SessionContext aContext )
throws
EJBException
{
mContext = aContext;
}
public void ejbActivate()
throws
EJBException
{
}
public void ejbPassivate()
throws
EJBException
{
}
public void ejbRemove()
throws
EJBException
{
}
}
