protected function _addGroup(GroupListModel $result, $filterList, $filterArray, $label, $avoidClosed = false)
 {
     try {
         //Closed alarms
         $newFilterList = clone $filterList;
         if ($avoidClosed) {
             $filterArray[] = array('fieldName' => AlarmFilterFields::STATE, 'value' => AlarmModel::STATE_CLOSED, 'inverted' => true);
         }
         foreach ($filterArray as $filter) {
             $newFilterList->addFilter(new \App_ListFilter_EqualFilter($filter));
         }
         $partialResult = $this->_alarmSrv->listAll($newFilterList, array('paging' => array('count' => 0)));
         if ($partialResult instanceof ListResultModel) {
             $result->addGroup(new GroupCountResultModel(array('label' => $label, 'stream' => $partialResult)));
         }
     } catch (PermissionException $e) {
         //Nothing to do
     } catch (NotAllowedException $e) {
         //Nothing to do
     }
 }
Exemplo n.º 2
0
 /**
  *
  */
 public function findAll($filters = array(), $options = array())
 {
     $data = array();
     if (isset($filters['filterList']) && $filters['filterList'] instanceof \App_ListFilter) {
         $data['filterList'] = $filters['filterList'];
     } else {
         $data['filterList'] = new \App_ListFilter();
     }
     $filterList = $data['filterList'];
     $filterList->addExtraData('organizationId', self::$organizationId);
     if (isset($options['maxFirstPages'])) {
         $data['maxFirstPages'] = $options['maxFirstPages'];
         unset($options['maxFirstPages']);
     }
     $data['paging'] = $options;
     if (!isset($data['paging']['count'])) {
         $data['paging']['count'] = static::DEFAULT_ITEMS_PER_PAGE;
     }
     if ($filterList->getGrouping() == null || $filterList->getGroup() && !$filterList->getHighlighting()) {
         $iter = new SimIterator($data);
         $result = new StreamResultModel();
         $result->setIterator($iter);
         return $result;
     }
     $dataList = $this->_findAllEricsson($data);
     if (isset($dataList['items'])) {
         $items = $dataList['items'];
         foreach ($items as $id => $data) {
             $items[$id] = new SimModel($data);
         }
         $result = new Model\ListResultModel();
         $result->setItems($items);
         if ($dataList['count'] !== null) {
             $result->setCount($dataList['count']);
         }
         return $result;
     } else {
         $result = new Model\GroupListModel();
         foreach ($dataList as $group) {
             if (isset($group['label'])) {
                 $groupModel = new Model\GroupResultModel();
                 $groupModel->setLabel($group['label']);
                 $groupModel->setCount(isset($group['count']) ? $group['count'] : 0);
                 $items = array();
                 if (!empty($group['items'])) {
                     $items = $group['items'];
                     foreach ($items as $id => $data) {
                         $items[$id] = new SimModel($data);
                     }
                 }
                 $groupModel->setItems($items);
                 $result->addGroup($groupModel);
             }
         }
         return $result;
     }
 }