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);
}
}
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();
}
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;
}
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);
}
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;
}
Aggregations