Beispiel #1
0
func (order *Order) ForceStatePosition(stateMachine *state.StateMachine, targetState string, position *Position) error {
	if stateMachine == nil {
		stateMachine = DefaultStateMachine
	}
	err := stateMachine.ForceTransitionToState(position.GetState(), targetState)
	if err != nil {
		return err
	}
	return order.Upsert()
}
Beispiel #2
0
// SetState performs the transition to target state
// If stateMachine is nil, the default state machine is used
func (order *Order) SetState(stateMachine *state.StateMachine, targetState string) error {
	if stateMachine == nil {
		stateMachine = DefaultStateMachine
	}
	err := stateMachine.TransitionToState(order.GetState(), targetState)
	if err != nil {
		return err
	}
	return order.Upsert()
}
Beispiel #3
0
func (order *Order) SetInitialState(stateMachine *state.StateMachine) {
	order.State = stateMachine.GetInitialState()
}
Beispiel #4
0
func (position *Position) SetInitialState(stateMachine *state.StateMachine) {
	position.State = stateMachine.GetInitialState()
}