Java Code Examples for org.camunda.bpm.engine.repository.ProcessDefinition#getKey()

The following examples show how to use org.camunda.bpm.engine.repository.ProcessDefinition#getKey() . 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: PathCoverageExecutionListener.java    From camunda-bpm-process-test-coverage with Apache License 2.0 6 votes vote down vote up
@Override
public void notify(DelegateExecution execution) throws Exception {

    if (coverageTestRunState == null) {
        logger.warning("Coverage execution listener in use but no coverage run state assigned!");
        return;
    }

    final RepositoryService repositoryService = execution.getProcessEngineServices().getRepositoryService();

    // Get the process definition in order to obtain the key
    final ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(
            execution.getProcessDefinitionId()).singleResult();

    final String transitionId = execution.getCurrentTransitionId();

    // Record sequence flow coverage
    final CoveredSequenceFlow coveredSequenceFlow = new CoveredSequenceFlow(processDefinition.getKey(),
            transitionId);
    coverageTestRunState.addCoveredElement(coveredSequenceFlow);

    // Record possible event coverage
    handleEvent(transitionId, processDefinition, repositoryService);

}
 
Example 2
Source File: ProcessList.java    From camunda-bpm-platform-osgi with Apache License 2.0 6 votes vote down vote up
public void printProcessDefinition(String deploymentId) {
  String[] header = new String[]{"ID", "KEY", "NAME", "DEPLOYMENT", "CATEGORY"};

  List<ProcessDefinition> processes = engine.getRepositoryService().createProcessDefinitionQuery().deploymentId(deploymentId).list();
  String[][] data = new String[processes.size()][header.length];
  int i = 0;
  for (ProcessDefinition process : processes) {
    data[i++] = new String[]{
        process.getId(),
        process.getKey(),
        process.getName(),
        process.getDeploymentId(),
        process.getCategory()
    };
  }
  ASCIITable.getInstance().printTable(header, data);


}
 
Example 3
Source File: ProcessDefinitionDto.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static ProcessDefinitionDto fromProcessDefinition(ProcessDefinition definition) {
  ProcessDefinitionDto dto = new ProcessDefinitionDto();
  dto.id = definition.getId();
  dto.key = definition.getKey();
  dto.category = definition.getCategory();
  dto.description = definition.getDescription();
  dto.name = definition.getName();
  dto.version = definition.getVersion();
  dto.resource = definition.getResourceName();
  dto.deploymentId = definition.getDeploymentId();
  dto.diagram = definition.getDiagramResourceName();
  dto.suspended = definition.isSuspended();
  dto.tenantId = definition.getTenantId();
  dto.versionTag = definition.getVersionTag();
  dto.historyTimeToLive = definition.getHistoryTimeToLive();
  dto.isStartableInTasklist = definition.isStartableInTasklist();
  return dto;
}
 
Example 4
Source File: HalProcessDefinition.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static HalProcessDefinition fromProcessDefinition(ProcessDefinition processDefinition, ProcessEngine processEngine) {
  HalProcessDefinition halProcDef = new HalProcessDefinition();

  halProcDef.id = processDefinition.getId();
  halProcDef.key = processDefinition.getKey();
  halProcDef.category = processDefinition.getCategory();
  halProcDef.description = processDefinition.getDescription();
  halProcDef.name = processDefinition.getName();
  halProcDef.version = processDefinition.getVersion();
  halProcDef.versionTag = processDefinition.getVersionTag();
  halProcDef.resource = processDefinition.getResourceName();
  halProcDef.deploymentId = processDefinition.getDeploymentId();
  halProcDef.diagram = processDefinition.getDiagramResourceName();
  halProcDef.suspended = processDefinition.isSuspended();
  halProcDef.contextPath = ApplicationContextPathUtil.getApplicationPathForDeployment(processEngine, processDefinition.getDeploymentId());

  halProcDef.linker.createLink(REL_SELF, processDefinition.getId());
  halProcDef.linker.createLink(REL_DEPLOYMENT, processDefinition.getDeploymentId());
  halProcDef.linker.createLink(REL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getResourceName());

  return halProcDef;
}
 
Example 5
Source File: PathCoverageExecutionListener.java    From camunda-bpm-process-test-coverage with Apache License 2.0 5 votes vote down vote up
private void addEventToCoverage(ProcessDefinition processDefinition, FlowNode node) {

        if (node instanceof IntermediateThrowEvent) {

            final CoveredFlowNode coveredElement = new CoveredFlowNode(processDefinition.getKey(), node.getId());
            // We consider entered throw elements as also ended
            coveredElement.setEnded(true);

            coverageTestRunState.addCoveredElement(coveredElement);
        }
    }
 
Example 6
Source File: HistoricProcessInstanceReportImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void doAuthCheck(CommandContext commandContext) {
  // since a report does only make sense in context of historic
  // data, the authorization check will be performed here
  for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    if (processDefinitionIdIn == null && processDefinitionKeyIn == null) {
      checker.checkReadHistoryAnyProcessDefinition();
    } else {
      List<String> processDefinitionKeys = new ArrayList<String>();
      if (processDefinitionKeyIn != null) {
        processDefinitionKeys.addAll(Arrays.asList(processDefinitionKeyIn));
      }

      if (processDefinitionIdIn != null) {
        for (String processDefinitionId : processDefinitionIdIn) {
          ProcessDefinition processDefinition = commandContext.getProcessDefinitionManager()
            .findLatestProcessDefinitionById(processDefinitionId);

          if (processDefinition != null && processDefinition.getKey() != null) {
            processDefinitionKeys.add(processDefinition.getKey());
          }
        }
      }

      if (!processDefinitionKeys.isEmpty()) {
        for (String processDefinitionKey : processDefinitionKeys) {
          checker.checkReadHistoryProcessDefinition(processDefinitionKey);
        }
      }
    }
  }
}
 
Example 7
Source File: IntermediateEventExecutionListener.java    From camunda-bpm-process-test-coverage with Apache License 2.0 3 votes vote down vote up
private CoveredFlowNode createCoveredFlowNode(DelegateExecution execution) {

        // Get the process definition in order to obtain the key
        final RepositoryService repositoryService = execution.getProcessEngineServices().getRepositoryService();
        final ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(
                execution.getProcessDefinitionId()).singleResult();

        final String currentActivityId = execution.getCurrentActivityId();

        final CoveredFlowNode coveredFlowNode = new CoveredFlowNode(processDefinition.getKey(), currentActivityId);

        return coveredFlowNode;
    }