AnsweredAssumed Answered

Why? Variables of type ByteArray cannot be used to query

Question asked by mgriffith on Aug 8, 2011
Latest reply on Aug 9, 2011 by ronald.van.kuijk
Hello all,

I have a POJO that I am using to create some meta-data for a user task, so that I may be able to link back to it from a MVC controller like Spring or Struts.  I was previously just doing this with a UUID, storing that in the task as a variable and using the task service to look up my task based on the UUID.  This was working fine, and when I went to extend this approach to use a POJO so that I could add additional information to the task that I might want later, I get an error on the query:
org.activiti.engine.ActivitiException: Variables of type ByteArray cannot be used to query
    org.activiti.engine.impl.QueryVariableValue.initialize(QueryVariableValue.java:46)

The code simply looks like this:

– In the TaskListener on create event:

String uuid = UUID.randomUUID().toString();
TaskMetaData taskMetaData= new TaskMetaData(uuid);
taskMetaData.setApprovalLinkURL("http://localhost:8080/activiti-rest/pages/approve.do?taskId=");
taskMetaData.setClaimLinkURL("http://localhost:8080/activiti-rest/pages/claim.do?taskId=");

String feedDescription= 
   "<h1>Workflow Task</h1><br/><div id=\"workflow_link\">"
   + "</div> | "
   + "<a href=\""
   + taskMetaData.getApprovalLinkURL()
   + taskMetaData.getId()
   + "\" title=\"Approve Task\">Approve Task</a> | "
   + "<a href=\""
   + taskMetaData.getClaimLinkURL()
   + taskMetaData.getId()
   + "\" title=\"Claim Task\">Claim Task</a> | <br/> ";

taskMetaData.setDescription(feedDescription);
  
// set the UUID as a process variable
task.setVariable("taskId", taskMetaData);

In my MVC model, I am trying to lookup the task via the task meta data object:


TaskMetaData taskMetaData= new TaskMetaData(taskId);
Task task = taskService.createTaskQuery().processVariableValueEquals("taskId", taskMetaData).singleResult();
if (task == null) {
   throw new ActivitiException("No such task");
}

It fails on the query due to the error stated above.  Below is my POJO:

public class TaskMetaData implements Serializable, Comparable<TaskMetaData> {

   private static final long serialVersionUID = 2932507457670328496L;
   private final String id;
   private String approvalLinkURL;
   private String claimLinkURL;
   private String description;
   
   public TaskMetaData(String id) {
      super();
      this.id = id;
   }
   
   public String getApprovalLinkURL() {
      return approvalLinkURL;
   }


   public void setApprovalLinkURL(String approvalLinkURL) {
      this.approvalLinkURL = approvalLinkURL;
   }


   public String getClaimLinkURL() {
      return claimLinkURL;
   }


   public void setClaimLinkURL(String claimLinkURL) {
      this.claimLinkURL = claimLinkURL;
   }


   public String getDescription() {
      return description;
   }


   public void setDescription(String description) {
      this.description = description;
   }


   public String getId() {
      return id;
   }

   @Override
   public boolean equals(Object obj) {
      if (obj == this) {
         return true;
      }
      if (obj == null || !getClass().equals(obj.getClass())) {
         return false;
      }
      TaskMetaData that = (TaskMetaData) obj;
      return this.id.equalsIgnoreCase(that.getId());
   }

   @Override
   public int hashCode() {
      return new HashCodeBuilder(11, 1117).append(id).toHashCode();
   }

   @Override
   public String toString() {
         
      return ToStringBuilder.reflectionToString(this,
            ToStringStyle.DEFAULT_STYLE);
   }

   @Override
   public int compareTo(TaskMetaData compare) {
      if (compare == null) {
         return 0;
      }
      String thatId = compare.getId();
      if (id != null && thatId != null) {
         return id.compareTo(thatId);
      } else {
         return 0;
      }

   }

}

Any/All replies are appreciated!

Thanks in advance,
MG

Outcomes