Search in sources :

Example 1 with QueryPropertyImpl

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

the class CommentManager method findEventsByTaskId.

@SuppressWarnings("unchecked")
public List<Event> findEventsByTaskId(String taskId) {
    checkHistoryEnabled();
    ListQueryParameterObject query = new ListQueryParameterObject();
    query.setParameter(taskId);
    query.getOrderingProperties().add(new QueryOrderingProperty(new QueryPropertyImpl("TIME_"), Direction.DESCENDING));
    return getDbEntityManager().selectList("selectEventsByTaskId", query);
}
Also used : ListQueryParameterObject(org.camunda.bpm.engine.impl.db.ListQueryParameterObject) QueryPropertyImpl(org.camunda.bpm.engine.impl.QueryPropertyImpl) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty)

Example 2 with QueryPropertyImpl

use of org.camunda.bpm.engine.impl.QueryPropertyImpl 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 3 with QueryPropertyImpl

use of org.camunda.bpm.engine.impl.QueryPropertyImpl 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 4 with QueryPropertyImpl

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

the class HistoricBatchManager method findCleanableHistoricBatchesReportByCriteria.

@SuppressWarnings("unchecked")
public List<CleanableHistoricBatchReportResult> findCleanableHistoricBatchesReportByCriteria(CleanableHistoricBatchReportImpl query, Page page, Map<String, Integer> batchOperationsForHistoryCleanup) {
    query.setCurrentTimestamp(ClockUtil.getCurrentTime());
    query.setParameter(batchOperationsForHistoryCleanup);
    query.getOrderingProperties().add(new QueryOrderingProperty(new QueryPropertyImpl("TYPE_"), Direction.ASCENDING));
    if (batchOperationsForHistoryCleanup.isEmpty()) {
        return getDbEntityManager().selectList("selectOnlyFinishedBatchesReportEntities", query, page);
    } else {
        return getDbEntityManager().selectList("selectFinishedBatchesReportEntities", query, page);
    }
}
Also used : QueryPropertyImpl(org.camunda.bpm.engine.impl.QueryPropertyImpl) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty)

Example 5 with QueryPropertyImpl

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

the class HistoricBatchManager method findHistoricBatchIdsForCleanup.

@SuppressWarnings("unchecked")
public List<String> findHistoricBatchIdsForCleanup(Integer batchSize, Map<String, Integer> batchOperationsForHistoryCleanup) {
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("currentTimestamp", ClockUtil.getCurrentTime());
    queryParameters.put("map", batchOperationsForHistoryCleanup);
    ListQueryParameterObject parameterObject = new ListQueryParameterObject();
    parameterObject.setParameter(queryParameters);
    parameterObject.getOrderingProperties().add(new QueryOrderingProperty(new QueryPropertyImpl("END_TIME_"), Direction.ASCENDING));
    parameterObject.setFirstResult(0);
    parameterObject.setMaxResults(batchSize);
    return (List<String>) getDbEntityManager().selectList("selectHistoricBatchIdsForCleanup", parameterObject);
}
Also used : ListQueryParameterObject(org.camunda.bpm.engine.impl.db.ListQueryParameterObject) HashMap(java.util.HashMap) QueryPropertyImpl(org.camunda.bpm.engine.impl.QueryPropertyImpl) ListQueryParameterObject(org.camunda.bpm.engine.impl.db.ListQueryParameterObject) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty) List(java.util.List)

Aggregations

QueryPropertyImpl (org.camunda.bpm.engine.impl.QueryPropertyImpl)6 QueryOrderingProperty (org.camunda.bpm.engine.impl.QueryOrderingProperty)5 QueryProperty (org.camunda.bpm.engine.query.QueryProperty)3 QueryEntityRelationCondition (org.camunda.bpm.engine.impl.QueryEntityRelationCondition)2 ListQueryParameterObject (org.camunda.bpm.engine.impl.db.ListQueryParameterObject)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 Direction (org.camunda.bpm.engine.impl.Direction)1 VariableInstanceQueryProperty (org.camunda.bpm.engine.impl.VariableInstanceQueryProperty)1 VariableOrderProperty (org.camunda.bpm.engine.impl.VariableOrderProperty)1 JSONObject (org.camunda.bpm.engine.impl.util.json.JSONObject)1