- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
/**
* Инициализация набора действий, определенных для контейнера.
* @param context
* @throws DfException
*/
protected void initializeTransitions(EditorContext context) throws DfException{
AbstractDocumentModel documentModel = getDocumentModel();
AbstractState state = documentModel.getLifeCyclePolicy(context).getState(context);
if (!documentModel.isNew())
{
addTransition(TransitionName.CREATE_DETACHED_COMMISSION, TransitionHandler.CREATE_DETACHED_COMMISSION);
addTransition(TransitionName.PRINT, TransitionHandler.PRINT);
}
AbstractTaskModel taskModel = context.getTaskModel();
if (taskModel instanceof ReviewDocumentTaskModel && !(taskModel instanceof ExpeditionaryProcessingDocumentTaskModel)){
// && !(taskModel instanceof AttachFileAndReviewDocumentTaskModel)){
if ((taskModel instanceof AttachFileToDocumentTaskModel || taskModel instanceof WaitForScanningTaskModel) && ((documentModel instanceof InternalDocumentModel) || (documentModel instanceof OutgoingDocumentModel) || (documentModel instanceof IncomingDocumentModel)))
addTransition(TransitionName.PRINT_BARCODE, TransitionHandler.PRINT_BARCODE);
if (taskModel instanceof AbstractDocumentTaskModel){
if ( state instanceof AbstractDraftState ){
if( state instanceof NewProtocolDraftState)
addTransition(ContainerAction.ACTION_NAME, TransitionName.SEND_DRAFT, TransitionName.REGISTER, TransitionHandler.SEND_DRAFT);
else if (state instanceof NewDraftState)
addTransition(TransitionName.SEND_DRAFT, TransitionHandler.SEND_DRAFT);
if (state instanceof AbstractApprovalDraftState)
addTransition(TransitionName.REWORK_DRAFT, TransitionHandler.REWORK_DRAFT);
if (state instanceof AnalyseDraftState)
addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_ANALYSE, TransitionHandler.SEND_DRAFT);
if (state instanceof ControlDraftState)
addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_CONTROL, TransitionHandler.SEND_DRAFT);
if (state instanceof ApproveDraftState)
addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_APPROVAL, TransitionHandler.SEND_DRAFT);
if (state instanceof SignDraftState)
addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_SIGN, TransitionHandler.SEND_DRAFT);
if (state instanceof ExternalApproveDraftState)
addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_APPROVAL, TransitionHandler.SEND_DRAFT);
if (state instanceof ControlApproveDraftState)
addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_CONTROLED, TransitionHandler.SEND_DRAFT);
if (state instanceof ConfirmationDraftState)
addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_CONFIRM, TransitionHandler.SEND_DRAFT);
}
}
}
.................. несколько страниц такого кода ...........................
if (state instanceof AbstractApprovalDraftState ||
state instanceof ReworkDraftState ||
state instanceof NewDocumentState ||
state instanceof RegisterDocumentState ||
state instanceof ReviewDocumentState ||
state instanceof ExecuteDocumentState){
addTransition(TransitionName.SAVE, TransitionHandler.SAVE);
}
super.initializeTransitions(context);
}
Автор решил захардкодить в одном месте логику переходов между всеми состояниями всех жизненных циклов всех документов, реализованных в системе документооборота. Получился говнокод-BPM-движок. А внешне код очень даже солидный: с константами и комментариями... и названиями классов вроде: ExpeditionaryProcessingDocumentTaskModel