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