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);
}
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;
}
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;
}
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;
}
}
Aggregations