org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity Java Examples

The following examples show how to use org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity. 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: GetDeploymentProcessModelCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public InputStream execute(final CommandContext commandContext) {
  ProcessDefinitionEntity processDefinition = Context
          .getProcessEngineConfiguration()
          .getDeploymentCache()
          .findDeployedProcessDefinitionById(processDefinitionId);

  for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    checker.checkReadProcessDefinition(processDefinition);
  }

  final String deploymentId = processDefinition.getDeploymentId();
  final String resourceName = processDefinition.getResourceName();

  InputStream processModelStream = commandContext.runWithoutAuthorization(new Callable<InputStream>() {
    public InputStream call() throws Exception {
      return new GetDeploymentResourceCmd(deploymentId, resourceName).execute(commandContext);
    }
  });

  return processModelStream;
}
 
Example #2
Source File: UserOperationLogContextEntryBuilder.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public UserOperationLogContextEntryBuilder inContextOf(ExecutionEntity processInstance, List<PropertyChange> propertyChanges) {

    if (propertyChanges == null || propertyChanges.isEmpty()) {
      if (OPERATION_TYPE_CREATE.equals(entry.getOperationType())) {
        propertyChanges = Arrays.asList(PropertyChange.EMPTY_CHANGE);
      }
    }
    entry.setPropertyChanges(propertyChanges);
    entry.setRootProcessInstanceId(processInstance.getRootProcessInstanceId());
    entry.setProcessInstanceId(processInstance.getProcessInstanceId());
    entry.setProcessDefinitionId(processInstance.getProcessDefinitionId());
    entry.setExecutionId(processInstance.getId());
    entry.setCaseInstanceId(processInstance.getCaseInstanceId());

    ProcessDefinitionEntity definition = processInstance.getProcessDefinition();
    if (definition != null) {
      entry.setProcessDefinitionKey(definition.getKey());
      entry.setDeploymentId(definition.getDeploymentId());
    }

    return this;
  }
 
Example #3
Source File: BpmnDeployer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
protected List<ProcessDefinitionEntity> transformDefinitions(DeploymentEntity deployment, ResourceEntity resource, Properties properties) {
  byte[] bytes = resource.getBytes();
  ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);

  BpmnParse bpmnParse = bpmnParser
      .createParse()
      .sourceInputStream(inputStream)
      .deployment(deployment)
      .name(resource.getName());

  if (!deployment.isValidatingSchema()) {
    bpmnParse.setSchemaResource(null);
  }

  bpmnParse.execute();

  if (!properties.contains(JOB_DECLARATIONS_PROPERTY)) {
    properties.set(JOB_DECLARATIONS_PROPERTY, new HashMap<String, List<JobDeclaration<?, ?>>>());
  }
  properties.get(JOB_DECLARATIONS_PROPERTY).putAll(bpmnParse.getJobDeclarations());

  return bpmnParse.getProcessDefinitions();
}
 
Example #4
Source File: AbstractPaLocalScriptEngineTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected ProcessApplicationInterface getProcessApplication() {
  ProcessApplicationReference reference = processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<ProcessApplicationReference>() {
    public ProcessApplicationReference execute(CommandContext commandContext) {
      ProcessDefinitionEntity definition = commandContext
          .getProcessDefinitionManager()
          .findLatestProcessDefinitionByKey(PROCESS_ID);
      String deploymentId = definition.getDeploymentId();
      ProcessApplicationManager processApplicationManager = processEngineConfiguration.getProcessApplicationManager();
      return processApplicationManager.getProcessApplicationForDeployment(deploymentId);
    }
  });

  assertNotNull(reference);

  ProcessApplicationInterface processApplication = null;
  try {
    processApplication = reference.getProcessApplication();
  } catch (ProcessApplicationUnavailableException e) {
    fail("Could not retrieve process application");
  }

  return processApplication.getRawObject();
}
 
Example #5
Source File: DefaultConditionHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected List<ConditionHandlerResult> evaluateConditionStartByProcessDefinitionId(CommandContext commandContext, ConditionSet conditionSet,
    String processDefinitionId) {
  DeploymentCache deploymentCache = commandContext.getProcessEngineConfiguration().getDeploymentCache();
  ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);

  List<ConditionHandlerResult> results = new ArrayList<ConditionHandlerResult>();

  if (processDefinition != null && !processDefinition.isSuspended()) {
    List<ActivityImpl> activities = findConditionalStartEventActivities(processDefinition);
    if (activities.isEmpty()) {
      throw LOG.exceptionWhenEvaluatingConditionalStartEventByProcessDefinition(processDefinitionId);
    }
    for (ActivityImpl activity : activities) {
      if (evaluateCondition(conditionSet, activity)) {
        results.add(new ConditionHandlerResult(processDefinition, activity));
      }
    }
  }
  return results;
}
 
Example #6
Source File: BpmnDeployer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void addAuthorizationsFromIterator(Set<Expression> exprSet, ProcessDefinitionEntity processDefinition, ExprType exprType) {
  if (exprSet != null) {
    for (Expression expr : exprSet) {
      IdentityLinkEntity identityLink = new IdentityLinkEntity();
      identityLink.setProcessDef(processDefinition);
      if (exprType.equals(ExprType.USER)) {
        identityLink.setUserId(expr.toString());
      } else if (exprType.equals(ExprType.GROUP)) {
        identityLink.setGroupId(expr.toString());
      }
      identityLink.setType(IdentityLinkType.CANDIDATE);
      identityLink.setTenantId(processDefinition.getTenantId());
      identityLink.insert();
    }
  }
}
 
Example #7
Source File: GetDeploymentProcessDiagramLayoutCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public DiagramLayout execute(final CommandContext commandContext) {
  ProcessDefinitionEntity processDefinition = Context
      .getProcessEngineConfiguration()
      .getDeploymentCache()
      .findDeployedProcessDefinitionById(processDefinitionId);

  for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    checker.checkReadProcessDefinition(processDefinition);
  }

  InputStream processModelStream = commandContext.runWithoutAuthorization(new Callable<InputStream>() {
    public InputStream call() throws Exception {
      return new GetDeploymentProcessModelCmd(processDefinitionId).execute(commandContext);
    }
  });

  InputStream processDiagramStream = commandContext.runWithoutAuthorization(new Callable<InputStream>() {
    public InputStream call() throws Exception {
      return new GetDeploymentProcessDiagramCmd(processDefinitionId).execute(commandContext);
    }
  });

  return new ProcessDiagramLayoutFactory().getProcessDiagramLayout(processModelStream, processDiagramStream);
}
 
Example #8
Source File: ProcessApplicationEventListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = { "org/camunda/bpm/application/impl/event/ProcessApplicationEventListenerTest.testExecutionListener.bpmn20.xml" })
public void testShouldNotIncrementExecutionListenerCountOnStartAndEndOfProcessInstance() {
  final AtomicInteger eventCount = new AtomicInteger();

  EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
    public ExecutionListener getExecutionListener() {
      // this process application returns an execution listener
      return new ExecutionListener() {
        public void notify(DelegateExecution execution) throws Exception {
          if (!(((CoreExecution) execution).getEventSource() instanceof ProcessDefinitionEntity))
            eventCount.incrementAndGet();
        }
      };
    }
  };

  // register app so that it receives events
  managementService.registerProcessApplication(deploymentId, processApplication.getReference());

  // Start process instance.
  runtimeService.startProcessInstanceByKey("startToEnd");

  assertEquals(5, eventCount.get());
}
 
Example #9
Source File: BpmnDeploymentTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testDiagramCreationDisabled() {
  repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/bpmn/parse/BpmnParseTest.testParseDiagramInterchangeElements.bpmn20.xml").deploy();

  // Graphical information is not yet exposed publicly, so we need to do some plumbing
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
    @Override
    public ProcessDefinitionEntity execute(CommandContext commandContext) {
      return Context.getProcessEngineConfiguration()
                    .getDeploymentCache()
                    .findDeployedLatestProcessDefinitionByKey("myProcess");
    }
  });

  assertNotNull(processDefinitionEntity);
  assertEquals(7, processDefinitionEntity.getActivities().size());

  // Check that no diagram has been created
  List<String> resourceNames = repositoryService.getDeploymentResourceNames(processDefinitionEntity.getDeploymentId());
  assertEquals(1, resourceNames.size());

  repositoryService.deleteDeployment(repositoryService.createDeploymentQuery().singleResult().getId(), true);
}
 
Example #10
Source File: CreateMigrationPlanCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public MigrationPlan execute(CommandContext commandContext) {
  ProcessDefinitionEntity sourceProcessDefinition = getProcessDefinition(commandContext, migrationBuilder.getSourceProcessDefinitionId(), "Source");
  ProcessDefinitionEntity targetProcessDefinition = getProcessDefinition(commandContext, migrationBuilder.getTargetProcessDefinitionId(), "Target");

  checkAuthorization(commandContext, sourceProcessDefinition, targetProcessDefinition);

  MigrationPlanImpl migrationPlan = new MigrationPlanImpl(sourceProcessDefinition.getId(), targetProcessDefinition.getId());
  List<MigrationInstruction> instructions = new ArrayList<MigrationInstruction>();

  if (migrationBuilder.isMapEqualActivities()) {
    instructions.addAll(generateInstructions(commandContext, sourceProcessDefinition, targetProcessDefinition, migrationBuilder.isUpdateEventTriggersForGeneratedInstructions()));
  }

  instructions.addAll(migrationBuilder.getExplicitMigrationInstructions());
  migrationPlan.setInstructions(instructions);

  validateMigrationPlan(commandContext, migrationPlan, sourceProcessDefinition, targetProcessDefinition);

  return migrationPlan;
}
 
Example #11
Source File: ProcessApplicationContextUtil.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static void doContextSwitch(final Runnable runnable, ProcessDefinitionEntity contextDefinition) {
  ProcessApplicationReference processApplication = getTargetProcessApplication(contextDefinition);
  if (requiresContextSwitch(processApplication)) {
    Context.executeWithinProcessApplication(new Callable<Void>() {

      @Override
      public Void call() throws Exception {
        runnable.run();
        return null;
      }
    }, processApplication);
  }
  else {
    runnable.run();
  }
}
 
Example #12
Source File: DefaultCorrelationHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected List<CorrelationHandlerResult> correlateStartMessageByEventSubscription(CommandContext commandContext, String messageName, CorrelationSet correlationSet) {
  List<CorrelationHandlerResult> results = new ArrayList<CorrelationHandlerResult>();
  DeploymentCache deploymentCache = commandContext.getProcessEngineConfiguration().getDeploymentCache();

  List<EventSubscriptionEntity> messageEventSubscriptions = findMessageStartEventSubscriptions(commandContext, messageName, correlationSet);
  for (EventSubscriptionEntity messageEventSubscription : messageEventSubscriptions) {

    if (messageEventSubscription.getConfiguration() != null) {
      String processDefinitionId = messageEventSubscription.getConfiguration();
      ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
      // only an active process definition will be returned
      if (processDefinition != null && !processDefinition.isSuspended()) {
        CorrelationHandlerResult result = CorrelationHandlerResult.matchedProcessDefinition(processDefinition, messageEventSubscription.getActivityId());
        results.add(result);

      } else {
        LOG.couldNotFindProcessDefinitionForEventSubscription(messageEventSubscription, processDefinitionId);
      }
    }
  }
  return results;
}
 
Example #13
Source File: DeploymentCacheCfgTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testPlugInOwnCacheImplementation() {

  // given
  DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();

  // when
  Cache<String, ProcessDefinitionEntity> cache = deploymentCache.getProcessDefinitionCache();

  // then
  assertThat(cache, instanceOf(MyCacheImplementation.class));
}
 
Example #14
Source File: MigratingProcessInstance.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public MigratingProcessInstance(String processInstanceId, ProcessDefinitionEntity sourceDefinition, ProcessDefinitionEntity targetDefinition) {
  this.processInstanceId = processInstanceId;
  this.migratingActivityInstances = new ArrayList<MigratingActivityInstance>();
  this.migratingTransitionInstances = new ArrayList<MigratingTransitionInstance>();
  this.migratingEventScopeInstances = new ArrayList<MigratingEventScopeInstance>();
  this.migratingCompensationSubscriptionInstances = new ArrayList<MigratingCompensationEventSubscriptionInstance>();
  this.sourceDefinition = sourceDefinition;
  this.targetDefinition = targetDefinition;
}
 
Example #15
Source File: MigrationBatchJobHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
protected void postProcessJob(MigrationBatchConfiguration configuration, JobEntity job) {
  if (job.getDeploymentId() == null) {
    CommandContext commandContext = Context.getCommandContext();
    String sourceProcessDefinitionId = configuration.getMigrationPlan().getSourceProcessDefinitionId();

    ProcessDefinitionEntity processDefinition = getProcessDefinition(commandContext, sourceProcessDefinitionId);
    job.setDeploymentId(processDefinition.getDeploymentId());
  }
}
 
Example #16
Source File: AbstractModificationCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected ProcessDefinitionEntity getProcessDefinition(CommandContext commandContext, String processDefinitionId) {

    return commandContext
        .getProcessEngineConfiguration()
        .getDeploymentCache()
        .findDeployedProcessDefinitionById(processDefinitionId);
  }
 
Example #17
Source File: BpmnDeployer.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void removeObsoleteTimers(ProcessDefinitionEntity processDefinition) {
  List<JobEntity> jobsToDelete = getJobManager()
    .findJobsByConfiguration(TimerStartEventJobHandler.TYPE, processDefinition.getKey(), processDefinition.getTenantId());

  for (JobEntity job :jobsToDelete) {
      new DeleteJobsCmd(job.getId()).execute(Context.getCommandContext());
  }
}
 
Example #18
Source File: GetRenderedStartFormCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public Object execute(CommandContext commandContext) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
  DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
  ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
  ensureNotNull("Process Definition '" + processDefinitionId + "' not found", "processDefinition", processDefinition);

  for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    checker.checkReadProcessDefinition(processDefinition);
  }

  StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
  if (startFormHandler == null) {
    return null;
  }

  FormEngine formEngine = Context
    .getProcessEngineConfiguration()
    .getFormEngines()
    .get(formEngineName);

  ensureNotNull("No formEngine '" + formEngineName + "' defined process engine configuration", "formEngine", formEngine);

  StartFormData startForm = startFormHandler.createStartFormData(processDefinition);

  Object renderedStartForm = null;
  try {
    renderedStartForm = formEngine.renderStartForm(startForm);
  } catch (ScriptEvaluationException e) {
    LOG.exceptionWhenStartFormScriptEvaluation(processDefinitionId, e);
  }
  return renderedStartForm;
}
 
Example #19
Source File: AbstractSetStateCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected String getDeploymentIdByProcessDefinition(CommandContext commandContext, String processDefinitionId) {
  ProcessDefinitionEntity definition = commandContext.getProcessDefinitionManager().getCachedResourceDefinitionEntity(processDefinitionId);
  if (definition == null) {
    definition = commandContext.getProcessDefinitionManager().findLatestDefinitionById(processDefinitionId);
  }
  if (definition != null) {
    return definition.getDeploymentId();
  }
  return null;
}
 
Example #20
Source File: RecalculateJobDuedateCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public Void execute(final CommandContext commandContext) {
  final JobEntity job = commandContext.getJobManager().findJobById(jobId);
  ensureNotNull(NotFoundException.class, "No job found with id '" + jobId + "'", "job", job);

  // allow timer jobs only
  checkJobType(job);

  for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    checker.checkUpdateJob(job);
  }

  // prepare recalculation
  final TimerDeclarationImpl timerDeclaration = findTimerDeclaration(commandContext, job);
  final TimerEntity timer = (TimerEntity) job;
  Date oldDuedate = job.getDuedate();
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      timerDeclaration.resolveAndSetDuedate(timer.getExecution(), timer, creationDateBased);
    }
  };

  // run recalculation in correct context
  ProcessDefinitionEntity contextDefinition = commandContext
      .getProcessEngineConfiguration()
      .getDeploymentCache()
      .findDeployedProcessDefinitionById(job.getProcessDefinitionId());
  ProcessApplicationContextUtil.doContextSwitch(runnable, contextDefinition);

  // log operation
  List<PropertyChange> propertyChanges = new ArrayList<>();
  propertyChanges.add(new PropertyChange("duedate", oldDuedate, job.getDuedate()));
  propertyChanges.add(new PropertyChange("creationDateBased", null, creationDateBased));
  commandContext.getOperationLogManager().logJobOperation(UserOperationLogEntry.OPERATION_TYPE_RECALC_DUEDATE, jobId,
      job.getJobDefinitionId(), job.getProcessInstanceId(), job.getProcessDefinitionId(), job.getProcessDefinitionKey(),
      propertyChanges);

  return null;
}
 
Example #21
Source File: DeleteProcessDefinitionsByIdsCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected boolean isLatestProcessDefinition(ProcessDefinitionEntity processDefinition) {
  ProcessDefinitionManager processDefinitionManager = Context.getCommandContext().getProcessDefinitionManager();
  String key = processDefinition.getKey();
  String tenantId = processDefinition.getTenantId();
  ProcessDefinitionEntity latestProcessDefinition = processDefinitionManager.findLatestDefinitionByKeyAndTenantId(key, tenantId);
  return processDefinition.getId().equals(latestProcessDefinition.getId());
}
 
Example #22
Source File: ManagementAuthorizationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testGetTableNameWithoutAuthorization() {
  // given

  try {
    // when
    managementService.getTableName(ProcessDefinitionEntity.class);
    fail("Exception expected: It should not be possible to get the table name");
  } catch (AuthorizationException e) {
    // then
    String message = e.getMessage();
    assertTextPresent(REQUIRED_ADMIN_AUTH_EXCEPTION, message);
  }
}
 
Example #23
Source File: DeleteIdentityLinkForProcessDefinitionCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public Void execute(CommandContext commandContext) {
  ProcessDefinitionEntity processDefinition = Context
    .getCommandContext()
    .getProcessDefinitionManager()
    .findLatestProcessDefinitionById(processDefinitionId);

  ensureNotNull("Cannot find process definition with id " + processDefinitionId, "processDefinition", processDefinition);
  processDefinition.deleteIdentityLink(userId, groupId);

  return null;
}
 
Example #24
Source File: ManagementAuthorizationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testGetTableNameAsCamundaAdmin() {
  // given
  identityService.setAuthentication(userId, Collections.singletonList(Groups.CAMUNDA_ADMIN));
  String tablePrefix = processEngineConfiguration.getDatabaseTablePrefix();

  // when
  String tableName = managementService.getTableName(ProcessDefinitionEntity.class);

  // then
  assertEquals(tablePrefix + "ACT_RE_PROCDEF", tableName);
}
 
Example #25
Source File: MigratingInstanceParseContext.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public MigratingInstanceParseContext(
    MigratingInstanceParser parser,
    MigrationPlan migrationPlan,
    ExecutionEntity processInstance,
    ProcessDefinitionEntity targetProcessDefinition) {
  this.parser = parser;
  this.sourceProcessDefinition = processInstance.getProcessDefinition();
  this.targetProcessDefinition = targetProcessDefinition;
  this.migratingProcessInstance = new MigratingProcessInstance(processInstance.getId(), sourceProcessDefinition, targetProcessDefinition);
  this.mapping = new ActivityExecutionTreeMapping(Context.getCommandContext(), processInstance.getId());
  this.instructionsBySourceScope = organizeInstructionsBySourceScope(migrationPlan);
}
 
Example #26
Source File: AbstractMigrationCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected ProcessDefinitionEntity resolveTargetProcessDefinition(CommandContext commandContext) {
  String targetProcessDefinitionId = executionBuilder.getMigrationPlan()
      .getTargetProcessDefinitionId();

  ProcessDefinitionEntity sourceProcessDefinition =
      getProcessDefinition(commandContext, targetProcessDefinitionId);
  EnsureUtil.ensureNotNull("sourceProcessDefinition", sourceProcessDefinition);

  return sourceProcessDefinition;
}
 
Example #27
Source File: RecalculateJobDuedateCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected TimerDeclarationImpl findTimerDeclarationForProcessStartEvent(CommandContext commandContext, JobEntity job) {
  ProcessDefinitionEntity processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentCache().findDeployedProcessDefinitionById(job.getProcessDefinitionId());
  @SuppressWarnings("unchecked")
  List<TimerDeclarationImpl> timerDeclarations = (List<TimerDeclarationImpl>) processDefinition.getProperty(BpmnParse.PROPERTYNAME_START_TIMER);
  for (TimerDeclarationImpl timerDeclarationCandidate : timerDeclarations) {
    if (timerDeclarationCandidate.getJobDefinitionId().equals(job.getJobDefinitionId())) {
      return timerDeclarationCandidate;
    }
  }
  return null;
}
 
Example #28
Source File: CreateMigrationPlanCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected ProcessDefinitionEntity getProcessDefinition(CommandContext commandContext, String id, String type) {
  EnsureUtil.ensureNotNull(BadUserRequestException.class, type + " process definition id", id);

  try {
    return commandContext.getProcessEngineConfiguration()
      .getDeploymentCache().findDeployedProcessDefinitionById(id);
  }
  catch (NullValueException e) {
    throw LOG.processDefinitionDoesNotExist(id, type);
  }
}
 
Example #29
Source File: GetDeployedProcessDefinitionCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected ProcessDefinitionEntity findByKey(DeploymentCache deploymentCache, String processDefinitionKey) {
  if (isTenantIdSet) {
    return deploymentCache.findDeployedLatestProcessDefinitionByKeyAndTenantId(processDefinitionKey, processDefinitionTenantId);

  } else {
    return deploymentCache.findDeployedLatestProcessDefinitionByKey(processDefinitionKey);
  }
}
 
Example #30
Source File: MigrateProcessInstanceCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public Void execute(final CommandContext commandContext) {
  final MigrationPlan migrationPlan = executionBuilder.getMigrationPlan();
  final Collection<String> processInstanceIds = collectProcessInstanceIds();

  ensureNotNull(BadUserRequestException.class,
      "Migration plan cannot be null", "migration plan", migrationPlan);
  ensureNotEmpty(BadUserRequestException.class,
      "Process instance ids cannot empty", "process instance ids", processInstanceIds);
  ensureNotContainsNull(BadUserRequestException.class,
      "Process instance ids cannot be null", "process instance ids", processInstanceIds);

  ProcessDefinitionEntity sourceDefinition = resolveSourceProcessDefinition(commandContext);
  final ProcessDefinitionEntity targetDefinition = resolveTargetProcessDefinition(commandContext);

  checkAuthorizations(commandContext, sourceDefinition, targetDefinition);

  if (writeOperationLog) {
    writeUserOperationLog(commandContext,
        sourceDefinition,
        targetDefinition,
        processInstanceIds.size(),
        false);
  }

  commandContext.runWithoutAuthorization((Callable<Void>) () -> {
    for (String processInstanceId : processInstanceIds) {
      migrateProcessInstance(commandContext, processInstanceId, migrationPlan, targetDefinition);
    }
    return null;
  });

  return null;
}