Search in sources :

Example 6 with JSONObject

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

the class DeleteProcessInstanceBatchConfigurationJsonConverter method toJsonObject.

public JSONObject toJsonObject(DeleteProcessInstanceBatchConfiguration configuration) {
    JSONObject json = new JSONObject();
    JsonUtil.addField(json, DELETE_REASON, configuration.getDeleteReason());
    JsonUtil.addListField(json, PROCESS_INSTANCE_IDS, configuration.getIds());
    JsonUtil.addField(json, SKIP_CUSTOM_LISTENERS, configuration.isSkipCustomListeners());
    JsonUtil.addField(json, SKIP_SUBPROCESSES, configuration.isSkipSubprocesses());
    return json;
}
Also used : JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject)

Example 7 with JSONObject

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

the class UpdateProcessInstancesSuspendStateBatchConfigurationJsonConverter method toJsonObject.

public JSONObject toJsonObject(UpdateProcessInstancesSuspendStateBatchConfiguration configuration) {
    JSONObject json = new JSONObject();
    JsonUtil.addListField(json, PROCESS_INSTANCE_IDS, configuration.getIds());
    JsonUtil.addField(json, SUSPENDING, configuration.getSuspended());
    return json;
}
Also used : JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject)

Example 8 with JSONObject

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

the class FilterEntity method setPropertiesInternal.

public void setPropertiesInternal(String properties) {
    if (properties != null) {
        JSONObject jsonObject = new JSONObject(properties);
        this.properties = JsonUtil.jsonObjectAsMap(jsonObject);
    } else {
        this.properties = null;
    }
}
Also used : JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject)

Example 9 with JSONObject

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

the class JsonUtil method jsonArrayAsList.

/**
 * Converts a {@link JSONArray} to a {@link List}. It supports nested {@link JSONObject}
 * and {@link JSONArray}.
 *
 * @param jsonArray the json array to convert
 * @return the resulting map
 */
public static List<Object> jsonArrayAsList(JSONArray jsonArray) {
    if (jsonArray == null) {
        return null;
    } else {
        List<Object> list = new ArrayList<Object>();
        for (int i = 0; i < jsonArray.length(); i++) {
            Object value = optJavaNull(jsonArray.get(i));
            if (JSONObject.class.isInstance(value)) {
                value = jsonObjectAsMap(JSONObject.class.cast(value));
            } else if (JSONArray.class.isInstance(value)) {
                value = jsonArrayAsList(JSONArray.class.cast(value));
            }
            list.add(value);
        }
        return list;
    }
}
Also used : ArrayList(java.util.ArrayList) JSONArray(org.camunda.bpm.engine.impl.util.json.JSONArray) JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject)

Example 10 with JSONObject

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

the class FilterTaskQueryTest method testDeprecatedOrderingFormatDeserializationSecondaryOrdering.

/**
 * Tests compatibility with serialization format that was used in 7.2
 */
@SuppressWarnings("deprecation")
public void testDeprecatedOrderingFormatDeserializationSecondaryOrdering() {
    String sortByNameAsc = "RES." + TaskQueryProperty.NAME.getName() + " " + Direction.ASCENDING.getName();
    String secondaryOrdering = sortByNameAsc + ", RES." + TaskQueryProperty.ASSIGNEE.getName() + " " + Direction.DESCENDING.getName();
    JsonTaskQueryConverter converter = (JsonTaskQueryConverter) FilterEntity.queryConverter.get(EntityTypes.TASK);
    JSONObject queryJson = converter.toJsonObject(filter.<TaskQuery>getQuery());
    // when I apply a secondary ordering
    queryJson.put(JsonTaskQueryConverter.ORDER_BY, secondaryOrdering);
    TaskQueryImpl deserializedTaskQuery = (TaskQueryImpl) converter.toObject(queryJson);
    // then the ordering is applied accordingly
    assertEquals(2, deserializedTaskQuery.getOrderingProperties().size());
    QueryOrderingProperty orderingProperty1 = deserializedTaskQuery.getOrderingProperties().get(0);
    assertNull(orderingProperty1.getRelation());
    assertEquals("asc", orderingProperty1.getDirection().getName());
    assertNull(orderingProperty1.getRelationConditions());
    assertTrue(orderingProperty1.isContainedProperty());
    assertEquals(TaskQueryProperty.NAME.getName(), orderingProperty1.getQueryProperty().getName());
    assertNull(orderingProperty1.getQueryProperty().getFunction());
    QueryOrderingProperty orderingProperty2 = deserializedTaskQuery.getOrderingProperties().get(1);
    assertNull(orderingProperty2.getRelation());
    assertEquals("desc", orderingProperty2.getDirection().getName());
    assertNull(orderingProperty2.getRelationConditions());
    assertTrue(orderingProperty2.isContainedProperty());
    assertEquals(TaskQueryProperty.ASSIGNEE.getName(), orderingProperty2.getQueryProperty().getName());
    assertNull(orderingProperty2.getQueryProperty().getFunction());
}
Also used : JsonTaskQueryConverter(org.camunda.bpm.engine.impl.json.JsonTaskQueryConverter) JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty)

Aggregations

JSONObject (org.camunda.bpm.engine.impl.util.json.JSONObject)40 ArrayList (java.util.ArrayList)10 JSONArray (org.camunda.bpm.engine.impl.util.json.JSONArray)5 TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)4 QueryOrderingProperty (org.camunda.bpm.engine.impl.QueryOrderingProperty)3 JsonTaskQueryConverter (org.camunda.bpm.engine.impl.json.JsonTaskQueryConverter)3 QueryProperty (org.camunda.bpm.engine.query.QueryProperty)3 Map (java.util.Map)2 QueryOperator (org.camunda.bpm.engine.impl.QueryOperator)2 Test (org.junit.Test)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Writer (java.io.Writer)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 HttpPost (org.apache.http.client.methods.HttpPost)1 Direction (org.camunda.bpm.engine.impl.Direction)1 QueryEntityRelationCondition (org.camunda.bpm.engine.impl.QueryEntityRelationCondition)1