Java Code Examples for org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity

The following examples show how to use org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity. These examples are extracted from open source projects. 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 Project: lemon   Source File: AutoCompleteFirstTaskListener.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 获得第一个节点.
 */
public PvmActivity findFirstActivity(String processDefinitionId) {
    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration().getProcessDefinitionCache()
            .get(processDefinitionId);

    ActivityImpl startActivity = processDefinitionEntity.getInitial();

    if (startActivity.getOutgoingTransitions().size() != 1) {
        throw new IllegalStateException(
                "start activity outgoing transitions cannot more than 1, now is : "
                        + startActivity.getOutgoingTransitions().size());
    }

    PvmTransition pvmTransition = startActivity.getOutgoingTransitions()
            .get(0);
    PvmActivity targetActivity = pvmTransition.getDestination();

    if (!"userTask".equals(targetActivity.getProperty("type"))) {
        logger.debug("first activity is not userTask, just skip");

        return null;
    }

    return targetActivity;
}
 
Example 2
protected List<ProcessInstanceRepresentation> convertInstanceList(List<HistoricProcessInstance> instances) {
  List<ProcessInstanceRepresentation> result = new ArrayList<ProcessInstanceRepresentation>();
  if (CollectionUtils.isNotEmpty(instances)) {

    for (HistoricProcessInstance processInstance : instances) {
      User userRep = null;
      if (processInstance.getStartUserId() != null) {
        CachedUser user = userCache.getUser(processInstance.getStartUserId());
        if (user != null && user.getUser() != null) {
          userRep = user.getUser();
        }
      }

      ProcessDefinitionEntity procDef = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId());
      ProcessInstanceRepresentation instanceRepresentation = new ProcessInstanceRepresentation(processInstance, procDef, procDef.isGraphicalNotationDefined(), userRep);
      result.add(instanceRepresentation);
    }

  }
  return result;
}
 
Example 3
protected void createTimerForDelayedExecution(CommandContext commandContext, List<ProcessDefinitionEntity> processDefinitions) {
    for (ProcessDefinitionEntity processDefinition : processDefinitions) {
        TimerJobEntity timer = new TimerJobEntity();
        timer.setJobType(Job.JOB_TYPE_TIMER);
        timer.setRevision(1);
        timer.setProcessDefinitionId(processDefinition.getId());

        // Inherit tenant identifier (if applicable)
        if (processDefinition.getTenantId() != null) {
            timer.setTenantId(processDefinition.getTenantId());
        }

        timer.setDuedate(executionDate);
        timer.setJobHandlerType(getDelayedExecutionJobHandlerType());
        timer.setJobHandlerConfiguration(TimerChangeProcessDefinitionSuspensionStateJobHandler.createJobHandlerConfiguration(includeProcessInstances));
        commandContext.getJobEntityManager().schedule(timer);
    }
}
 
Example 4
@Override
public ProcessDefinition getProcessDefinition(String definitionId)
{
    ProcessDefinitionQuery query = activitiProcessEngine
            .getRepositoryService()
            .createProcessDefinitionQuery()
            .processDefinitionId(definitionId);
    
    if (tenantService.isEnabled() && deployWorkflowsInTenant) 
    {
        query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "@%");
    }
    
    org.activiti.engine.repository.ProcessDefinition processDefinition = query.singleResult();
    
    if (processDefinition == null) 
    {
        throw new EntityNotFoundException(definitionId); 
    }

    ProcessDefinition deploymentRest = createProcessDefinitionRest((ProcessDefinitionEntity) processDefinition);
    return deploymentRest;
}
 
Example 5
Source Project: flowable-engine   Source File: BpmnDeployer.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected void addTimerDeclarations(ProcessDefinitionEntity processDefinition, List<TimerJobEntity> timers) {
    List<TimerDeclarationImpl> timerDeclarations = (List<TimerDeclarationImpl>) processDefinition.getProperty(BpmnParse.PROPERTYNAME_START_TIMER);
    if (timerDeclarations != null) {
        for (TimerDeclarationImpl timerDeclaration : timerDeclarations) {
            TimerJobEntity timer = timerDeclaration.prepareTimerEntity(null);
            if (timer != null) {
                timer.setProcessDefinitionId(processDefinition.getId());

                // Inherit timer (if applicable)
                if (processDefinition.getTenantId() != null) {
                    timer.setTenantId(processDefinition.getTenantId());
                }
                timers.add(timer);
            }
        }
    }
}
 
Example 6
Source Project: activiti6-boot2   Source File: ResourceNameUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Finds the name of a resource for the diagram for a process definition.  Assumes that the
 * process definition's key and (BPMN) resource name are already set.
 *
 * <p>It will first look for an image resource which matches the process specifically, before
 * resorting to an image resource which matches the BPMN 2.0 xml file resource.
 *
 * <p>Example: if the deployment contains a BPMN 2.0 xml resource called 'abc.bpmn20.xml'
 * containing only one process with key 'myProcess', then this method will look for an image resources
 * called'abc.myProcess.png' (or .jpg, or .gif, etc.) or 'abc.png' if the previous one wasn't
 * found.
 *
 * <p>Example 2: if the deployment contains a BPMN 2.0 xml resource called 'abc.bpmn20.xml'
 * containing three processes (with keys a, b and c), then this method will first look for an image resource
 * called 'abc.a.png' before looking for 'abc.png' (likewise for b and c). Note that if abc.a.png,
 * abc.b.png and abc.c.png don't exist, all processes will have the same image: abc.png.
 *
 * @return name of an existing resource, or null if no matching image resource is found in the resources.
 */
public static String getProcessDiagramResourceNameFromDeployment(
    ProcessDefinitionEntity processDefinition, Map<String, ResourceEntity> resources) {
  
  if (StringUtils.isEmpty(processDefinition.getResourceName())) {
    throw new IllegalStateException("Provided process definition must have its resource name set.");
  }
  
  String bpmnResourceBase = stripBpmnFileSuffix(processDefinition.getResourceName());
  String key = processDefinition.getKey();
  
  for (String diagramSuffix : DIAGRAM_SUFFIXES) {
    String possibleName = bpmnResourceBase + key + "." + diagramSuffix;
    if (resources.containsKey(possibleName)) {
      return possibleName;
    }
    
    possibleName = bpmnResourceBase + diagramSuffix;
    if (resources.containsKey(possibleName)) {
      return possibleName;
    }
  }
  
  return null;
}
 
Example 7
Source Project: flowable-engine   Source File: GetStartFormCmd.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public StartFormData execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) commandContext
            .getProcessEngineConfiguration()
            .getDeploymentManager()
            .findDeployedProcessDefinitionById(processDefinitionId);
    if (processDefinition == null) {
        throw new ActivitiObjectNotFoundException("No process definition found for id '" + processDefinitionId + "'", ProcessDefinition.class);
    }

    StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
    if (startFormHandler == null) {
        throw new ActivitiException("No startFormHandler defined in process '" + processDefinitionId + "'");
    }

    return startFormHandler.createStartFormData(processDefinition);
}
 
Example 8
/**
 * Get the taskDefinition key based on the Activiti task definition id,
 * @param taskDefinitionKey String
 * @param processDefinitionId String
 * @return WorkflowTaskDefinition
 */
public WorkflowTaskDefinition getTaskDefinition(String taskDefinitionKey, String processDefinitionId)
{
	 ProcessDefinitionEntity procDef = (ProcessDefinitionEntity) activitiUtil.getDeployedProcessDefinition(processDefinitionId);
	 Collection<PvmActivity> userTasks = findUserTasks(procDef.getInitial());
	 
	 TaskDefinition taskDefinition = null;
	 for(PvmActivity activity : userTasks)
	 {
		 taskDefinition = procDef.getTaskDefinitions().get(activity.getId());
		 if(taskDefinitionKey.equals(taskDefinition.getKey()))
		 {
			 String formKey = getFormKey(taskDefinition);
			 WorkflowNode node = convert(activity);
			 return factory.createTaskDefinition(formKey, node, formKey, false);
		 }
	 }
	 
	 return null;
}
 
Example 9
Source Project: flowable-engine   Source File: StartEventParseHandler.java    License: Apache License 2.0 6 votes vote down vote up
protected void selectInitial(BpmnParse bpmnParse, ActivityImpl startEventActivity, StartEvent startEvent, ProcessDefinitionEntity processDefinition) {
    if (processDefinition.getInitial() == null) {
        processDefinition.setInitial(startEventActivity);
    } else {
        // validate that there is a single none start event / timer start event:
        if (!startEventActivity.getProperty("type").equals("messageStartEvent")
                && !startEventActivity.getProperty("type").equals("signalStartEvent")
                && !startEventActivity.getProperty("type").equals("startTimerEvent")) {
            String currentInitialType = (String) processDefinition.getInitial().getProperty("type");
            if (currentInitialType.equals("messageStartEvent")) {
                processDefinition.setInitial(startEventActivity);
            } else {
                throw new ActivitiException("multiple none start events or timer start events not supported on process definition");
            }
        }
    }
}
 
Example 10
Source Project: lemon   Source File: RollbackTaskCmd.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查找回退的目的节点.
 */
public ActivityImpl findTargetActivity(CommandContext commandContext,
        TaskEntity taskEntity) {
    if (activityId == null) {
        String historyTaskId = this.findNearestUserTask(commandContext);
        HistoricTaskInstanceEntity historicTaskInstanceEntity = commandContext
                .getHistoricTaskInstanceEntityManager()
                .findHistoricTaskInstanceById(historyTaskId);
        this.activityId = historicTaskInstanceEntity.getTaskDefinitionKey();
    }

    String processDefinitionId = taskEntity.getProcessDefinitionId();
    ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd(
            processDefinitionId).execute(commandContext);

    return processDefinitionEntity.findActivity(activityId);
}
 
Example 11
/**
 * getHighLightedFlows
 *
 * @param processDefinition
 * @param processInstanceId
 * @return
 */
private List<String> getHighLightedFlows(ProcessDefinitionEntity processDefinition, String processInstanceId) {

    List<String> highLightedFlows = new ArrayList<String>();

    List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery()
            .processInstanceId(processInstanceId)
            //order by startime asc is not correct. use default order is correct.
            //.orderByHistoricActivityInstanceStartTime().asc()/*.orderByActivityId().asc()*/
            .list();

    LinkedList<HistoricActivityInstance> hisActInstList = new LinkedList<HistoricActivityInstance>();
    hisActInstList.addAll(historicActivityInstances);

    getHighlightedFlows(processDefinition.getActivities(), hisActInstList, highLightedFlows);

    return highLightedFlows;
}
 
Example 12
Source Project: activiti6-boot2   Source File: BpmnDeploymentHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets the most recent persisted process definition that matches this one for tenant and key.
 * If none is found, returns null.  This method assumes that the tenant and key are properly
 * set on the process definition entity.
 */
public ProcessDefinitionEntity getMostRecentVersionOfProcessDefinition(ProcessDefinitionEntity processDefinition) {
  String key = processDefinition.getKey();
  String tenantId = processDefinition.getTenantId();
  ProcessDefinitionEntityManager processDefinitionManager 
    = Context.getCommandContext().getProcessEngineConfiguration().getProcessDefinitionEntityManager();

  ProcessDefinitionEntity existingDefinition = null;

  if (tenantId != null && !tenantId.equals(ProcessEngineConfiguration.NO_TENANT_ID)) {
    existingDefinition = processDefinitionManager.findLatestProcessDefinitionByKeyAndTenantId(key, tenantId);
  } else {
    existingDefinition = processDefinitionManager.findLatestProcessDefinitionByKey(key);
  }

  return existingDefinition;
}
 
Example 13
Source Project: activiti6-boot2   Source File: BpmnDeploymentHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Updates all timers and events for the process definition.  This removes obsolete message and signal
 * subscriptions and timers, and adds new ones.
 */
public void updateTimersAndEvents(ProcessDefinitionEntity processDefinition, 
    ProcessDefinitionEntity previousProcessDefinition, ParsedDeployment parsedDeployment) {
  
  Process process = parsedDeployment.getProcessModelForProcessDefinition(processDefinition);
  BpmnModel bpmnModel = parsedDeployment.getBpmnModelForProcessDefinition(processDefinition);

  eventSubscriptionManager.removeObsoleteMessageEventSubscriptions(previousProcessDefinition);
  eventSubscriptionManager.addMessageEventSubscriptions(processDefinition, process, bpmnModel);

  eventSubscriptionManager.removeObsoleteSignalEventSubScription(previousProcessDefinition);
  eventSubscriptionManager.addSignalEventSubscriptions(Context.getCommandContext(), processDefinition, process, bpmnModel);

  timerManager.removeObsoleteTimers(processDefinition);
  timerManager.scheduleTimers(processDefinition, process);
}
 
Example 14
Source Project: activiti6-boot2   Source File: EventSubscriptionManager.java    License: Apache License 2.0 6 votes vote down vote up
protected void addMessageEventSubscriptions(ProcessDefinitionEntity processDefinition, Process process, BpmnModel bpmnModel) {
  if (CollectionUtil.isNotEmpty(process.getFlowElements())) {
    for (FlowElement element : process.getFlowElements()) {
      if (element instanceof StartEvent) {
        StartEvent startEvent = (StartEvent) element;
        if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions())) {
          EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0);
          if (eventDefinition instanceof MessageEventDefinition) {
            MessageEventDefinition messageEventDefinition = (MessageEventDefinition) eventDefinition;
            insertMessageEvent(messageEventDefinition, startEvent, processDefinition, bpmnModel);
          }
        }
      } 
    }
  }
}
 
Example 15
Source Project: lemon   Source File: AutoCompleteFirstTaskEventListener.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 获得第一个节点.
 */
public PvmActivity findFirstActivity(String processDefinitionId) {
    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration().getProcessDefinitionCache()
            .get(processDefinitionId);

    ActivityImpl startActivity = processDefinitionEntity.getInitial();

    if (startActivity.getOutgoingTransitions().size() != 1) {
        throw new IllegalStateException(
                "start activity outgoing transitions cannot more than 1, now is : "
                        + startActivity.getOutgoingTransitions().size());
    }

    PvmTransition pvmTransition = startActivity.getOutgoingTransitions()
            .get(0);
    PvmActivity targetActivity = pvmTransition.getDestination();

    if (!"userTask".equals(targetActivity.getProperty("type"))) {
        logger.debug("first activity is not userTask, just skip");

        return null;
    }

    return targetActivity;
}
 
Example 16
Source Project: activiti6-boot2   Source File: TimerManager.java    License: Apache License 2.0 6 votes vote down vote up
protected void removeObsoleteTimers(ProcessDefinitionEntity processDefinition) {
  List<TimerJobEntity> jobsToDelete = null;

  if (processDefinition.getTenantId() != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinition.getTenantId())) {
    jobsToDelete = Context.getCommandContext().getTimerJobEntityManager().findJobsByTypeAndProcessDefinitionKeyAndTenantId(
        TimerStartEventJobHandler.TYPE, processDefinition.getKey(), processDefinition.getTenantId());
  } else {
    jobsToDelete = Context.getCommandContext().getTimerJobEntityManager()
        .findJobsByTypeAndProcessDefinitionKeyNoTenantId(TimerStartEventJobHandler.TYPE, processDefinition.getKey());
  }

  if (jobsToDelete != null) {
    for (TimerJobEntity job :jobsToDelete) {
      new CancelJobsCmd(job.getId()).execute(Context.getCommandContext());
    }
  }
}
 
Example 17
/**
 * 读取流程资源
 */
@RequestMapping(value = "trace/data/auto/{executionId}")
public void readResource(@PathVariable("executionId") String executionId, HttpServletResponse response)
        throws Exception {
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(executionId).singleResult();
    BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);
    ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
    List<String> highLightedFlows = getHighLightedFlows(processDefinition, processInstance.getId());
    InputStream imageStream =diagramGenerator.generateDiagram(bpmnModel, "png", activeActivityIds, highLightedFlows);

    // 输出资源内容到相应对象
    byte[] b = new byte[1024];
    int len;
    while ((len = imageStream.read(b, 0, 1024)) != -1) {
        response.getOutputStream().write(b, 0, len);
    }
}
 
Example 18
/**
 * Ensures that the process definition is cached in the appropriate places, including the
 * deployment's collection of deployed artifacts and the deployment manager's cache, as well
 * as caching any ProcessDefinitionInfos.
 */
public void updateCachingAndArtifacts(ParsedDeployment parsedDeployment) {
  CommandContext commandContext = Context.getCommandContext();
  final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
  DeploymentCache<ProcessDefinitionCacheEntry> processDefinitionCache 
    = processEngineConfiguration.getDeploymentManager().getProcessDefinitionCache();
  DeploymentEntity deployment = parsedDeployment.getDeployment();

  for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) {
    BpmnModel bpmnModel = parsedDeployment.getBpmnModelForProcessDefinition(processDefinition);
    Process process = parsedDeployment.getProcessModelForProcessDefinition(processDefinition);
    ProcessDefinitionCacheEntry cacheEntry = new ProcessDefinitionCacheEntry(processDefinition, bpmnModel, process);
    processDefinitionCache.add(processDefinition.getId(), cacheEntry);
    addDefinitionInfoToCache(processDefinition, processEngineConfiguration, commandContext);
  
    // Add to deployment for further usage
    deployment.addDeployedArtifact(processDefinition);
  }
}
 
Example 19
Source Project: lemon   Source File: RollbackCmd.java    License: Apache License 2.0 6 votes vote down vote up
public void initSource() {
    // source task
    this.jumpInfo.setSourceTaskId(this.taskId);

    TaskEntity sourceTask = Context.getCommandContext()
            .getTaskEntityManager().findTaskById(this.taskId);
    this.jumpInfo.setSourceTask(sourceTask);

    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration()
            .getDeploymentManager()
            .findDeployedProcessDefinitionById(
                    sourceTask.getProcessDefinitionId());
    // source activity
    this.jumpInfo.setSourceActivityId(sourceTask.getTaskDefinitionKey());
    this.jumpInfo.setSourceActivity(processDefinitionEntity
            .findActivity(this.jumpInfo.getSourceActivityId()));

    HistoricTaskInstanceEntity sourceHistoryTask = Context
            .getCommandContext().getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstanceById(this.jumpInfo.getSourceTaskId());
}
 
Example 20
/**
 * 读取流程资源
 */
@RequestMapping(value = "trace/data/auto/{executionId}")
public void readResource(@PathVariable("executionId") String executionId, HttpServletResponse response)
        throws Exception {
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(executionId).singleResult();
    BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);
    ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
    List<String> highLightedFlows = getHighLightedFlows(processDefinition, processInstance.getId());
    InputStream imageStream =diagramGenerator.generateDiagram(bpmnModel, "png", activeActivityIds, highLightedFlows);

    // 输出资源内容到相应对象
    byte[] b = new byte[1024];
    int len;
    while ((len = imageStream.read(b, 0, 1024)) != -1) {
        response.getOutputStream().write(b, 0, len);
    }
}
 
Example 21
protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinitionEntity newProcessDefinition) {
    // check that the new process definition version contains the current activity
    if (execution.getActivity() != null && !newProcessDefinition.contains(execution.getActivity())) {
        throw new ActivitiException(
                "The new process definition " +
                        "(key = '" + newProcessDefinition.getKey() + "') " +
                        "does not contain the current activity " +
                        "(id = '" + execution.getActivity().getId() + "') " +
                        "of the process instance " +
                        "(id = '" + processInstanceId + "').");
    }

    // switch the process instance to the new process definition version
    execution.setProcessDefinition(newProcessDefinition);

    // and change possible existing tasks (as the process definition id is stored there too)
    List<TaskEntity> tasks = commandContext.getTaskEntityManager().findTasksByExecutionId(execution.getId());
    for (TaskEntity taskEntity : tasks) {
        taskEntity.setProcessDefinitionId(newProcessDefinition.getId());
        commandContext.getHistoryManager().recordTaskProcessDefinitionChange(taskEntity.getId(), newProcessDefinition.getId());
    }
}
 
Example 22
Source Project: lemon   Source File: ReOpenProcessCmd.java    License: Apache License 2.0 5 votes vote down vote up
public ExecutionEntity createProcessInstance(
        ProcessDefinitionEntity processDefinition, String id) {
    ActivityImpl initial = processDefinition.getInitial();

    if (initial == null) {
        throw new ActivitiException(
                "Cannot start process instance, initial activity where the process instance should start is null.");
    }

    ExecutionEntity processInstance = new ExecutionEntity(initial);
    processInstance.setId(id);
    processInstance.insert();
    processInstance.setProcessDefinition(processDefinition);
    processInstance.setTenantId(processDefinition.getTenantId());
    processInstance.setProcessInstance(processInstance);
    processInstance.initialize();

    InterpretableExecution scopeInstance = processInstance;

    List<ActivityImpl> initialActivityStack = processDefinition
            .getInitialActivityStack(initial);

    for (ActivityImpl initialActivity : initialActivityStack) {
        if (initialActivity.isScope()) {
            scopeInstance = (InterpretableExecution) scopeInstance
                    .createExecution();
            scopeInstance.setActivity(initialActivity);

            if (initialActivity.isScope()) {
                scopeInstance.initialize();
            }
        }
    }

    scopeInstance.setActivity(initial);

    return processInstance;
}
 
Example 23
public ProcessDefinitionEntity findProcessDefinitionEntityByTaskId(  
        String taskId) throws Exception {  
    // 取得流程定义  
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)  
            .getDeployedProcessDefinition(findTaskById(taskId)  
                    .getProcessDefinitionId());  
  
    if (processDefinition == null) {  
        throw new Exception("流程定义未找到!");  
    }  
  
    return processDefinition;  
}
 
Example 24
Source Project: lemon   Source File: ActivitiInternalProcessConnector.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获得开始事件id.
 */
public String findInitialActivityId(String processDefinitionId) {
    GetDeploymentProcessDefinitionCmd getDeploymentProcessDefinitionCmd = new GetDeploymentProcessDefinitionCmd(
            processDefinitionId);
    ProcessDefinitionEntity processDefinition = processEngine
            .getManagementService().executeCommand(
                    getDeploymentProcessDefinitionCmd);

    return processDefinition.getInitial().getId();
}
 
Example 25
Source Project: activiti6-boot2   Source File: DefaultStartFormHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void parseConfiguration(List<FormProperty> formProperties, String formKey, DeploymentEntity deployment, ProcessDefinition processDefinition) {
  super.parseConfiguration(formProperties, formKey, deployment, processDefinition);
  if (StringUtils.isNotEmpty(formKey)) {
    ((ProcessDefinitionEntity) processDefinition).setStartFormKey(true);
  }
}
 
Example 26
@Override
public Void execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = commandContext
            .getProcessDefinitionEntityManager()
            .findProcessDefinitionById(processDefinitionId);

    if (processDefinition == null) {
        throw new ActivitiObjectNotFoundException("Cannot find process definition with id " + processDefinitionId, ProcessDefinition.class);
    }

    processDefinition.addIdentityLink(userId, groupId);

    return null;
}
 
Example 27
Source Project: my_curd   Source File: ActivitiKit.java    License: Apache License 2.0 5 votes vote down vote up
private static List<String> getHighLightedFlows(ProcessDefinitionEntity processDefinitionEntity, List<HistoricActivityInstance> historicActivityInstances) {
    List<String> highFlows = new ArrayList<String>();
    for (int i = 0; i < historicActivityInstances.size() - 1; i++) {
        ActivityImpl activityImpl = processDefinitionEntity.findActivity(historicActivityInstances.get(i).getActivityId());
        List<ActivityImpl> sameStartTimeNodes = new ArrayList<>();
        ActivityImpl sameActivityImpl1 = processDefinitionEntity.findActivity(historicActivityInstances.get(i + 1).getActivityId());
        sameStartTimeNodes.add(sameActivityImpl1);
        for (int j = i + 1; j < historicActivityInstances.size() - 1; j++) {
            HistoricActivityInstance activityImpl1 = historicActivityInstances.get(j);
            HistoricActivityInstance activityImpl2 = historicActivityInstances.get(j + 1);
            if (activityImpl1.getStartTime().equals(activityImpl2.getStartTime())) {
                ActivityImpl sameActivityImpl2 = processDefinitionEntity.findActivity(activityImpl2.getActivityId());
                sameStartTimeNodes.add(sameActivityImpl2);
            } else {
                break;
            }
        }
        List<PvmTransition> pvmTransitions = activityImpl.getOutgoingTransitions();// 取出节点的所有出去的线
        for (PvmTransition pvmTransition : pvmTransitions) {
            ActivityImpl pvmActivityImpl = (ActivityImpl) pvmTransition.getDestination();
            if (sameStartTimeNodes.contains(pvmActivityImpl)) {
                highFlows.add(pvmTransition.getId());
            }
        }
    }
    return highFlows;
}
 
Example 28
private List<String> getHighLightedFlows(String processInstanceId, ProcessDefinitionEntity processDefinition) {

        List<String> highLightedFlows = new ArrayList<String>();
        List<HistoricActivityInstance> historicActivityInstances = historyService
                .createHistoricActivityInstanceQuery()
                .processInstanceId(processInstanceId)
                .orderByHistoricActivityInstanceStartTime().asc().list();

        List<String> historicActivityInstanceList = new ArrayList<String>();
        for (HistoricActivityInstance hai : historicActivityInstances) {
            historicActivityInstanceList.add(hai.getActivityId());
        }

        // add current activities to list
        List<String> highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId);
        historicActivityInstanceList.addAll(highLightedActivities);

        // activities and their sequence-flows
        for (ActivityImpl activity : processDefinition.getActivities()) {
            int index = historicActivityInstanceList.indexOf(activity.getId());

            if (index >= 0 && index + 1 < historicActivityInstanceList.size()) {
                List<PvmTransition> pvmTransitionList = activity
                        .getOutgoingTransitions();
                for (PvmTransition pvmTransition : pvmTransitionList) {
                    String destinationFlowId = pvmTransition.getDestination().getId();
                    if (destinationFlowId.equals(historicActivityInstanceList.get(index + 1))) {
                        highLightedFlows.add(pvmTransition.getId());
                    }
                }
            }
        }
        return highLightedFlows;
    }
 
Example 29
@Override
public ProcessDefinitionEntity findProcessDefinitionByDeploymentAndKeyAndTenantId(String deploymentId, String processDefinitionKey, String tenantId) {
  Map<String, Object> parameters = new HashMap<String, Object>();
  parameters.put("deploymentId", deploymentId);
  parameters.put("processDefinitionKey", processDefinitionKey);
  parameters.put("tenantId", tenantId);
  return (ProcessDefinitionEntity) getDbSqlSession().selectOne("selectProcessDefinitionByDeploymentAndKeyAndTenantId", parameters);
}
 
Example 30
Source Project: activiti6-boot2   Source File: Activiti6Test.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Simple test that checks if all databases have correcly added the process definition tag.
 */
@Test
@org.activiti.engine.test.Deployment(resources = "org/activiti/engine/test/api/v6/Activiti6Test.testOneTaskProcess.bpmn20.xml")
public void testProcessDefinitionTagCreated() {
  ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
  assertNull(((ProcessDefinitionEntity) processDefinition).getEngineVersion());
}