当前位置: 首页>>代码示例>>Java>>正文


Java ProcessDefinition类代码示例

本文整理汇总了Java中org.camunda.bpm.engine.repository.ProcessDefinition的典型用法代码示例。如果您正苦于以下问题:Java ProcessDefinition类的具体用法?Java ProcessDefinition怎么用?Java ProcessDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProcessDefinition类属于org.camunda.bpm.engine.repository包,在下文中一共展示了ProcessDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: list

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
 * Gets currently active process definitions
 *
 * @return {@link} of process definitions
 */
public Result<WorkflowDto> list() {
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery()
            .active()
            .orderByProcessDefinitionName()
            .asc()
            .latestVersion();

    List<ProcessDefinition> workflows = query.list();

    List<WorkflowDto> dtos = workflows.stream()
            .map(workflow -> new WorkflowDto(
                    workflow.getId(),
                    workflow.getKey(),
                    workflow.getName(),
                    workflow.getDescription()
            ))
            .collect(Collectors.toList());


    Result<WorkflowDto> result = new Result<>();
    result.setCount(query.count());
    result.setItems(dtos);

    return result;
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:31,代码来源:WorkflowList.java

示例2: create

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
 * Creates process instance from process definition.
 *
 * <p>
 *     Only parameters corresponding to form attributes defined on Start task will be stored.
 *     Others will be silently ignored.
 * </p>
 *
 * @param key Specified key of {@link WorkflowDto}
 * @param businessKey Specified business key (reference to external resource)
 * @param params Initial process variables
 * @return New process instance ID
 */
public String create(String key, String businessKey, Map<String, Object> params) {
    ProcessDefinition definition = repositoryService.createProcessDefinitionQuery()
            .processDefinitionKey(key)
            .latestVersion()
            .singleResult();

    notNull(definition, () -> new MissingObject(ProcessDefinition.class, key));

    BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(definition.getId());
    if(!canStart(modelInstance, unwrap(user))) {
        throw new ForbiddenOperation(null);
    }

    StartFormData formData = formService.getStartFormData(definition.getId());
    Map<String, Object> filteredParams = filterDefinedFields(formData, params);


    ProcessInstance instance = formService.submitStartForm(
            definition.getId(), businessKey, filteredParams
    );

    return instance.getId();
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:37,代码来源:ProcessList.java

示例3: createMigrationPlan

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
 * Creates an engine specific migration plan.
 *
 * @param sourceProcessDefinition source process definition
 * @param targetProcessDefinition target process definition
 * @param migrationPlan {@link MigrationPlan}
 * @return a {@link org.camunda.bpm.engine.migration.MigrationPlan}
 */
protected org.camunda.bpm.engine.migration.MigrationPlan createMigrationPlan(ProcessDefinition sourceProcessDefinition, ProcessDefinition targetProcessDefinition, MigrationPlan migrationPlan) {
  MigrationPlanBuilder migrationPlanBuilder = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId());
  migrationPlanBuilder.mapEqualActivities();

  for (MigrationInstruction migrationInstruction : migrationPlan.getInstructions()) {
    List<String> sourceActivityIds = migrationInstruction.getSourceActivityIds();
    List<String> targetActivityIds = migrationInstruction.getTargetActivityIds();
    for (int idx = 0; idx < sourceActivityIds.size(); idx++) {
      MigrationInstructionBuilder migrationInstructionBuilder = migrationPlanBuilder.mapActivities(sourceActivityIds.get(idx), targetActivityIds.get(idx));
      if (migrationInstruction.isUpdateEventTrigger()) {
        migrationInstructionBuilder.updateEventTrigger();
      }
    }
  }
  return migrationPlanBuilder.build();
}
 
开发者ID:satspeedy,项目名称:camunda-migrator,代码行数:25,代码来源:MigrationPlanService.java

示例4: validate

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
private boolean validate(Migration migration, ProcessDefinition sourceDefinition, ProcessDefinition targetDefinition) {
  MigrationPlan migrationPlan = migration.getMigrationPlan();

  validateProcessDefinitions(migrationPlan, sourceDefinition, targetDefinition);
  validateMigration(migration);
  validateMigrationActivities(migration.getProcessInstanceQuery());

  org.camunda.bpm.engine.runtime.ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceDefinition.getId());
  if (!migration.getProcessInstanceQuery().getProcessActivityIds().isEmpty()) {
    processInstanceQuery.activityIdIn(migration.getProcessInstanceQuery().getProcessActivityIds().toArray(new String[0]));
  }
  if (processInstanceQuery.count() == 0) {
    LOG.info("\tNo process instance exists for SOURCE process definition key {} and version tag {} and version {}. Migration skipped!", migrationPlan.getSourceProcessDefinitionKey(), migrationPlan.getSourceProcessVersionTag(), sourceDefinition.getVersion());
    return false;
  }
  return true;
}
 
开发者ID:satspeedy,项目名称:camunda-migrator,代码行数:18,代码来源:MigrationService.java

示例5: execute

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
private void execute(MigrationPlanContainer migrationPlanContainer) {
  ProcessDefinition sourceDefinition = migrationPlanContainer.getSourceDefinition();
  ProcessDefinition targetDefinition = migrationPlanContainer.getTargetDefinition();
  MigrationPlanExecutionBuilder migrationPlanExecutionBuilder = migrationPlanContainer.getMigrationPlanExecutionBuilder();

  LOG.info("\tMigrating all process instances from SOURCE process definition " + sourceDefinition.getId() + " to TARGET process definition " + targetDefinition.getId());
  for (ProcessInstance processInstance : runtimeService.createProcessInstanceQuery().processDefinitionId(sourceDefinition.getId()).list()) {
    LOG.info("\tMigrating process instance with id " + processInstance.getId());
  }

  try {
    migrationPlanExecutionBuilder.execute();
    // .executeAsync() for asynchronous execution in a batch (useful for large numbers of instances)
  } catch (MigratingProcessInstanceValidationException e) {
    throw new IllegalMigrationStateException("Validation error occurred during executing the migration from SOURCE process definition " + sourceDefinition.getId() + " to TARGET process definition " + targetDefinition.getId() + ": " + e.getValidationReport().toString(), e);
  }

  LOG.info("\tSuccessfully migrated all process instances from SOURCE process definition " + sourceDefinition.getId() + " to TARGET process definition " + targetDefinition.getId());
}
 
开发者ID:satspeedy,项目名称:camunda-migrator,代码行数:20,代码来源:MigrationService.java

示例6: shouldThrowExceptionOnFindProcessInstancesToModifyIfNoCancelDefined

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
@Test(expected = IllegalMigrationStateException.class)
public void shouldThrowExceptionOnFindProcessInstancesToModifyIfNoCancelDefined() {
  //given
  String activityId = "activityId";
  Modification modification = new Modification();
  modification.setSourceProcessDefinitionKey("processDefinitionKey");
  modification.setSourceProcessVersionTag("versionTag");
  ModificationInstruction modificationInstruction = new ModificationInstruction();
  modificationInstruction.setType(ModificationInstructionType.START_AFTER_ACTIVITY);
  modificationInstruction.setActivityId(activityId);
  List<ModificationInstruction> instructions = Collections.singletonList(modificationInstruction);
  modification.setInstructions(instructions);

  String processDefinitionId = "processDefinitionId";
  ProcessDefinition processDefinitionMock = mock(ProcessDefinition.class);
  when(processDefinitionMock.getId()).thenReturn(processDefinitionId);
  when(processDefinitionServiceMock.fetchLatestProcessDefinitionByKeyAndVersionTag(modification.getSourceProcessDefinitionKey(), modification.getSourceProcessVersionTag())).thenReturn(processDefinitionMock);

  //when
  modificationService.findProcessInstancesToModify(modification);

  //then
  //exception expected
}
 
开发者ID:satspeedy,项目名称:camunda-migrator,代码行数:25,代码来源:ModificationServiceTest.java

示例7: shouldAssertVersionIsAlreadyDeployedAndZipFileHasNoChanges

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
@Test
public void shouldAssertVersionIsAlreadyDeployedAndZipFileHasNoChanges() {
  //given
  final ChangelogVersion changelogVersion = new ChangelogVersion();
  final Resource zipResource = mock(Resource.class);
  changelogVersion.setVersionTag("V1");
  when(repositoryServiceMock.createProcessDefinitionQuery().versionTag("V1").list()).thenReturn(Collections.singletonList(mock(ProcessDefinition.class)));
  final String bpmnHash = "111";
  when(processDefinitionServiceMock.extractBPMNHashValuesFromEngine()).thenReturn(Collections.singletonList(bpmnHash));
  when(zipResourceServiceMock.extractHashValuesFromZipEntries(changelogVersion, zipResource)).thenReturn(Collections.singletonList(bpmnHash));

  //when
  final boolean result = deploymentService.isVersionAlreadyDeployed(changelogVersion, zipResource);

  //then
  assertThat(result, is(true));
}
 
开发者ID:satspeedy,项目名称:camunda-migrator,代码行数:18,代码来源:DeploymentServiceTest.java

示例8: shouldAssertVersionIsNotAlreadyDeployedWhenZipFileHasChanges

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
@Test
public void shouldAssertVersionIsNotAlreadyDeployedWhenZipFileHasChanges() {
  //given
  final ChangelogVersion changelogVersion = new ChangelogVersion();
  final Resource zipResource = mock(Resource.class);
  changelogVersion.setVersionTag("V1");
  when(repositoryServiceMock.createProcessDefinitionQuery().versionTag("V1").list()).thenReturn(Collections.singletonList(mock(ProcessDefinition.class)));
  final String bpmnHash = "111";
  final String newBpmnHash = "222";
  when(processDefinitionServiceMock.extractBPMNHashValuesFromEngine()).thenReturn(Collections.singletonList(bpmnHash));
  when(zipResourceServiceMock.extractHashValuesFromZipEntries(changelogVersion, zipResource)).thenReturn(Collections.singletonList(newBpmnHash));

  //when
  final boolean result = deploymentService.isVersionAlreadyDeployed(changelogVersion, zipResource);

  //then
  assertThat(result, is(false));
}
 
开发者ID:satspeedy,项目名称:camunda-migrator,代码行数:19,代码来源:DeploymentServiceTest.java

示例9: shouldReturnLatestProcessDefinition

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
@Ignore
  @Test
  public void shouldReturnLatestProcessDefinition() {
    // given
    String processDefinitionKey = "processDefinitionKey";
    String processVersionTag = "processVersionTag";

    ProcessDefinition processDefinitionMock = mock(ProcessDefinition.class);

    ProcessDefinitionQuery processDefinitionQueryMock = mock(ProcessDefinitionQuery.class);
//    Query<ProcessDefinitionQuery, ProcessDefinition> processDefinitionQueryMock = (Query<ProcessDefinitionQuery, ProcessDefinition>) mock(Query.class);

    when(repositoryServiceMock.createProcessDefinitionQuery()
      .processDefinitionKey(processDefinitionKey)
      .versionTag(processVersionTag)
      .orderByProcessDefinitionId()
      .desc()).thenReturn(processDefinitionQueryMock);
    when(processDefinitionQueryMock.list()).thenReturn(Collections.singletonList(processDefinitionMock));

    // when
    ProcessDefinition processDefinition = processDefinitionService.fetchLatestProcessDefinitionByKeyAndVersionTag(processDefinitionKey, processVersionTag);

    // then
    assertThat(processDefinition, equalTo(processDefinitionMock));
  }
 
开发者ID:satspeedy,项目名称:camunda-migrator,代码行数:26,代码来源:ProcessDefinitionServiceTest.java

示例10: shouldReturnProcessDefinitions

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
@Ignore
@Test
public void shouldReturnProcessDefinitions() {
  // given
  String processDefinitionKey = "processDefinitionKey";
  String processVersionTag = "processVersionTag";

  ProcessDefinition processDefinitionMock = mock(ProcessDefinition.class);
  ProcessDefinition processDefinition2Mock = mock(ProcessDefinition.class);

  ProcessDefinitionQuery processDefinitionQueryMock = mock(ProcessDefinitionQuery.class);
  when(repositoryServiceMock.createProcessDefinitionQuery()
    .processDefinitionKey(processDefinitionKey)
    .versionTag(processVersionTag)
    .orderByProcessDefinitionId()
    .desc()).thenReturn(processDefinitionQueryMock);
  when(processDefinitionQueryMock.list()).thenReturn(Arrays.asList(processDefinitionMock, processDefinition2Mock));

  // when
  final List<ProcessDefinition> processDefinitions = processDefinitionService.fetchProcessDefinitionsByKeyAndVersionTag(processDefinitionKey, processVersionTag);

  // then
  assertThat(processDefinitions, hasSize(2));
  assertThat(processDefinitions, hasItems(processDefinitionMock, processDefinition2Mock));
}
 
开发者ID:satspeedy,项目名称:camunda-migrator,代码行数:26,代码来源:ProcessDefinitionServiceTest.java

示例11: migrate

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
public void migrate(MigrationPlan plan) {
  ProcessDefinitionFinder processDefinitionFinder = new ProcessDefinitionFinder(processEngine.getRepositoryService());
  ProcessDefinition sourceProcessDefinition = processDefinitionFinder
    .find(plan.getFrom())
    .orElseThrow(() -> new RuntimeException("Source process definition not found!"));
  ProcessDefinition targetProcessDefinition = processDefinitionFinder
    .find(plan.getTo())
    .orElseThrow(() -> new RuntimeException("Destination process definition not found!"));

  List<ProcessInstance> processInstances = processEngine.getRuntimeService().createProcessInstanceQuery()
    .processDefinitionId(sourceProcessDefinition.getId()).active().list();
  log.info("migrating {} process instance(s)", processInstances.size());
  processInstances
    .stream()
    .map(ProcessInstance::getId)
    .peek(processInstanceId -> log.info("migrating process instance ID {}", processInstanceId))
    .map(processInstanceId -> StepExecutionContext.builder().processEngine(processEngine)
      .sourceProcessDefinitionId(sourceProcessDefinition.getId())
      .targetProcessDefinitionId(targetProcessDefinition.getId())
      .processInstanceId(processInstanceId)
      .build())
    .forEach(stepExecutionContext -> {
      plan.getSteps().forEach(step -> step.prepare(stepExecutionContext));
      plan.getSteps().forEach(step -> step.perform(stepExecutionContext));
    });
}
 
开发者ID:camunda,项目名称:camunda-bpm-migration,代码行数:27,代码来源:Migrator.java

示例12: find

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
public Optional<ProcessDefinition> find(ProcessDefinitionSpec spec) {
  ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();

  add(processDefinitionQuery, ProcessDefinitionQuery::processDefinitionKey, spec.getProcessDefinitionKey());
  add(processDefinitionQuery, ProcessDefinitionQuery::versionTag, spec.getVersionTag());
  add(processDefinitionQuery, ProcessDefinitionQuery::processDefinitionVersion, spec.getProcessDefinitionVersion());

  if (spec.getDeploymentSpec() != null) {
    Optional<Deployment> deployment = findDeployment(spec.getDeploymentSpec());
    if (!deployment.isPresent()) {
      return Optional.empty();
    } else {
      add(processDefinitionQuery, ProcessDefinitionQuery::deploymentId, deployment.get(), Deployment::getId);
    }
  }

  return Optional.ofNullable(processDefinitionQuery.singleResult());
}
 
开发者ID:camunda,项目名称:camunda-bpm-migration,代码行数:19,代码来源:ProcessDefinitionFinder.java

示例13: creates_key_for_task

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
@Test
public void creates_key_for_task() {
  ProcessDefinition processDefinition = CamundaReactorTestHelper.processDefinition();
  final DelegateTask task = mock(DelegateTask.class, RETURNS_DEEP_STUBS);

  RepositoryService repositoryService = mock(RepositoryService.class);
  when(repositoryService.getProcessDefinition(processDefinition.getId())).thenReturn(processDefinition);
  when(task.getProcessEngineServices().getRepositoryService()).thenReturn(repositoryService);

  when(task.getBpmnModelElementInstance().getElementType().getTypeName()).thenReturn("userTask");
  when(task.getProcessDefinitionId()).thenReturn("process:1:1");

  when(task.getEventName()).thenReturn("create");
  when(task.getTaskDefinitionKey()).thenReturn("task1");

  assertThat(SelectorBuilder.selector(task).key()).isEqualTo("/camunda/task/{type}/process/task1/create");
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:18,代码来源:SelectorBuilderTest.java

示例14: initializeTestMethodCoverage

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
 * Adds a test method to the class coverage.
 * 
 * @param processEngine
 * @param deploymentId
 *            The deployment ID of the test method run. (Hint: Every test
 *            method run has its own deployment.)
 * @param processDefinitions
 *            The process definitions of the test method deployment.
 * @param testName
 *            The name of the test method.
 */
public void initializeTestMethodCoverage(ProcessEngine processEngine, String deploymentId,
        List<ProcessDefinition> processDefinitions, String testName) {

    final MethodCoverage testCoverage = new MethodCoverage(deploymentId);
    for (ProcessDefinition processDefinition : processDefinitions) {

        // Construct the pristine coverage object

        // TODO decide on the builders fate
        final ProcessCoverage processCoverage = new ProcessCoverage(processEngine, processDefinition);

        testCoverage.addProcessCoverage(processCoverage);
    }

    classCoverage.addTestMethodCoverage(testName, testCoverage);
}
 
开发者ID:camunda,项目名称:camunda-bpm-process-test-coverage,代码行数:29,代码来源:CoverageTestRunState.java

示例15: initializeMethodCoverage

import org.camunda.bpm.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
 * Initialize the current test method coverage.
 * 
 * @param description
 */
private void initializeMethodCoverage(Description description) {

    // Not a @ClassRule run and deployments present
    if (deploymentId != null) {

        final List<ProcessDefinition> deployedProcessDefinitions = processEngine.getRepositoryService().createProcessDefinitionQuery().deploymentId(
            deploymentId).list();

        final List<ProcessDefinition> relevantProcessDefinitions = new ArrayList<ProcessDefinition>();
        for (ProcessDefinition definition: deployedProcessDefinitions) {
            if (!isExcluded(definition)) {
                relevantProcessDefinitions.add(definition);
            }
        }

        coverageTestRunState.initializeTestMethodCoverage(processEngine,
                deploymentId,
                relevantProcessDefinitions,
                description.getMethodName());

    }
}
 
开发者ID:camunda,项目名称:camunda-bpm-process-test-coverage,代码行数:28,代码来源:TestCoverageProcessEngineRule.java


注:本文中的org.camunda.bpm.engine.repository.ProcessDefinition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。