Search in sources :

Example 1 with VariableOrderProperty

use of org.camunda.bpm.engine.impl.VariableOrderProperty in project camunda-bpm-platform by camunda.

the class TaskQueryDto method convertQueryOrderingPropertiesToSortingDtos.

public static List<SortingDto> convertQueryOrderingPropertiesToSortingDtos(List<QueryOrderingProperty> orderingProperties) {
    List<SortingDto> sortingDtos = new ArrayList<SortingDto>();
    for (QueryOrderingProperty orderingProperty : orderingProperties) {
        SortingDto sortingDto;
        if (orderingProperty instanceof VariableOrderProperty) {
            sortingDto = convertVariableOrderPropertyToSortingDto((VariableOrderProperty) orderingProperty);
        } else {
            sortingDto = convertQueryOrderingPropertyToSortingDto(orderingProperty);
        }
        sortingDtos.add(sortingDto);
    }
    return sortingDtos;
}
Also used : SortingDto(org.camunda.bpm.engine.rest.dto.SortingDto) ArrayList(java.util.ArrayList) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty) VariableOrderProperty(org.camunda.bpm.engine.impl.VariableOrderProperty)

Example 2 with VariableOrderProperty

use of org.camunda.bpm.engine.impl.VariableOrderProperty in project camunda-bpm-platform by camunda.

the class FilterTaskQueryTest method testOrderByVariables.

public void testOrderByVariables() {
    // given
    TaskQueryImpl query = (TaskQueryImpl) taskService.createTaskQuery().orderByProcessVariable("foo", ValueType.STRING).asc().orderByExecutionVariable("foo", ValueType.STRING).asc().orderByCaseInstanceVariable("foo", ValueType.STRING).asc().orderByCaseExecutionVariable("foo", ValueType.STRING).asc().orderByTaskVariable("foo", ValueType.STRING).asc();
    Filter filter = filterService.newTaskFilter("extendedOrFilter");
    filter.setQuery(query);
    filterService.saveFilter(filter);
    // when
    filter = filterService.getFilter(filter.getId());
    // then
    List<QueryOrderingProperty> expectedOrderingProperties = new ArrayList<QueryOrderingProperty>(query.getOrderingProperties());
    verifyOrderingProperties(expectedOrderingProperties, ((TaskQueryImpl) filter.getQuery()).getOrderingProperties());
    for (QueryOrderingProperty prop : ((TaskQueryImpl) filter.getQuery()).getOrderingProperties()) {
        assertTrue(prop instanceof VariableOrderProperty);
    }
}
Also used : TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) Filter(org.camunda.bpm.engine.filter.Filter) ArrayList(java.util.ArrayList) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty) VariableOrderProperty(org.camunda.bpm.engine.impl.VariableOrderProperty)

Example 3 with VariableOrderProperty

use of org.camunda.bpm.engine.impl.VariableOrderProperty 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;
}
Also used : QueryPropertyImpl(org.camunda.bpm.engine.impl.QueryPropertyImpl) VariableInstanceQueryProperty(org.camunda.bpm.engine.impl.VariableInstanceQueryProperty) QueryProperty(org.camunda.bpm.engine.query.QueryProperty) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty) VariableOrderProperty(org.camunda.bpm.engine.impl.VariableOrderProperty) QueryEntityRelationCondition(org.camunda.bpm.engine.impl.QueryEntityRelationCondition)

Aggregations

QueryOrderingProperty (org.camunda.bpm.engine.impl.QueryOrderingProperty)3 VariableOrderProperty (org.camunda.bpm.engine.impl.VariableOrderProperty)3 ArrayList (java.util.ArrayList)2 Filter (org.camunda.bpm.engine.filter.Filter)1 QueryEntityRelationCondition (org.camunda.bpm.engine.impl.QueryEntityRelationCondition)1 QueryPropertyImpl (org.camunda.bpm.engine.impl.QueryPropertyImpl)1 TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)1 VariableInstanceQueryProperty (org.camunda.bpm.engine.impl.VariableInstanceQueryProperty)1 QueryProperty (org.camunda.bpm.engine.query.QueryProperty)1 SortingDto (org.camunda.bpm.engine.rest.dto.SortingDto)1