it.amattioli.workstate.core
Class EventRepository

Show UML class diagram
java.lang.Object
  extended by it.amattioli.workstate.core.EventRepository

public class EventRepository
extends Object

A MetaEvent container.

An object of this class allows the management of MetaEvent instances and the creation of events starting from these.

To create events you will need the event name to find the correct MetaEvent to be used, and the list of the actual parameters.

These parameters can be objects compatibles with the class of the formal parameter, or strings. Strings will be converted to the right class using a ConversionService instance.


Constructor Summary
EventRepository(ConversionService defaultConversionService)
          Construct a new EventRepository whose default ConversionService is passed as a parameter.
 
Method Summary
 void addMetaEvent(MetaEvent newMetaEvent)
          Add a MetaEvent to this repository.
 Event buildEvent(String name, Map<String,Object> stringParameters)
          Build a new event.
 Event buildEvent(String name, Map<String,Object> stringParameters, ConversionService customConversionService)
          Build a new event given: Its name (tag) Its actual parameters A conversion service to transform string parameters to real parameters In the parameters map the keys are the parameter names while the values are the parameter values or strings that can be converted to the parameter values using the conversion service.
 boolean containsEvent(String name)
          Check if this repository contains a MetaEvent with the given tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventRepository

public EventRepository(ConversionService defaultConversionService)
Construct a new EventRepository whose default ConversionService is passed as a parameter.

Parameters:
defaultConversionService - the default conversion service
Method Detail

addMetaEvent

public void addMetaEvent(MetaEvent newMetaEvent)
Add a MetaEvent to this repository. The added MetaEvent will be referenced later using its tag. If this repository already conatins a MetaEvent with the same tag it will be replaced.

Parameters:
newMetaEvent - the meta-event to be added

buildEvent

public Event buildEvent(String name,
                        Map<String,Object> stringParameters,
                        ConversionService customConversionService)
                 throws WorkflowException
Build a new event given: In the parameters map the keys are the parameter names while the values are the parameter values or strings that can be converted to the parameter values using the conversion service. If a keys has not a corresponding formal parameter definition in the meta-event the map entry will be ignored. If no conversion service is passed the default one will be used.

Parameters:
name - The event name (tag)
stringParameters - A map containing the event actual parameters. The keys are the parameter names while the values are the parameter values or strings that can be converted to the parameter values using the conversion service
customConversionService - A conversion service. If null the default one will be used
Returns:
the built event. If the passed event name does not correspond to any MetaEvent contained in this repository null will be returned
Throws:
ClassCastException - if a parameter class is not a string and is not compatible with the formal parameter definition
WorkflowException - if the conversion service is not able to convert a string in the real parameter

buildEvent

public Event buildEvent(String name,
                        Map<String,Object> stringParameters)
                 throws WorkflowException
Build a new event. The same as buildEvent(String, Map, ConversionService) but with default conversion service.

Throws:
WorkflowException

containsEvent

public boolean containsEvent(String name)
Check if this repository contains a MetaEvent with the given tag.

Parameters:
name - the meta-event tag
Returns:
true if this repository contains a meta-event with the given tag, false otherwise


Copyright © 2011. All Rights Reserved.