Class StateEntityServiceImpl<T extends org.chenile.stm.StateEntity>
java.lang.Object
org.chenile.workflow.service.impl.StateEntityServiceImpl<T>
- Type Parameters:
T-
- All Implemented Interfaces:
StateEntityService<T>
public class StateEntityServiceImpl<T extends org.chenile.stm.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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStateEntityServiceImpl(org.chenile.stm.STM<T> stm, org.chenile.stm.impl.STMActionsInfoProvider stmActionsInfoProvider, org.chenile.utils.entity.service.EntityStore<T> entityStore) -
Method Summary
Modifier and TypeMethodDescriptionAn implementation of the create method that delegates to the entity store after filling up the mandatory attributes.getAllowedActionsAndMetadata(org.chenile.stm.State state) 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
-
entityStore
protected final org.chenile.utils.entity.service.EntityStore<T extends org.chenile.stm.StateEntity> entityStore
-
-
Constructor Details
-
StateEntityServiceImpl
public StateEntityServiceImpl(org.chenile.stm.STM<T> stm, org.chenile.stm.impl.STMActionsInfoProvider stmActionsInfoProvider, org.chenile.utils.entity.service.EntityStore<T> entityStore) - Parameters:
stm- the state machine that has read the corresponding State Transition DiagramstmActionsInfoProvider- the provider that gives out info about the state diagramentityStore- the store for persisting the entity
-
-
Method Details
-
processEntity
Internally 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
-
create
An 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 interfaceStateEntityService<T extends org.chenile.stm.StateEntity>- Parameters:
entity- the state entity that needs to be created.- Returns:
- the entity with the allowed actions
-
process
An 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 interfaceStateEntityService<T extends org.chenile.stm.StateEntity>- Parameters:
entity- the entity on which the event has happenedevent- - the name of the event that happened on the entitypayload- - Additional parameters for the event (event specific)- Returns:
- the mutated entity along with allowed actions
-
processById
This form is expected from the web. The client merely must pass the ID and the event rather than the whole entity.- Specified by:
processByIdin interfaceStateEntityService<T extends org.chenile.stm.StateEntity>- Parameters:
id- - the ID of the event. This is useful if the entire entity is not passed by the front endevent- - Name of the event that has happened on the entitypayload- - Additional parameters for the event (event specific)- Returns:
- the mutated entity along with allowed actions
-
getAllowedActionsAndMetadata
- Specified by:
getAllowedActionsAndMetadatain interfaceStateEntityService<T extends org.chenile.stm.StateEntity>
-
getAllowedActionsAndMetadata
- Specified by:
getAllowedActionsAndMetadatain interfaceStateEntityService<T extends org.chenile.stm.StateEntity>
-
makeStateEntityResponse
-
retrieve
- Specified by:
retrievein interfaceStateEntityService<T extends org.chenile.stm.StateEntity>
-