Esempio n. 1
0
        protected internal override void eventNotificationsCompleted(PvmExecutionImpl execution)
        {
            execution.leaveActivityInstance();

            PvmExecutionImpl      superExecution     = execution.SuperExecution;
            CmmnActivityExecution superCaseExecution = execution.SuperCaseExecution;

            SubProcessActivityBehavior        subProcessActivityBehavior = null;
            TransferVariablesActivityBehavior transferVariablesBehavior  = null;

            // copy variables before destroying the ended sub process instance
            if (superExecution != null)
            {
                PvmActivity activity = superExecution.getActivity();
                subProcessActivityBehavior = (SubProcessActivityBehavior)activity.ActivityBehavior;
                try
                {
                    subProcessActivityBehavior.passOutputVariables(superExecution, execution);
                }
                catch (Exception e)
                {
                    LOG.exceptionWhileCompletingSupProcess(execution, e);
                    throw e;
                }
                catch (Exception e)
                {
                    LOG.exceptionWhileCompletingSupProcess(execution, e);
                    throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
                }
            }
            else if (superCaseExecution != null)
            {
                CmmnActivity activity = superCaseExecution.Activity;
                transferVariablesBehavior = (TransferVariablesActivityBehavior)activity.ActivityBehavior;
                try
                {
                    transferVariablesBehavior.transferVariables(execution, superCaseExecution);
                }
                catch (Exception e)
                {
                    LOG.exceptionWhileCompletingSupProcess(execution, e);
                    throw e;
                }
                catch (Exception e)
                {
                    LOG.exceptionWhileCompletingSupProcess(execution, e);
                    throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
                }
            }

            execution.destroy();
            execution.remove();

            // and trigger execution afterwards
            if (superExecution != null)
            {
                superExecution.SubProcessInstance = null;
                try
                {
                    subProcessActivityBehavior.completed(superExecution);
                }
                catch (Exception e)
                {
                    LOG.exceptionWhileCompletingSupProcess(execution, e);
                    throw e;
                }
                catch (Exception e)
                {
                    LOG.exceptionWhileCompletingSupProcess(execution, e);
                    throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
                }
            }
            else if (superCaseExecution != null)
            {
                superCaseExecution.complete();
            }
        }
Esempio n. 2
0
        protected internal override void postTransitionNotification(CmmnExecution execution)
        {
            if (!execution.CaseInstanceExecution)
            {
                execution.remove();
            }
            else
            {
                CmmnExecution    superCaseExecution = execution.SuperCaseExecution;
                PvmExecutionImpl superExecution     = execution.SuperExecution;

                if (superCaseExecution != null)
                {
                    TransferVariablesActivityBehavior behavior = (TransferVariablesActivityBehavior)getActivityBehavior(superCaseExecution);
                    behavior.transferVariables(execution, superCaseExecution);
                    superCaseExecution.complete();
                }
                else if (superExecution != null)
                {
                    SubProcessActivityBehavior behavior = (SubProcessActivityBehavior)getActivityBehavior(superExecution);

                    try
                    {
                        behavior.passOutputVariables(superExecution, execution);
                    }
                    catch (Exception e)
                    {
                        LOG.completingSubCaseError(execution, e);
                        throw e;
                    }
                    catch (Exception e)
                    {
                        LOG.completingSubCaseError(execution, e);
                        throw LOG.completingSubCaseErrorException(execution, e);
                    }

                    // set sub case instance to null
                    superExecution.SubCaseInstance = null;

                    try
                    {
                        behavior.completed(superExecution);
                    }
                    catch (Exception e)
                    {
                        LOG.completingSubCaseError(execution, e);
                        throw e;
                    }
                    catch (Exception e)
                    {
                        LOG.completingSubCaseError(execution, e);
                        throw LOG.completingSubCaseErrorException(execution, e);
                    }
                }

                execution.SuperCaseExecution = null;
                execution.SuperExecution     = null;
            }

            CmmnExecution parent = execution.Parent;

            if (parent != null)
            {
                CmmnActivityBehavior behavior = getActivityBehavior(parent);
                if (behavior is CmmnCompositeActivityBehavior)
                {
                    CmmnCompositeActivityBehavior compositeBehavior = (CmmnCompositeActivityBehavior)behavior;
                    compositeBehavior.handleChildCompletion(parent, execution);
                }
            }
        }