Search in sources :

Example 21 with CommandContext

use of org.activiti.engine.impl.interceptor.CommandContext in project Activiti by Activiti.

the class ProcessDefinitionInfoEntityManager method updateProcessDefinitionInfo.

public void updateProcessDefinitionInfo(ProcessDefinitionInfoEntity updatedProcessDefinitionInfo) {
    CommandContext commandContext = Context.getCommandContext();
    DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
    dbSqlSession.update(updatedProcessDefinitionInfo);
    if (Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
        Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, updatedProcessDefinitionInfo));
    }
}
Also used : CommandContext(org.activiti.engine.impl.interceptor.CommandContext) DbSqlSession(org.activiti.engine.impl.db.DbSqlSession)

Example 22 with CommandContext

use of org.activiti.engine.impl.interceptor.CommandContext in project Activiti by Activiti.

the class TaskEntity method setOwner.

public void setOwner(String owner, boolean dispatchUpdateEvent) {
    if (owner == null && this.owner == null) {
        return;
    }
    //    if (owner!=null && owner.equals(this.owner)) {
    //      return;
    //    }
    this.owner = owner;
    CommandContext commandContext = Context.getCommandContext();
    if (commandContext != null) {
        commandContext.getHistoryManager().recordTaskOwnerChange(id, owner);
        if (owner != null && processInstanceId != null) {
            getProcessInstance().involveUser(owner, IdentityLinkType.PARTICIPANT);
        }
        if (dispatchUpdateEvent && commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
            if (dispatchUpdateEvent) {
                commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, this));
            }
        }
    }
}
Also used : CommandContext(org.activiti.engine.impl.interceptor.CommandContext)

Example 23 with CommandContext

use of org.activiti.engine.impl.interceptor.CommandContext in project Activiti by Activiti.

the class TaskEntity method setDescription.

public void setDescription(String description) {
    this.description = description;
    CommandContext commandContext = Context.getCommandContext();
    if (commandContext != null) {
        commandContext.getHistoryManager().recordTaskDescriptionChange(id, description);
    }
}
Also used : CommandContext(org.activiti.engine.impl.interceptor.CommandContext)

Example 24 with CommandContext

use of org.activiti.engine.impl.interceptor.CommandContext in project Activiti by Activiti.

the class TaskEntity method setAssignee.

public void setAssignee(String assignee, boolean dispatchAssignmentEvent, boolean dispatchUpdateEvent) {
    CommandContext commandContext = Context.getCommandContext();
    if (assignee == null && this.assignee == null) {
        // ACT-1923: even if assignee is unmodified and null, this should be stored in history.
        if (commandContext != null) {
            commandContext.getHistoryManager().recordTaskAssigneeChange(id, assignee);
        }
        return;
    }
    this.assignee = assignee;
    // setAssignee outside a service method.  E.g. while creating a new task.
    if (commandContext != null) {
        commandContext.getHistoryManager().recordTaskAssigneeChange(id, assignee);
        if (assignee != null && processInstanceId != null) {
            getProcessInstance().involveUser(assignee, IdentityLinkType.PARTICIPANT);
        }
        if (!StringUtils.equals(initialAssignee, assignee)) {
            fireEvent(TaskListener.EVENTNAME_ASSIGNMENT);
            initialAssignee = assignee;
        }
        if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
            if (dispatchAssignmentEvent) {
                commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.TASK_ASSIGNED, this));
            }
            if (dispatchUpdateEvent) {
                commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, this));
            }
        }
    }
}
Also used : CommandContext(org.activiti.engine.impl.interceptor.CommandContext)

Example 25 with CommandContext

use of org.activiti.engine.impl.interceptor.CommandContext in project Activiti by Activiti.

the class TaskEntity method update.

public void update() {
    // Needed to make history work: the setter will also update the historic task
    setOwner(this.getOwner());
    setAssignee(this.getAssignee(), true, false);
    setDelegationState(this.getDelegationState());
    setName(this.getName());
    setDescription(this.getDescription());
    setPriority(this.getPriority());
    setCategory(this.getCategory());
    setCreateTime(this.getCreateTime());
    setDueDate(this.getDueDate());
    setParentTaskId(this.getParentTaskId());
    setFormKey(formKey);
    CommandContext commandContext = Context.getCommandContext();
    DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
    dbSqlSession.update(this);
    if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
        commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, this));
    }
}
Also used : CommandContext(org.activiti.engine.impl.interceptor.CommandContext) DbSqlSession(org.activiti.engine.impl.db.DbSqlSession)

Aggregations

CommandContext (org.activiti.engine.impl.interceptor.CommandContext)72 CommandExecutor (org.activiti.engine.impl.interceptor.CommandExecutor)18 DbSqlSession (org.activiti.engine.impl.db.DbSqlSession)13 SignalEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity)8 Date (java.util.Date)7 ActivitiException (org.activiti.engine.ActivitiException)7 CommandConfig (org.activiti.engine.impl.interceptor.CommandConfig)7 EventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity)7 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)7 MessageEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity)6 HashMap (java.util.HashMap)4 TimerEntity (org.activiti.engine.impl.persistence.entity.TimerEntity)4 Job (org.activiti.engine.runtime.Job)4 Deployment (org.activiti.engine.test.Deployment)4 ArrayList (java.util.ArrayList)3 GregorianCalendar (java.util.GregorianCalendar)3 List (java.util.List)3 ExtensionElement (org.activiti.bpmn.model.ExtensionElement)3 DynamicBpmnService (org.activiti.engine.DynamicBpmnService)3 JobEntity (org.activiti.engine.impl.persistence.entity.JobEntity)3