Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JBPM-9422] Selection tasks via org.kie.server.client.UserTaskService… #1817

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,36 +55,36 @@ public void addNamedQueries(String ormFile) {
}
}

public String getQuery(String name, Map<String, Object> params) {
StringBuffer query = null;
if (!queries.containsKey(name)) {
return null;
}
String operand = " and ";
StringBuffer buf = new StringBuffer(queries.get(name));
if (buf.indexOf("where") == -1) {
operand = " where ";
}
if (params != null && params.containsKey(FILTER)) {
public String getQuery(String name, Map<String, Object> params) {
StringBuffer query = null;
if (!queries.containsKey(name)) {
return null;
}
String operand = " and ";

StringBuffer buf = new StringBuffer(queries.get(name));
if (buf.indexOf("where") == -1) {
operand = " where ";
}
if (params != null && params.containsKey(FILTER)) {

buf.append(operand + params.get(FILTER));
query = buf;
}
if (params != null && params.containsKey(ORDER_BY_KEY)) {
buf.append(" \n ORDER BY " + adaptOrderBy((String)params.get("orderby")));
if (params.containsKey(ASCENDING_KEY)) {
buf.append(" ASC");
} else if (params.containsKey(DESCENDING_KEY)) {
buf.append(" DESC");
}
query = buf;
}
return (query == null ? null : query.toString() );
}

if (params != null && params.containsKey(ORDER_BY_KEY)) {
boolean audit = buf.indexOf("AuditTaskImpl") >= 0;
buf.append(" \n ORDER BY " + adaptOrderBy(audit, (String) params.get("orderby")));
if (params.containsKey(ASCENDING_KEY)) {
buf.append(" ASC");
} else if (params.containsKey(DESCENDING_KEY)) {
buf.append(" DESC");
}
query = buf;
}

return (query == null ? null : query.toString());
}

protected void parse(String ormFile) throws XMLStreamException {
String name = null;
Expand Down Expand Up @@ -128,7 +128,7 @@ protected void parse(String ormFile) throws XMLStreamException {
}
}

private String adaptOrderBy(String orderBy) {
private String adaptOrderBy(boolean audit, String orderBy) {
if (orderBy != null) {
if (orderBy.equals("ProcessInstanceId")) {
return "log.processInstanceId";
Expand All @@ -151,13 +151,13 @@ private String adaptOrderBy(String orderBy) {
} else if (orderBy.equalsIgnoreCase("Priority")) {
return "t.priority";
} else if (orderBy.equalsIgnoreCase("Status")) {
return "t.taskData.status";
return (!audit) ? "t.taskData.status" : "t.status";
} else if (orderBy.equalsIgnoreCase("CreatedOn")) {
return "t.taskData.createdOn";
return (!audit) ? "t.taskData.createdOn" : "t.createOn";
} else if (orderBy.equalsIgnoreCase("CreatedBy")) {
return "t.taskData.createdBy.id";
return (!audit) ? "t.taskData.createdBy.id" : "t.createdBy";
} else if (orderBy.equalsIgnoreCase("DueOn")) {
return "t.taskData.expirationTime";
return (!audit) ? "t.taskData.expirationTime" : "t.dueDate";
}
}
return orderBy;
Expand Down