Search in sources :

Example 1 with QueryEntityRelationCondition

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

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

the class FilterTaskQueryTest method verifyOrderingProperties.

protected void verifyOrderingProperties(List<QueryOrderingProperty> expectedProperties, List<QueryOrderingProperty> actualProperties) {
    assertEquals(expectedProperties.size(), actualProperties.size());
    for (int i = 0; i < expectedProperties.size(); i++) {
        QueryOrderingProperty expectedProperty = expectedProperties.get(i);
        QueryOrderingProperty actualProperty = actualProperties.get(i);
        assertEquals(expectedProperty.getRelation(), actualProperty.getRelation());
        assertEquals(expectedProperty.getDirection(), actualProperty.getDirection());
        assertEquals(expectedProperty.isContainedProperty(), actualProperty.isContainedProperty());
        assertEquals(expectedProperty.getQueryProperty(), actualProperty.getQueryProperty());
        List<QueryEntityRelationCondition> expectedRelationConditions = expectedProperty.getRelationConditions();
        List<QueryEntityRelationCondition> actualRelationConditions = expectedProperty.getRelationConditions();
        if (expectedRelationConditions != null && actualRelationConditions != null) {
            assertEquals(expectedRelationConditions.size(), actualRelationConditions.size());
            for (int j = 0; j < expectedRelationConditions.size(); j++) {
                QueryEntityRelationCondition expectedFilteringProperty = expectedRelationConditions.get(j);
                QueryEntityRelationCondition actualFilteringProperty = expectedRelationConditions.get(j);
                assertEquals(expectedFilteringProperty.getProperty(), actualFilteringProperty.getProperty());
                assertEquals(expectedFilteringProperty.getComparisonProperty(), actualFilteringProperty.getComparisonProperty());
                assertEquals(expectedFilteringProperty.getScalarValue(), actualFilteringProperty.getScalarValue());
            }
        } else if ((expectedRelationConditions == null && actualRelationConditions != null) || (expectedRelationConditions != null && actualRelationConditions == null)) {
            fail("Expected filtering properties: " + expectedRelationConditions + ". " + "Actual filtering properties: " + actualRelationConditions);
        }
    }
}
Also used : QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty) QueryEntityRelationCondition(org.camunda.bpm.engine.impl.QueryEntityRelationCondition)

Example 3 with QueryEntityRelationCondition

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

QueryEntityRelationCondition (org.camunda.bpm.engine.impl.QueryEntityRelationCondition)3 QueryOrderingProperty (org.camunda.bpm.engine.impl.QueryOrderingProperty)2 QueryPropertyImpl (org.camunda.bpm.engine.impl.QueryPropertyImpl)2 QueryProperty (org.camunda.bpm.engine.query.QueryProperty)2 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