@Override
  public List<WorkflowDefinition> getActiveWorkflowDefinitions(
      long companyId, int start, int end, OrderByComparator<WorkflowDefinition> orderByComparator)
      throws WorkflowException {

    try {
      if (orderByComparator == null) {
        orderByComparator = _workflowComparatorFactory.getDefinitionNameComparator(true);
      }

      ServiceContext serviceContext = new ServiceContext();

      serviceContext.setCompanyId(companyId);

      List<KaleoDefinition> kaleoDefinitions =
          _kaleoDefinitionLocalService.getKaleoDefinitions(
              true,
              start,
              end,
              KaleoDefinitionOrderByComparator.getOrderByComparator(
                  orderByComparator, _kaleoWorkflowModelConverter),
              serviceContext);

      return toWorkflowDefinitions(kaleoDefinitions);
    } catch (Exception e) {
      throw new WorkflowException(e);
    }
  }
  @Override
  public List<WorkflowDefinition> getWorkflowDefinitions(
      long companyId,
      String name,
      int start,
      int end,
      OrderByComparator<WorkflowDefinition> orderByComparator)
      throws WorkflowException {

    try {
      ServiceContext serviceContext = new ServiceContext();

      serviceContext.setCompanyId(companyId);

      List<KaleoDefinition> kaleoDefinitions =
          _kaleoDefinitionLocalService.getKaleoDefinitions(
              name,
              start,
              end,
              KaleoDefinitionOrderByComparator.getOrderByComparator(
                  orderByComparator, _kaleoWorkflowModelConverter),
              serviceContext);

      return toWorkflowDefinitions(kaleoDefinitions);
    } catch (Exception e) {
      throw new WorkflowException(e);
    }
  }