Search in sources :

Example 31 with PropertyChange

use of org.camunda.bpm.engine.impl.persistence.entity.PropertyChange in project camunda-bpm-platform by camunda.

the class DeleteHistoricDecisionInstancesBatchCmd method writeUserOperationLog.

protected void writeUserOperationLog(CommandContext commandContext, int numInstances) {
    List<PropertyChange> propertyChanges = new ArrayList<PropertyChange>();
    propertyChanges.add(new PropertyChange("nrOfInstances", null, numInstances));
    propertyChanges.add(new PropertyChange("async", null, true));
    propertyChanges.add(new PropertyChange("type", null, "history"));
    propertyChanges.add(new PropertyChange("deleteReason", null, deleteReason));
    commandContext.getOperationLogManager().logDecisionInstanceOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE, propertyChanges);
}
Also used : PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) ArrayList(java.util.ArrayList)

Example 32 with PropertyChange

use of org.camunda.bpm.engine.impl.persistence.entity.PropertyChange in project camunda-bpm-platform by camunda.

the class UserOperationLogTaskServiceAndBeanTest method testAllTrackedProperties.

public void testAllTrackedProperties() {
    Date yesterday = new Date(new Date().getTime() - 86400000);
    Date tomorrow = new Date(new Date().getTime() + 86400000);
    TaskEntity entity = new TaskEntity();
    // call all tracked setter methods
    entity.setAssignee("er");
    entity.setDelegationState(DelegationState.PENDING);
    entity.setDeleted(true);
    entity.setDescription("a description");
    entity.setDueDate(tomorrow);
    entity.setFollowUpDate(yesterday);
    entity.setName("to do");
    entity.setOwner("icke");
    entity.setParentTaskId("parent");
    entity.setPriority(73);
    // and validate the change list
    Map<String, PropertyChange> changes = entity.getPropertyChanges();
    assertEquals("er", changes.get(ASSIGNEE).getNewValue());
    assertSame(DelegationState.PENDING, changes.get(DELEGATION).getNewValue());
    assertTrue((Boolean) changes.get(DELETE).getNewValue());
    assertEquals("a description", changes.get(DESCRIPTION).getNewValue());
    assertEquals(tomorrow, changes.get(DUE_DATE).getNewValue());
    assertEquals(yesterday, changes.get(FOLLOW_UP_DATE).getNewValue());
    assertEquals("to do", changes.get(NAME).getNewValue());
    assertEquals("icke", changes.get(OWNER).getNewValue());
    assertEquals("parent", changes.get(PARENT_TASK).getNewValue());
    assertEquals(73, changes.get(PRIORITY).getNewValue());
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) Date(java.util.Date)

Example 33 with PropertyChange

use of org.camunda.bpm.engine.impl.persistence.entity.PropertyChange in project camunda-bpm-platform by camunda.

the class UserOperationLogTaskServiceAndBeanTest method testBeanPropertyChanges.

public void testBeanPropertyChanges() {
    TaskEntity entity = new TaskEntity();
    // assign and validate changes
    entity.setAssignee("icke");
    Map<String, PropertyChange> changes = entity.getPropertyChanges();
    assertEquals(1, changes.size());
    assertNull(changes.get(ASSIGNEE).getOrgValue());
    assertEquals("icke", changes.get(ASSIGNEE).getNewValue());
    // assign it again
    entity.setAssignee("er");
    changes = entity.getPropertyChanges();
    assertEquals(1, changes.size());
    // original value is still null because the task was not saved
    assertNull(changes.get(ASSIGNEE).getOrgValue());
    assertEquals("er", changes.get(ASSIGNEE).getNewValue());
    // set a due date
    entity.setDueDate(new Date());
    changes = entity.getPropertyChanges();
    assertEquals(2, changes.size());
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) Date(java.util.Date)

Example 34 with PropertyChange

use of org.camunda.bpm.engine.impl.persistence.entity.PropertyChange in project camunda-bpm-platform by camunda.

the class DeleteGroupIdentityLinkCmd method execute.

@Override
public Void execute(CommandContext commandContext) {
    super.execute(commandContext);
    PropertyChange propertyChange = new PropertyChange(type, null, groupId);
    commandContext.getOperationLogManager().logLinkOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE_GROUP_LINK, task, propertyChange);
    return null;
}
Also used : PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)

Example 35 with PropertyChange

use of org.camunda.bpm.engine.impl.persistence.entity.PropertyChange 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

PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)35 ArrayList (java.util.ArrayList)12 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)4 UserOperationLogContextEntry (org.camunda.bpm.engine.impl.oplog.UserOperationLogContextEntry)4 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)4 AttachmentEntity (org.camunda.bpm.engine.impl.persistence.entity.AttachmentEntity)3 UserOperationLogManager (org.camunda.bpm.engine.impl.persistence.entity.UserOperationLogManager)3 Date (java.util.Date)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 JobDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)2 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)2 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 DbEntityManager (org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)1 HistoryLevel (org.camunda.bpm.engine.impl.history.HistoryLevel)1 HistoryEvent (org.camunda.bpm.engine.impl.history.event.HistoryEvent)1 HistoryEventProcessor (org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor)1 HistoryEventProducer (org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1