public static final String SORT_BY = "sortBy";
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;
}