Package org.camunda.bpm.engine.impl

Examples of org.camunda.bpm.engine.impl.TaskQueryImpl


  public static final String SORT_ORDER = "sortOrder";
  protected static JsonTaskQueryVariableValueConverter variableValueConverter = new JsonTaskQueryVariableValueConverter();

  public JSONObject toJsonObject(TaskQuery taskQuery) {
    JSONObject json = new JSONObject();
    TaskQueryImpl query = (TaskQueryImpl) taskQuery;

    addField(json, TASK_ID, query.getTaskId());
    addField(json, NAME, query.getName());
    addField(json, NAME_LIKE, query.getNameLike());
    addField(json, DESCRIPTION, query.getDescription());
    addField(json, DESCRIPTION_LIKE, query.getDescriptionLike());
    addField(json, PRIORITY, query.getPriority());
    addField(json, MIN_PRIORITY, query.getMinPriority());
    addField(json, MAX_PRIORITY, query.getMaxPriority());
    addField(json, ASSIGNEE, query.getAssignee());
    addField(json, ASSIGNEE_LIKE, query.getAssigneeLike());
    addField(json, INVOLVED_USER, query.getInvolvedUser());
    addField(json, OWNER, query.getOwner());
    addDefaultField(json, UNASSIGNED, false, query.isUnassigned());
    addField(json, DELEGATION_STATE, query.getDelegationStateString());
    addField(json, CANDIDATE_USER, query.getCandidateUser());
    addField(json, CANDIDATE_GROUP, query.getCandidateGroup());
    addListField(json, CANDIDATE_GROUPS, query.getCandidateGroupsInternal());
    addField(json, PROCESS_INSTANCE_ID, query.getProcessInstanceId());
    addField(json, EXECUTION_ID, query.getExecutionId());
    addArrayField(json, ACTIVITY_INSTANCE_ID_IN, query.getActivityInstanceIdIn());
    addDateField(json, CREATED, query.getCreateTime());
    addDateField(json, CREATED_BEFORE, query.getCreateTimeBefore());
    addDateField(json, CREATED_AFTER, query.getCreateTimeAfter());
    addField(json, KEY, query.getKey());
    addField(json, KEY_LIKE, query.getKeyLike());
    addField(json, PROCESS_DEFINITION_KEY, query.getProcessDefinitionKey());
    addField(json, PROCESS_DEFINITION_ID, query.getProcessDefinitionId());
    addField(json, PROCESS_DEFINITION_NAME, query.getProcessDefinitionName());
    addField(json, PROCESS_DEFINITION_NAME_LIKE, query.getProcessDefinitionNameLike());
    addField(json, PROCESS_INSTANCE_BUSINESS_KEY, query.getProcessInstanceBusinessKey());
    addField(json, PROCESS_INSTANCE_BUSINESS_KEY_LIKE, query.getProcessInstanceBusinessKeyLike());
    addVariablesFields(json, query.getVariables());
    addDateField(json, DUE, query.getDueDate());
    addDateField(json, DUE_BEFORE, query.getDueBefore());
    addDateField(json, DUE_AFTER, query.getDueAfter());
    addDateField(json, FOLLOW_UP, query.getFollowUpDate());
    addDateField(json, FOLLOW_UP_BEFORE, query.getFollowUpBefore());
    addDefaultField(json, FOLLOW_UP_NULL_ACCEPTED, false, query.isFollowUpNullAccepted());
    addDateField(json, FOLLOW_UP_AFTER, query.getFollowUpAfter());
    addDefaultField(json, EXCLUDE_SUBTASKS, false, query.isExcludeSubtasks());
    addSuspensionState(json, query.getSuspensionState());
    addField(json, CASE_DEFINITION_KEY, query.getCaseDefinitionKey());
    addField(json, CASE_DEFINITION_ID, query.getCaseDefinitionId());
    addField(json, CASE_DEFINITION_NAME, query.getCaseDefinitionName());
    addField(json, CASE_DEFINITION_NAME_LIKE, query.getCaseDefinitionNameLike());
    addField(json, CASE_INSTANCE_ID, query.getCaseInstanceId());
    addField(json, CASE_INSTANCE_BUSINESS_KEY, query.getCaseInstanceBusinessKey());
    addField(json, CASE_INSTANCE_BUSINESS_KEY_LIKE, query.getCaseInstanceBusinessKeyLike());
    addField(json, CASE_EXECUTION_ID, query.getCaseExecutionId());
    addDefaultField(json, ORDER_BY, ListQueryParameterObject.DEFAULT_ORDER_BY, query.getOrderBy());

    // expressions
    for (Map.Entry<String, String> expressionEntry : query.getExpressions().entrySet()) {
      json.put(expressionEntry.getKey() + "Expression", expressionEntry.getValue());
    }

    return json;
  }
View Full Code Here


  protected void addVariable(JSONArray array, TaskQueryVariableValue variable) {
    array.put(variableValueConverter.toJsonObject(variable));
  }

  public TaskQuery toObject(JSONObject json) {
    TaskQueryImpl query = new TaskQueryImpl();

    if (json.has(TASK_ID)) {
      query.taskId(json.getString(TASK_ID));
    }
    if (json.has(NAME)) {
      query.taskName(json.getString(NAME));
    }
    if (json.has(NAME_LIKE)) {
      query.taskNameLike(json.getString(NAME_LIKE));
    }
    if (json.has(DESCRIPTION)) {
      query.taskDescription(json.getString(DESCRIPTION));
    }
    if (json.has(DESCRIPTION_LIKE)) {
      query.taskDescriptionLike(json.getString(DESCRIPTION_LIKE));
    }
    if (json.has(PRIORITY)) {
      query.taskPriority(json.getInt(PRIORITY));
    }
    if (json.has(MIN_PRIORITY)) {
      query.taskMinPriority(json.getInt(MIN_PRIORITY));
    }
    if (json.has(MAX_PRIORITY)) {
      query.taskMaxPriority(json.getInt(MAX_PRIORITY));
    }
    if (json.has(ASSIGNEE)) {
      query.taskAssignee(json.getString(ASSIGNEE));
    }
    if (json.has(ASSIGNEE_LIKE)) {
      query.taskAssigneeLike(json.getString(ASSIGNEE_LIKE));
    }
    if (json.has(INVOLVED_USER)) {
      query.taskInvolvedUser(json.getString(INVOLVED_USER));
    }
    if (json.has(OWNER)) {
      query.taskOwner(json.getString(OWNER));
    }
    if (json.has(UNASSIGNED) && json.getBoolean(UNASSIGNED)) {
        query.taskUnassigned();
    }
    if (json.has(DELEGATION_STATE)) {
      query.taskDelegationState(DelegationState.valueOf(json.getString(DELEGATION_STATE)));
    }
    if (json.has(CANDIDATE_USER)) {
      query.taskCandidateUser(json.getString(CANDIDATE_USER));
    }
    if (json.has(CANDIDATE_GROUP)) {
      query.taskCandidateGroup(json.getString(CANDIDATE_GROUP));
    }
    if (json.has(CANDIDATE_GROUPS) && !json.has(CANDIDATE_USER) && !json.has(CANDIDATE_GROUP)) {
      query.taskCandidateGroupIn(getList(json.getJSONArray(CANDIDATE_GROUPS)));
    }
    if (json.has(PROCESS_INSTANCE_ID)) {
      query.processInstanceId(json.getString(PROCESS_INSTANCE_ID));
    }
    if (json.has(EXECUTION_ID)) {
      query.executionId(json.getString(EXECUTION_ID));
    }
    if (json.has(ACTIVITY_INSTANCE_ID_IN)) {
      query.activityInstanceIdIn(getArray(json.getJSONArray(ACTIVITY_INSTANCE_ID_IN)));
    }
    if (json.has(CREATED)) {
      query.taskCreatedOn(new Date(json.getLong(CREATED)));
    }
    if (json.has(CREATED_BEFORE)) {
      query.taskCreatedBefore(new Date(json.getLong(CREATED_BEFORE)));
    }
    if (json.has(CREATED_AFTER)) {
      query.taskCreatedAfter(new Date(json.getLong(CREATED_AFTER)));
    }
    if (json.has(KEY)) {
      query.taskDefinitionKey(json.getString(KEY));
    }
    if (json.has(KEY_LIKE)) {
      query.taskDefinitionKeyLike(json.getString(KEY_LIKE));
    }
    if (json.has(PROCESS_DEFINITION_KEY)) {
      query.processDefinitionKey(json.getString(PROCESS_DEFINITION_KEY));
    }
    if (json.has(PROCESS_DEFINITION_ID)) {
      query.processDefinitionId(json.getString(PROCESS_DEFINITION_ID));
    }
    if (json.has(PROCESS_DEFINITION_NAME)) {
      query.processDefinitionName(json.getString(PROCESS_DEFINITION_NAME));
    }
    if (json.has(PROCESS_DEFINITION_NAME_LIKE)) {
      query.processDefinitionNameLike(json.getString(PROCESS_DEFINITION_NAME_LIKE));
    }
    if (json.has(PROCESS_INSTANCE_BUSINESS_KEY)) {
      query.processInstanceBusinessKey(json.getString(PROCESS_INSTANCE_BUSINESS_KEY));
    }
    if (json.has(PROCESS_INSTANCE_BUSINESS_KEY_LIKE)) {
      query.processInstanceBusinessKeyLike(json.getString(PROCESS_INSTANCE_BUSINESS_KEY_LIKE));
    }
    if (json.has(TASK_VARIABLES)) {
      addVariables(query, json.getJSONArray(TASK_VARIABLES), true, false);
    }
    if (json.has(PROCESS_VARIABLES)) {
      addVariables(query, json.getJSONArray(PROCESS_VARIABLES), false, true);
    }
    if (json.has(CASE_INSTANCE_VARIABLES)) {
      addVariables(query, json.getJSONArray(CASE_INSTANCE_VARIABLES), false, false);
    }
    if (json.has(DUE)) {
      query.dueDate(new Date(json.getLong(DUE)));
    }
    if (json.has(DUE_BEFORE)) {
      query.dueBefore(new Date(json.getLong(DUE_BEFORE)));
    }
    if (json.has(DUE_AFTER)) {
      query.dueAfter(new Date(json.getLong(DUE_AFTER)));
    }
    if (json.has(FOLLOW_UP)) {
      query.followUpDate(new Date(json.getLong(FOLLOW_UP)));
    }
    if (json.has(FOLLOW_UP_BEFORE)) {
      query.followUpBefore(new Date(json.getLong(FOLLOW_UP_BEFORE)));
    }
    if (json.has(FOLLOW_UP_AFTER)) {
      query.followUpAfter(new Date(json.getLong(FOLLOW_UP_AFTER)));
    }
    if (json.has(FOLLOW_UP_NULL_ACCEPTED)) {
      query.setFollowUpNullAccepted(json.getBoolean(FOLLOW_UP_NULL_ACCEPTED));
    }
    if (json.has(EXCLUDE_SUBTASKS) && json.getBoolean(EXCLUDE_SUBTASKS)) {
      query.excludeSubtasks();
    }
    if (json.has(SUSPENDED) && json.getBoolean(SUSPENDED)) {
      query.suspended();
    }
    if (json.has(ACTIVE) && json.getBoolean(ACTIVE)) {
      query.active();
    }
    if (json.has(CASE_DEFINITION_KEY)) {
      query.caseDefinitionKey(json.getString(CASE_DEFINITION_KEY));
    }
    if (json.has(CASE_DEFINITION_ID)) {
      query.caseDefinitionId(json.getString(CASE_DEFINITION_ID));
    }
    if (json.has(CASE_DEFINITION_NAME)) {
      query.caseDefinitionName(json.getString(CASE_DEFINITION_NAME));
    }
    if (json.has(CASE_DEFINITION_NAME_LIKE)) {
      query.caseDefinitionNameLike(json.getString(CASE_DEFINITION_NAME_LIKE));
    }
    if (json.has(CASE_INSTANCE_ID)) {
      query.caseInstanceId(json.getString(CASE_INSTANCE_ID));
    }
    if (json.has(CASE_INSTANCE_BUSINESS_KEY)) {
      query.caseInstanceBusinessKey(json.getString(CASE_INSTANCE_BUSINESS_KEY));
    }
    if (json.has(CASE_INSTANCE_BUSINESS_KEY_LIKE)) {
      query.caseInstanceBusinessKeyLike(json.getString(CASE_INSTANCE_BUSINESS_KEY_LIKE));
    }
    if (json.has(CASE_EXECUTION_ID)) {
      query.caseExecutionId(json.getString(CASE_EXECUTION_ID));
    }
    if (json.has(ORDER_BY)) {
      query.setOrderBy(json.getString(ORDER_BY));
    }
    if (json.has(SORT_BY)) {
      setSortBy(query, json.getString(SORT_BY));
    }
    if (json.has(SORT_ORDER)) {
      String sortOrder = json.getString(SORT_ORDER);
      if (Direction.ASCENDING.getName().equals(sortOrder)) {
        query.asc();
      }
      else if (Direction.DESCENDING.getName().equals(sortOrder)) {
        query.desc();
      }
      else {
        throw new NotValidException("Unknown sort ordering '" + sortOrder + "' in query");
      }
    }

    // expressions
    Iterator jsonIterator = json.keys();
    while (jsonIterator.hasNext()) {
      String key = (String) jsonIterator.next();
      if (key.endsWith("Expression")) {
        String expression = json.getString(key);
        query.addExpression(key.substring(0, key.length() - "Expression".length()), expression);
      }
    }

    return query;
  }
View Full Code Here

  public ExecutionQueryImpl createExecutionQuery() {
    return new ExecutionQueryImpl();
  }

  public TaskQueryImpl createTaskQuery() {
    return new TaskQueryImpl();
  }
View Full Code Here

    }
  }


  public static TaskQueryDto fromQuery(Query<?, ?> query) {
    TaskQueryImpl taskQuery = (TaskQueryImpl) query;

    TaskQueryDto dto = new TaskQueryDto();

    dto.activityInstanceIdIn = taskQuery.getActivityInstanceIdIn();
    dto.assignee = taskQuery.getAssignee();
    dto.assigneeLike = taskQuery.getAssigneeLike();
    dto.caseDefinitionId = taskQuery.getCaseDefinitionId();
    dto.caseDefinitionKey = taskQuery.getCaseDefinitionKey();
    dto.caseDefinitionName = taskQuery.getCaseDefinitionName();
    dto.caseDefinitionNameLike = taskQuery.getCaseDefinitionNameLike();
    dto.caseExecutionId = taskQuery.getCaseExecutionId();
    dto.caseInstanceBusinessKey = taskQuery.getCaseInstanceBusinessKey();
    dto.caseInstanceBusinessKeyLike = taskQuery.getCaseInstanceBusinessKeyLike();
    dto.caseInstanceId = taskQuery.getCaseInstanceId();

    dto.candidateUser = taskQuery.getCandidateUser();
    dto.candidateGroup = taskQuery.getCandidateGroup();
    dto.candidateGroups = taskQuery.getCandidateGroupsInternal();

    dto.processInstanceBusinessKey = taskQuery.getProcessInstanceBusinessKey();
    dto.processInstanceBusinessKeyLike = taskQuery.getProcessInstanceBusinessKeyLike();
    dto.processDefinitionKey = taskQuery.getProcessDefinitionKey();
    dto.processDefinitionId = taskQuery.getProcessDefinitionId();
    dto.executionId = taskQuery.getExecutionId();
    dto.activityInstanceIdIn = taskQuery.getActivityInstanceIdIn();
    dto.processDefinitionName = taskQuery.getProcessDefinitionName();
    dto.processDefinitionNameLike = taskQuery.getProcessDefinitionNameLike();
    dto.processInstanceId = taskQuery.getProcessInstanceId();
    dto.assignee = taskQuery.getAssignee();
    dto.assigneeLike = taskQuery.getAssigneeLike();
    dto.taskDefinitionKey = taskQuery.getKey();
    dto.taskDefinitionKeyLike = taskQuery.getKeyLike();
    dto.description = taskQuery.getDescription();
    dto.descriptionLike = taskQuery.getDescriptionLike();
    dto.involvedUser = taskQuery.getInvolvedUser();
    dto.maxPriority = taskQuery.getMaxPriority();
    dto.minPriority = taskQuery.getMinPriority();
    dto.name = taskQuery.getName();
    dto.nameLike = taskQuery.getNameLike();
    dto.owner = taskQuery.getOwner();
    dto.priority = taskQuery.getPriority();
    dto.unassigned = taskQuery.isUnassignedInternal();

    dto.dueAfter = taskQuery.getDueAfter();
    dto.dueBefore = taskQuery.getDueBefore();
    dto.dueDate = taskQuery.getDueDate();
    dto.followUpAfter = taskQuery.getFollowUpAfter();

    if (taskQuery.isFollowUpNullAccepted()) {
      dto.followUpBeforeOrNotExistent = taskQuery.getFollowUpBefore();
    } else {
      dto.followUpBefore = taskQuery.getFollowUpBefore();
    }
    dto.followUpDate = taskQuery.getFollowUpDate();
    dto.createdAfter = taskQuery.getCreateTimeAfter();
    dto.createdBefore = taskQuery.getCreateTimeBefore();
    dto.createdOn = taskQuery.getCreateTime();

    if (taskQuery.getDelegationState() != null) {
      dto.delegationState = taskQuery.getDelegationState().toString();
    }

    dto.processVariables = new ArrayList<VariableQueryParameterDto>();
    dto.taskVariables = new ArrayList<VariableQueryParameterDto>();
    dto.caseInstanceVariables = new ArrayList<VariableQueryParameterDto>();
    for (TaskQueryVariableValue variableValue : taskQuery.getVariables()) {
      VariableQueryParameterDto variableValueDto = new VariableQueryParameterDto(variableValue);

      if (variableValue.isProcessInstanceVariable()) {
        dto.processVariables.add(variableValueDto);
      } else if (variableValue.isLocal()) {
        dto.taskVariables.add(variableValueDto);
      } else {
        dto.caseInstanceVariables.add(variableValueDto);
      }
    }

    if (taskQuery.getSuspensionState() == SuspensionState.ACTIVE) {
      dto.active = true;
    }
    if (taskQuery.getSuspensionState() == SuspensionState.SUSPENDED) {
      dto.suspended = true;
    }

    // expressions
    Map<String, String> expressions = taskQuery.getExpressions();
    if (expressions.containsKey("taskAssignee")) {
      dto.setAssigneeExpression(expressions.get("taskAssignee"));
    }
    if (expressions.containsKey("taskAssigneeLike")) {
      dto.setAssigneeLikeExpression(expressions.get("taskAssigneeLike"));
    }
    if (expressions.containsKey("taskOwner")) {
      dto.setOwnerExpression(expressions.get("taskOwner"));
    }
    if (expressions.containsKey("taskCandidateUser")) {
      dto.setCandidateUserExpression(expressions.get("taskCandidateUser"));
    }
    if (expressions.containsKey("taskInvolvedUser")) {
      dto.setInvolvedUserExpression(expressions.get("taskInvolvedUser"));
    }
    if (expressions.containsKey("taskCandidateGroup")) {
      dto.setCandidateGroupExpression(expressions.get("taskCandidateGroup"));
    }
    if (expressions.containsKey("taskCandidateGroupIn")) {
      dto.setCandidateGroupsExpression(expressions.get("taskCandidateGroupIn"));
    }
    if (expressions.containsKey("taskCreatedOne")) {
      dto.setCreatedOnExpression(expressions.get("taskCreatedOne"));
    }
    if (expressions.containsKey("taskCreatedBefore")) {
      dto.setCreatedBeforeExpression(expressions.get("taskCreatedBefore"));
    }
    if (expressions.containsKey("taskCreatedAfter")) {
      dto.setCreatedAfterExpression(expressions.get("taskCreatedAfter"));
    }
    if (expressions.containsKey("dueDate")) {
      dto.setDueDateExpression(expressions.get("dueDate"));
    }
    if (expressions.containsKey("dueBefore")) {
      dto.setDueBeforeExpression(expressions.get("dueBefore"));
    }
    if (expressions.containsKey("dueAfter")) {
      dto.setDueAfterExpression(expressions.get("dueAfter"));
    }
    if (expressions.containsKey("followUpDate")) {
      dto.setFollowUpDateExpression(expressions.get("followUpDate"));
    }

    if (!taskQuery.isFollowUpNullAccepted()) {
      if (expressions.containsKey("followUpBefore")) {
        dto.setFollowUpBeforeExpression(expressions.get("followUpBefore"));
      }
    } else {
      if (expressions.containsKey("followUpBefore")) {
View Full Code Here

  public boolean matches(Object argument) {
    if (argument == null) {
      return false;
    }

    TaskQueryImpl argumentQuery = (TaskQueryImpl) argument;

    if (taskName != null) {
      return taskName.equals(argumentQuery.getName());
    } else if (argumentQuery.getName() != null) {
      return false;
    }

    return true;
  }
View Full Code Here

    when(processEngine.getAuthorizationService()).thenReturn(authorizationServiceMock);
    when(processEngine.getIdentityService()).thenReturn(identityServiceMock);

    TaskService taskService = processEngine.getTaskService();
    when(taskService.createTaskQuery()).thenReturn(new TaskQueryImpl());

    variableInstanceQueryMock = mock(VariableInstanceQuery.class);
    when(processEngine.getRuntimeService().createVariableInstanceQuery())
      .thenReturn(variableInstanceQueryMock);
    when(variableInstanceQueryMock.variableScopeIdIn((String) anyVararg()))
View Full Code Here

    verify(filterServiceMock).getFilter(eq(MockProvider.NON_EXISTING_ID));
  }

  @Test
  public void testGetFilterWithCandidateGroupQuery() {
    TaskQueryImpl query = new TaskQueryImpl();
    query.taskCandidateGroup("abc");
    Filter filter = new FilterEntity("Task").setName("test").setQuery(query);
    when(filterServiceMock.getFilter(EXAMPLE_FILTER_ID)).thenReturn(filter);

    given()
      .pathParam("id", EXAMPLE_FILTER_ID)
View Full Code Here

      .get(SINGLE_FILTER_URL);
  }

  @Test
  public void testGetFilterWithCandidateUserQuery() {
    TaskQueryImpl query = new TaskQueryImpl();
    query.taskCandidateUser("abc");
    Filter filter = new FilterEntity("Task").setName("test").setQuery(query);
    when(filterServiceMock.getFilter(EXAMPLE_FILTER_ID)).thenReturn(filter);

    given()
      .pathParam("id", EXAMPLE_FILTER_ID)
View Full Code Here

      .get(SINGLE_FILTER_URL);
  }

  @Test
  public void testGetFilterWithFollowUpBeforeOrNotExistentExpression() {
    TaskQueryImpl query = new TaskQueryImpl();
    query.followUpBeforeOrNotExistentExpression("#{now()}");
    Filter filter = new FilterEntity("Task").setName("test").setQuery(query);
    when(filterServiceMock.getFilter(EXAMPLE_FILTER_ID)).thenReturn(filter);

    given()
      .pathParam("id", EXAMPLE_FILTER_ID)
View Full Code Here

  public ExecutionQueryImpl createExecutionQuery() {
    return new ExecutionQueryImpl();
  }

  public TaskQueryImpl createTaskQuery() {
    return new TaskQueryImpl();
  }
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.impl.TaskQueryImpl

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.