Search in sources :

Example 6 with JSONArray

use of org.camunda.bpm.engine.impl.util.json.JSONArray in project camunda-bpm-platform by camunda.

the class JsonTaskQueryConverter method addVariable.

protected void addVariable(JSONObject json, String variableType, TaskQueryVariableValue variable) {
    JSONArray array = json.optJSONArray(variableType);
    if (array == null) {
        array = new JSONArray();
    }
    addVariable(array, variable);
    json.put(variableType, array);
}
Also used : JSONArray(org.camunda.bpm.engine.impl.util.json.JSONArray)

Example 7 with JSONArray

use of org.camunda.bpm.engine.impl.util.json.JSONArray in project camunda-bpm-platform by camunda.

the class JsonTaskQueryConverter method toJsonObject.

public JSONObject toJsonObject(TaskQuery taskQuery, boolean isOrQueryActive) {
    JSONObject json = new JSONObject();
    TaskQueryImpl query = (TaskQueryImpl) taskQuery;
    addField(json, TASK_ID, query.getTaskId());
    addField(json, NAME, query.getName());
    addField(json, NAME_NOT_EQUAL, query.getNameNotEqual());
    addField(json, NAME_LIKE, query.getNameLike());
    addField(json, NAME_NOT_LIKE, query.getNameNotLike());
    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());
    addDefaultField(json, ASSIGNED, false, query.isAssigned());
    addField(json, DELEGATION_STATE, query.getDelegationStateString());
    addField(json, CANDIDATE_USER, query.getCandidateUser());
    addField(json, CANDIDATE_GROUP, query.getCandidateGroup());
    addListField(json, CANDIDATE_GROUPS, query.getCandidateGroupsInternal());
    addDefaultField(json, WITH_CANDIDATE_GROUPS, false, query.isWithCandidateGroups());
    addDefaultField(json, WITHOUT_CANDIDATE_GROUPS, false, query.isWithoutCandidateGroups());
    addDefaultField(json, WITH_CANDIDATE_USERS, false, query.isWithCandidateUsers());
    addDefaultField(json, WITHOUT_CANDIDATE_USERS, false, query.isWithoutCandidateUsers());
    addField(json, INCLUDE_ASSIGNED_TASKS, query.isIncludeAssignedTasksInternal());
    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());
    addArrayField(json, KEYS, query.getKeys());
    addField(json, KEY_LIKE, query.getKeyLike());
    addField(json, PARENT_TASK_ID, query.getParentTaskId());
    addField(json, PROCESS_DEFINITION_KEY, query.getProcessDefinitionKey());
    addArrayField(json, PROCESS_DEFINITION_KEYS, query.getProcessDefinitionKeys());
    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());
    addArrayField(json, PROCESS_INSTANCE_BUSINESS_KEYS, query.getProcessInstanceBusinessKeys());
    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());
    addSuspensionStateField(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());
    addTenantIdFields(json, query);
    if (query.getQueries().size() > 1 && !isOrQueryActive) {
        JSONArray orQueries = new JSONArray();
        for (TaskQueryImpl orQuery : query.getQueries()) {
            if (orQuery != null && orQuery.isOrQueryActive()) {
                orQueries.put(toJsonObject(orQuery, true));
            }
        }
        addField(json, OR_QUERIES, orQueries);
    }
    if (query.getOrderingProperties() != null && !query.getOrderingProperties().isEmpty()) {
        addField(json, ORDERING_PROPERTIES, JsonQueryOrderingPropertyConverter.ARRAY_CONVERTER.toJsonArray(query.getOrderingProperties()));
    }
    // expressions
    for (Map.Entry<String, String> expressionEntry : query.getExpressions().entrySet()) {
        json.put(expressionEntry.getKey() + "Expression", expressionEntry.getValue());
    }
    return json;
}
Also used : JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) JSONArray(org.camunda.bpm.engine.impl.util.json.JSONArray) Map(java.util.Map)

Example 8 with JSONArray

use of org.camunda.bpm.engine.impl.util.json.JSONArray in project camunda-bpm-platform by camunda.

the class JsonArrayOfObjectsConverter method toJsonArray.

public JSONArray toJsonArray(List<T> objects) {
    JSONArray jsonArray = new JSONArray();
    for (T object : objects) {
        JSONObject jsonObject = objectConverter.toJsonObject(object);
        jsonArray.put(jsonObject);
    }
    return jsonArray;
}
Also used : JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject) JSONArray(org.camunda.bpm.engine.impl.util.json.JSONArray)

Example 9 with JSONArray

use of org.camunda.bpm.engine.impl.util.json.JSONArray in project camunda-bpm-platform by camunda.

the class JsonUtil method jsonObjectAsMap.

/**
 * Converts a {@link JSONObject} to a {@link Map}. It supports nested {@link JSONObject}
 * and {@link JSONArray}.
 *
 * @param jsonObject the json object to convert
 * @return the resulting map
 */
public static Map<String, Object> jsonObjectAsMap(JSONObject jsonObject) {
    if (jsonObject == null) {
        return null;
    } else {
        Map<String, Object> map = new HashMap<String, Object>();
        Iterator keys = jsonObject.keys();
        while (keys.hasNext()) {
            String key = (String) keys.next();
            Object value = optJavaNull(jsonObject.get(key));
            if (JSONObject.class.isInstance(value)) {
                value = jsonObjectAsMap(JSONObject.class.cast(value));
            } else if (JSONArray.class.isInstance(value)) {
                value = jsonArrayAsList(JSONArray.class.cast(value));
            }
            map.put(key, value);
        }
        return map;
    }
}
Also used : HashMap(java.util.HashMap) Iterator(java.util.Iterator) JSONArray(org.camunda.bpm.engine.impl.util.json.JSONArray) JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject)

Aggregations

JSONArray (org.camunda.bpm.engine.impl.util.json.JSONArray)9 JSONObject (org.camunda.bpm.engine.impl.util.json.JSONObject)7 Date (java.util.Date)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Direction (org.camunda.bpm.engine.impl.Direction)1 QueryOrderingProperty (org.camunda.bpm.engine.impl.QueryOrderingProperty)1 VariableInstanceQueryProperty (org.camunda.bpm.engine.impl.VariableInstanceQueryProperty)1 JsonUtil.jsonArrayAsList (org.camunda.bpm.engine.impl.util.JsonUtil.jsonArrayAsList)1 JsonUtil.jsonObjectAsMap (org.camunda.bpm.engine.impl.util.JsonUtil.jsonObjectAsMap)1 QueryProperty (org.camunda.bpm.engine.query.QueryProperty)1