public void getDomainSpecifDataForTasks(
      final int startRange,
      String filterValue,
      final List<TaskSummary> myTasksFromDataSet,
      boolean lastPageExactCount) {

    FilterSettings variablesTableSettings = view.getVariablesTableSettings(filterValue);
    variablesTableSettings.setTablePageSize(-1);
    variablesTableSettings.setServerTemplateId(selectedServerTemplate);

    dataSetQueryHelperDomainSpecific.setDataSetHandler(variablesTableSettings);
    dataSetQueryHelperDomainSpecific.setCurrentTableSettings(variablesTableSettings);
    dataSetQueryHelperDomainSpecific.setLastOrderedColumn(COLUMN_TASK_ID);
    dataSetQueryHelperDomainSpecific.setLastSortOrder(SortOrder.ASCENDING);

    List<Comparable> tasksIds = new ArrayList<Comparable>();
    for (TaskSummary task : myTasksFromDataSet) {
      tasksIds.add(task.getTaskId());
    }
    DataSetFilter filter = new DataSetFilter();
    ColumnFilter filter1 = equalsTo(COLUMN_TASK_VARIABLE_TASK_ID, tasksIds);
    filter.addFilterColumn(filter1);
    variablesTableSettings.getDataSetLookup().addOperation(filter);

    dataSetQueryHelperDomainSpecific.lookupDataSet(
        0,
        createDataSetDomainSpecificCallback(
            startRange,
            myTasksFromDataSet,
            variablesTableSettings.getDataSet(),
            lastPageExactCount));
  }
  @Override
  protected void onSearchEvent(@Observes SearchEvent searchEvent) {
    textSearchStr = searchEvent.getFilter();
    if (textSearchStr != null && textSearchStr.trim().length() > 0) {
      Map<String, Object> params = new HashMap<String, Object>();
      params.put("textSearch", textSearchStr);
      dataSetQueryHelper.getCurrentTableSettings().getKey();

      view.applyFilterOnPresenter(dataSetQueryHelper.getCurrentTableSettings().getKey());
    }
  }
 @Override
 protected void onSearchEvent(@Observes SearchEvent searchEvent) {
   textSearchStr = searchEvent.getFilter();
   view.applyFilterOnPresenter(dataSetQueryHelper.getCurrentTableSettings().getKey());
 }
 public void filterGrid(FilterSettings tableSettings) {
   dataSetQueryHelper.setCurrentTableSettings(tableSettings);
   refreshGrid();
 }
 protected TaskSummary createTaskSummaryFromDataSet(final DataSet dataSet, int i) {
   return new TaskSummary(
       dataSetQueryHelper.getColumnLongValue(dataSet, COLUMN_TASK_ID, i),
       dataSetQueryHelper.getColumnStringValue(dataSet, COLUMN_NAME, i),
       dataSetQueryHelper.getColumnStringValue(dataSet, COLUMN_DESCRIPTION, i),
       dataSetQueryHelper.getColumnStringValue(dataSet, COLUMN_STATUS, i),
       dataSetQueryHelper.getColumnIntValue(dataSet, COLUMN_PRIORITY, i),
       dataSetQueryHelper.getColumnStringValue(dataSet, COLUMN_ACTUAL_OWNER, i),
       dataSetQueryHelper.getColumnStringValue(dataSet, COLUMN_CREATED_BY, i),
       dataSetQueryHelper.getColumnDateValue(dataSet, COLUMN_CREATED_ON, i),
       dataSetQueryHelper.getColumnDateValue(dataSet, COLUMN_ACTIVATION_TIME, i),
       dataSetQueryHelper.getColumnDateValue(dataSet, COLUMN_DUE_DATE, i),
       dataSetQueryHelper.getColumnStringValue(dataSet, COLUMN_PROCESS_ID, i),
       dataSetQueryHelper.getColumnLongValue(dataSet, COLUMN_PROCESS_SESSION_ID, i),
       dataSetQueryHelper.getColumnLongValue(dataSet, COLUMN_PROCESS_INSTANCE_ID, i),
       dataSetQueryHelper.getColumnStringValue(dataSet, COLUMN_DEPLOYMENT_ID, i),
       dataSetQueryHelper.getColumnLongValue(dataSet, COLUMN_PARENT_ID, i),
       HUMAN_TASKS_WITH_ADMIN_DATASET.equals(dataSet.getUUID()));
 }
  @Override
  public void getData(final Range visibleRange) {
    try {
      if (!isAddingDefaultFilters()) {
        FilterSettings currentTableSettings = dataSetQueryHelper.getCurrentTableSettings();

        if (currentTableSettings != null) {
          currentTableSettings.setServerTemplateId(selectedServerTemplate);
          currentTableSettings.setTablePageSize(view.getListGrid().getPageSize());
          ColumnSortList columnSortList = view.getListGrid().getColumnSortList();
          if (columnSortList != null && columnSortList.size() > 0) {
            dataSetQueryHelper.setLastOrderedColumn(
                columnSortList.size() > 0
                    ? columnSortList.get(0).getColumn().getDataStoreName()
                    : "");
            dataSetQueryHelper.setLastSortOrder(
                (columnSortList.size() > 0) && columnSortList.get(0).isAscending()
                    ? SortOrder.ASCENDING
                    : SortOrder.DESCENDING);
          } else {
            dataSetQueryHelper.setLastOrderedColumn(COLUMN_CREATED_ON);
            dataSetQueryHelper.setLastSortOrder(SortOrder.ASCENDING);
          }

          final List<ColumnFilter> filters = getColumnFilters(textSearchStr);
          if (filters.isEmpty() == false) {
            if (currentTableSettings.getDataSetLookup().getFirstFilterOp() != null) {
              currentTableSettings
                  .getDataSetLookup()
                  .getFirstFilterOp()
                  .addFilterColumn(OR(filters));
            } else {
              final DataSetFilter filter = new DataSetFilter();
              filter.addFilterColumn(OR(filters));
              currentTableSettings.getDataSetLookup().addOperation(filter);
            }
          }
          boolean isAdminDataset =
              currentTableSettings
                  .getDataSetLookup()
                  .getDataSetUUID()
                  .equals(HUMAN_TASKS_WITH_ADMIN_DATASET);

          if (isAdminDataset
              || currentTableSettings
                  .getDataSetLookup()
                  .getDataSetUUID()
                  .equals(HUMAN_TASKS_WITH_USER_DATASET)) {
            if (currentTableSettings.getDataSetLookup().getFirstFilterOp() != null) {
              currentTableSettings
                  .getDataSetLookup()
                  .getFirstFilterOp()
                  .addFilterColumn(getUserGroupFilters(isAdminDataset));
            } else {
              final DataSetFilter filter = new DataSetFilter();
              filter.addFilterColumn(getUserGroupFilters(isAdminDataset));
              currentTableSettings.getDataSetLookup().addOperation(filter);
            }
          }
          dataSetQueryHelper.setDataSetHandler(currentTableSettings);
          dataSetQueryHelper.lookupDataSet(
              visibleRange.getStart(),
              createDataSetTaskCallback(visibleRange.getStart(), currentTableSettings));
        } else {
          taskService
              .call(
                  new RemoteCallback<List<TaskSummary>>() {
                    @Override
                    public void callback(List<TaskSummary> taskSummaries) {
                      boolean lastPage = false;
                      if (taskSummaries.size() < visibleRange.getLength()) {
                        lastPage = true;
                      }
                      updateDataOnCallback(
                          taskSummaries,
                          visibleRange.getStart(),
                          visibleRange.getStart() + taskSummaries.size(),
                          lastPage);
                    }
                  })
              .getActiveTasks(
                  selectedServerTemplate,
                  visibleRange.getStart() / visibleRange.getLength(),
                  visibleRange.getLength());
        }
      }
    } catch (Exception e) {
      errorPopup.showMessage(constants.UnexpectedError(e.getMessage()));
    }
  }
  @Override
  public void getData(final Range visibleRange) {
    try {
      if (!isAddingDefaultFilters()) {
        FilterSettings currentTableSettings = dataSetQueryHelper.getCurrentTableSettings();
        if (currentTableSettings != null) {
          currentTableSettings.setTablePageSize(view.getListGrid().getPageSize());
          ColumnSortList columnSortList = view.getListGrid().getColumnSortList();
          // GWT.log( "-----PIVarList getData table name " + currentTableSettings.getTableName() );
          if (columnSortList != null && columnSortList.size() > 0) {
            dataSetQueryHelper.setLastOrderedColumn(
                (columnSortList.size() > 0)
                    ? columnSortList.get(0).getColumn().getDataStoreName()
                    : "");
            dataSetQueryHelper.setLastSortOrder(
                (columnSortList.size() > 0) && columnSortList.get(0).isAscending()
                    ? SortOrder.ASCENDING
                    : SortOrder.DESCENDING);
          } else {
            dataSetQueryHelper.setLastOrderedColumn(
                DataSetProcessInstanceListVariableViewImpl.VARIABLE_NAME);
            dataSetQueryHelper.setLastSortOrder(SortOrder.ASCENDING);
          }

          if (textSearchStr != null && textSearchStr.trim().length() > 0) {

            DataSetFilter filter = new DataSetFilter();
            List<ColumnFilter> filters = new ArrayList<ColumnFilter>();
            filters.add(
                likeTo(
                    DataSetProcessInstanceListVariableViewImpl.PROCESS_NAME,
                    "%" + textSearchStr.toLowerCase() + "%",
                    false));
            filters.add(
                likeTo(
                    DataSetProcessInstanceListVariableViewImpl.PROCESS_INSTANCE_ID,
                    "%" + textSearchStr.toLowerCase() + "%",
                    false));
            filters.add(
                likeTo(
                    DataSetProcessInstanceListVariableViewImpl.VARIABLE_VALUE,
                    "%" + textSearchStr.toLowerCase() + "%",
                    false));
            filter.addFilterColumn(OR(filters));

            if (currentTableSettings.getDataSetLookup().getFirstFilterOp() != null) {
              currentTableSettings
                  .getDataSetLookup()
                  .getFirstFilterOp()
                  .addFilterColumn(OR(filters));
            } else {
              currentTableSettings.getDataSetLookup().addOperation(filter);
            }
            textSearchStr = "";
          }
          dataSetQueryHelper.setDataSetHandler(currentTableSettings);
          dataSetQueryHelper.lookupDataSet(
              visibleRange.getStart(),
              new DataSetReadyCallback() {
                @Override
                public void callback(DataSet dataSet) {
                  if (dataSet != null) {
                    List<ProcessInstanceVariableSummary> myProcessInstancesFromDataSet =
                        new ArrayList<ProcessInstanceVariableSummary>();

                    for (int i = 0; i < dataSet.getRowCount(); i++) {
                      myProcessInstancesFromDataSet.add(
                          new ProcessInstanceVariableSummary(
                              dataSetQueryHelper.getColumnLongValue(
                                  dataSet,
                                  DataSetProcessInstanceListVariableViewImpl.PROCESS_INSTANCE_ID,
                                  i),
                              dataSetQueryHelper.getColumnStringValue(
                                  dataSet,
                                  DataSetProcessInstanceListVariableViewImpl.PROCESS_NAME,
                                  i),
                              dataSetQueryHelper.getColumnLongValue(
                                  dataSet,
                                  DataSetProcessInstanceListVariableViewImpl.VARIABLE_ID,
                                  i),
                              dataSetQueryHelper.getColumnStringValue(
                                  dataSet,
                                  DataSetProcessInstanceListVariableViewImpl.VARIABLE_NAME,
                                  i),
                              dataSetQueryHelper.getColumnStringValue(
                                  dataSet,
                                  DataSetProcessInstanceListVariableViewImpl.VARIABLE_VALUE,
                                  i)));
                    }
                    PageResponse<ProcessInstanceVariableSummary>
                        processInstanceSummaryPageResponse =
                            new PageResponse<ProcessInstanceVariableSummary>();
                    processInstanceSummaryPageResponse.setPageRowList(
                        myProcessInstancesFromDataSet);
                    processInstanceSummaryPageResponse.setStartRowIndex(visibleRange.getStart());
                    processInstanceSummaryPageResponse.setTotalRowSize(
                        dataSet.getRowCountNonTrimmed());
                    processInstanceSummaryPageResponse.setTotalRowSizeExact(true);
                    if (visibleRange.getStart() + dataSet.getRowCount()
                        == dataSet.getRowCountNonTrimmed()) {
                      processInstanceSummaryPageResponse.setLastPage(true);
                    } else {
                      processInstanceSummaryPageResponse.setLastPage(false);
                    }
                    DataSetProcessInstanceVariableListPresenter.this.updateDataOnCallback(
                        processInstanceSummaryPageResponse);
                  }
                  view.hideBusyIndicator();
                }

                @Override
                public void notFound() {
                  view.hideBusyIndicator();
                  errorPopup.showMessage(
                      "Not found DataSet with UUID [  "
                          + PROCESS_INSTANCE_WITH_VARIABLES_DATASET
                          + " ] ");
                  GWT.log(
                      "DataSet with UUID [  "
                          + PROCESS_INSTANCE_WITH_VARIABLES_DATASET
                          + " ] not found.");
                }

                @Override
                public boolean onError(final ClientRuntimeError error) {
                  view.hideBusyIndicator();
                  errorPopup.showMessage(
                      "DataSet with UUID [  "
                          + PROCESS_INSTANCE_WITH_VARIABLES_DATASET
                          + " ] error: "
                          + error.getThrowable());
                  GWT.log(
                      "DataSet with UUID [  "
                          + PROCESS_INSTANCE_WITH_VARIABLES_DATASET
                          + " ] error: ",
                      error.getThrowable());
                  return false;
                }
              });
        } else {
          view.hideBusyIndicator();
        }
      }
    } catch (Exception e) {
      GWT.log(
          "Error looking up dataset with UUID [ " + PROCESS_INSTANCE_WITH_VARIABLES_DATASET + " ]");
    }
  }
  @Override
  public void getData(final Range visibleRange) {
    try {
      FilterSettings currentTableSettings = dataSetQueryHelper.getCurrentTableSettings();
      if (currentTableSettings != null) {
        currentTableSettings.setTablePageSize(view.getListGrid().getPageSize());
        ColumnSortList columnSortList = view.getListGrid().getColumnSortList();
        GWT.log(
            "-----taskList getData "
                + columnSortList.size()
                + "currentTableSettings table name "
                + currentTableSettings.getTableName());
        if (columnSortList != null && columnSortList.size() > 0) {
          dataSetQueryHelper.setLastOrderedColumn(
              (columnSortList.size() > 0)
                  ? columnSortList.get(0).getColumn().getDataStoreName()
                  : "");
          dataSetQueryHelper.setLastSortOrder(
              (columnSortList.size() > 0) && columnSortList.get(0).isAscending()
                  ? SortOrder.ASCENDING
                  : SortOrder.DESCENDING);
        } else {
          dataSetQueryHelper.setLastOrderedColumn(DataSetTasksListGridViewImpl.COLUMN_CREATEDON);
          dataSetQueryHelper.setLastSortOrder(SortOrder.ASCENDING);
        }
        dataSetQueryHelper.setDataSetHandler(currentTableSettings);
        dataSetQueryHelper.lookupDataSet(
            visibleRange.getStart(),
            new DataSetReadyCallback() {
              @Override
              public void callback(DataSet dataSet) {
                if (dataSet != null) {
                  List<TaskSummary> myTasksFromDataSet = new ArrayList<TaskSummary>();

                  for (int i = 0; i < dataSet.getRowCount(); i++) {
                    myTasksFromDataSet.add(
                        new TaskSummary(
                            dataSetQueryHelper.getColumnLongValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_TASKID, i),
                            dataSetQueryHelper.getColumnStringValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_NAME, i),
                            dataSetQueryHelper.getColumnStringValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_DESCRIPTION, i),
                            dataSetQueryHelper.getColumnStringValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_STATUS, i),
                            dataSetQueryHelper.getColumnIntValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_PRIORITY, i),
                            dataSetQueryHelper.getColumnStringValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_ACTUALOWNER, i),
                            dataSetQueryHelper.getColumnStringValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_CREATEDBY, i),
                            dataSetQueryHelper.getColumnDateValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_CREATEDON, i),
                            dataSetQueryHelper.getColumnDateValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_ACTIVATIONTIME, i),
                            dataSetQueryHelper.getColumnDateValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_DUEDATE, i),
                            dataSetQueryHelper.getColumnStringValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_PROCESSID, i),
                            dataSetQueryHelper.getColumnLongValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_PROCESSSESSIONID, i),
                            dataSetQueryHelper.getColumnLongValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_PROCESSINSTANCEID, i),
                            dataSetQueryHelper.getColumnStringValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_DEPLOYMENTID, i),
                            dataSetQueryHelper.getColumnLongValue(
                                dataSet, DataSetTasksListGridViewImpl.COLUMN_PARENTID, i)));
                  }
                  PageResponse<TaskSummary> taskSummaryPageResponse =
                      new PageResponse<TaskSummary>();
                  taskSummaryPageResponse.setPageRowList(myTasksFromDataSet);
                  taskSummaryPageResponse.setStartRowIndex(visibleRange.getStart());
                  taskSummaryPageResponse.setTotalRowSize(dataSet.getRowCountNonTrimmed());
                  taskSummaryPageResponse.setTotalRowSizeExact(true);
                  if (visibleRange.getStart() + dataSet.getRowCount()
                      == dataSet.getRowCountNonTrimmed()) {
                    taskSummaryPageResponse.setLastPage(true);
                  } else {
                    taskSummaryPageResponse.setLastPage(false);
                  }
                  DataSetTasksListGridPresenter.this.updateDataOnCallback(taskSummaryPageResponse);
                }
                view.hideBusyIndicator();
              }

              @Override
              public void notFound() {
                view.hideBusyIndicator();
                errorPopup.showMessage("Not found DataSet with UUID [  jbpmHumanTasks ] ");
                GWT.log("DataSet with UUID [  jbpmHumanTasks ] not found.");
              }

              @Override
              public boolean onError(final ClientRuntimeError error) {
                view.hideBusyIndicator();
                error.getThrowable().printStackTrace();
                errorPopup.showMessage(
                    "DataSet with UUID [  jbpmHumanTasks ] error: " + error.getThrowable());
                GWT.log("DataSet with UUID [  jbpmHumanTasks ] error: ", error.getThrowable());
                return false;
              }
            });
      } else {
        view.hideBusyIndicator();
      }
    } catch (Exception e) {
      GWT.log("Error looking up dataset with UUID [ jbpmHumanTasks ]");
    }
  }