Skip to content

Commit

Permalink
Merge branch 'develop' into fix/AAE-26470-reduce-keycloak-users-respo…
Browse files Browse the repository at this point in the history
…nse-size
  • Loading branch information
jesty authored Oct 14, 2024
2 parents af5c932 + ffd8ef5 commit 4a3554e
Show file tree
Hide file tree
Showing 12 changed files with 3,134 additions and 3,997 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Predicate toPredicate(
applyProcessVariableFilters(root, query, criteriaBuilder);
applySorting(
root,
() -> root.join(ProcessInstanceEntity_.variables, JoinType.LEFT),
root.join(ProcessInstanceEntity_.variables, JoinType.LEFT),
searchRequest.sort(),
query,
criteriaBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import jakarta.persistence.metamodel.SingularAttribute;
import java.util.Collection;
import java.util.Set;
import java.util.function.Supplier;
import org.activiti.cloud.dialect.CustomPostgreSQLDialect;
import org.activiti.cloud.services.query.model.ProcessVariableEntity;
import org.activiti.cloud.services.query.model.ProcessVariableEntity_;
import org.activiti.cloud.services.query.rest.exception.IllegalFilterException;
import org.activiti.cloud.services.query.rest.filter.VariableFilter;
import org.activiti.cloud.services.query.rest.payload.CloudRuntimeEntitySort;
import org.springframework.data.jpa.domain.Specification;
Expand Down Expand Up @@ -116,52 +116,56 @@ protected Predicate getVariableValueCondition(
VariableFilter filter,
CriteriaBuilder criteriaBuilder
) {
VariableValueCondition valueConditionStrategy =
switch (filter.type()) {
case STRING -> new StringVariableValueCondition(
valueColumnPath,
filter.operator(),
filter.value(),
criteriaBuilder
);
case INTEGER -> new IntegerVariableValueCondition(
valueColumnPath,
filter.operator(),
filter.value(),
criteriaBuilder
);
case BIGDECIMAL -> new BigDecimalVariableValueCondition(
valueColumnPath,
filter.operator(),
filter.value(),
criteriaBuilder
);
case DATE -> new DateVariableValueCondition(
valueColumnPath,
filter.operator(),
filter.value(),
criteriaBuilder
);
case DATETIME -> new DatetimeVariableValueCondition(
valueColumnPath,
filter.operator(),
filter.value(),
criteriaBuilder
);
case BOOLEAN -> new BooleanVariableValueCondition(
valueColumnPath,
filter.operator(),
filter.value(),
criteriaBuilder
);
};
try {
VariableValueCondition valueConditionStrategy =
switch (filter.type()) {
case STRING -> new StringVariableValueCondition(
valueColumnPath,
filter.operator(),
filter.value(),
criteriaBuilder
);
case INTEGER -> new IntegerVariableValueCondition(
valueColumnPath,
filter.operator(),
filter.value(),
criteriaBuilder
);
case BIGDECIMAL -> new BigDecimalVariableValueCondition(
valueColumnPath,
filter.operator(),
filter.value(),
criteriaBuilder
);
case DATE -> new DateVariableValueCondition(
valueColumnPath,
filter.operator(),
filter.value(),
criteriaBuilder
);
case DATETIME -> new DatetimeVariableValueCondition(
valueColumnPath,
filter.operator(),
filter.value(),
criteriaBuilder
);
case BOOLEAN -> new BooleanVariableValueCondition(
valueColumnPath,
filter.operator(),
filter.value(),
criteriaBuilder
);
};

return valueConditionStrategy.toPredicate();
return valueConditionStrategy.toPredicate();
} catch (IllegalFilterException e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage());
}
}

protected void applySorting(
Root<T> root,
Supplier<SetJoin<T, ProcessVariableEntity>> joinSupplier,
SetJoin<T, ProcessVariableEntity> joinedProcessVars,
CloudRuntimeEntitySort sort,
CriteriaQuery<?> query,
CriteriaBuilder criteriaBuilder
Expand All @@ -170,22 +174,21 @@ protected void applySorting(
validateSort(sort);
Expression<Object> orderByClause;
if (sort.isProcessVariable()) {
SetJoin<T, ProcessVariableEntity> join = joinSupplier.get();
Expression<?> extractedValue = criteriaBuilder.function(
CustomPostgreSQLDialect.getExtractionFunction(sort.type()),
Object.class,
join.get(ProcessVariableEntity_.value)
joinedProcessVars.get(ProcessVariableEntity_.value)
);
orderByClause =
criteriaBuilder
.selectCase()
.when(
criteriaBuilder.and(
criteriaBuilder.equal(
join.get(ProcessVariableEntity_.processDefinitionKey),
joinedProcessVars.get(ProcessVariableEntity_.processDefinitionKey),
sort.processDefinitionKey()
),
criteriaBuilder.equal(join.get(ProcessVariableEntity_.name), sort.field())
criteriaBuilder.equal(joinedProcessVars.get(ProcessVariableEntity_.name), sort.field())
),
extractedValue
)
Expand Down
Loading

0 comments on commit 4a3554e

Please sign in to comment.