org.camunda.bpm.engine.impl.history.event.HistoryEvent Java Examples

The following examples show how to use org.camunda.bpm.engine.impl.history.event.HistoryEvent. 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: DefaultHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public List<HistoryEvent> createUserOperationLogEvents(UserOperationLogContext context) {
  List<HistoryEvent> historyEvents = new ArrayList<HistoryEvent>();

  String operationId = Context.getCommandContext().getOperationId();
  context.setOperationId(operationId);

  for (UserOperationLogContextEntry entry : context.getEntries()) {
    for (PropertyChange propertyChange : entry.getPropertyChanges()) {
      UserOperationLogEntryEventEntity evt = new UserOperationLogEntryEventEntity();

      initUserOperationLogEvent(evt, context, entry, propertyChange);

      historyEvents.add(evt);
    }
  }

  return historyEvents;
}
 
Example #2
Source File: AbstractSetProcessInstanceStateCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
protected void triggerHistoryEvent(CommandContext commandContext){
  HistoryLevel historyLevel = commandContext.getProcessEngineConfiguration().getHistoryLevel();
  List<ProcessInstance> updatedProcessInstances = obtainProcessInstances(commandContext);
  //suspension state is not updated synchronously
  if (getNewSuspensionState() != null && updatedProcessInstances != null) {
    for (final ProcessInstance processInstance: updatedProcessInstances) {

      if (historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_UPDATE, processInstance)) {
        HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
          @Override
          public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
            HistoricProcessInstanceEventEntity processInstanceUpdateEvt = (HistoricProcessInstanceEventEntity)
                producer.createProcessInstanceUpdateEvt((DelegateExecution) processInstance);
            if (SuspensionState.SUSPENDED.getStateCode() == getNewSuspensionState().getStateCode()) {
              processInstanceUpdateEvt.setState(HistoricProcessInstance.STATE_SUSPENDED);
            } else {
              processInstanceUpdateEvt.setState(HistoricProcessInstance.STATE_ACTIVE);
            }
            return processInstanceUpdateEvt;
          }
        });
      }
    }
  }
}
 
Example #3
Source File: UserOperationLogContextEntryBuilder.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public UserOperationLogContextEntryBuilder inContextOf(HistoryEvent historyEvent, ResourceDefinitionEntity<?> definition, 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(historyEvent.getRootProcessInstanceId());
    entry.setProcessDefinitionId(historyEvent.getProcessDefinitionId());
    entry.setProcessInstanceId(historyEvent.getProcessInstanceId());
    entry.setExecutionId(historyEvent.getExecutionId());
    entry.setCaseDefinitionId(historyEvent.getCaseDefinitionId());
    entry.setCaseInstanceId(historyEvent.getCaseInstanceId());
    entry.setCaseExecutionId(historyEvent.getCaseExecutionId());

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

    return this;
  }
 
Example #4
Source File: DefaultHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public HistoryEvent createActivityInstanceEndEvt(DelegateExecution execution) {
  final ExecutionEntity executionEntity = (ExecutionEntity) execution;

  // create event instance
  HistoricActivityInstanceEventEntity evt = loadActivityInstanceEventEntity(executionEntity);
  evt.setActivityInstanceState(executionEntity.getActivityInstanceState());

  // initialize event
  initActivityInstanceEvent(evt, (ExecutionEntity) execution, HistoryEventTypes.ACTIVITY_INSTANCE_END);

  evt.setEndTime(ClockUtil.getCurrentTime());
  if(evt.getStartTime() != null) {
    evt.setDurationInMillis(evt.getEndTime().getTime()-evt.getStartTime().getTime());
  }

  return evt;
}
 
Example #5
Source File: DbHistoryEventHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/** general history event insert behavior */
  protected void insertOrUpdate(HistoryEvent historyEvent) {

    final DbEntityManager dbEntityManager = getDbEntityManager();

    if(isInitialEvent(historyEvent)) {
      dbEntityManager.insert(historyEvent);
    } else {
      if(dbEntityManager.getCachedEntity(historyEvent.getClass(), historyEvent.getId()) == null) {
        if (historyEvent instanceof HistoricScopeInstanceEvent) {
          // if this is a scope, get start time from existing event in DB
          HistoricScopeInstanceEvent existingEvent = (HistoricScopeInstanceEvent) dbEntityManager.selectById(historyEvent.getClass(), historyEvent.getId());
          if(existingEvent != null) {
            HistoricScopeInstanceEvent historicScopeInstanceEvent = (HistoricScopeInstanceEvent) historyEvent;
            historicScopeInstanceEvent.setStartTime(existingEvent.getStartTime());
          }
        }
        if(historyEvent.getId() == null) {
//          dbSqlSession.insert(historyEvent);
        } else {
          dbEntityManager.merge(historyEvent);
        }
      }
    }
  }
 
Example #6
Source File: PvmExecutionImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void setProcessBusinessKey(String businessKey) {
  final PvmExecutionImpl processInstance = getProcessInstance();
  processInstance.setBusinessKey(businessKey);

  HistoryLevel historyLevel = Context
  .getCommandContext().getProcessEngineConfiguration().getHistoryLevel();
  if (historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_UPDATE, processInstance)) {

    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createProcessInstanceUpdateEvt(processInstance);
      }
    });
  }
}
 
Example #7
Source File: DefaultHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public HistoryEvent createActivityInstanceUpdateEvt(DelegateExecution execution, DelegateTask task) {
  final ExecutionEntity executionEntity = (ExecutionEntity) execution;

  // create event instance
  HistoricActivityInstanceEventEntity evt = loadActivityInstanceEventEntity(executionEntity);

  // initialize event
  initActivityInstanceEvent(evt, executionEntity, HistoryEventTypes.ACTIVITY_INSTANCE_UPDATE);

  // update task assignment
  if(task != null) {
    evt.setTaskId(task.getId());
    evt.setTaskAssignee(task.getAssignee());
  }

  return evt;
}
 
Example #8
Source File: DefaultCmmnHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public HistoryEvent createCaseActivityInstanceEndEvt(DelegateCaseExecution caseExecution) {
  final CaseExecutionEntity caseExecutionEntity = (CaseExecutionEntity) caseExecution;

  // create event instance
  HistoricCaseActivityInstanceEventEntity evt = loadCaseActivityInstanceEventEntity(caseExecutionEntity);

  // initialize event
  initCaseActivityInstanceEvent(evt, caseExecutionEntity, HistoryEventTypes.CASE_ACTIVITY_INSTANCE_END);

  // set end time
  evt.setEndTime(ClockUtil.getCurrentTime());

  // calculate duration
  if (evt.getStartTime() != null) {
    evt.setDurationInMillis(evt.getEndTime().getTime() - evt.getStartTime().getTime());
  }

  return evt;
}
 
Example #9
Source File: DefaultHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public HistoryEvent createHistoricJobLogFailedEvt(Job job, Throwable exception) {
  HistoricJobLogEventEntity event = (HistoricJobLogEventEntity) createHistoricJobLogEvt(job, HistoryEventTypes.JOB_FAIL);

  if(exception != null) {
    // exception message
    event.setJobExceptionMessage(exception.getMessage());

    // stacktrace
    String exceptionStacktrace = getExceptionStacktrace(exception);
    byte[] exceptionBytes = toByteArray(exceptionStacktrace);

    ByteArrayEntity byteArray = createJobExceptionByteArray(exceptionBytes, ResourceTypes.HISTORY);
    byteArray.setRootProcessInstanceId(event.getRootProcessInstanceId());

    if (isHistoryRemovalTimeStrategyStart()) {
      byteArray.setRemovalTime(event.getRemovalTime());
    }

    event.setExceptionByteArrayId(byteArray.getId());
  }

  return event;
}
 
Example #10
Source File: IncidentEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void fireHistoricIncidentEvent(final HistoryEventType eventType) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();

  HistoryLevel historyLevel = processEngineConfiguration.getHistoryLevel();
  if(historyLevel.isHistoryEventProduced(eventType, this)) {

    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {

        HistoryEvent event = null;
        if (HistoryEvent.INCIDENT_CREATE.equals(eventType.getEventName())) {
          event = producer.createHistoricIncidentCreateEvt(IncidentEntity.this);

        } else if (HistoryEvent.INCIDENT_RESOLVE.equals(eventType.getEventName())) {
          event = producer.createHistoricIncidentResolveEvt(IncidentEntity.this);

        } else if (HistoryEvent.INCIDENT_DELETE.equals(eventType.getEventName())) {
          event = producer.createHistoricIncidentDeleteEvt(IncidentEntity.this);
        }
        return event;
      }
    });
  }
}
 
Example #11
Source File: DefaultHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public HistoryEvent createProcessInstanceMigrateEvt(DelegateExecution execution) {
  final ExecutionEntity executionEntity = (ExecutionEntity) execution;

  // create event instance
  HistoricProcessInstanceEventEntity evt = newProcessInstanceEventEntity(executionEntity);

  // initialize event
  initProcessInstanceEvent(evt, executionEntity, HistoryEventTypes.PROCESS_INSTANCE_MIGRATE);

  if (executionEntity.isSuspended()) {
    evt.setState(HistoricProcessInstance.STATE_SUSPENDED);
  } else {
    evt.setState(HistoricProcessInstance.STATE_ACTIVE);
  }

  return evt;
}
 
Example #12
Source File: DefaultAuthorizationProvider.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void provideRemovalTime(AuthorizationEntity authorization, Task task) {
  String rootProcessInstanceId = getRootProcessInstanceId(task);

  if (rootProcessInstanceId != null) {
    authorization.setRootProcessInstanceId(rootProcessInstanceId);

    if (isHistoryRemovalTimeStrategyStart()) {
      HistoryEvent rootProcessInstance = findHistoricProcessInstance(rootProcessInstanceId);

      Date removalTime = null;
      if (rootProcessInstance != null) {
        removalTime = rootProcessInstance.getRemovalTime();

      }

      authorization.setRemovalTime(removalTime);

    }
  }
}
 
Example #13
Source File: SaveAuthorizationCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void provideRemovalTime(CommandContext commandContext) {
  for (Entry<Resources, Supplier<HistoryEvent>> resourceEntry :
      getHistoricInstanceResources(commandContext)) {
    Resources resource = resourceEntry.getKey();
    if (isResourceEqualTo(resource)) {

      Supplier<HistoryEvent> historyEventSupplier = resourceEntry.getValue();

      HistoryEvent historyEvent = historyEventSupplier.get();
      provideRemovalTime(historyEvent);

      break;
    }
  }
}
 
Example #14
Source File: VariableInstanceHistoryListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(final VariableInstanceEntity variableInstance, final AbstractVariableScope sourceScope) {
  if (getHistoryLevel().isHistoryEventProduced(HistoryEventTypes.VARIABLE_INSTANCE_CREATE, variableInstance) && !variableInstance.isTransient()) {
    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createHistoricVariableCreateEvt(variableInstance, sourceScope);
      }
    });
  }
}
 
Example #15
Source File: HistoricJobLogManager.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void fireJobFailedEvent(final Job job, final Throwable exception) {
  if (isHistoryEventProduced(HistoryEventTypes.JOB_FAIL, job)) {
    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createHistoricJobLogFailedEvt(job, exception);
      }

      @Override
      public void postHandleSingleHistoryEventCreated(HistoryEvent event) {
        ((JobEntity) job).setLastFailureLogId(event.getId());
      }
    });
  }
}
 
Example #16
Source File: HistoricJobLogManager.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void fireJobCreatedEvent(final Job job) {
  if (isHistoryEventProduced(HistoryEventTypes.JOB_CREATE, job)) {
    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createHistoricJobLogCreateEvt(job);
      }
    });
  }
}
 
Example #17
Source File: ExecutionEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void fireHistoricActivityInstanceUpdate() {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
  HistoryLevel historyLevel = configuration.getHistoryLevel();
  if (historyLevel.isHistoryEventProduced(HistoryEventTypes.ACTIVITY_INSTANCE_UPDATE, this)) {
    // publish update event for current activity instance (containing the id
    // of the sub process/case)
    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createActivityInstanceUpdateEvt(ExecutionEntity.this);
      }
    });
  }
}
 
Example #18
Source File: MigratingActivityInstance.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void migrateActivityInstanceHistory(final DelegateExecution execution) {
  HistoryLevel historyLevel = Context.getProcessEngineConfiguration().getHistoryLevel();
  if (!historyLevel.isHistoryEventProduced(HistoryEventTypes.ACTIVITY_INSTANCE_MIGRATE, this)) {
    return;
  }

  HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
    @Override
    public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
      return producer.createActivityInstanceMigrateEvt(MigratingActivityInstance.this);
    }
  });
}
 
Example #19
Source File: HistoricTaskInstanceManager.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void createHistoricTask(final TaskEntity task) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();

  HistoryLevel historyLevel = configuration.getHistoryLevel();
  if(historyLevel.isHistoryEventProduced(HistoryEventTypes.TASK_INSTANCE_CREATE, task)) {

    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createTaskInstanceCreateEvt(task);
      }
    });

  }
}
 
Example #20
Source File: MigratingActivityInstance.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void migrateProcessInstanceHistory(final DelegateExecution execution) {
  HistoryLevel historyLevel = Context.getProcessEngineConfiguration().getHistoryLevel();
  if (!historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_MIGRATE, this)) {
    return;
  }

  HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
    @Override
    public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
      return producer.createProcessInstanceMigrateEvt(execution);
    }
  });
}
 
Example #21
Source File: CaseActivityInstanceEndListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected HistoryEvent createHistoryEvent(DelegateCaseExecution caseExecution) {
  ensureHistoryLevelInitialized();
  if (historyLevel.isHistoryEventProduced(HistoryEventTypes.CASE_ACTIVITY_INSTANCE_END, caseExecution)) {
    return eventProducer.createCaseActivityInstanceEndEvt(caseExecution);
  }
  else {
    return null;
  }
}
 
Example #22
Source File: SaveAuthorizationCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void provideRemovalTime(HistoryEvent historicInstance) {

    if (historicInstance != null) {
      String rootProcessInstanceId = historicInstance.getRootProcessInstanceId();
      authorization.setRootProcessInstanceId(rootProcessInstanceId);

      Date removalTime = historicInstance.getRemovalTime();
      authorization.setRemovalTime(removalTime);

    } else { // reset
      authorization.setRootProcessInstanceId(null);
      authorization.setRemovalTime(null);

    }
  }
 
Example #23
Source File: CustomHistoryEventHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
public void shouldReceiveMigrateEvents() {
  // given
  VariableMap variables = Variables.createVariables().putValue("foo", "bar");

  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
  String processDefinitionId = processInstance.getProcessDefinitionId();
  String processInstanceId = processInstance.getId();

  Task task = taskService.createTaskQuery().singleResult();
  ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstanceId).getActivityInstances("theTask")[0];

  MigrationPlan migrationPlan = runtimeService.createMigrationPlan(processDefinitionId, processDefinitionId).mapEqualActivities().build();
  recorderHandler.clear();

  // when
  runtimeService.newMigration(migrationPlan).processInstanceIds(processInstanceId).execute();

  // then
  // one process instance, one activity instance, one task instance, one variable instance
  assertThat(recorderHandler.size()).isEqualTo(4);

  List<HistoryEvent> processInstanceEvents = recorderHandler.getEventsForEntity(processInstanceId);
  assertThat(processInstanceEvents).hasSize(1);
  assertThat(processInstanceEvents.get(0).getEventType()).isEqualTo(HistoryEventTypes.PROCESS_INSTANCE_MIGRATE.getEventName());

  List<HistoryEvent> activityInstanceEvents = recorderHandler.getEventsForEntity(activityInstance.getId());
  assertThat(activityInstanceEvents).hasSize(1);
  assertThat(activityInstanceEvents.get(0).getEventType()).isEqualTo(HistoryEventTypes.ACTIVITY_INSTANCE_MIGRATE.getEventName());

  List<HistoryEvent> taskEvents = recorderHandler.getEventsForEntity(task.getId());
  assertThat(taskEvents).hasSize(1);
  assertThat(taskEvents.get(0).getEventType()).isEqualTo(HistoryEventTypes.TASK_INSTANCE_MIGRATE.getEventName());

  List<HistoryEvent> variableEvents = recorderHandler.getEventsForEntity(null); // variable events currently have no id set
  assertThat(variableEvents).hasSize(1);
  assertThat(variableEvents.get(0).getEventType()).isEqualTo(HistoryEventTypes.VARIABLE_INSTANCE_MIGRATE.getEventName());
}
 
Example #24
Source File: VariableInstanceHistoryListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void onDelete(final VariableInstanceEntity variableInstance, final AbstractVariableScope sourceScope) {
  if (getHistoryLevel().isHistoryEventProduced(HistoryEventTypes.VARIABLE_INSTANCE_DELETE, variableInstance) && !variableInstance.isTransient()) {
    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createHistoricVariableDeleteEvt(variableInstance, sourceScope);
      }
    });
  }
}
 
Example #25
Source File: CamundaEventingIT.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldEventHistoryTaskMultipleAssignmentChanges() {
  // given
  startEventingInstance();
  Task task = taskService.createTaskQuery().active().singleResult();
  eventCaptor.clear();

  // when
  taskService.addCandidateUser(task.getId(), "user1");
  taskService.addCandidateUser(task.getId(), "user2");

  // then in reverse order

  // Add candidate user
  HistoryEvent candidateUserEvent = eventCaptor.historyEvents.pop();
  assertThat(candidateUserEvent.getEventType()).isEqualTo("add-identity-link");
  if (candidateUserEvent instanceof HistoricIdentityLinkLogEventEntity) {
    assertThat(((HistoricIdentityLinkLogEventEntity) candidateUserEvent).getType()).isEqualTo("candidate");
    assertThat(((HistoricIdentityLinkLogEventEntity) candidateUserEvent).getOperationType()).isEqualTo("add");
    assertThat(((HistoricIdentityLinkLogEventEntity) candidateUserEvent).getUserId()).isEqualTo("user2");
  } else {
    fail("Expected identity link log event");
  }

  // Add candidate user
  candidateUserEvent = eventCaptor.historyEvents.pop();
  assertThat(candidateUserEvent.getEventType()).isEqualTo("add-identity-link");
  if (candidateUserEvent instanceof HistoricIdentityLinkLogEventEntity) {
    assertThat(((HistoricIdentityLinkLogEventEntity) candidateUserEvent).getType()).isEqualTo("candidate");
    assertThat(((HistoricIdentityLinkLogEventEntity) candidateUserEvent).getOperationType()).isEqualTo("add");
    assertThat(((HistoricIdentityLinkLogEventEntity) candidateUserEvent).getUserId()).isEqualTo("user1");
  } else {
    fail("Expected identity link log event");
  }

  assertThat(eventCaptor.historyEvents).isEmpty();
}
 
Example #26
Source File: SaveAuthorizationCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected HistoryEvent getHistoricTaskInstance(CommandContext commandContext) {
  String historicTaskInstanceId = authorization.getResourceId();

  if (isNullOrAny(historicTaskInstanceId)) {
    return null;
  }

  return commandContext.getHistoricTaskInstanceManager()
      .findHistoricTaskInstanceById(historicTaskInstanceId);
}
 
Example #27
Source File: EntityFilterTest.java    From camunda-bpm-elasticsearch with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldTransformJsonToMapAndApplyMixInFilter() throws IOException {
  String json = jsonTransformer.transformToJson(historyEvent);
  assertFalse(json.contains(HistoryEvent.class.getName()));

  Map<String,Object> jsonMap = jsonTransformer.transformJsonToMap(json);
  assertFalse(jsonMap.containsKey(""));
}
 
Example #28
Source File: EntityFilterTest.java    From camunda-bpm-elasticsearch with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  jsonTransformer = new JsonTransformer();

  historyEvent = new HistoryEvent();
  historyEvent.setId("id");
  historyEvent.setExecutionId("ExecutionId");
  historyEvent.setProcessDefinitionId("processDefinitionId");
  historyEvent.setProcessInstanceId("processInstanceId");
  historyEvent.setEventType(HistoryEvent.ACTIVITY_EVENT_TYPE_START);

  assertEquals(HistoryEvent.class, historyEvent.getPersistentState());
}
 
Example #29
Source File: DefaultHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void provideRemovalTime(HistoryEvent historyEvent) {
  String rootProcessInstanceId = historyEvent.getRootProcessInstanceId();
  if (rootProcessInstanceId != null) {
    HistoricProcessInstanceEventEntity historicRootProcessInstance =
      getHistoricRootProcessInstance(rootProcessInstanceId);

    if (historicRootProcessInstance != null) {
      Date removalTime = historicRootProcessInstance.getRemovalTime();
      historyEvent.setRemovalTime(removalTime);
    }
  }
}
 
Example #30
Source File: DbHistoryEventHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void handleEvent(HistoryEvent historyEvent) {

    if (historyEvent instanceof HistoricVariableUpdateEventEntity) {
      insertHistoricVariableUpdateEntity((HistoricVariableUpdateEventEntity) historyEvent);
    } else if(historyEvent instanceof HistoricDecisionEvaluationEvent) {
      insertHistoricDecisionEvaluationEvent((HistoricDecisionEvaluationEvent) historyEvent);
    } else {
      insertOrUpdate(historyEvent);
    }

  }