Package org.camunda.bpm.engine.impl

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


  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());
    if (query.getCandidateUser() == null && query.getCandidateGroup() == null) {
      addListField(json, CANDIDATE_GROUPS, query.getCandidateGroups());
    }
    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());
    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(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

TOP

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

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.