com.netscape.pm.model
Class HistoryEventFactory

java.lang.Object
  |
  +--com.netscape.pm.model.HistoryEventFactory

public class HistoryEventFactory
extends java.lang.Object

Creates a history event object, used to record historical information about the progress of a process instance. History events that are created from this factory class are not automatically logged; events must be bound to a process instance in order to be logged properly. The method addHistoryEvent off the IProcessInstance interface must be used for this purpose.

 public void doGet( HttpServletRequest req, HttpServletResponse res ) 
     throws ServletException, IOException
 {
     res.setContentType( "text/html; charset=ISO-8859-4" );

     javax.naming.Context cxt = new javax.naming.InitialContext();
     String jndiName = "java:comp/env/" + IPMApplication.DEFAULT_JNDI_ROOT
                     + "/" + localName;
     IPMApplicationHome home = (IPMApplicationHome) cxt.lookup( jndiName );
     IPMApplication app = home.create();

     long instanceId = Long.parseLong( req.getParameter(
                                             IUIParameters.INSTANCE_ID ) );
     String forkId = req.getParameter( IUIParameters.FORK_ID );
     String nodeName = req.getParameter( IUIParameters.NODE_NAME );

     IWorkItemPK pk = WorkItemPKFactory.create( instanceId,
                                                forkId,
                                                nodeName );
     pk.setEditable( true );
     
     IWorkItem wi = app.findWorkItem( pk );
     IProcessInstance pi = wi.getProcessInstance();

     IHistoryEvent he = HistoryEventFactory.create( wi, IHistoryEvent.LOG,
                                                    "a log message",
                                                    "a log comment" );
     pi.addHistoryEvent( he );
     pi.setData( "name", req.getParameter( "name" ) );
     wi.save();
     wi.release( true );

     res.getWriter().flush();
     res.getWriter().close();
 }
 

See Also:
IHistoryEvent

Constructor Summary
HistoryEventFactory()
           
 
Method Summary
static IHistoryEvent create(IWorkItem wi)
          Creates an instance of a history event from the given work item.
static IHistoryEvent create(IWorkItem wi, int eventType)
          Creates an instance of a history event from the given work item and event type.
static IHistoryEvent create(IWorkItem wi, int eventType, java.lang.String eventId)
          Creates an instance of a history event from the given work item, event type and event id.
static IHistoryEvent create(IWorkItem wi, int eventType, java.lang.String eventId, java.lang.String comment)
          Creates an instance of a history event from the given work item, event type, event id, and comment string.
static IHistoryEvent create(IWorkItem wi, java.lang.String eventId, java.lang.String comment)
          Creates an instance of a history event from the given work item, event id, and comment string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HistoryEventFactory

public HistoryEventFactory()
Method Detail

create

public static IHistoryEvent create(IWorkItem wi)
                            throws PMException
Creates an instance of a history event from the given work item. Events created via this method are created with the event type set to USER_ACTION, and the event id set to the value of the work item's conclusion.

Once a history event has been created, its properties cannot be modified; hence if the developer wants to modify the event id or comment logged in the history log, one of the other create methods should be used.

Parameters:
wi - the current work item
Returns:
an instance of a history event.
Throws:
PMException - if there is a problem retrieving the process instance associated with the given work item.
Since:
PM 6.0
See Also:
IHistoryEvent.USER_ACTION, IWorkItem

create

public static IHistoryEvent create(IWorkItem wi,
                                   int eventType)
                            throws PMException
Creates an instance of a history event from the given work item and event type. Events created via this method are created with the event id set to the value of the work item's conclusion.

Once a history event has been created, its properties cannot be modified; hence if the developer wants to modify the event id or comment logged in the history log, one of the other create methods should be used.

Parameters:
wi - the current work item
eventType - the event type of the history event
Returns:
an instance of a history event.
Throws:
PMException - if there is a problem retrieving the process instance associated with the given work item.
Since:
PM 6.0
See Also:
IHistoryEvent.USER_ACTION, IHistoryEvent.AUTOMATED_STEP, IHistoryEvent.MANAGEMENT_EVENT, IHistoryEvent.EXCEPTION_EVENT, IWorkItem

create

public static IHistoryEvent create(IWorkItem wi,
                                   int eventType,
                                   java.lang.String eventId)
                            throws PMException
Creates an instance of a history event from the given work item, event type and event id.

Once a history event has been created, its properties cannot be modified; hence if the developer wants to modify the event comment logged in the history log, one of the other create methods should be used.

Parameters:
wi - the current work item
eventType - the event type of the history event
eventId - the event id of the history event
Returns:
an instance of a history event.
Throws:
PMException - if there is a problem retrieving the process instance associated with the given work item.
Since:
PM 6.0
See Also:
IHistoryEvent.USER_ACTION, IHistoryEvent.AUTOMATED_STEP, IHistoryEvent.MANAGEMENT_EVENT, IHistoryEvent.EXCEPTION_EVENT, IHistoryEvent.getEventId(), IWorkItem

create

public static IHistoryEvent create(IWorkItem wi,
                                   java.lang.String eventId,
                                   java.lang.String comment)
                            throws PMException
Creates an instance of a history event from the given work item, event id, and comment string. Events created via this method are created with the event type set to LOG.

Once a history event has been created, its properties cannot be modified; hence if the developer wants to modify the event type of the history event, one of the other create methods should be used.

Parameters:
wi - the current work item
eventId - the event id of the history event
comment - the history comment string
Returns:
an instance of a history event.
Throws:
PMException - if there is a problem retrieving the process instance associated with the given work item.
Since:
PM 6.0
See Also:
IHistoryEvent.LOG, IWorkItem

create

public static IHistoryEvent create(IWorkItem wi,
                                   int eventType,
                                   java.lang.String eventId,
                                   java.lang.String comment)
                            throws PMException
Creates an instance of a history event from the given work item, event type, event id, and comment string.
Parameters:
wi - the current work item
eventType - the event type of the history event
eventId - the event id of the history event
comment - the history comment string
Returns:
an instance of a history event.
Throws:
PMException - if there is a problem retrieving the process instance associated with the given work item.
Since:
PM 6.0
See Also:
IHistoryEvent.LOG, IWorkItem