state machine config separate methods
This commit is contained in:
parent
ff060688a3
commit
ea3ba70d14
2 changed files with 121 additions and 83 deletions
|
|
@ -181,26 +181,6 @@ public class FinalSessionStateMachineConfig
|
|||
.source(TaskType.RequirementsAndObligationsCreate).target(TaskType.ObligationsAdmission)
|
||||
.action(obligationAdmissionAction)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.ObligationsAdmission)
|
||||
.target(TaskType.PSEUDO_waitAfterObligationAdmissionError)
|
||||
.guard(oblAdmGuard)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.PSEUDO_waitAfterObligationAdmissionError).target(TaskType.InclusionToPool)
|
||||
.action(chain(obligationAdmissionContinueAction, inclusionToPoolAction))
|
||||
.event(SsnEvent.CONTINUE)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.PSEUDO_waitAfterObligationAdmissionError).target(TaskType.ObligationsAdmission)
|
||||
.action(StateMachineUtil.chain(discardOblAdmStash, obligationAdmissionAction))
|
||||
.event(SsnEvent.REPEAT)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.ObligationsAdmission).target(TaskType.InclusionToPool)
|
||||
.guard(invert(oblAdmGuard))
|
||||
.action(chain(obligationAdmissionContinueAction, inclusionToPoolAction))
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.InclusionToPool).target(TaskType.InspectionObligations)
|
||||
.action(inspOblDepositReturnAction)
|
||||
|
|
@ -211,6 +191,44 @@ public class FinalSessionStateMachineConfig
|
|||
.action(formingPaymentInstructionReturnMkrAction)
|
||||
.action(formingPaymentInstructionAssetsAction)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.FinishingSession)
|
||||
.target(TaskType.EndStageNotification)
|
||||
.action(endStageNotificationAction);
|
||||
sourceObligationAdmission(transitions);
|
||||
sourcePseudoAfterOAError(transitions);
|
||||
sourceFormingPaymentInstruction(transitions);
|
||||
sourcePseudoWaitSdfAfterPaymentInstructions(transitions);
|
||||
}
|
||||
|
||||
private void sourceObligationAdmission(StateMachineTransitionConfigurer<TaskType, SsnEvent> transitions) throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source(TaskType.ObligationsAdmission)
|
||||
.target(TaskType.PSEUDO_waitAfterObligationAdmissionError)
|
||||
.guard(oblAdmGuard)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.ObligationsAdmission).target(TaskType.InclusionToPool)
|
||||
.guard(invert(oblAdmGuard))
|
||||
.action(chain(obligationAdmissionContinueAction, inclusionToPoolAction));
|
||||
}
|
||||
|
||||
private void sourcePseudoAfterOAError(StateMachineTransitionConfigurer<TaskType, SsnEvent> transitions) throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source(TaskType.PSEUDO_waitAfterObligationAdmissionError).target(TaskType.InclusionToPool)
|
||||
.action(chain(obligationAdmissionContinueAction, inclusionToPoolAction))
|
||||
.event(SsnEvent.CONTINUE)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.PSEUDO_waitAfterObligationAdmissionError).target(TaskType.ObligationsAdmission)
|
||||
.action(StateMachineUtil.chain(discardOblAdmStash, obligationAdmissionAction))
|
||||
.event(SsnEvent.REPEAT);
|
||||
}
|
||||
|
||||
private void sourceFormingPaymentInstruction(StateMachineTransitionConfigurer<TaskType, SsnEvent> transitions) throws Exception {
|
||||
transitions
|
||||
//если не создалось paymentInstruction'ов
|
||||
.withExternal()
|
||||
.source(TaskType.FormingPaymentInstruction)
|
||||
|
|
@ -222,19 +240,17 @@ public class FinalSessionStateMachineConfig
|
|||
.withExternal()
|
||||
.source(TaskType.FormingPaymentInstruction)
|
||||
.target(TaskType.PSEUDO_waitSdfAfterPaymentInstructions)
|
||||
.guard(PaymentsWereCreatedGuard.instance)
|
||||
.and()
|
||||
.guard(PaymentsWereCreatedGuard.instance);
|
||||
}
|
||||
|
||||
private void sourcePseudoWaitSdfAfterPaymentInstructions(StateMachineTransitionConfigurer<TaskType, SsnEvent> transitions) throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source(TaskType.PSEUDO_waitSdfAfterPaymentInstructions)
|
||||
.target(TaskType.FinishingSession)
|
||||
.guard(new SdfGuard(SdfGuardExtractorAfterAssets.instance))
|
||||
.action(finishingSessionAction)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.FinishingSession)
|
||||
.target(TaskType.EndStageNotification)
|
||||
.action(endStageNotificationAction);
|
||||
for (var event: EnumSet.of(SsnEvent.SDF_01, SsnEvent.SDF_57, SsnEvent.SDF_04)) {
|
||||
.source(TaskType.PSEUDO_waitSdfAfterPaymentInstructions)
|
||||
.target(TaskType.FinishingSession)
|
||||
.guard(new SdfGuard(SdfGuardExtractorAfterAssets.instance))
|
||||
.action(finishingSessionAction);
|
||||
for (var event : EnumSet.of(SsnEvent.SDF_01, SsnEvent.SDF_57, SsnEvent.SDF_04)) {
|
||||
transitions
|
||||
.withInternal()
|
||||
.source(TaskType.PSEUDO_waitSdfAfterPaymentInstructions)
|
||||
|
|
|
|||
|
|
@ -178,26 +178,6 @@ public class IntermediateMkrSessionStateMachineConfig
|
|||
.source(TaskType.RequirementsAndObligationsCreate).target(TaskType.ObligationsAdmission)
|
||||
.action(obligationAdmissionAction)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.ObligationsAdmission)
|
||||
.target(TaskType.PSEUDO_waitAfterObligationAdmissionError)
|
||||
.guard(oblAdmGuard)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.PSEUDO_waitAfterObligationAdmissionError).target(TaskType.InclusionToPool)
|
||||
.action(chain(obligationAdmissionContinueAction, inclusionToPoolAction))
|
||||
.event(SsnEvent.CONTINUE)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.PSEUDO_waitAfterObligationAdmissionError).target(TaskType.ObligationsAdmission)
|
||||
.action(StateMachineUtil.chain(discardOblAdmStash, obligationAdmissionAction))
|
||||
.event(SsnEvent.REPEAT)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.ObligationsAdmission).target(TaskType.InclusionToPool)
|
||||
.guard(invert(oblAdmGuard))
|
||||
.action(chain(obligationAdmissionContinueAction, inclusionToPoolAction))
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.InclusionToPool).target(TaskType.InspectionObligations)
|
||||
.action(inspectionObligationsV2Action)
|
||||
|
|
@ -206,36 +186,6 @@ public class IntermediateMkrSessionStateMachineConfig
|
|||
.source(TaskType.InspectionObligations).target(TaskType.FormingPaymentInstruction)
|
||||
.action(formingPaymentInstructionAssetsAction)
|
||||
.and()
|
||||
//если не создалось paymentInstruction'ов
|
||||
.withExternal()
|
||||
.source(TaskType.FormingPaymentInstruction)
|
||||
.target(TaskType.AgainRevise)
|
||||
.guard(PaymentsWereNotCreatedGuard.instance)
|
||||
.action(againRevise)
|
||||
.and()
|
||||
//если создались paymentInstruction, переходим в режим ожидания
|
||||
.withExternal()
|
||||
.source(TaskType.FormingPaymentInstruction)
|
||||
.target(TaskType.PSEUDO_waitSdfAfterPaymentInstructions)
|
||||
.guard(PaymentsWereCreatedGuard.instance)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.PSEUDO_waitSdfAfterPaymentInstructions)
|
||||
.target(TaskType.AgainRevise)
|
||||
.guard(new SdfGuard(SdfGuardExtractorAfterAssets.instance))
|
||||
.action(againRevise)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.AgainRevise)
|
||||
.target(TaskType.FinishingSession)
|
||||
.action(finishingSessionAction)
|
||||
.guard(reviseSuccessGuard)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.AgainRevise)
|
||||
.target(TaskType.PSEUDO_waitSdfAfterAgainRevise)
|
||||
.guard(invert(reviseSuccessGuard))
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.PSEUDO_waitSdfAfterAgainRevise)
|
||||
.target(TaskType.AgainRevise)
|
||||
|
|
@ -246,7 +196,64 @@ public class IntermediateMkrSessionStateMachineConfig
|
|||
.source(TaskType.FinishingSession)
|
||||
.target(TaskType.EndStageNotification)
|
||||
.action(endStageNotificationAction);
|
||||
for (var event: EnumSet.of(SsnEvent.SDF_01, SsnEvent.SDF_57, SsnEvent.SDF_04)) {
|
||||
sourceObligationAdmission(transitions);
|
||||
sourcePseudoWaitAfterObligationAdmissionError(transitions);
|
||||
sourceFormingPaymentInstructions(transitions);
|
||||
sourcePseudoWaitSdfAfterPaymentInstructions(transitions);
|
||||
sourceAgainRevise(transitions);
|
||||
}
|
||||
|
||||
private void sourceObligationAdmission(StateMachineTransitionConfigurer<TaskType, SsnEvent> transitions) throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source(TaskType.ObligationsAdmission)
|
||||
.target(TaskType.PSEUDO_waitAfterObligationAdmissionError)
|
||||
.guard(oblAdmGuard)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.ObligationsAdmission).target(TaskType.InclusionToPool)
|
||||
.guard(invert(oblAdmGuard))
|
||||
.action(chain(obligationAdmissionContinueAction, inclusionToPoolAction));
|
||||
}
|
||||
|
||||
private void sourcePseudoWaitAfterObligationAdmissionError(StateMachineTransitionConfigurer<TaskType, SsnEvent> transitions) throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source(TaskType.PSEUDO_waitAfterObligationAdmissionError).target(TaskType.InclusionToPool)
|
||||
.action(chain(obligationAdmissionContinueAction, inclusionToPoolAction))
|
||||
.event(SsnEvent.CONTINUE)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.PSEUDO_waitAfterObligationAdmissionError).target(TaskType.ObligationsAdmission)
|
||||
.action(StateMachineUtil.chain(discardOblAdmStash, obligationAdmissionAction))
|
||||
.event(SsnEvent.REPEAT);
|
||||
}
|
||||
|
||||
private void sourceFormingPaymentInstructions(StateMachineTransitionConfigurer<TaskType, SsnEvent> transitions) throws Exception {
|
||||
transitions
|
||||
//если не создалось paymentInstruction'ов
|
||||
.withExternal()
|
||||
.source(TaskType.FormingPaymentInstruction)
|
||||
.target(TaskType.AgainRevise)
|
||||
.guard(PaymentsWereNotCreatedGuard.instance)
|
||||
.action(againRevise)
|
||||
.and()
|
||||
//если создались paymentInstruction, переходим в режим ожидания
|
||||
.withExternal()
|
||||
.source(TaskType.FormingPaymentInstruction)
|
||||
.target(TaskType.PSEUDO_waitSdfAfterPaymentInstructions)
|
||||
.guard(PaymentsWereCreatedGuard.instance);
|
||||
}
|
||||
|
||||
private void sourcePseudoWaitSdfAfterPaymentInstructions(StateMachineTransitionConfigurer<TaskType, SsnEvent> transitions) throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source(TaskType.PSEUDO_waitSdfAfterPaymentInstructions)
|
||||
.target(TaskType.AgainRevise)
|
||||
.guard(new SdfGuard(SdfGuardExtractorAfterAssets.instance))
|
||||
.action(againRevise);
|
||||
|
||||
for (var event : EnumSet.of(SsnEvent.SDF_01, SsnEvent.SDF_57, SsnEvent.SDF_04)) {
|
||||
transitions
|
||||
.withInternal()
|
||||
.source(TaskType.PSEUDO_waitSdfAfterPaymentInstructions)
|
||||
|
|
@ -255,6 +262,21 @@ public class IntermediateMkrSessionStateMachineConfig
|
|||
}
|
||||
}
|
||||
|
||||
private void sourceAgainRevise(StateMachineTransitionConfigurer<TaskType, SsnEvent> transitions) throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source(TaskType.AgainRevise)
|
||||
.target(TaskType.FinishingSession)
|
||||
.action(finishingSessionAction)
|
||||
.guard(reviseSuccessGuard)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TaskType.AgainRevise)
|
||||
.target(TaskType.PSEUDO_waitSdfAfterAgainRevise)
|
||||
.guard(invert(reviseSuccessGuard));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void configure(StateMachineConfigurationConfigurer<TaskType, SsnEvent> config) throws Exception {
|
||||
StateMachineListenerAdapter<TaskType, SsnEvent> loggingChangeStateListener
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue