use of org.camunda.bpm.engine.impl.QueryOrderingProperty in project camunda-bpm-platform by camunda.
the class FilterTaskQueryTest method testDeprecatedOrderingFormatDeserializationFunctionOrdering.
/**
* Tests compatibility with serialization format that was used in 7.2
*/
@SuppressWarnings("deprecation")
public void testDeprecatedOrderingFormatDeserializationFunctionOrdering() {
String orderingWithFunction = "LOWER(RES." + TaskQueryProperty.NAME.getName() + ") asc";
JsonTaskQueryConverter converter = (JsonTaskQueryConverter) FilterEntity.queryConverter.get(EntityTypes.TASK);
JSONObject queryJson = converter.toJsonObject(filter.<TaskQuery>getQuery());
// when I apply an ordering with a function
queryJson.put(JsonTaskQueryConverter.ORDER_BY, orderingWithFunction);
TaskQueryImpl deserializedTaskQuery = (TaskQueryImpl) converter.toObject(queryJson);
assertEquals(1, deserializedTaskQuery.getOrderingProperties().size());
// then the ordering is applied accordingly
QueryOrderingProperty orderingProperty = deserializedTaskQuery.getOrderingProperties().get(0);
assertNull(orderingProperty.getRelation());
assertEquals("asc", orderingProperty.getDirection().getName());
assertNull(orderingProperty.getRelationConditions());
assertFalse(orderingProperty.isContainedProperty());
assertEquals(TaskQueryProperty.NAME_CASE_INSENSITIVE.getName(), orderingProperty.getQueryProperty().getName());
assertEquals(TaskQueryProperty.NAME_CASE_INSENSITIVE.getFunction(), orderingProperty.getQueryProperty().getFunction());
}
use of org.camunda.bpm.engine.impl.QueryOrderingProperty in project camunda-bpm-platform by camunda.
the class JsonQueryOrderingPropertyConverter method toObject.
public QueryOrderingProperty toObject(JSONObject jsonObject) {
String relation = null;
if (jsonObject.has(RELATION)) {
relation = jsonObject.getString(RELATION);
}
QueryOrderingProperty property = null;
if (QueryOrderingProperty.RELATION_VARIABLE.equals(relation)) {
property = new VariableOrderProperty();
} else {
property = new QueryOrderingProperty();
}
property.setRelation(relation);
if (jsonObject.has(QUERY_PROPERTY)) {
String propertyName = jsonObject.getString(QUERY_PROPERTY);
String propertyFunction = null;
if (jsonObject.has(QUERY_PROPERTY_FUNCTION)) {
propertyFunction = jsonObject.getString(QUERY_PROPERTY_FUNCTION);
}
QueryProperty queryProperty = new QueryPropertyImpl(propertyName, propertyFunction);
property.setQueryProperty(queryProperty);
}
if (jsonObject.has(DIRECTION)) {
String direction = jsonObject.getString(DIRECTION);
property.setDirection(Direction.findByName(direction));
}
if (jsonObject.has(RELATION_CONDITIONS)) {
List<QueryEntityRelationCondition> relationConditions = JsonQueryFilteringPropertyConverter.ARRAY_CONVERTER.toObject(jsonObject.getJSONArray(RELATION_CONDITIONS));
property.setRelationConditions(relationConditions);
}
return property;
}
use of org.camunda.bpm.engine.impl.QueryOrderingProperty in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method assertQuerySorting.
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void assertQuerySorting(String property, Query<?, ?> query, Comparable... items) {
AbstractQuery<?, ?> queryImpl = (AbstractQuery<?, ?>) query;
// save order properties to later reverse ordering
List<QueryOrderingProperty> orderProperties = queryImpl.getOrderingProperties();
List<? extends Comparable> sortedList = Arrays.asList(items);
Collections.sort(sortedList);
List<Matcher<Object>> matchers = new ArrayList<Matcher<Object>>();
for (Comparable comparable : sortedList) {
matchers.add(hasProperty(property, equalTo(comparable)));
}
List<?> instances = query.asc().list();
assertEquals(sortedList.size(), instances.size());
assertThat(instances, contains(matchers.toArray(new Matcher[matchers.size()])));
// reverse ordering
for (QueryOrderingProperty orderingProperty : orderProperties) {
orderingProperty.setDirection(Direction.DESCENDING);
}
// reverse matchers
Collections.reverse(matchers);
instances = query.list();
assertEquals(sortedList.size(), instances.size());
assertThat(instances, contains(matchers.toArray(new Matcher[matchers.size()])));
}
Aggregations