Package org.camunda.bpm.engine.delegate

Examples of org.camunda.bpm.engine.delegate.Expression


      task.setDescription(description);
    }
  }

  protected void initializeTaskDueDate(TaskEntity task, VariableScope variableScope) {
    Expression dueDateExpression = taskDefinition.getDueDateExpression();
    if(dueDateExpression != null) {
      Object dueDate = dueDateExpression.getValue(variableScope);
      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 ProcessEngineException("Due date expression does not resolve to a Date or Date string: " +
              dueDateExpression.getExpressionText());
        }
      }
    }
  }
View Full Code Here


      }
    }
  }

  protected void initializeTaskPriority(TaskEntity task, VariableScope variableScope) {
    Expression priorityExpression = taskDefinition.getPriorityExpression();
    if (priorityExpression != null) {
      Object priority = priorityExpression.getValue(variableScope);

      if (priority != null) {
        if (priority instanceof String) {
          try {
            task.setPriority(Integer.valueOf((String) priority));

          } catch (NumberFormatException e) {
            throw new ProcessEngineException("Priority does not resolve to a number: " + priority, e);
          }
        } else if (priority instanceof Number) {
          task.setPriority(((Number) priority).intValue());

        } else {
          throw new ProcessEngineException("Priority expression does not resolve to a number: " +
                  priorityExpression.getExpressionText());
        }
      }
    }
  }
View Full Code Here

    // candidateGroups
    initializeTaskCandidateGroups(task, variableScope);
  }

  protected void initializeTaskAssignee(TaskEntity task, VariableScope variableScope) {
    Expression assigneeExpression = taskDefinition.getAssigneeExpression();
    if (assigneeExpression != null) {
      task.setAssignee((String) assigneeExpression.getValue(variableScope));
    }
  }
View Full Code Here

public class DefaultTaskFormHandler extends DefaultFormHandler implements TaskFormHandler {

  public TaskFormData createTaskForm(TaskEntity task) {
    TaskFormDataImpl taskFormData = new TaskFormDataImpl();

    Expression formKey = task.getTaskDefinition().getFormKey();

    if (formKey != null) {
      Object formValue = formKey.getValue(task);
      if (formValue != null) {
        taskFormData.setFormKey(formValue.toString());
      }
    }
View Full Code Here

  private void addAuthorizationsFromIterator(Set<Expression> exprSet, ProcessDefinitionEntity processDefinition, ExprType exprType) {
    CommandContext commandContext = Context.getCommandContext();
    if (exprSet != null) {
      Iterator<Expression> iterator = exprSet.iterator();
      while (iterator.hasNext()) {
        Expression expr = iterator.next();
        IdentityLinkEntity identityLink = new IdentityLinkEntity();
        identityLink.setProcessDef(processDefinition);
        if (exprType.equals(ExprType.USER)) {
           identityLink.setUserId(expr.toString());
        } else if (exprType.equals(ExprType.GROUP)) {
          identityLink.setGroupId(expr.toString());
        }
        identityLink.setType(IdentityLinkType.CANDIDATE);
        commandContext.getDbEntityManager().insert(identityLink);
      }
    }
View Full Code Here

  }

  public void testDecorateName() {
    // given
    String aTaskName = "A Task Name";
    Expression nameExpression = expressionManager.createExpression(aTaskName);
    taskDefinition.setNameExpression(nameExpression);

    // when
    decorate(task, taskDecorator);
View Full Code Here

  public void testDecorateNameFromVariable() {
    // given
    String aTaskName = "A Task Name";
    taskService.setVariable(task.getId(), "taskName", aTaskName);

    Expression nameExpression = expressionManager.createExpression("${taskName}");
    taskDefinition.setNameExpression(nameExpression);

    // when
    decorate(task, taskDecorator);
View Full Code Here

  }

  public void testDecorateDescription() {
    // given
    String aDescription = "This is a Task";
    Expression descriptionExpression = expressionManager.createExpression(aDescription);
    taskDefinition.setDescriptionExpression(descriptionExpression);

    // when
    decorate(task, taskDecorator);
View Full Code Here

  public void testDecorateDescriptionFromVariable() {
    // given
    String aDescription = "This is a Task";
    taskService.setVariable(task.getId(), "description", aDescription);

    Expression descriptionExpression = expressionManager.createExpression("${description}");
    taskDefinition.setDescriptionExpression(descriptionExpression);

    // when
    decorate(task, taskDecorator);
View Full Code Here

  public void testDecorateDueDate() {
    // given
    String aDueDate = "2014-06-01";
    Date dueDate = DateTimeUtil.parseDate(aDueDate);

    Expression dueDateExpression = expressionManager.createExpression(aDueDate);
    taskDefinition.setDueDateExpression(dueDateExpression);

    // when
    decorate(task, taskDecorator);
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.delegate.Expression

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.