protected function _getListGroupsSimType(PB\Inventory\ListQuery $req)
 {
     $status = array(PB\SimType::GLOBALTYPE => 'GLOBAL', PB\SimType::LOCALTYPE => 'LOCAL');
     $maxFirstPage = $req->getGroupsWithFirstPage() !== null ? $req->getGroupsWithFirstPage() : 5;
     $response = new PB\Inventory\ListQuery\Response();
     $result = new PB\Result();
     $response->setResult($result);
     if ($req->getFilter() === null) {
         $filterMess = new PB\Inventory\ListQuery\Filter();
     } else {
         $filterMess = $req->getFilter();
     }
     try {
         foreach ($status as $state => $label) {
             $auxReq = clone $req;
             $criteria = new Criteria();
             $criteria->setType(Criteria\Type::SIM_TYPE);
             $criteria->setSimType($state);
             $criteria->setReverse(false);
             $auxReq->setFilter(clone $filterMess);
             $auxReq->getFilter()->addCriterias($criteria);
             $sims = $this->_listSims($auxReq);
             $data = new PB\Inventory\ListQuery\Response\Data();
             $cacheData = $auxReq->serialize();
             $cacheId = uniqid();
             \App::cache()->save($cacheData, 'mock' . $cacheId, array(), $req->getQueryPaging()->getMaxTimeout());
             $data->setHandler($cacheId);
             $data->setDescription($label);
             $result->setCode(0);
             $result->setReason('Ok');
             $data->setRowCounter($sims->count());
             if ($maxFirstPage > 0) {
                 while ($sims->hasNext()) {
                     $sims->getNext();
                     $sim = $sims->current();
                     $sim['id'] = $sim['_id'];
                     unset($sim['_id']);
                     $row = new PB\Inventory\Row();
                     $row->parse($sim, new \DrSlump\Protobuf\Codec\PhpArray());
                     $data->addPage($row);
                 }
             }
             $maxFirstPage--;
             $response->addData($data);
         }
     } catch (Exception $e) {
         \App::log()->WARN($e);
         $result->setCode(1);
         $result->setReason($e->getMessage());
     }
     return $response;
 }
 protected function _processDataMessage(InventoryData $dataMessage, Paging $paging, \App_ListFilter $filterList = null, $protoResponse = false)
 {
     $result = array();
     $result['count'] = $dataMessage->getRowCounter();
     $description = $dataMessage->getDescription();
     if (!$description && $description !== "0") {
         $description = self::DEFAULT_GROUP_LABEL;
     }
     $result['label'] = $description;
     if (isset($filterList) && $filterList->getHighlighting() === null) {
         $cursor = $dataMessage->getHandler();
         if ($result['label'] !== null) {
             $filterList->setGroup($result['label']);
         }
         $filterList->setCursor($cursor, $result['count'], $paging->getMaxTimeout());
         $result['cursor'] = $cursor;
     }
     $rows = $dataMessage->getPageList();
     //For streaming
     if ($protoResponse) {
         return $rows;
     }
     $items = array();
     $codec = new \DrSlump\Protobuf\Codec\PhpArray();
     if (!empty($rows)) {
         foreach ($rows as $row) {
             $data = $codec->encode($row);
             $id = $data['id'];
             $items[] = $this->_mapEricssonModelToModel($data);
         }
     }
     $result['items'] = $items;
     return $result;
 }