/**
  * Returns all items matching the criterias for the report
  *
  * @param \ThinkopenAt\TimeFlies\Domain\Dto\ReportConfiguration $reportConfiguration
  * @param \ThinkopenAt\TimeFlies\Domain\Model\Category $category
  * @return \TYPO3\Flow\Persistence\QueryResultInterface All items as requested by the report configuration
  */
 public function findForReport(ReportConfiguration $reportConfiguration, Category $category = NULL)
 {
     $query = $this->createQuery();
     $constraints = array();
     $orderings = array('category' => \TYPO3\Flow\Persistence\QueryInterface::ORDER_ASCENDING, 'begin' => \TYPO3\Flow\Persistence\QueryInterface::ORDER_ASCENDING);
     $query->setOrderings($orderings);
     // Set required categories
     if ($reportConfiguration->getIncludeSubcategories()) {
         $categoryIdentifiers = $this->categoryRepository->findAllIdentifiersRecursive($category);
     } else {
         $categoryIdentifiers = array($category->getIdentifier());
     }
     $constraints[] = $query->in('category', $categoryIdentifiers);
     // Set required comment
     switch ($reportConfiguration->getCommentOperator()) {
         case 'dont_care':
             break;
         case 'contains':
             $constraints[] = $query->contains('comment', $reportConfiguration->getComment());
             break;
         case 'not_contains':
             $constraints[] = $query->logicalNot($query->contains('comment', $reportConfiguration->getComment()));
             break;
         default:
             throw new \Exception('Invalid compare operator');
             break;
     }
     // Set required begin/end
     $constraints[] = $query->greaterThanOrEqual('begin', $reportConfiguration->getBegin());
     $constraints[] = $query->lessThanOrEqual('begin', $reportConfiguration->getEnd());
     $query->matching($query->logicalAnd($constraints));
     return $query->execute();
 }
 /**
  * @param \ThinkopenAt\TimeFlies\Domain\Model\Category $category
  * @return void
  */
 public function deleteAction(Category $category)
 {
     $this->categoryRepository->remove($category);
     $this->addFlashMessage('Deleted a category.');
     $this->redirect('index');
 }
 /**
  * @param \ThinkopenAt\TimeFlies\Domain\Model\Item $item
  * @return void
  */
 public function editAction(Item $item)
 {
     $this->view->assign('item', $item);
     $this->view->assign('rootCategories', $this->categoryRepository->findByParent(NULL));
 }