use of org.camunda.bpm.engine.impl.QueryOrderingProperty in project camunda-bpm-platform by camunda.
the class FilterTaskQueryTest method testDeprecatedOrderingFormatDeserializationSingleOrdering.
/**
* Tests compatibility with serialization format that was used in 7.2
*/
@SuppressWarnings("deprecation")
public void testDeprecatedOrderingFormatDeserializationSingleOrdering() {
String sortByNameAsc = "RES." + TaskQueryProperty.NAME.getName() + " " + Direction.ASCENDING.getName();
JsonTaskQueryConverter converter = (JsonTaskQueryConverter) FilterEntity.queryConverter.get(EntityTypes.TASK);
JSONObject queryJson = converter.toJsonObject(filter.<TaskQuery>getQuery());
// when I apply a specific ordering by one dimension
queryJson.put(JsonTaskQueryConverter.ORDER_BY, sortByNameAsc);
TaskQueryImpl deserializedTaskQuery = (TaskQueryImpl) converter.toObject(queryJson);
// then the ordering is applied accordingly
assertEquals(1, deserializedTaskQuery.getOrderingProperties().size());
QueryOrderingProperty orderingProperty = deserializedTaskQuery.getOrderingProperties().get(0);
assertNull(orderingProperty.getRelation());
assertEquals("asc", orderingProperty.getDirection().getName());
assertNull(orderingProperty.getRelationConditions());
assertTrue(orderingProperty.isContainedProperty());
assertEquals(TaskQueryProperty.NAME.getName(), orderingProperty.getQueryProperty().getName());
assertNull(orderingProperty.getQueryProperty().getFunction());
}
use of org.camunda.bpm.engine.impl.QueryOrderingProperty 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.QueryOrderingProperty in project camunda-bpm-platform by camunda.
the class JsonTaskQueryConverter method toObject.
@Override
public TaskQuery toObject(JSONObject json) {
TaskQueryImpl query = new TaskQueryImpl();
if (json.has(OR_QUERIES)) {
for (int i = 0; i < json.getJSONArray(OR_QUERIES).length(); i++) {
query.addOrQuery((TaskQueryImpl) toObject(json.getJSONArray(OR_QUERIES).getJSONObject(i)));
}
}
if (json.has(TASK_ID)) {
query.taskId(json.getString(TASK_ID));
}
if (json.has(NAME)) {
query.taskName(json.getString(NAME));
}
if (json.has(NAME_NOT_EQUAL)) {
query.taskNameNotEqual(json.getString(NAME_NOT_EQUAL));
}
if (json.has(NAME_LIKE)) {
query.taskNameLike(json.getString(NAME_LIKE));
}
if (json.has(NAME_NOT_LIKE)) {
query.taskNameNotLike(json.getString(NAME_NOT_LIKE));
}
if (json.has(DESCRIPTION)) {
query.taskDescription(json.getString(DESCRIPTION));
}
if (json.has(DESCRIPTION_LIKE)) {
query.taskDescriptionLike(json.getString(DESCRIPTION_LIKE));
}
if (json.has(PRIORITY)) {
query.taskPriority(json.getInt(PRIORITY));
}
if (json.has(MIN_PRIORITY)) {
query.taskMinPriority(json.getInt(MIN_PRIORITY));
}
if (json.has(MAX_PRIORITY)) {
query.taskMaxPriority(json.getInt(MAX_PRIORITY));
}
if (json.has(ASSIGNEE)) {
query.taskAssignee(json.getString(ASSIGNEE));
}
if (json.has(ASSIGNEE_LIKE)) {
query.taskAssigneeLike(json.getString(ASSIGNEE_LIKE));
}
if (json.has(INVOLVED_USER)) {
query.taskInvolvedUser(json.getString(INVOLVED_USER));
}
if (json.has(OWNER)) {
query.taskOwner(json.getString(OWNER));
}
if (json.has(ASSIGNED) && json.getBoolean(ASSIGNED)) {
query.taskAssigned();
}
if (json.has(UNASSIGNED) && json.getBoolean(UNASSIGNED)) {
query.taskUnassigned();
}
if (json.has(DELEGATION_STATE)) {
query.taskDelegationState(DelegationState.valueOf(json.getString(DELEGATION_STATE)));
}
if (json.has(CANDIDATE_USER)) {
query.taskCandidateUser(json.getString(CANDIDATE_USER));
}
if (json.has(CANDIDATE_GROUP)) {
query.taskCandidateGroup(json.getString(CANDIDATE_GROUP));
}
if (json.has(CANDIDATE_GROUPS) && !json.has(CANDIDATE_USER) && !json.has(CANDIDATE_GROUP)) {
query.taskCandidateGroupIn(getList(json.getJSONArray(CANDIDATE_GROUPS)));
}
if (json.has(WITH_CANDIDATE_GROUPS) && json.getBoolean(WITH_CANDIDATE_GROUPS)) {
query.withCandidateGroups();
}
if (json.has(WITHOUT_CANDIDATE_GROUPS) && json.getBoolean(WITHOUT_CANDIDATE_GROUPS)) {
query.withoutCandidateGroups();
}
if (json.has(WITH_CANDIDATE_USERS) && json.getBoolean(WITH_CANDIDATE_USERS)) {
query.withCandidateUsers();
}
if (json.has(WITHOUT_CANDIDATE_USERS) && json.getBoolean(WITHOUT_CANDIDATE_USERS)) {
query.withoutCandidateUsers();
}
if (json.has(INCLUDE_ASSIGNED_TASKS) && json.getBoolean(INCLUDE_ASSIGNED_TASKS)) {
query.includeAssignedTasksInternal();
}
if (json.has(PROCESS_INSTANCE_ID)) {
query.processInstanceId(json.getString(PROCESS_INSTANCE_ID));
}
if (json.has(EXECUTION_ID)) {
query.executionId(json.getString(EXECUTION_ID));
}
if (json.has(ACTIVITY_INSTANCE_ID_IN)) {
query.activityInstanceIdIn(getArray(json.getJSONArray(ACTIVITY_INSTANCE_ID_IN)));
}
if (json.has(CREATED)) {
query.taskCreatedOn(new Date(json.getLong(CREATED)));
}
if (json.has(CREATED_BEFORE)) {
query.taskCreatedBefore(new Date(json.getLong(CREATED_BEFORE)));
}
if (json.has(CREATED_AFTER)) {
query.taskCreatedAfter(new Date(json.getLong(CREATED_AFTER)));
}
if (json.has(KEY)) {
query.taskDefinitionKey(json.getString(KEY));
}
if (json.has(KEYS)) {
query.taskDefinitionKeyIn(getArray(json.getJSONArray(KEYS)));
}
if (json.has(KEY_LIKE)) {
query.taskDefinitionKeyLike(json.getString(KEY_LIKE));
}
if (json.has(PARENT_TASK_ID)) {
query.taskParentTaskId(json.getString(PARENT_TASK_ID));
}
if (json.has(PROCESS_DEFINITION_KEY)) {
query.processDefinitionKey(json.getString(PROCESS_DEFINITION_KEY));
}
if (json.has(PROCESS_DEFINITION_KEYS)) {
query.processDefinitionKeyIn(getArray(json.getJSONArray(PROCESS_DEFINITION_KEYS)));
}
if (json.has(PROCESS_DEFINITION_ID)) {
query.processDefinitionId(json.getString(PROCESS_DEFINITION_ID));
}
if (json.has(PROCESS_DEFINITION_NAME)) {
query.processDefinitionName(json.getString(PROCESS_DEFINITION_NAME));
}
if (json.has(PROCESS_DEFINITION_NAME_LIKE)) {
query.processDefinitionNameLike(json.getString(PROCESS_DEFINITION_NAME_LIKE));
}
if (json.has(PROCESS_INSTANCE_BUSINESS_KEY)) {
query.processInstanceBusinessKey(json.getString(PROCESS_INSTANCE_BUSINESS_KEY));
}
if (json.has(PROCESS_INSTANCE_BUSINESS_KEYS)) {
query.processInstanceBusinessKeyIn(getArray(json.getJSONArray(PROCESS_INSTANCE_BUSINESS_KEYS)));
}
if (json.has(PROCESS_INSTANCE_BUSINESS_KEY_LIKE)) {
query.processInstanceBusinessKeyLike(json.getString(PROCESS_INSTANCE_BUSINESS_KEY_LIKE));
}
if (json.has(TASK_VARIABLES)) {
addVariables(query, json.getJSONArray(TASK_VARIABLES), true, false);
}
if (json.has(PROCESS_VARIABLES)) {
addVariables(query, json.getJSONArray(PROCESS_VARIABLES), false, true);
}
if (json.has(CASE_INSTANCE_VARIABLES)) {
addVariables(query, json.getJSONArray(CASE_INSTANCE_VARIABLES), false, false);
}
if (json.has(DUE)) {
query.dueDate(new Date(json.getLong(DUE)));
}
if (json.has(DUE_BEFORE)) {
query.dueBefore(new Date(json.getLong(DUE_BEFORE)));
}
if (json.has(DUE_AFTER)) {
query.dueAfter(new Date(json.getLong(DUE_AFTER)));
}
if (json.has(FOLLOW_UP)) {
query.followUpDate(new Date(json.getLong(FOLLOW_UP)));
}
if (json.has(FOLLOW_UP_BEFORE)) {
query.followUpBefore(new Date(json.getLong(FOLLOW_UP_BEFORE)));
}
if (json.has(FOLLOW_UP_AFTER)) {
query.followUpAfter(new Date(json.getLong(FOLLOW_UP_AFTER)));
}
if (json.has(FOLLOW_UP_NULL_ACCEPTED)) {
query.setFollowUpNullAccepted(json.getBoolean(FOLLOW_UP_NULL_ACCEPTED));
}
if (json.has(EXCLUDE_SUBTASKS) && json.getBoolean(EXCLUDE_SUBTASKS)) {
query.excludeSubtasks();
}
if (json.has(SUSPENDED) && json.getBoolean(SUSPENDED)) {
query.suspended();
}
if (json.has(ACTIVE) && json.getBoolean(ACTIVE)) {
query.active();
}
if (json.has(CASE_DEFINITION_KEY)) {
query.caseDefinitionKey(json.getString(CASE_DEFINITION_KEY));
}
if (json.has(CASE_DEFINITION_ID)) {
query.caseDefinitionId(json.getString(CASE_DEFINITION_ID));
}
if (json.has(CASE_DEFINITION_NAME)) {
query.caseDefinitionName(json.getString(CASE_DEFINITION_NAME));
}
if (json.has(CASE_DEFINITION_NAME_LIKE)) {
query.caseDefinitionNameLike(json.getString(CASE_DEFINITION_NAME_LIKE));
}
if (json.has(CASE_INSTANCE_ID)) {
query.caseInstanceId(json.getString(CASE_INSTANCE_ID));
}
if (json.has(CASE_INSTANCE_BUSINESS_KEY)) {
query.caseInstanceBusinessKey(json.getString(CASE_INSTANCE_BUSINESS_KEY));
}
if (json.has(CASE_INSTANCE_BUSINESS_KEY_LIKE)) {
query.caseInstanceBusinessKeyLike(json.getString(CASE_INSTANCE_BUSINESS_KEY_LIKE));
}
if (json.has(CASE_EXECUTION_ID)) {
query.caseExecutionId(json.getString(CASE_EXECUTION_ID));
}
if (json.has(TENANT_IDS)) {
query.tenantIdIn(getArray(json.getJSONArray(TENANT_IDS)));
}
if (json.has(WITHOUT_TENANT_ID)) {
query.withoutTenantId();
}
if (json.has(ORDER_BY)) {
List<QueryOrderingProperty> orderingProperties = JsonLegacyQueryOrderingPropertyConverter.INSTANCE.fromOrderByString(json.getString(ORDER_BY));
query.setOrderingProperties(orderingProperties);
}
if (json.has(ORDERING_PROPERTIES)) {
JSONArray jsonArray = json.getJSONArray(ORDERING_PROPERTIES);
query.setOrderingProperties(JsonQueryOrderingPropertyConverter.ARRAY_CONVERTER.toObject(jsonArray));
}
// expressions
Iterator jsonIterator = json.keys();
while (jsonIterator.hasNext()) {
String key = (String) jsonIterator.next();
if (key.endsWith("Expression")) {
String expression = json.getString(key);
query.addExpression(key.substring(0, key.length() - "Expression".length()), expression);
}
}
return query;
}
use of org.camunda.bpm.engine.impl.QueryOrderingProperty in project camunda-bpm-platform by camunda.
the class LdapIdentityProviderSession method applyRequestControls.
protected void applyRequestControls(AbstractQuery<?, ?> query) {
try {
List<Control> controls = new ArrayList<Control>();
List<QueryOrderingProperty> orderBy = query.getOrderingProperties();
if (orderBy != null) {
for (QueryOrderingProperty orderingProperty : orderBy) {
String propertyName = orderingProperty.getQueryProperty().getName();
if (UserQueryProperty.USER_ID.getName().equals(propertyName)) {
controls.add(new SortControl(ldapConfiguration.getUserIdAttribute(), Control.CRITICAL));
} else if (UserQueryProperty.EMAIL.getName().equals(propertyName)) {
controls.add(new SortControl(ldapConfiguration.getUserEmailAttribute(), Control.CRITICAL));
} else if (UserQueryProperty.FIRST_NAME.getName().equals(propertyName)) {
controls.add(new SortControl(ldapConfiguration.getUserFirstnameAttribute(), Control.CRITICAL));
} else if (UserQueryProperty.LAST_NAME.getName().equals(propertyName)) {
controls.add(new SortControl(ldapConfiguration.getUserLastnameAttribute(), Control.CRITICAL));
}
}
}
initialContext.setRequestControls(controls.toArray(new Control[0]));
} catch (Exception e) {
throw new IdentityProviderException("Exception while setting paging settings", e);
}
}
use of org.camunda.bpm.engine.impl.QueryOrderingProperty 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);
}
}
Aggregations