@Override
  public Collection<ProcessInstanceSummary> getProcessInstances(
      List<Integer> states, String filterText, int filterType, String initiator) {
    Collection<ProcessInstanceDesc> result = null;
    if (filterType == 0) {
      // search by process id
      result = dataService.getProcessInstancesByProcessId(states, filterText, initiator);
    } else if (filterType == 1) {
      // search by process name
      result = dataService.getProcessInstancesByProcessName(states, filterText, initiator);
    } else {
      result = dataService.getProcessInstances(states, initiator);
    }

    return ProcessInstanceHelper.adaptCollection(result);
  }
 public Collection<VariableSummary> getVariablesCurrentState(
     long processInstanceId, String processId) {
   Map<String, String> properties =
       new HashMap<String, String>(bpmn2Service.getProcessData(processId));
   return VariableHelper.adaptCollection(
       dataService.getVariablesCurrentState(processInstanceId), properties, processInstanceId);
 }
  @Override
  public void setProcessVariable(long processInstanceId, String variableId, Object value) {
    ProcessInstanceDesc piDesc = dataService.getProcessInstanceById(processInstanceId);
    KieSession ksession = domainService.getSessionById(piDesc.getSessionId());
    ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);

    ((WorkflowProcessInstance) processInstance).setVariable(variableId, value);
  }
  @Override
  public Collection<String> getAvailableSignals(String businessKey, long processInstanceId) {
    ProcessInstanceDesc piDesc = dataService.getProcessInstanceById(processInstanceId);
    KieSession ksession = domainService.getSessionById(piDesc.getSessionId());
    ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
    Collection<String> activeSignals = new ArrayList<String>();

    if (processInstance != null) {
      ((ProcessInstanceImpl) processInstance)
          .setProcess(ksession.getKieBase().getProcess(processInstance.getProcessId()));
      Collection<NodeInstance> activeNodes =
          ((WorkflowProcessInstance) processInstance).getNodeInstances();

      activeSignals.addAll(ProcessInstanceHelper.collectActiveSignals(activeNodes));
    }

    return activeSignals;
  }
 public ProcessInstanceSummary getProcessInstanceById(long processInstanceId) {
   return ProcessInstanceHelper.adapt(dataService.getProcessInstanceById(processInstanceId));
 }
 public Collection<ProcessSummary> getProcessesByFilter(String filter) {
   return ProcessHelper.adaptCollection(dataService.getProcessesByFilter(filter));
 }
 public Collection<ProcessInstanceSummary> getProcessInstancesBySessionId(String sessionId) {
   return ProcessInstanceHelper.adaptCollection(
       dataService.getProcessInstancesBySessionId(sessionId));
 }
 public Collection<ProcessInstanceSummary> getProcessInstances() {
   return ProcessInstanceHelper.adaptCollection(dataService.getProcessInstances());
 }
 @Override
 public Collection<NodeInstanceSummary> getProcessInstanceCompletedNodes(long processInstanceId) {
   ProcessInstanceDesc piDesc = dataService.getProcessInstanceById(processInstanceId);
   return NodeInstanceHelper.adaptCollection(
       dataService.getProcessInstanceCompletedNodes(piDesc.getSessionId(), processInstanceId));
 }
 @Override
 public Collection<VariableSummary> getVariableHistory(long processInstanceId, String variableId) {
   return VariableHelper.adaptCollection(
       dataService.getVariableHistory(processInstanceId, variableId));
 }
 public Collection<NodeInstanceSummary> getProcessInstanceFullHistory(long processInstanceId) {
   ProcessInstanceDesc piDesc = dataService.getProcessInstanceById(processInstanceId);
   return NodeInstanceHelper.adaptCollection(
       dataService.getProcessInstanceFullHistory(piDesc.getSessionId(), processInstanceId));
 }
 public Collection<ProcessInstanceSummary> getProcessInstancesByProcessDefinition(
     String processDefId) {
   return ProcessInstanceHelper.adaptCollection(
       dataService.getProcessInstancesByProcessDefinition(processDefId));
 }