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 Summary
Modifier and TypeFieldDescriptionprotected final EntityStore<T>
private final STMActionsInfoProvider
-
Constructor Summary
ConstructorDescriptionStateEntityServiceImpl
(STM<T> stm, STMActionsInfoProvider stmActionsInfoProvider, 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.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 T
processEntity
(T entity, String event, Object payload) Internally used by both the create and process methods.
-
Field Details
-
stm
-
entityStore
-
stmActionsInfoProvider
-
-
Constructor Details
-
StateEntityServiceImpl
public StateEntityServiceImpl(STM<T> stm, STMActionsInfoProvider stmActionsInfoProvider, 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:
create
in interfaceStateEntityService<T extends 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:
process
in interfaceStateEntityService<T extends 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:
processById
in interfaceStateEntityService<T extends 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:
getAllowedActionsAndMetadata
in interfaceStateEntityService<T extends StateEntity>
-
getAllowedActionsAndMetadata
- Specified by:
getAllowedActionsAndMetadata
in interfaceStateEntityService<T extends StateEntity>
-
makeStateEntityResponse
-
retrieve
- Specified by:
retrieve
in interfaceStateEntityService<T extends StateEntity>
- Parameters:
id
- The ID of the state entity- Returns:
- the state entity along with allowed actions
-