Package org.activiti.engine.impl.persistence.entity

Examples of org.activiti.engine.impl.persistence.entity.TaskEntity


  public UserTaskActivityBehavior(TaskDefinition taskDefinition) {
    this.taskDefinition = taskDefinition;
  }

  public void execute(ActivityExecution execution) throws Exception {
    TaskEntity task = TaskEntity.createAndInsert(execution);
    task.setExecution(execution);
    task.setTaskDefinition(taskDefinition);

    if (taskDefinition.getNameExpression() != null) {
      String name = (String) taskDefinition.getNameExpression().getValue(execution);
      task.setName(name);
    }

    if (taskDefinition.getDescriptionExpression() != null) {
      String description = (String) taskDefinition.getDescriptionExpression().getValue(execution);
      task.setDescription(description);
    }
   
    if(taskDefinition.getDueDateExpression() != null) {
      Object dueDate = taskDefinition.getDueDateExpression().getValue(execution);
      if(dueDate != null) {
        if (dueDate instanceof Date) {
          task.setDueDate((Date) dueDate);
        } else if (dueDate instanceof String) {
          BusinessCalendar businessCalendar = Context
            .getProcessEngineConfiguration()
            .getBusinessCalendarManager()
            .getBusinessCalendar(DueDateBusinessCalendar.NAME);
          task.setDueDate(businessCalendar.resolveDuedate((String) dueDate));
        } else {
          throw new ActivitiIllegalArgumentException("Due date expression does not resolve to a Date or Date string: " +
              taskDefinition.getDueDateExpression().getExpressionText());
        }
      }
    }

    if (taskDefinition.getPriorityExpression() != null) {
      final Object priority = taskDefinition.getPriorityExpression().getValue(execution);
      if (priority != null) {
        if (priority instanceof String) {
          try {
            task.setPriority(Integer.valueOf((String) priority));
          } catch (NumberFormatException e) {
            throw new ActivitiIllegalArgumentException("Priority does not resolve to a number: " + priority, e);
          }
        } else if (priority instanceof Number) {
          task.setPriority(((Number) priority).intValue());
        } else {
          throw new ActivitiIllegalArgumentException("Priority expression does not resolve to a number: " +
                  taskDefinition.getPriorityExpression().getExpressionText());
        }
      }
    }
   
    if (taskDefinition.getCategoryExpression() != null) {
      final Object category = taskDefinition.getCategoryExpression().getValue(execution);
      if (category != null) {
        if (category instanceof String) {
          task.setCategory((String) category);
        } else {
           throw new ActivitiIllegalArgumentException("Category expression does not resolve to a string: " +
               taskDefinition.getCategoryExpression().getExpressionText());
        }
      }
    }
   
    if (taskDefinition.getFormKeyExpression() != null) {
      final Object formKey = taskDefinition.getFormKeyExpression().getValue(execution);
      if (formKey != null) {
        if (formKey instanceof String) {
          task.setFormKey((String) formKey);
        } else {
           throw new ActivitiIllegalArgumentException("FormKey expression does not resolve to a string: " +
               taskDefinition.getFormKeyExpression().getExpressionText());
        }
      }
    }
   
    handleAssignments(task, execution);
  
    // All properties set, now firing 'create' events
    if (Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
      Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
        ActivitiEventBuilder.createEntityEvent(ActivitiEventType.TASK_CREATED, task));
    }

    task.fireEvent(TaskListener.EVENTNAME_CREATE);
  }
View Full Code Here


    this.formEngineName = formEngineName;
  }


  public Object execute(CommandContext commandContext) {
    TaskEntity task = commandContext
      .getTaskEntityManager()
      .findTaskById(taskId);
    if (task == null) {
      throw new ActivitiObjectNotFoundException("Task '" + taskId +"' not found", Task.class);
    }
   
    if (task.getTaskDefinition() == null) {
      throw new ActivitiException("Task form definition for '" + taskId +"' not found");
    }
   
    TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
    if (taskFormHandler == null) {
      return null;
    }
   
    FormEngine formEngine = commandContext
View Full Code Here

  public Map<String, Object> execute(CommandContext commandContext) {
    if(taskId == null) {
      throw new ActivitiIllegalArgumentException("taskId is null");
    }
   
    TaskEntity task = commandContext
      .getTaskEntityManager()
      .findTaskById(taskId);
   
    if (task==null) {
      throw new ActivitiObjectNotFoundException("task "+taskId+" doesn't exist", Task.class);
    }

    Map<String, Object> taskVariables;
    if (isLocal) {
      taskVariables = task.getVariablesLocal();
    } else {
      taskVariables = task.getVariables();
    }
   
    if (variableNames==null) {
      variableNames = taskVariables.keySet();
    }
   
    // this copy is made to avoid lazy initialization outside a command context
    Map<String, Object> variables = new HashMap<String, Object>();
    for (String variableName: variableNames) {
      variables.put(variableName, task.getVariable(variableName));
    }
   
    return variables;
  }
View Full Code Here

    }
    if(variableName == null) {
      throw new ActivitiIllegalArgumentException("variableName is null");
    }
   
    TaskEntity task = commandContext
      .getTaskEntityManager()
      .findTaskById(taskId);
   
    if (task==null) {
      throw new ActivitiObjectNotFoundException("task "+taskId+" doesn't exist", Task.class);
    }
    boolean hasVariable = false;
   
    if (isLocal) {
      hasVariable = task.hasVariableLocal(variableName);
    } else {
      hasVariable = task.hasVariable(variableName);
    }
   
    return hasVariable;
  }
View Full Code Here

    this.taskId = taskId;
  }
 
  public Task execute(CommandContext commandContext) {
    Date currentTime = commandContext.getProcessEngineConfiguration().getClock().getCurrentTime();
    TaskEntity task = TaskEntity.create(currentTime);
    task.setId(taskId);
    return task;
  }
View Full Code Here

   
    if(taskId == null) {
      throw new ActivitiIllegalArgumentException("taskId is null");
    }
   
    TaskEntity task = commandContext
      .getTaskEntityManager()
      .findTaskById(taskId);
   
    if (task == null) {
      throw new ActivitiObjectNotFoundException("Cannot find task with id " + taskId, Task.class);
    }
   
    if (task.isSuspended()) {
      throw new ActivitiException(getSuspendedTaskException());
    }
   
    return execute(commandContext, task);
  }
View Full Code Here

    return attachment;
  }

  private void verifyParameters(CommandContext commandContext) {
    if (taskId != null) {
      TaskEntity task = commandContext.getTaskEntityManager().findTaskById(taskId);

      if (task == null) {
        throw new ActivitiObjectNotFoundException("Cannot find task with id " + taskId, Task.class);
      }

      if (task.isSuspended()) {
        throw new ActivitiException("It is not allowed to add an attachment to a suspended task");
      }
    }
   
    if (processInstanceId != null) {
View Full Code Here

    }
    if(variableName == null) {
      throw new ActivitiIllegalArgumentException("variableName is null");
    }
   
    TaskEntity task = commandContext
      .getTaskEntityManager()
      .findTaskById(taskId);
   
    if (task==null) {
      throw new ActivitiObjectNotFoundException("task "+taskId+" doesn't exist", Task.class);
    }
   
    Object value;
   
    if (isLocal) {
      value = task.getVariableLocal(variableName);
    } else {
      value = task.getVariable(variableName);
    }
   
    return value;
  }
View Full Code Here

 
  public Comment execute(CommandContext commandContext) {
   
    // Validate task
    if (taskId != null) {
      TaskEntity task = commandContext.getTaskEntityManager().findTaskById(taskId);

      if (task == null) {
        throw new ActivitiObjectNotFoundException("Cannot find task with id " + taskId, Task.class);
      }

      if (task.isSuspended()) {
        throw new ActivitiException(getSuspendedTaskException());
      }
    }
   
    if (processInstanceId != null) {
View Full Code Here

  public GetTaskFormCmd(String taskId) {
    this.taskId = taskId;
  }

  public TaskFormData execute(CommandContext commandContext) {
    TaskEntity task = commandContext
      .getTaskEntityManager()
      .findTaskById(taskId);
    if (task == null) {
      throw new ActivitiObjectNotFoundException("No task found for taskId '" + taskId +"'", Task.class);
    }
   
    if(task.getTaskDefinition() != null) {
      TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
      if (taskFormHandler == null) {
        throw new ActivitiException("No taskFormHandler specified for task '" + taskId +"'");
      }
     
      return taskFormHandler.createTaskForm(task);
View Full Code Here

TOP

Related Classes of org.activiti.engine.impl.persistence.entity.TaskEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.