Search in sources :

Example 1 with QueryProperty

use of org.camunda.bpm.engine.query.QueryProperty in project camunda-bpm-platform by camunda.

the class TaskQueryDto method sortByValueForQueryEntityRelationCondition.

public static String sortByValueForQueryEntityRelationCondition(QueryEntityRelationCondition relationCondition) {
    QueryProperty property = relationCondition.getProperty();
    QueryProperty comparisonProperty = relationCondition.getComparisonProperty();
    if (VariableInstanceQueryProperty.EXECUTION_ID.equals(property) && TaskQueryProperty.PROCESS_INSTANCE_ID.equals(comparisonProperty)) {
        return SORT_BY_PROCESS_VARIABLE;
    } else if (VariableInstanceQueryProperty.EXECUTION_ID.equals(property) && TaskQueryProperty.EXECUTION_ID.equals(comparisonProperty)) {
        return SORT_BY_EXECUTION_VARIABLE;
    } else if (VariableInstanceQueryProperty.TASK_ID.equals(property) && TaskQueryProperty.TASK_ID.equals(comparisonProperty)) {
        return SORT_BY_TASK_VARIABLE;
    } else if (VariableInstanceQueryProperty.CASE_EXECUTION_ID.equals(property) && TaskQueryProperty.CASE_INSTANCE_ID.equals(comparisonProperty)) {
        return SORT_BY_CASE_INSTANCE_VARIABLE;
    } else if (VariableInstanceQueryProperty.CASE_EXECUTION_ID.equals(property) && TaskQueryProperty.CASE_EXECUTION_ID.equals(comparisonProperty)) {
        return SORT_BY_CASE_EXECUTION_VARIABLE;
    } else {
        throw new RestException("Unknown relation condition for task query  with query property " + property + " and comparison property " + comparisonProperty);
    }
}
Also used : TaskQueryProperty(org.camunda.bpm.engine.impl.TaskQueryProperty) QueryProperty(org.camunda.bpm.engine.query.QueryProperty) VariableInstanceQueryProperty(org.camunda.bpm.engine.impl.VariableInstanceQueryProperty) RestException(org.camunda.bpm.engine.rest.exception.RestException)

Example 2 with QueryProperty

use of org.camunda.bpm.engine.query.QueryProperty in project camunda-bpm-platform by camunda.

the class MybatisJoinHelper method orderBySelection.

public static String orderBySelection(QueryOrderingProperty orderingProperty, int index) {
    QueryProperty queryProperty = orderingProperty.getQueryProperty();
    StringBuilder sb = new StringBuilder();
    if (queryProperty.getFunction() != null) {
        sb.append(queryProperty.getFunction());
        sb.append("(");
    }
    sb.append(tableAlias(orderingProperty.getRelation(), index));
    sb.append(".");
    sb.append(queryProperty.getName());
    if (queryProperty.getFunction() != null) {
        sb.append(")");
    }
    return sb.toString();
}
Also used : QueryProperty(org.camunda.bpm.engine.query.QueryProperty)

Example 3 with QueryProperty

use of org.camunda.bpm.engine.query.QueryProperty in project camunda-bpm-platform by camunda.

the class JsonLegacyQueryOrderingPropertyConverter method fromOrderByString.

public List<QueryOrderingProperty> fromOrderByString(String orderByString) {
    List<QueryOrderingProperty> properties = new ArrayList<QueryOrderingProperty>();
    String[] orderByClauses = orderByString.split(ORDER_BY_DELIMITER);
    for (String orderByClause : orderByClauses) {
        orderByClause = orderByClause.trim();
        String[] clauseParts = orderByClause.split(" ");
        if (clauseParts.length == 0) {
            continue;
        } else if (clauseParts.length > 2) {
            throw new ProcessEngineException("Invalid order by clause: " + orderByClause);
        }
        String function = null;
        String propertyPart = clauseParts[0];
        int functionArgumentBegin = propertyPart.indexOf("(");
        if (functionArgumentBegin >= 0) {
            function = propertyPart.substring(0, functionArgumentBegin);
            int functionArgumentEnd = propertyPart.indexOf(")");
            propertyPart = propertyPart.substring(functionArgumentBegin + 1, functionArgumentEnd);
        }
        String[] propertyParts = propertyPart.split("\\.");
        String property = null;
        if (propertyParts.length == 1) {
            property = propertyParts[0];
        } else if (propertyParts.length == 2) {
            property = propertyParts[1];
        } else {
            throw new ProcessEngineException("Invalid order by property part: " + clauseParts[0]);
        }
        QueryProperty queryProperty = new QueryPropertyImpl(property, function);
        Direction direction = null;
        if (clauseParts.length == 2) {
            String directionPart = clauseParts[1];
            direction = Direction.findByName(directionPart);
        }
        QueryOrderingProperty orderingProperty = new QueryOrderingProperty(null, queryProperty);
        orderingProperty.setDirection(direction);
        properties.add(orderingProperty);
    }
    return properties;
}
Also used : QueryPropertyImpl(org.camunda.bpm.engine.impl.QueryPropertyImpl) ArrayList(java.util.ArrayList) QueryProperty(org.camunda.bpm.engine.query.QueryProperty) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty) Direction(org.camunda.bpm.engine.impl.Direction) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 4 with QueryProperty

use of org.camunda.bpm.engine.query.QueryProperty 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 5 with QueryProperty

use of org.camunda.bpm.engine.query.QueryProperty in project camunda-bpm-platform by camunda.

the class JsonQueryOrderingPropertyConverter method toJsonObject.

public JSONObject toJsonObject(QueryOrderingProperty property) {
    JSONObject jsonObject = new JSONObject();
    JsonUtil.addField(jsonObject, RELATION, property.getRelation());
    QueryProperty queryProperty = property.getQueryProperty();
    if (queryProperty != null) {
        JsonUtil.addField(jsonObject, QUERY_PROPERTY, queryProperty.getName());
        JsonUtil.addField(jsonObject, QUERY_PROPERTY_FUNCTION, queryProperty.getFunction());
    }
    Direction direction = property.getDirection();
    if (direction != null) {
        JsonUtil.addField(jsonObject, DIRECTION, direction.getName());
    }
    if (property.hasRelationConditions()) {
        JSONArray relationConditionsJson = JsonQueryFilteringPropertyConverter.ARRAY_CONVERTER.toJsonArray(property.getRelationConditions());
        JsonUtil.addField(jsonObject, RELATION_CONDITIONS, relationConditionsJson);
    }
    return jsonObject;
}
Also used : JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject) VariableInstanceQueryProperty(org.camunda.bpm.engine.impl.VariableInstanceQueryProperty) QueryProperty(org.camunda.bpm.engine.query.QueryProperty) JSONArray(org.camunda.bpm.engine.impl.util.json.JSONArray) Direction(org.camunda.bpm.engine.impl.Direction)

Aggregations

QueryProperty (org.camunda.bpm.engine.query.QueryProperty)8 QueryPropertyImpl (org.camunda.bpm.engine.impl.QueryPropertyImpl)3 VariableInstanceQueryProperty (org.camunda.bpm.engine.impl.VariableInstanceQueryProperty)3 JSONObject (org.camunda.bpm.engine.impl.util.json.JSONObject)3 Direction (org.camunda.bpm.engine.impl.Direction)2 QueryEntityRelationCondition (org.camunda.bpm.engine.impl.QueryEntityRelationCondition)2 QueryOrderingProperty (org.camunda.bpm.engine.impl.QueryOrderingProperty)2 ArrayList (java.util.ArrayList)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 TaskQueryProperty (org.camunda.bpm.engine.impl.TaskQueryProperty)1 VariableOrderProperty (org.camunda.bpm.engine.impl.VariableOrderProperty)1 JSONArray (org.camunda.bpm.engine.impl.util.json.JSONArray)1 RestException (org.camunda.bpm.engine.rest.exception.RestException)1