當前位置: 首頁>>代碼示例>>Java>>正文


Java ProcessInstance.isEnded方法代碼示例

本文整理匯總了Java中org.activiti.engine.runtime.ProcessInstance.isEnded方法的典型用法代碼示例。如果您正苦於以下問題:Java ProcessInstance.isEnded方法的具體用法?Java ProcessInstance.isEnded怎麽用?Java ProcessInstance.isEnded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.activiti.engine.runtime.ProcessInstance的用法示例。


在下文中一共展示了ProcessInstance.isEnded方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startWorkflow

import org.activiti.engine.runtime.ProcessInstance; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
public WorkflowPath startWorkflow(String workflowDefinitionId, Map<QName, Serializable> parameters)
{
    try
    {
        String currentUserName = AuthenticationUtil.getFullyAuthenticatedUser();
        Authentication.setAuthenticatedUserId(currentUserName);
        
        String processDefId = createLocalId(workflowDefinitionId);
        
        // Set start task properties. This should be done before instance is started, since it's id will be used
        Map<String, Object> variables = propertyConverter.getStartVariables(processDefId, parameters);
        variables.put(WorkflowConstants.PROP_CANCELLED, Boolean.FALSE);
        
        // Add company home
        Object companyHome = nodeConverter.convertNode(getCompanyHome());
        variables.put(WorkflowConstants.PROP_COMPANY_HOME, companyHome);
         
        // Add the initiator
        NodeRef initiator = getPersonNodeRef(currentUserName);
        if (initiator != null)
        {
            variables.put(WorkflowConstants.PROP_INITIATOR, nodeConverter.convertNode(initiator));
            // Also add the initiator home reference, if one exists
            NodeRef initiatorHome = (NodeRef) nodeService.getProperty(initiator, ContentModel.PROP_HOMEFOLDER);
            if (initiatorHome != null)
            {
                variables.put(WorkflowConstants.PROP_INITIATOR_HOME, nodeConverter.convertNode(initiatorHome));
            }
        }
        
        // Start the process-instance
        CommandContext context = Context.getCommandContext();
        boolean isContextSuspended = false;
        if (context != null && context.getException() == null)
        {
            // MNT-11926: push null context to stack to avoid context reusage when new instance is not flushed
            Context.setCommandContext(null);
            isContextSuspended = true;
        }
        try
        {
            ProcessInstance instance = runtimeService.startProcessInstanceById(processDefId, variables);
            if (instance.isEnded())
            {
                return typeConverter.buildCompletedPath(instance.getId(), instance.getId());
            }
            else
            {
                WorkflowPath path = typeConverter.convert((Execution) instance);
                endStartTaskAutomatically(path, instance);
                return path;
            }
        }
        finally
        {
            if (isContextSuspended)
            {
                // pop null context out of stack
                Context.removeCommandContext();
            }
        }
    }
    catch (ActivitiException ae)
    {
        String msg = messageService.getMessage(ERR_START_WORKFLOW, workflowDefinitionId);
        if(logger.isDebugEnabled())
        {
        	logger.debug(msg, ae);
        }
        throw new WorkflowException(msg, ae);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:76,代碼來源:ActivitiWorkflowEngine.java


注:本文中的org.activiti.engine.runtime.ProcessInstance.isEnded方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。