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() }
// 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() }
func (order *Order) SetInitialState(stateMachine *state.StateMachine) { order.State = stateMachine.GetInitialState() }
func (position *Position) SetInitialState(stateMachine *state.StateMachine) { position.State = stateMachine.GetInitialState() }