Search in sources :

Example 11 with JSONObject

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

the class FilterTaskQueryTest method testDeprecatedOrderingFormatDeserializationSingleOrdering.

/**
 * Tests compatibility with serialization format that was used in 7.2
 */
@SuppressWarnings("deprecation")
public void testDeprecatedOrderingFormatDeserializationSingleOrdering() {
    String sortByNameAsc = "RES." + TaskQueryProperty.NAME.getName() + " " + Direction.ASCENDING.getName();
    JsonTaskQueryConverter converter = (JsonTaskQueryConverter) FilterEntity.queryConverter.get(EntityTypes.TASK);
    JSONObject queryJson = converter.toJsonObject(filter.<TaskQuery>getQuery());
    // when I apply a specific ordering by one dimension
    queryJson.put(JsonTaskQueryConverter.ORDER_BY, sortByNameAsc);
    TaskQueryImpl deserializedTaskQuery = (TaskQueryImpl) converter.toObject(queryJson);
    // then the ordering is applied accordingly
    assertEquals(1, deserializedTaskQuery.getOrderingProperties().size());
    QueryOrderingProperty orderingProperty = deserializedTaskQuery.getOrderingProperties().get(0);
    assertNull(orderingProperty.getRelation());
    assertEquals("asc", orderingProperty.getDirection().getName());
    assertNull(orderingProperty.getRelationConditions());
    assertTrue(orderingProperty.isContainedProperty());
    assertEquals(TaskQueryProperty.NAME.getName(), orderingProperty.getQueryProperty().getName());
    assertNull(orderingProperty.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)

Example 12 with JSONObject

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

the class JsonQueryFilteringPropertyConverter method toObject.

public QueryEntityRelationCondition toObject(JSONObject jsonObject) {
    // this is limited in that it allows only String values;
    // that is sufficient for current use case with task filters
    // but could be extended by a data type in the future
    Object scalarValue = null;
    if (jsonObject.has(SCALAR_VALUE)) {
        scalarValue = jsonObject.getString(SCALAR_VALUE);
    }
    QueryProperty baseProperty = null;
    if (jsonObject.has(BASE_PROPERTY)) {
        baseProperty = new QueryPropertyImpl(jsonObject.getString(BASE_PROPERTY));
    }
    QueryProperty comparisonProperty = null;
    if (jsonObject.has(COMPARISON_PROPERTY)) {
        comparisonProperty = new QueryPropertyImpl(jsonObject.getString(COMPARISON_PROPERTY));
    }
    return new QueryEntityRelationCondition(baseProperty, comparisonProperty, scalarValue);
}
Also used : QueryPropertyImpl(org.camunda.bpm.engine.impl.QueryPropertyImpl) QueryProperty(org.camunda.bpm.engine.query.QueryProperty) JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject) QueryEntityRelationCondition(org.camunda.bpm.engine.impl.QueryEntityRelationCondition)

Example 13 with JSONObject

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

the class MigrationBatchConfigurationJsonConverter method toJsonObject.

public JSONObject toJsonObject(MigrationBatchConfiguration configuration) {
    JSONObject json = new JSONObject();
    JsonUtil.addField(json, MIGRATION_PLAN, MigrationPlanJsonConverter.INSTANCE, configuration.getMigrationPlan());
    JsonUtil.addListField(json, PROCESS_INSTANCE_IDS, configuration.getIds());
    JsonUtil.addField(json, SKIP_LISTENERS, configuration.isSkipCustomListeners());
    JsonUtil.addField(json, SKIP_IO_MAPPINGS, configuration.isSkipIoMappings());
    return json;
}
Also used : JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject)

Example 14 with JSONObject

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

the class MigrationBatchConfigurationJsonConverter method readProcessInstanceIds.

protected List<String> readProcessInstanceIds(JSONObject jsonObject) {
    List<Object> objects = JsonUtil.jsonArrayAsList(jsonObject.getJSONArray(PROCESS_INSTANCE_IDS));
    List<String> processInstanceIds = new ArrayList<String>();
    for (Object object : objects) {
        processInstanceIds.add((String) object);
    }
    return processInstanceIds;
}
Also used : ArrayList(java.util.ArrayList) JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject)

Example 15 with JSONObject

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

the class MigrationPlanJsonConverter method toJsonObject.

public JSONObject toJsonObject(MigrationPlan migrationPlan) {
    JSONObject json = new JSONObject();
    JsonUtil.addField(json, SOURCE_PROCESS_DEFINITION_ID, migrationPlan.getSourceProcessDefinitionId());
    JsonUtil.addField(json, TARGET_PROCESS_DEFINITION_ID, migrationPlan.getTargetProcessDefinitionId());
    JsonUtil.addListField(json, INSTRUCTIONS, MigrationInstructionJsonConverter.INSTANCE, migrationPlan.getInstructions());
    return json;
}
Also used : JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject)

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