Search in sources :

Example 1 with UserOperationLogContextEntry

use of org.camunda.bpm.engine.impl.oplog.UserOperationLogContextEntry in project camunda-bpm-platform by camunda.

the class DefaultHistoryEventProducer method createUserOperationLogEvents.

// User Operation Logs ///////////////////////////
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;
}
Also used : PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) ArrayList(java.util.ArrayList) UserOperationLogContextEntry(org.camunda.bpm.engine.impl.oplog.UserOperationLogContextEntry)

Example 2 with UserOperationLogContextEntry

use of org.camunda.bpm.engine.impl.oplog.UserOperationLogContextEntry in project camunda-bpm-platform by camunda.

the class SetJobDefinitionPriorityCmd method createJobDefinitionOperationLogEntry.

protected void createJobDefinitionOperationLogEntry(UserOperationLogContext opLogContext, Long previousPriority, JobDefinitionEntity jobDefinition) {
    PropertyChange propertyChange = new PropertyChange(JOB_DEFINITION_OVERRIDING_PRIORITY, previousPriority, jobDefinition.getOverridingJobPriority());
    UserOperationLogContextEntry entry = UserOperationLogContextEntryBuilder.entry(UserOperationLogEntry.OPERATION_TYPE_SET_PRIORITY, EntityTypes.JOB_DEFINITION).inContextOf(jobDefinition).propertyChanges(propertyChange).create();
    opLogContext.addEntry(entry);
}
Also used : PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) UserOperationLogContextEntry(org.camunda.bpm.engine.impl.oplog.UserOperationLogContextEntry)

Example 3 with UserOperationLogContextEntry

use of org.camunda.bpm.engine.impl.oplog.UserOperationLogContextEntry in project camunda-bpm-platform by camunda.

the class SetJobDefinitionPriorityCmd method createCascadeJobsOperationLogEntry.

protected void createCascadeJobsOperationLogEntry(UserOperationLogContext opLogContext, JobDefinitionEntity jobDefinition) {
    // old value is unknown
    PropertyChange propertyChange = new PropertyChange(SetJobPriorityCmd.JOB_PRIORITY_PROPERTY, null, jobDefinition.getOverridingJobPriority());
    UserOperationLogContextEntry entry = UserOperationLogContextEntryBuilder.entry(UserOperationLogEntry.OPERATION_TYPE_SET_PRIORITY, EntityTypes.JOB).inContextOf(jobDefinition).propertyChanges(propertyChange).create();
    opLogContext.addEntry(entry);
}
Also used : PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) UserOperationLogContextEntry(org.camunda.bpm.engine.impl.oplog.UserOperationLogContextEntry)

Example 4 with UserOperationLogContextEntry

use of org.camunda.bpm.engine.impl.oplog.UserOperationLogContextEntry in project camunda-bpm-platform by camunda.

the class CustomUserOperationLogTest method testDoNotOverwriteUserId.

@Test
public void testDoNotOverwriteUserId() throws Exception {
    commandExecutor.execute(new Command<Void>() {

        @Override
        public Void execute(final CommandContext commandContext) {
            final UserOperationLogContext userOperationLogContext = new UserOperationLogContext();
            userOperationLogContext.setUserId("kermit");
            final UserOperationLogContextEntry entry = new UserOperationLogContextEntry("foo", "bar");
            entry.setPropertyChanges(Arrays.asList(new PropertyChange(null, null, null)));
            entry.setTaskId(TASK_ID);
            userOperationLogContext.addEntry(entry);
            commandContext.getOperationLogManager().logUserOperations(userOperationLogContext);
            return null;
        }
    });
    // and check its there
    assertThat(historyService.createUserOperationLogQuery().taskId(TASK_ID).singleResult().getUserId(), is("kermit"));
}
Also used : PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) UserOperationLogContext(org.camunda.bpm.engine.impl.oplog.UserOperationLogContext) UserOperationLogContextEntry(org.camunda.bpm.engine.impl.oplog.UserOperationLogContextEntry) Test(org.junit.Test)

Aggregations

UserOperationLogContextEntry (org.camunda.bpm.engine.impl.oplog.UserOperationLogContextEntry)4 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)4 ArrayList (java.util.ArrayList)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 UserOperationLogContext (org.camunda.bpm.engine.impl.oplog.UserOperationLogContext)1 Test (org.junit.Test)1