Class StateEntityServiceImpl<T extends StateEntity>
java.lang.Object
org.chenile.workflow.service.impl.StateEntityServiceImpl<T>
- Type Parameters:
- T-
- All Implemented Interfaces:
- StateEntityService<T>
public class StateEntityServiceImpl<T extends StateEntity>
extends Object
implements StateEntityService<T>
A generic implementation of the 
This implementation uses the Chenile State Machine
The state transition diagram should be customized for the particular entity and must be read by the State Transition Machine that is injected into this service. After that, the machine would entirely control the workflow. Please read the Chenile tutorial page about how to generate a project that uses this state machine.
StateEntityService for all state entities. This implementation uses the Chenile State Machine
The state transition diagram should be customized for the particular entity and must be read by the State Transition Machine that is injected into this service. After that, the machine would entirely control the workflow. Please read the Chenile tutorial page about how to generate a project that uses this state machine.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final EntityStore<T>private final STMActionsInfoProvider
- 
Constructor SummaryConstructorsConstructorDescriptionStateEntityServiceImpl(STM<T> stm, STMActionsInfoProvider stmActionsInfoProvider, EntityStore<T> entityStore) 
- 
Method SummaryModifier and TypeMethodDescriptionconfig()An implementation of the create method that delegates to the entity store after filling up the mandatory attributes.protected StateEntityServiceResponse<T>makeStateEntityResponse(T entity) An implementation of the process method that allows to track all the changes to the entity via events.processById(String id, String event, Object payload) This form is expected from the web.protected TprocessEntity(T entity, String event, Object payload) Internally used by both the create and process methods.
- 
Field Details- 
stm
- 
entityStore
- 
stmActionsInfoProvider
 
- 
- 
Constructor Details- 
StateEntityServiceImplpublic StateEntityServiceImpl(STM<T> stm, STMActionsInfoProvider stmActionsInfoProvider, EntityStore<T> entityStore) - Parameters:
- stm- the state machine that has read the corresponding State Transition Diagram
- stmActionsInfoProvider- the provider that gives out info about the state diagram
- entityStore- the store for persisting the entity
 
 
- 
- 
Method Details- 
processEntityInternally used by both the create and process methods.- Parameters:
- entity- the entity which needs to be created or processed.
- event- the event if it is not a create operation.
- payload- the payload if the event field is not null
- Returns:
- the mutated entity along with allowed actions
 
- 
createAn implementation of the create method that delegates to the entity store after filling up the mandatory attributes. It makes sure that it empties out the state if state has been supplied because we want STM to supply the initial state.- Specified by:
- createin interface- StateEntityService<T extends StateEntity>
- Parameters:
- entity- the state entity that needs to be created.
- Returns:
- the entity with the allowed actions
 
- 
processAn implementation of the process method that allows to track all the changes to the entity via events. This form is best suited for internal use and will not be exposed to the web. (We made the method public for some rare situations. This will be made protected over future releases)- Specified by:
- processin interface- StateEntityService<T extends StateEntity>
- Parameters:
- entity- the entity on which the event has happened
- event- - the name of the event that happened on the entity
- payload- - Additional parameters for the event (event specific)
- Returns:
- the mutated entity along with allowed actions
 
- 
processByIdThis form is expected from the web. The client merely must pass the ID and the event rather than the whole entity.- Specified by:
- processByIdin interface- StateEntityService<T extends StateEntity>
- Parameters:
- id- - the ID of the event. This is useful if the entire entity is not passed by the front end
- event- - Name of the event that has happened on the entity
- payload- - Additional parameters for the event (event specific)
- Returns:
- the mutated entity along with allowed actions
 
- 
getAllowedActionsAndMetadata- Specified by:
- getAllowedActionsAndMetadatain interface- StateEntityService<T extends StateEntity>
 
- 
getAllowedActionsAndMetadata- Specified by:
- getAllowedActionsAndMetadatain interface- StateEntityService<T extends StateEntity>
 
- 
makeStateEntityResponse
- 
retrieve- Specified by:
- retrievein interface- StateEntityService<T extends StateEntity>
- Parameters:
- id- The ID of the state entity
- Returns:
- the state entity along with allowed actions
 
- 
config- Specified by:
- configin interface- StateEntityService<T extends StateEntity>
 
 
-