private function prepareListBuilder(array $fieldDescriptors, Request $request, ListBuilderInterface $listBuilder)
    {
        $restHelper = $this->get('sulu_core.doctrine_rest_helper');
        $restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);
        $listBuilder->addSelectField($fieldDescriptors['handlerClass']);
        $listBuilder->addSelectField($fieldDescriptors['taskId']);

        if ($entityClass = $request->get('entity-class')) {
            $listBuilder->where($fieldDescriptors['entityClass'], $entityClass);
        }

        if ($entityId = $request->get('entity-id')) {
            $listBuilder->where($fieldDescriptors['entityId'], $entityId);
        }

        if ($locale = $request->get('locale')) {
            $listBuilder->where($fieldDescriptors['locale'], $locale);
        }

        if ($handlerClasses = $request->get('handler-class')) {
            $handlerClassList = explode(',', $handlerClasses);
            if (0 < count($handlerClassList)) {
                $listBuilder->in($fieldDescriptors['handlerClass'], $handlerClassList);
            }
        }

        if (null !== ($schedule = $request->get('schedule'))
            && in_array($schedule, array_keys(self::$scheduleComparators))
        ) {
            $listBuilder->where($fieldDescriptors['schedule'], new \DateTime(), self::$scheduleComparators[$schedule]);
        }

        return $listBuilder;
    }