bea.com | products | dev2dev | support | askBEA
 Download Docs   Site Map   Glossary 
Search

Programming BPM Client Apps

 Previous Next Contents Index View as PDF  

Configuring Business Calendars

Business calendars enable you to define the operating hours for an organization. For more information about administering business calendars, see "Administering Business Calendars" in Administering Data in Using the WebLogic Integration Studio.

This section describes the tasks associated with configuring business calendars, including the following topics

 


Adding a Business Calendar

To add a business calendar, use the following com.bea.wlpi.server.admin.Admin method:

public java.lang.String addBusinessCalendar(
com.bea.wlpi.common.BusinessCalendarInfo calendarInfo
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException

The following table describes the addBusinessCalendar() method parameter for which you must specify a value.

Table 12-1 addBusinessCalendar() Method Parameter  

Parameter

Description

Valid Values

calendarInfo

New business calendar information.

A BusinessCalendarInfo object.

For information about defining the BusinessCalendarInfo object, see BusinessCalendarInfo Object.


 

This method returns the ID of the new business calendar.

For example, the following code adds a business calendar based on the contents of the specified calendarInfo object. In this example, admin represents the EJBObject reference to the Admin EJB.

admin.addBusinessCalendar(calendarInfo);

For more information about the addBusinessCalendar() method, see the com.bea.wlpi.server.admin.Admin Javadoc.

 


Getting Business Calendars

To get the contents of all business calendars that are currently defined, use the following com.bea.wlpi.server.admin.Admin method:

public java.util.List getAllBusinessCalendars(
boolean includeDefinition
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException

The following table describes the getAllBusinessCalendars() method parameter for which you must specify a value.

Table 12-2 getAllBusinessCalendars() Method Parameter  

Parameter

Description

Valid Values

includeDefintion

Boolean flag specifying whether or not to include the XML calendar specification

true (include XML) or false (do not include XML).


 

This method returns a list of com.bea.wlpi.common.BusinessCalendarInfo objects. To access information about each business calendar, use the BusinessCalendarInfo object methods described in BusinessCalendarInfo Object.

For example, the following code gets the business calendar information and saves it to the calendars list object. In this example, admin represents the EJBObject reference to the Admin EJB.

List calendars = admin.getAllBusinessCalendars();

For more information about the getAllBusinessCalendars() method, see the com.bea.wlpi.server.admin.Admin Javadoc.

 


Getting a Business Calendar Definition

To get a business calendar definition, use the following com.bea.wlpi.server.admin.Admin method:

public java.lang.String getBusinessCalendarDefinition(
java.lang.String calendarId
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException

The following table describes the getBusinessCalendarDefinition() method parameter for which you must specify a value.

Table 12-3 getBusinessCalendarDefinition() Method Parameter  

Parameter

Description

Valid Values

calendarId

ID of the business calendar for which you want to retrieve the definition.

String specifying a valid business calendar ID.

To get the calendar ID, use the following com.bea.wlpi.common.BusinessCalendarInfo method:

public final java.lang.String
getId()

For information about getting the BusinessCalendarInfo object, see Getting Business Calendars. For more information about the methods available to the BusinessCalendarInfo object, see BusinessCalendarInfo Object.


 

This method returns an XML file containing the business calendar definition that is compliant with the Business Calendar DTD.

For example, the following code gets information about a single business calendar definition and saves it to the calendar string. In this example, admin represents the EJBObject reference to the Admin EJB.

String calendar = admin.getBusinessCalendarDefinition();

For more information about the getBusinessCalendarDefinition() method, see the com.bea.wlpi.server.admin.Admin Javadoc.

 


Updating a Business Calendar

To update a business calendar, use the following com.bea.wlpi.server.admin.Admin method:

public void updateBusinessCalendar(
com.bea.wlpi.common.BusinessCalendarInfo calendarInfo
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException

The following table describes the updateBusinessCalendar() method parameter for which you must specify a value.

Table 12-4 updateBusinessCalendar() Method Parameter  

Parameter

Description

Valid Values

calendarInfo

Calendar information that you want to update.

A BusinessCalendarInfo object.

For information about defining the BusinessCalendarInfo object, see BusinessCalendarInfo Object.


 

For example, the following code updates a business calendar based on the contents of the specified calendarInfo object. In this example, admin represents the EJBObject reference to the Admin EJB.

admin.updateBusinessCalendar(calendarInfo);

For more information about the updateBusinessCalendar() method, see the com.bea.wlpi.server.admin.Admin Javadoc.

 


Deleting a Business Calendar

To delete a business calendar, use the following com.bea.wlpi.server.admin.Admin method:

public void deleteBusinessCalendar(
java.lang.String calendarId
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException

The following table describes the deleteBusinessCalendar() method parameter for which you must specify a value.

Table 12-5 deleteBusinessCalendar() Method Parameter  

Parameter

Description

Valid Values

calendarId

ID of the business calendar that you want to delete.

String specifying a valid business calendar ID.

To get the calendar ID, use the following com.bea.wlpi.common.BusinessCalendarInfo method:

public final java.lang.String
getId()

For information about getting the BusinessCalendarInfo object, see Getting Business Calendars. For more information about the methods available to the BusinessCalendarInfo object, see BusinessCalendarInfo Object.


 

For example, the following code deletes the specified business calendar. In this example, admin represents the EJBObject reference to the Admin EJB.

admin.deleteBusinessCalendar(calendarInfo);

For more information about the deleteBusinessCalendar() method, see the com.bea.wlpi.server.admin.Admin Javadoc.

 


Example of Configuring Business Calendars

This section provides excerpts from the command-line administration example that show how to configure business calendars.

Note: For more information about the command-line administration example, see Command-Line Administration Example.

In this example, an input stream is defined to communicate with the user, and the user is prompted to specify one of the following actions to be performed:

Important lines of code are highlighted in bold. In this example, admin represents the EJBObject reference to the Admin EJB.

/* Create an input stream to communicate with the user */
stdIn = new BufferedReader( new InputStreamReader( System.in ) );

/* Display Tool Title */
System.out.print( "\n--- Command Line Administration v1.1 ---" );

/* Display the main menu and interact with user */
while( true ) {
/* Display the menu */
System.out.println( "\n--- Main Menu ---" );
System.out.println( "\nEnter choice:" );
System.out.println( "1) Organizations" );
System.out.println( "2) Roles" );
System.out.println( "3) Users" );
System.out.println( "4) Security Realm" );
System.out.println( "5) Business Operations" );
System.out.println( "6) Event Keys" );
System.out.println( "7) Business Calendars" );
System.out.println( "8) EJB Catalog" );
System.out.println( "9) Server Properties" );
System.out.println( "Q) Quit" );
System.out.print( ">> " );
.
.
.
/**
* Method that interacts with the user to get all the required information
* to illustrate the Public API Methods available in the Admin interface
* that are related to WLPI Business Calendars.
*/
public static void mngBusinessCalendars() {\
boolean isGetDefinition;
BusinessCalendarInfo calendarInfo;
List calendarList;
String answer;
String calendarDefinition;
String calendarId;
String calendarName;
String calendarTimezone; // XML Document

/* Create an input stream to communicate with the user */
BufferedReader stdIn = new BufferedReader(
new InputStreamReader( System.in ) );

try {
/* Display the menu and interact with user */
while( true ) {
/* Display the menu */
System.out.println( "\n\n--- Business Calendars ---" );
System.out.println( "\nEnter choice:" );
System.out.println( "1) Add a Business Calendar" );
System.out.println( "2) Delete a Business Calendar" );
System.out.println( "3) List a Business Calendar Definition" );
System.out.println( "4) List all Business Calendars" );
System.out.println( "5) Update a Business Calendar" );
System.out.println( "B) Back to previous menu" );
System.out.println( "Q) Quit" );
System.out.print( ">> " );
/* Get user's selection */
String line = stdIn.readLine();
/* User pressed enter without making a selection ? */
if( line.equals( "" ) )
continue;
else if( line.length() > 1 ) {
System.out.println( "*** Invalid selection" );
continue;
}
/* Convert to uppercase and to char */
char choice = line.toUpperCase().charAt( 0 );
/* Process user's selection */
switch( choice ) {
.
.
.

Adding a Business Calendar

The following excerpt shows how to add a business calendar:

         /* Add Business Calendar */
case '1' :
/* Adding a new Business Calendar, thus we do not have
a calendar id. The server will assign it an return the
new ID. We must set it to the word 'null' to specify no
value (do not confuse with a null string). */
calendarId = new String( "null" );

/* Get Calendar Name for the new calendar to add */
if( ( calendarName = askQuestion( "\nEnter new Calendar Name" ) )
== null ) {
/* User cancelled the operation */
System.out.println( "*** Cancelled" );
break;
}

/* Get Calendar TimeZone for the new calendar to add */
if( ( calendarTimezone = askQuestion( "Enter Time Zone" ) ) == null ) {
/* User cancelled the operation */
System.out.println( "*** Cancelled" );
break;
}

/* A business calendar definition is an XML document
conforming to the BusinessCalendar.dtd document
type (see the WLPI javadocs).
It contains all the
information that defines the Business Calendar */
/* We need to build the XML Document */
calendarDefinition = createCalendarDefinition( calendarId,
calendarName, calendarTimezone );

/* Create a BusinessCalendarInfo object */
calendarInfo = new BusinessCalendarInfo( calendarId, calendarName,
calendarTimezone, calendarDefinition );

try {
/* WLPI Public API Method */
/* Create the new business calendar */
calendarId = admin.addBusinessCalendar( calendarInfo );

/* Success (No exception trown) */
System.out.println( "- Business Calendar added (ID=" +
calendarId + ")" );
}
catch( Exception e ) {
System.out.println( "*** Unable to add business calendar\n" );
System.err.println( e );
}
break;
.
.
.

Deleting a Business Calendar

The following excerpt shows how to delete a business calendar:

         /* Delete Business Calendar */
case '2' :
/* Get Calendar ID for the calendar to delete */
if( ( calendarId = askQuestion( "\nEnter Calendar ID to delete" ) )
== null ) {
/* User cancelled the operation */
System.out.println( "*** Cancelled" );
break;
}

try {
/* WLPI Public API Method */
/* Delete the business calendar */
admin.deleteBusinessCalendar( calendarId );

/* Success (No exception trown) */
System.out.println( "- Deleted" );
}
catch( Exception e ) {
System.out.println( "*** Unable to delete Business Calendar" );
System.err.println( e );
}
break;
.
.
.

Getting a Business Calendar Definition

The following excerpt shows how to get a business calendar definition:

         /* List a Business Calendar Definition */
case '3' :
/* Get Calendar ID for the calendar to delete */
if( ( calendarId = askQuestion( "\nEnter Calendar ID" ) ) == null ) {
/* User cancelled the operation */
System.out.println( "*** Cancelled" );
break;
}

try {
/* WLPI Public API Method */
/* Retrieve the definition of the business calendar. */
calendarDefinition = admin.getBusinessCalendarDefinition(
calendarId );

/* Success (No exception trown) */
System.out.println( "- Business Calendar definition:\n" +
calendarDefinition );
}
catch( Exception e ) {
System.out.println( "*** Unable to retrieve Business " +
"Calendar definition\n" );
System.err.println( e );
}
break;
.
.
.

Getting Business Calendars

The following excerpt shows how to get business calendars:

         /* List all Business Calendars */
case '4' :
/* Prompt user to select if we need to display the calendar definition */
if( ( answer = askQuestion( "\nList Definition (y/n)?" ) ) == null ) {
/* User cancelled the operation */
System.out.println( "*** Cancelled" );
break;
}

/* Parse the answer */
isGetDefinition = ( answer.equals( "y" ) || answer.equals( "Y" ) );

try {
/* WLPI Public API Method */
/* Retrieve all business calendars */
//Bug1 calendarList = admin.getAllBusinessCalendars(
//isGetDefinition );
calendarList = admin.getAllBusinessCalendars( false );

/* Any calendars defined ? */
if( calendarList.size() == 0 )
System.out.println( "\nNo Business Calendar defined" );
else
System.out.println( "\nDefined Business Calendars:" );

/* Process the list to display calendars and attributes */
for( int i = 0; i < calendarList.size(); i++ ) {
/* Retrieve an element from the list */
calendarInfo = ( BusinessCalendarInfo )calendarList.get( i );

/* Retrieve and display organization id */
System.out.println( "- ID: " + calendarInfo.getId() );

/* Retrieve and display calendar name */
System.out.println( " Name: " + calendarInfo.getName() );

/* Retrieve and display time zone */
System.out.println( " Time Zone: " + calendarInfo.getTimeZone() );

/* Display Business Calendar Definition ? */
if( isGetDefinition ) {
/* Retrieve and display calendar definition */
//Bug1 Description: getXML prefixes the returned
// string with invalid characters */
//Bug1 System.out.println( " Business Calendar
//definition:\n" +
//Bug1 calendarInfo.getXML() );
/* Work Around to retrieve calendar definition */
calendarDefinition = admin.getBusinessCalendarDefinition(
calendarInfo.getId() );
/* Display calendar definition */
System.out.println( " Business Calendar definition:\n" +
calendarDefinition );
}
}
}
catch( Exception e ) {
System.out.println( "*** Unable to retrieve Business Calendars" );
System.err.println( e );
}
break;
.
.
.

Updating a Business Calendar

The following excerpt shows how to update a business calendar:

         /* Update Business Calendar */
case '5' :
/* Get Calendar ID for the calendar to update */
if( ( calendarId = askQuestion( "\nEnter Calendar ID to update" ) )
== null ) {
/* User cancelled the operation */
System.out.println( "*** Cancelled" );
break;
}

try {
/* WLPI Public API Method */
/* Retrieve all business calendars in order to retrieve the
one to update*/
calendarList = admin.getAllBusinessCalendars( false );

/* Any calendars defined ? */
if( calendarList.size() == 0 ) {
System.out.println( "\nNo Business Calendar defined" );
break;
}

boolean isNotDefined = true;
calendarInfo = null;

/* Process the list to retrieve the info for the calendar to update */
for( int i = 0; i < calendarList.size(); i++ ) {
/* Retrieve an element from the list */
calendarInfo = ( BusinessCalendarInfo )calendarList.get( i );

/* Retrieve and display organization id */
if( calendarId.equals( calendarInfo.getId() ) ) {
isNotDefined = false;
break;
}
}

/* Is the calendar defined ? */
if( isNotDefined ) {
System.out.println( "*** This Business Calendar is
not defined" );
break;
}

System.out.println( "\nUpdating Business Calendar" );

/* Retrieve and display calendar name */
System.out.println( "- The current Name is: " +
calendarInfo.getName() );

/* Get new Calendar Name */
if( ( calendarName = askQuestion( " Enter a new Name " ) ) != null )
/* User entered a new value, thus let's update the value */
/* WLPI Public API Method */
calendarInfo.setName( calendarName );

/* Retrieve and display time zone */
System.out.println( "- The current Time Zone is: " +
calendarInfo.getTimeZone() );

/* Get Calendar TimeZone for the new calendar to add */
if( ( calendarTimezone = askQuestion( " Enter a new Time Zone " ) )
!= null )
/* User entered a new value, thus let's update the value */
/* WLPI Public API Method */
calendarInfo.setTimeZone( calendarTimezone );

/* Create the new business calendar definition */
calendarDefinition = updateCalendarDefinition( calendarId,
calendarInfo.getName(), calendarInfo.getTimeZone() );

/* Update the business calendar definition */
calendarInfo.setXML( calendarDefinition );

/* WLPI Public API Method */
admin.updateBusinessCalendar( calendarInfo );

/* Success (No exception trown) */
System.out.println( "\nUpdated" );
}
catch( Exception e ) {
System.out.println( "*** Unable to update Business Calendar" );
System.err.println( e );
}
break;
.
.
.

 

Back to Top Previous Next