org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition Java Examples

The following examples show how to use org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BpmnParseHandlerTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = "chapter6/dynamic-form/leave.bpmn")
public void testParseHandler() throws Exception {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertEquals("请假流程-动态表单-被PRE解析器修改", processDefinition.getName());
    assertEquals("leave-modified-by-post-parse-handler", processDefinition.getKey());

    RepositoryServiceImpl repositoryServiceImpl = (RepositoryServiceImpl) repositoryService;
    ReadOnlyProcessDefinition deployedProcessDefinition = repositoryServiceImpl
            .getDeployedProcessDefinition(processDefinition.getId());

    ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) deployedProcessDefinition;
    List<ActivityImpl> activitiList = processDefinitionEntity.getActivities();//获得当前任务的所有节点
    for (ActivityImpl activity : activitiList) {
        System.out.println("Activity Name: " + activity.getProperty("name") + ", async=" + activity.isAsync());
    }

    InputStream processBpmn = activitiRule.getRepositoryService()
            .getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getResourceName());
    String userHomeDir = getClass().getResource("/").getFile();
    FileUtils.copyInputStreamToFile(processBpmn,
            new File(userHomeDir + "/leave.bpmn20.xml"));
}
 
Example #2
Source File: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private WorkflowTask getTaskForTimer(Job job, ProcessInstance processInstance, Execution jobExecution) 
{
    if (job instanceof TimerEntity) 
    {
        ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
        List<String> activeActivityIds = runtimeService.getActiveActivityIds(jobExecution.getId());
        
        if(activeActivityIds.size() == 1)
        {
            PvmActivity targetActivity = def.findActivity(activeActivityIds.get(0));
            if(targetActivity != null)
            {
                // Only get tasks of active activity is a user-task 
                String activityType = (String) targetActivity.getProperty(ActivitiConstants.NODE_TYPE);
                if(ActivitiConstants.USER_TASK_NODE_TYPE.equals(activityType))
                {
                    Task task = taskService.createTaskQuery().executionId(job.getExecutionId()).singleResult();
                    return typeConverter.convert(task);
                }
            }
        }
    }
    return null;
}
 
Example #3
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Convert a {@link ProcessDefinition} into a {@link WorkflowDefinition}.
 * @param definition ProcessDefinition
 * @return WorkflowDefinition
 */
public WorkflowDefinition convert(ProcessDefinition definition)
{
    if(definition==null)
        return null;
    
    String defId = definition.getId();
    String defName = definition.getKey();
    int version = definition.getVersion();
    String defaultTitle = definition.getName();
    
    String startTaskName = null;
    StartFormData startFormData = getStartFormData(defId, defName);
    if(startFormData != null) 
    {
        startTaskName = startFormData.getFormKey();
    }
    
    ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(defId);
    PvmActivity startEvent = def.getInitial();
    WorkflowTaskDefinition startTask = getTaskDefinition(startEvent, startTaskName, definition.getKey(), true);
    
    return factory.createDefinition(defId,
                defName, version, defaultTitle,
                null, startTask);
}
 
Example #4
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public WorkflowTaskDefinition getTaskDefinition(Task task)
{
	// Get the task-form used (retrieved from cached process-definition)
	TaskFormData taskFormData = formService.getTaskFormData(task.getId());
    String taskDefId = null;
    if(taskFormData != null) 
    {
        taskDefId = taskFormData.getFormKey();
    }
    
    // Fetch node based on cached process-definition
    ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(task.getProcessDefinitionId());
    WorkflowNode node = convert(procDef.findActivity(task.getTaskDefinitionKey()), true);
    
    return factory.createTaskDefinition(taskDefId, node, taskDefId, false);
}
 
Example #5
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public WorkflowPath convert(Execution execution, ProcessInstance instance)
{
    if(execution == null)
        return null;
    
    boolean isActive = !execution.isEnded();
    
    // Convert workflow and collect variables
    Map<String, Object> workflowInstanceVariables = new HashMap<String, Object>();
    WorkflowInstance wfInstance = convertAndSetVariables(instance, workflowInstanceVariables);
    
    WorkflowNode node = null;
    // Get active node on execution
    List<String> nodeIds = runtimeService.getActiveActivityIds(execution.getId());

    if (nodeIds != null && nodeIds.size() >= 1)
    {
        ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(instance.getProcessDefinitionId());
        PvmActivity activity = procDef.findActivity(nodeIds.get(0));
        node = convert(activity);
    }

    return factory.createPath(execution.getId(), wfInstance, node, isActive);
}
 
Example #6
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String getFormKey(PvmActivity act, ReadOnlyProcessDefinition processDefinition)
{
    if(act instanceof ActivityImpl) 
    {
        ActivityImpl actImpl = (ActivityImpl) act;
        if (actImpl.getActivityBehavior() instanceof UserTaskActivityBehavior)        
        {
        	UserTaskActivityBehavior uta = (UserTaskActivityBehavior) actImpl.getActivityBehavior();
            return getFormKey(uta.getTaskDefinition());
        }
        else if(actImpl.getActivityBehavior() instanceof MultiInstanceActivityBehavior) 
        {
        	// Get the task-definition from the process-definition
        	if(processDefinition instanceof ProcessDefinitionEntity)
        	{
        		// Task definition id is the same the the activity id
        		TaskDefinition taskDef = ((ProcessDefinitionEntity) processDefinition).getTaskDefinitions().get(act.getId());
        		if(taskDef != null)
        		{
        			return getFormKey(taskDef);
        		}
        	}
        }
    }
    return null;
}
 
Example #7
Source File: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
* {@inheritDoc}
*/
public List<WorkflowTaskDefinition> getTaskDefinitions(String workflowDefinitionId)
{
    List<WorkflowTaskDefinition> defs = new ArrayList<WorkflowTaskDefinition>();
    String processDefinitionId = createLocalId(workflowDefinitionId);
    
    // This should return all task definitions, including the start-task
    ReadOnlyProcessDefinition processDefinition =((RepositoryServiceImpl)repoService).getDeployedProcessDefinition(processDefinitionId);

    String processName = ((ProcessDefinition)processDefinition).getKey();
    factory.checkDomain(processName);
    
    // Process start task definition
    PvmActivity startEvent = processDefinition.getInitial();
    
    String startTaskName = null;
    StartFormData startFormData = formService.getStartFormData(processDefinition.getId());
    if(startFormData != null) 
    {
        startTaskName = startFormData.getFormKey();
    }
    
    // Add start task definition
    defs.add(typeConverter.getTaskDefinition(startEvent, startTaskName, processDefinition.getId(), true));
    
    // Now, continue through process, finding all user-tasks
    Collection<PvmActivity> taskActivities = typeConverter.findUserTasks(startEvent);
    for(PvmActivity act : taskActivities)
    {
        String formKey = typeConverter.getFormKey(act, processDefinition);
        defs.add(typeConverter.getTaskDefinition(act, formKey, processDefinition.getId(), false));
    }
    
   return defs;
}
 
Example #8
Source File: BpmnDeploymentTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Deployment
public void testProcessDefinitionDescription() {
    String id = repositoryService.createProcessDefinitionQuery().singleResult().getId();
    org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) processEngineConfiguration.getFlowable5CompatibilityHandler()
            .getRawProcessConfiguration();
    ReadOnlyProcessDefinition processDefinition = ((RepositoryServiceImpl) activiti5ProcessEngineConfig.getRepositoryService()).getDeployedProcessDefinition(id);
    assertEquals("This is really good process documentation!", processDefinition.getDescription());
}
 
Example #9
Source File: BpmnDeploymentTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Deployment
public void testGetBpmnXmlFileThroughService() {
    String deploymentId = repositoryService.createDeploymentQuery().singleResult().getId();
    List<String> deploymentResources = repositoryService.getDeploymentResourceNames(deploymentId);

    // verify bpmn file name
    assertEquals(1, deploymentResources.size());
    String bpmnResourceName = "org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml";
    assertEquals(bpmnResourceName, deploymentResources.get(0));

    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertEquals(bpmnResourceName, processDefinition.getResourceName());
    assertNull(processDefinition.getDiagramResourceName());
    assertFalse(processDefinition.hasStartFormKey());

    org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) processEngineConfiguration.getFlowable5CompatibilityHandler()
            .getRawProcessConfiguration();
    ReadOnlyProcessDefinition readOnlyProcessDefinition = ((RepositoryServiceImpl) activiti5ProcessEngineConfig.getRepositoryService()).getDeployedProcessDefinition(processDefinition.getId());
    assertNull(readOnlyProcessDefinition.getDiagramResourceName());

    // verify content
    InputStream deploymentInputStream = repositoryService.getResourceAsStream(deploymentId, bpmnResourceName);
    String contentFromDeployment = readInputStreamToString(deploymentInputStream);
    assertTrue(contentFromDeployment.length() > 0);
    assertTrue(contentFromDeployment.contains("process id=\"emptyProcess\""));

    InputStream fileInputStream = ReflectUtil.getResourceAsStream("org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml");
    String contentFromFile = readInputStreamToString(fileInputStream);
    assertEquals(contentFromFile, contentFromDeployment);
}
 
Example #10
Source File: ProcessDefinitionPersistenceTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void testProcessDefinitionIntrospection() {
    String deploymentId = repositoryService
            .createDeployment()
            .addClasspathResource("org/activiti/engine/test/db/processOne.bpmn20.xml")
            .deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE)
            .deploy()
            .getId();

    String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
    ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (ProcessEngineConfigurationImpl) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawProcessConfiguration();
    ReadOnlyProcessDefinition processDefinition = ((RepositoryServiceImpl) activiti5ProcessEngineConfig.getRepositoryService()).getDeployedProcessDefinition(procDefId);

    assertEquals(procDefId, processDefinition.getId());
    assertEquals("Process One", processDefinition.getName());
    assertEquals("the first process", processDefinition.getProperty("documentation"));

    PvmActivity start = processDefinition.findActivity("start");
    assertNotNull(start);
    assertEquals("start", start.getId());
    assertEquals("S t a r t", start.getProperty("name"));
    assertEquals("the start event", start.getProperty("documentation"));
    assertEquals(Collections.EMPTY_LIST, start.getActivities());
    List<PvmTransition> outgoingTransitions = start.getOutgoingTransitions();
    assertEquals(1, outgoingTransitions.size());
    assertEquals("${a == b}", outgoingTransitions.get(0).getProperty(BpmnParse.PROPERTYNAME_CONDITION_TEXT));

    PvmActivity end = processDefinition.findActivity("end");
    assertNotNull(end);
    assertEquals("end", end.getId());

    PvmTransition transition = outgoingTransitions.get(0);
    assertEquals("flow1", transition.getId());
    assertEquals("Flow One", transition.getProperty("name"));
    assertEquals("The only transitions in the process", transition.getProperty("documentation"));
    assertSame(start, transition.getSource());
    assertSame(end, transition.getDestination());

    repositoryService.deleteDeployment(deploymentId);
}
 
Example #11
Source File: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private WorkflowTask endStartTask(String localTaskId)
{
    // We don't end a task, we set a variable on the process-instance 
    // to indicate that it's started
    String processInstanceId = localTaskId.replace(ActivitiConstants.START_TASK_PREFIX, "");
    if(false == typeConverter.isStartTaskActive(processInstanceId))
    {
        return typeConverter.getVirtualStartTask(processInstanceId, false);
    }
    
    // Set start task end date on the process
    runtimeService.setVariable(processInstanceId, ActivitiConstants.PROP_START_TASK_END_DATE, new Date());
    
    // Check if the current activity is a signalTask and the first activity in the process,
    // this is a workaround for processes without any task/waitstates that should otherwise end
    // when they are started.
    ProcessInstance processInstance = activitiUtil.getProcessInstance(processInstanceId);
    String currentActivity = ((ExecutionEntity)processInstance).getActivityId();
    
    ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
    PvmActivity activity = procDef.findActivity(currentActivity);
    if(isReceiveTask(activity) && isFirstActivity(activity, procDef)) 
    {
        // Signal the process to start flowing, beginning from the recieve task
        runtimeService.signal(processInstanceId);
        
        // It's possible the process has ended after signalling the receive task
    }
    // Return virtual start task for the execution, it's safe to use the
    // processInstanceId
    return typeConverter.getVirtualStartTask(processInstanceId, false);
}
 
Example #12
Source File: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean isFirstActivity(PvmActivity activity, ReadOnlyProcessDefinition procDef)
{
    if(procDef.getInitial().getOutgoingTransitions().size() == 1) 
    {
        if (procDef.getInitial().getOutgoingTransitions().get(0).getDestination().equals(activity)) 
        {
            return true;
        }
    }
    return false;
}
 
Example #13
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private WorkflowTask getVirtualStartTask(HistoricProcessInstance historicProcessInstance)
{
    if(historicProcessInstance == null)
    {
        return null;
    }
    String processInstanceId = historicProcessInstance.getId();

    if (!activitiUtil.isMultiTenantWorkflowDeploymentEnabled() && false == isCorrectTenantHistoric(processInstanceId))
    {
        return null;
    }
    
    String id = ActivitiConstants.START_TASK_PREFIX + processInstanceId;
    
    // Since the process instance is complete the Start Task must be complete!
    WorkflowTaskState state = WorkflowTaskState.COMPLETED;

    // We use the process-instance ID as execution-id. It's ended anyway
    WorkflowPath path  = buildCompletedPath(processInstanceId, processInstanceId);
    if(path == null)
    {
        return null;
    }
    
    // Convert start-event to start-task Node
    ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(historicProcessInstance.getProcessDefinitionId());
    WorkflowNode startNode = convert(procDef.getInitial(), true);
    
    String taskDefId = activitiUtil.getStartFormKey(historicProcessInstance.getProcessDefinitionId());
    WorkflowTaskDefinition taskDef = factory.createTaskDefinition(taskDefId, startNode, taskDefId, true);
    
    boolean completed = historicProcessInstance.getEndTime() != null;
    Map<QName, Serializable> properties = propertyConverter.getStartTaskProperties(historicProcessInstance, taskDefId, completed);
    
    // TODO: Figure out what name/description should be used for the start-task, start event's name?
    String defaultTitle = null;
    String defaultDescription = null;
    
    return factory.createTask(id,
                taskDef, taskDef.getId(), defaultTitle, defaultDescription, state, path, properties);
}
 
Example #14
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private WorkflowTask getVirtualStartTask(ProcessInstance processInstance, boolean inProgress)
{
    String processInstanceId = processInstance.getId();

    if (!activitiUtil.isMultiTenantWorkflowDeploymentEnabled() && !isCorrectTenantRuntime(processInstanceId))
    {
        return null;
    }
    
    String id = ActivitiConstants.START_TASK_PREFIX + processInstanceId;
    
    WorkflowTaskState state = null;
    if(inProgress)
    {
        state = WorkflowTaskState.IN_PROGRESS;
    }
    else
    {
        state = WorkflowTaskState.COMPLETED;
    }
    
    WorkflowPath path  = convert((Execution)processInstance);
    
    // Convert start-event to start-task Node
    String definitionId = processInstance.getProcessDefinitionId();
    ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(definitionId);
    WorkflowNode startNode = convert(procDef.getInitial(), true);
    
    String key = ((ProcessDefinition)procDef).getKey();
    StartFormData startFormData = getStartFormData(definitionId, key);
    String taskDefId = null;
    if(startFormData != null) 
    {
        taskDefId = startFormData.getFormKey();
    }
    WorkflowTaskDefinition taskDef = factory.createTaskDefinition(taskDefId, startNode, taskDefId, true);
    
    // Add properties based on HistoricProcessInstance
    HistoricProcessInstance historicProcessInstance = historyService
        .createHistoricProcessInstanceQuery()
        .processInstanceId(processInstanceId)
        .singleResult();
    
    Map<QName, Serializable> properties = propertyConverter.getStartTaskProperties(historicProcessInstance, taskDefId, !inProgress);
    
    // TODO: Figure out what name/description should be used for the start-task, start event's name?
    String defaultTitle = null;
    String defaultDescription = null;
    
    return factory.createTask(id,
                taskDef, taskDef.getId(), defaultTitle, defaultDescription, state, path, properties);
}
 
Example #15
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private WorkflowNode buildHistoricTaskWorkflowNode(HistoricTaskInstance historicTaskInstance) 
   {
   	ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(historicTaskInstance.getProcessDefinitionId());
   	PvmActivity taskActivity = procDef.findActivity(historicTaskInstance.getTaskDefinitionKey());
	return convert(taskActivity);
}
 
Example #16
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public String getWorkflowDefinitionName(String workflowDefinitionId)
{
	ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(workflowDefinitionId);
	return ((ProcessDefinition) def).getKey();
}
 
Example #17
Source File: ActivitiPropertyConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Map<String, Object> getStartVariables(String processDefId, Map<QName, Serializable> properties)
{
    ProcessDefinition procDef = activitiUtil.getProcessDefinition(processDefId);
    String startTaskTypeName = activitiUtil.getStartTaskTypeName(processDefId);
    TypeDefinition startTaskType  = factory.getTaskFullTypeDefinition(startTaskTypeName, true);
    
    // Lookup type definition for the startTask
    Map<QName, PropertyDefinition> taskProperties = startTaskType.getProperties();
    
    // Get all default values from the definitions
    Map<QName, Serializable> defaultProperties = new HashMap<QName, Serializable>();
    for (Map.Entry<QName, PropertyDefinition> entry : taskProperties.entrySet())
    {
        String defaultValue = entry.getValue().getDefaultValue();
        if (defaultValue != null)
        {
            defaultProperties.put(entry.getKey(), defaultValue);
        }
    }
    
    // Put all passed properties in map with defaults
    if(properties != null)
    {
        defaultProperties.putAll(properties);
    }
    
    // Special case for task description default value
    // Use the shared description set in the workflowinstance
    String description = (String) defaultProperties.get(WorkflowModel.PROP_DESCRIPTION);
    if(description == null)
    {
        String wfDescription = (String) defaultProperties.get(WorkflowModel.PROP_WORKFLOW_DESCRIPTION);
        String procDefKey = procDef.getKey();
        ReadOnlyProcessDefinition deployedDef = activitiUtil.getDeployedProcessDefinition(processDefId);
        String startEventName = deployedDef.getInitial().getId();
        String wfDefKey = factory.buildGlobalId(procDefKey);
        description = factory.getTaskDescription(startTaskType, wfDefKey, wfDescription, startEventName);
        defaultProperties.put(WorkflowModel.PROP_DESCRIPTION, description);
    }
    
    //Special case for workflowDueDate. 
    if(!defaultProperties.containsKey(WorkflowModel.PROP_WORKFLOW_DUE_DATE) && taskProperties.containsKey(WorkflowModel.PROP_WORKFLOW_DUE_DATE))
    {
        defaultProperties.put(WorkflowModel.PROP_WORKFLOW_DUE_DATE, null);
    }
    
    return handlerRegistry.handleVariablesToSet(defaultProperties, startTaskType, null, Void.class);
}
 
Example #18
Source File: RepositoryServiceImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public ReadOnlyProcessDefinition getDeployedProcessDefinition(String processDefinitionId) {
    return (ReadOnlyProcessDefinition) commandExecutor.execute(new GetDeploymentProcessDefinitionCmd(processDefinitionId));
}
 
Example #19
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取跟踪数据
 *
 * @param executionId
 * @return
 * @throws Exception
 */
@RequestMapping(value = "trace/data/{executionId}")
@ResponseBody
public List<Map<String, Object>> readActivityDatas(@PathVariable("executionId") String executionId) throws Exception {
    ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(executionId).singleResult();
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);

    RepositoryServiceImpl repositoryServiceImpl = (RepositoryServiceImpl) repositoryService;
    ReadOnlyProcessDefinition deployedProcessDefinition = repositoryServiceImpl
            .getDeployedProcessDefinition(executionEntity.getProcessDefinitionId());

    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deployedProcessDefinition;
    List<ActivityImpl> activitiList = processDefinition.getActivities();//获得当前任务的所有节点

    List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
    for (ActivityImpl activity : activitiList) {

        ActivityBehavior activityBehavior = activity.getActivityBehavior();

        boolean currentActiviti = false;
        // 当前节点
        String activityId = activity.getId();
        if (activeActivityIds.contains(activityId)) {
            currentActiviti = true;
        }
        Map<String, Object> activityImageInfo = packageSingleActivitiInfo(activity, executionEntity.getId(), currentActiviti);
        activityInfos.add(activityImageInfo);

        // 处理子流程
        if (activityBehavior instanceof SubProcessActivityBehavior) {
            List<ActivityImpl> innerActivityList = activity.getActivities();
            for (ActivityImpl innerActivity : innerActivityList) {
                String innerActivityId = innerActivity.getId();
                if (activeActivityIds.contains(innerActivityId)) {
                    currentActiviti = true;
                } else {
                    currentActiviti = false;
                }
                activityImageInfo = packageSingleActivitiInfo(innerActivity, executionEntity.getId(), currentActiviti);
                activityInfos.add(activityImageInfo);
            }
        }

    }

    return activityInfos;
}
 
Example #20
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取跟踪数据
 *
 * @param executionId
 * @return
 * @throws Exception
 */
@RequestMapping(value = "trace/data/{executionId}")
@ResponseBody
public List<Map<String, Object>> readActivityDatas(@PathVariable("executionId") String executionId) throws Exception {
    ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(executionId).singleResult();
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);

    RepositoryServiceImpl repositoryServiceImpl = (RepositoryServiceImpl) repositoryService;
    ReadOnlyProcessDefinition deployedProcessDefinition = repositoryServiceImpl
            .getDeployedProcessDefinition(executionEntity.getProcessDefinitionId());

    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deployedProcessDefinition;
    List<ActivityImpl> activitiList = processDefinition.getActivities();//获得当前任务的所有节点

    List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
    for (ActivityImpl activity : activitiList) {

        ActivityBehavior activityBehavior = activity.getActivityBehavior();

        boolean currentActiviti = false;
        // 当前节点
        String activityId = activity.getId();
        if (activeActivityIds.contains(activityId)) {
            currentActiviti = true;
        }
        Map<String, Object> activityImageInfo = packageSingleActivitiInfo(activity, executionEntity.getId(), currentActiviti);
        activityInfos.add(activityImageInfo);

        // 处理子流程
        if (activityBehavior instanceof SubProcessActivityBehavior) {
            List<ActivityImpl> innerActivityList = activity.getActivities();
            for (ActivityImpl innerActivity : innerActivityList) {
                String innerActivityId = innerActivity.getId();
                if (activeActivityIds.contains(innerActivityId)) {
                    currentActiviti = true;
                } else {
                    currentActiviti = false;
                }
                activityImageInfo = packageSingleActivitiInfo(innerActivity, executionEntity.getId(), currentActiviti);
                activityInfos.add(activityImageInfo);
            }
        }

    }

    return activityInfos;
}
 
Example #21
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取跟踪数据
 *
 * @param executionId
 * @return
 * @throws Exception
 */
@RequestMapping(value = "trace/data/{executionId}")
@ResponseBody
public List<Map<String, Object>> readActivityDatas(@PathVariable("executionId") String executionId) throws Exception {
    ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(executionId).singleResult();
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);

    RepositoryServiceImpl repositoryServiceImpl = (RepositoryServiceImpl) repositoryService;
    ReadOnlyProcessDefinition deployedProcessDefinition = repositoryServiceImpl
            .getDeployedProcessDefinition(executionEntity.getProcessDefinitionId());

    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deployedProcessDefinition;
    List<ActivityImpl> activitiList = processDefinition.getActivities();//获得当前任务的所有节点

    List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
    for (ActivityImpl activity : activitiList) {

        ActivityBehavior activityBehavior = activity.getActivityBehavior();

        boolean currentActiviti = false;
        // 当前节点
        String activityId = activity.getId();
        if (activeActivityIds.contains(activityId)) {
            currentActiviti = true;
        }
        Map<String, Object> activityImageInfo = packageSingleActivitiInfo(activity, executionEntity.getId(), currentActiviti);
        activityInfos.add(activityImageInfo);

        // 处理子流程
        if (activityBehavior instanceof SubProcessActivityBehavior) {
            List<ActivityImpl> innerActivityList = activity.getActivities();
            for (ActivityImpl innerActivity : innerActivityList) {
                String innerActivityId = innerActivity.getId();
                if (activeActivityIds.contains(innerActivityId)) {
                    currentActiviti = true;
                } else {
                    currentActiviti = false;
                }
                activityImageInfo = packageSingleActivitiInfo(innerActivity, executionEntity.getId(), currentActiviti);
                activityInfos.add(activityImageInfo);
            }
        }

    }

    return activityInfos;
}
 
Example #22
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取跟踪数据
 *
 * @param executionId
 * @return
 * @throws Exception
 */
@RequestMapping(value = "trace/data/{executionId}")
@ResponseBody
public List<Map<String, Object>> readActivityDatas(@PathVariable("executionId") String executionId) throws Exception {
    ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(executionId).singleResult();
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);

    RepositoryServiceImpl repositoryServiceImpl = (RepositoryServiceImpl) repositoryService;
    ReadOnlyProcessDefinition deployedProcessDefinition = repositoryServiceImpl
            .getDeployedProcessDefinition(executionEntity.getProcessDefinitionId());

    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deployedProcessDefinition;
    List<ActivityImpl> activitiList = processDefinition.getActivities();//获得当前任务的所有节点

    List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
    for (ActivityImpl activity : activitiList) {

        ActivityBehavior activityBehavior = activity.getActivityBehavior();

        boolean currentActiviti = false;
        // 当前节点
        String activityId = activity.getId();
        if (activeActivityIds.contains(activityId)) {
            currentActiviti = true;
        }
        Map<String, Object> activityImageInfo = packageSingleActivitiInfo(activity, executionEntity.getId(), currentActiviti);
        activityInfos.add(activityImageInfo);

        // 处理子流程
        if (activityBehavior instanceof SubProcessActivityBehavior) {
            List<ActivityImpl> innerActivityList = activity.getActivities();
            for (ActivityImpl innerActivity : innerActivityList) {
                String innerActivityId = innerActivity.getId();
                if (activeActivityIds.contains(innerActivityId)) {
                    currentActiviti = true;
                } else {
                    currentActiviti = false;
                }
                activityImageInfo = packageSingleActivitiInfo(innerActivity, executionEntity.getId(), currentActiviti);
                activityInfos.add(activityImageInfo);
            }
        }

    }

    return activityInfos;
}
 
Example #23
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取跟踪数据
 *
 * @param executionId
 * @return
 * @throws Exception
 */
@RequestMapping(value = "trace/data/{executionId}")
@ResponseBody
public List<Map<String, Object>> readActivityDatas(@PathVariable("executionId") String executionId) throws Exception {
    ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(executionId).singleResult();
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);

    RepositoryServiceImpl repositoryServiceImpl = (RepositoryServiceImpl) repositoryService;
    ReadOnlyProcessDefinition deployedProcessDefinition = repositoryServiceImpl
            .getDeployedProcessDefinition(executionEntity.getProcessDefinitionId());

    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deployedProcessDefinition;
    List<ActivityImpl> activitiList = processDefinition.getActivities();//获得当前任务的所有节点

    List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
    for (ActivityImpl activity : activitiList) {

        ActivityBehavior activityBehavior = activity.getActivityBehavior();

        boolean currentActiviti = false;
        // 当前节点
        String activityId = activity.getId();
        if (activeActivityIds.contains(activityId)) {
            currentActiviti = true;
        }
        Map<String, Object> activityImageInfo = packageSingleActivitiInfo(activity, executionEntity.getId(), currentActiviti);
        activityInfos.add(activityImageInfo);

        // 处理子流程
        if (activityBehavior instanceof SubProcessActivityBehavior) {
            List<ActivityImpl> innerActivityList = activity.getActivities();
            for (ActivityImpl innerActivity : innerActivityList) {
                String innerActivityId = innerActivity.getId();
                if (activeActivityIds.contains(innerActivityId)) {
                    currentActiviti = true;
                } else {
                    currentActiviti = false;
                }
                activityImageInfo = packageSingleActivitiInfo(innerActivity, executionEntity.getId(), currentActiviti);
                activityInfos.add(activityImageInfo);
            }
        }

    }

    return activityInfos;
}
 
Example #24
Source File: ActivitiUtil.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ReadOnlyProcessDefinition getDeployedProcessDefinition(String processDefinitionId) 
{
    // Currently, getDeployedProcessDefinition is still experimental and not exposed on 
    // RepositoryService interface
    return ((RepositoryServiceImpl)repoService).getDeployedProcessDefinition(processDefinitionId);
}