question: public StateMachine createStateMachine ( StateMachineDefinition stateMachineDefinition ) { final Map < EventDefinition , EventData > eventDataMap = stateMachineDefinition . getEventDataMap ( ) ; Set < Event > allEvents = createAllEvents ( eventDataMap ) ; Set < StateDefinition > stateDefinitions = stateMachineDefinition . getStates ( ) ; Set < State > states = new HashSet < > ( ) ; for ( StateDefinition stateDefinition : stateDefinitions ) { State state = convertStateDefinitionToState ( stateDefinition ) ; states . add ( state ) ; } StateMachine stateMachine = new StateMachine ( stateMachineDefinition . getVersion ( ) , stateMachineDefinition . getName ( ) , stateMachineDefinition . getDescription ( ) , states , stateMachineDefinition . getCorrelationId ( ) ) ; stateMachinesDAO . create ( stateMachine ) ; for ( Event event : allEvents ) { event . setStateMachineInstanceId ( stateMachine . getId ( ) ) ; eventPersistenceService . persistEvent ( event ) ; } for ( State state : stateMachine . getStates ( ) ) { auditDAO . create ( new AuditRecord ( stateMachine . getId ( ) , state . getId ( ) , 0L , Status . initialized , null , null ) ) ; } return stateMachine ; }
target:  Converts state machine definition to state machine domain object and saves in DB.