Java Code Examples for org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity#getTenantId()

The following examples show how to use org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity#getTenantId() . 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: DeleteProcessDefinitionsByIdsCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected Set<ProcessDefinitionGroup> groupByKeyAndTenant(List<ProcessDefinition> processDefinitions) {
  Set<ProcessDefinitionGroup> groups = new HashSet<ProcessDefinitionGroup>();
  Map<ProcessDefinitionGroup, List<ProcessDefinitionEntity>> map = new HashMap<ProcessDefinitionGroup, List<ProcessDefinitionEntity>>();

  for (ProcessDefinition current : processDefinitions) {
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) current;

    ProcessDefinitionGroup group = new ProcessDefinitionGroup();
    group.key = processDefinition.getKey();
    group.tenant = processDefinition.getTenantId();

    List<ProcessDefinitionEntity> definitions = group.processDefinitions;
    if (map.containsKey(group)) {
      definitions = map.get(group);
    }
    else {
      groups.add(group);
      map.put(group, definitions);
    }

    definitions.add(processDefinition);
  }

  return groups;
}
 
Example 2
Source File: MigrateProcessInstanceBatchCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public Batch execute(CommandContext commandContext) {
  Collection<String> collectedInstanceIds = collectProcessInstanceIds();

  MigrationPlan migrationPlan = executionBuilder.getMigrationPlan();

  ensureNotNull(BadUserRequestException.class,
      "Migration plan cannot be null", "migration plan", migrationPlan);

  ensureNotEmpty(BadUserRequestException.class,
      "Process instance ids cannot empty", "process instance ids", collectedInstanceIds);

  ensureNotContainsNull(BadUserRequestException.class,
      "Process instance ids cannot be null", "process instance ids", collectedInstanceIds);

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

  String tenantId = sourceDefinition.getTenantId();

  return new BatchBuilder(commandContext)
      .type(Batch.TYPE_PROCESS_INSTANCE_MIGRATION)
      .config(getConfiguration(collectedInstanceIds, sourceDefinition.getDeploymentId()))
      .permission(BatchPermissions.CREATE_BATCH_MIGRATE_PROCESS_INSTANCES)
      .permissionHandler(ctx ->
          checkAuthorizations(ctx, sourceDefinition, targetDefinition))
      .tenantId(tenantId)
      .operationLogHandler((ctx, instanceCount) ->
          writeUserOperationLog(ctx, sourceDefinition, targetDefinition,
              instanceCount, true))
      .build();
}
 
Example 3
Source File: RestartProcessInstancesBatchCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public Batch execute(CommandContext commandContext) {
  Collection<String> collectedInstanceIds = collectProcessInstanceIds();

  List<AbstractProcessInstanceModificationCommand> instructions = builder.getInstructions();
  ensureNotEmpty(BadUserRequestException.class, "Restart instructions cannot be empty",
      "instructions", instructions);
  ensureNotEmpty(BadUserRequestException.class, "Process instance ids cannot be empty",
      "processInstanceIds", collectedInstanceIds);
  ensureNotContainsNull(BadUserRequestException.class, "Process instance ids cannot be null",
      "processInstanceIds", collectedInstanceIds);

  String processDefinitionId = builder.getProcessDefinitionId();
  ProcessDefinitionEntity processDefinition =
      getProcessDefinition(commandContext, processDefinitionId);

  ensureNotNull(BadUserRequestException.class,
      "Process definition cannot be null", processDefinition);
  ensureTenantAuthorized(commandContext, processDefinition);

  String tenantId = processDefinition.getTenantId();

  return new BatchBuilder(commandContext)
      .type(Batch.TYPE_PROCESS_INSTANCE_RESTART)
      .config(getConfiguration(collectedInstanceIds, processDefinition.getDeploymentId()))
      .permission(BatchPermissions.CREATE_BATCH_RESTART_PROCESS_INSTANCES)
      .tenantId(tenantId)
      .operationLogHandler((ctx, instanceCount) ->
          writeUserOperationLog(ctx, processDefinition, instanceCount, true))
      .build();
}
 
Example 4
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 5
Source File: ProcessInstanceModificationBatchCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public Batch execute(CommandContext commandContext) {
  List<AbstractProcessInstanceModificationCommand> instructions = builder.getInstructions();
  ensureNotEmpty(BadUserRequestException.class,
      "Modification instructions cannot be empty", instructions);

  Collection<String> collectedInstanceIds = collectProcessInstanceIds();

  ensureNotEmpty(BadUserRequestException.class, "Process instance ids cannot be empty",
      "Process instance ids", collectedInstanceIds);

  ensureNotContainsNull(BadUserRequestException.class, "Process instance ids cannot be null",
      "Process instance ids", collectedInstanceIds);

  String processDefinitionId = builder.getProcessDefinitionId();
  ProcessDefinitionEntity processDefinition =
      getProcessDefinition(commandContext, processDefinitionId);

  ensureNotNull(BadUserRequestException.class,
      "Process definition id cannot be null", processDefinition);

  String tenantId = processDefinition.getTenantId();
  String annotation = builder.getAnnotation();

  return new BatchBuilder(commandContext)
      .type(Batch.TYPE_PROCESS_INSTANCE_MODIFICATION)
      .config(getConfiguration(collectedInstanceIds, processDefinition.getDeploymentId()))
      .tenantId(tenantId)
      .permission(BatchPermissions.CREATE_BATCH_MODIFY_PROCESS_INSTANCES)
      .operationLogHandler((ctx, instanceCount) ->
          writeUserOperationLog(ctx, processDefinition, instanceCount, true, annotation))
      .build();
}
 
Example 6
Source File: DefaultCallableElementTenantIdProvider.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected String getProcessDefinitionTenantId(ExecutionEntity execution) {
  ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) execution.getProcessDefinition();
  return processDefinition.getTenantId();
}
 
Example 7
Source File: BpmnDeployer.java    From camunda-bpm-platform with Apache License 2.0 3 votes vote down vote up
protected void addMessageStartEventSubscription(EventSubscriptionDeclaration messageEventDefinition, ProcessDefinitionEntity processDefinition) {

    String tenantId = processDefinition.getTenantId();

    if(isSameMessageEventSubscriptionAlreadyPresent(messageEventDefinition, tenantId)) {
      throw LOG.messageEventSubscriptionWithSameNameExists(processDefinition.getResourceName(), messageEventDefinition.getUnresolvedEventName());
    }

    EventSubscriptionEntity newSubscription = messageEventDefinition.createSubscriptionForStartEvent(processDefinition);
    newSubscription.insert();

  }