Skip to content

Commit

Permalink
Added support in QueryPlayground for TypedQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
tonydamage committed Aug 13, 2023
1 parent 12b1cfe commit c33da68
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.*;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.schema.query.TypedQuery;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -528,14 +530,21 @@ private void updateRequestWithMidpointQuery(

ObjectQuery queryWithExprEvaluated = null;
if (midPointQueryScript != null) {
PrismPropertyValue<ObjectQuery> filterValue = ExpressionUtil.evaluateExpression(new VariablesMap(), null, midPointQueryScript,
PrismPropertyValue<?> filterValue = ExpressionUtil.evaluateExpression(new VariablesMap(), null, midPointQueryScript,
MiscSchemaUtil.getExpressionProfile(), getPageBase().getExpressionFactory(), "", task, task.getResult());
queryWithExprEvaluated = filterValue.getRealValue();

queryText = prismContext.querySerializer().serialize(queryWithExprEvaluated.getFilter()).filterText();
getModelObject().setMidPointQuery(queryText);
if (filterValue != null) {
var realValue = filterValue.getRealValue();
if (realValue instanceof ObjectQuery objQuery) {
queryWithExprEvaluated = objQuery;
} else if (realValue instanceof TypedQuery<?> typed) {
queryWithExprEvaluated = typed.toObjectQuery();
}
if (queryWithExprEvaluated != null) {
queryText = prismContext.querySerializer().serialize(queryWithExprEvaluated.getFilter()).filterText();
getModelObject().setMidPointQuery(queryText);
}
}
}

if (queryWithExprEvaluated == null) {
ObjectFilter filter = prismContext.createQueryParser().parseFilter(clazz, queryText);
ObjectQuery objectQuery = prismContext.queryFactory().createQuery(filter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.util.exception.SchemaException;

import java.io.Serializable;
import java.util.Collection;

/**
Expand All @@ -25,7 +26,7 @@
*
* @param <T> Resulting item type
*/
public class TypedQuery<T> extends AbstractTypedQuery<T,TypedQuery<T>> {
public class TypedQuery<T> extends AbstractTypedQuery<T,TypedQuery<T>> implements Serializable {

private ObjectFilter filter;

Expand Down

0 comments on commit c33da68

Please sign in to comment.