0

我正在尝试将嵌套的自定义查询传递给 Redhat JBPM。为了传递嵌套的 SQL 查询,提供的 QueryParam 类支持通配符对象列表。

package org.kie.server.api.model.definition;


@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "query-param")
public class QueryParam {

@XmlElement(name = "cond-column")
private String column;
@XmlElement(name = "cond-operator")
private String operator;
@XmlElement(name = "cond-values")
private List<?> value;

public QueryParam() {

}
//Constructors
//Getters and Setters

}

这里List<?> value又可以包含同一类的对象列表。protected String serialize(Object object)JBPM 使用org.kie.server.client.impl.AbstractKieServicesClientImpl中的方法序列化这个类。产生的结果如下

   "query-params" : [ {
    "cond-column" : "Name",
    "cond-operator" : "EQUALS_TO",
    "cond-values" : [ "Jack" ]
  }, {
    "cond-column" : null,
    "cond-operator" : "OR",
    "cond-values" : [ {
      "column" : "Address",  //NOTE THE NAME COLUMN INSTEAD OF COND-COLUMN
      "operator" : "LIKE_TO",
      "value" : [ "%Test%" ]
    }, {
      "column" : "Age",
      "operator" : "EQUALS_TO",
      "value" : [ "14" ]
    } ]
  } ],

但是,JBPM 执行服务器期望的格式是

"query-params" : [ {
    "cond-column" : "Name",
    "cond-operator" : "EQUALS_TO",
    "cond-values" : [ "Jack" ]
  }, {
    "cond-column" : null,
    "cond-operator" : "OR",
    "cond-values" : [ {
      "cond-column" : "Address",  //NOTE THE NAME COLUMN INSTEAD OF COND-COLUMN
      "cond-operator" : "LIKE_TO",
      "cond-values" : [ "%Test%" ]
    }, {
      "cond-column" : "Age",
      "cond-operator" : "EQUALS_TO",
      "cond-values" : [ "14" ]
    } ]
  } ],

如何确保序列化后的查询参数结果格式如上?我无法控制任何类,因为这些是由 JBPM 提供的。

4

0 回答 0