protected function _findAllCustomerEricsson()
 {
     $methodName = static::METHOD_NAME_CUSTOMER_LIST;
     $proto = $this->_createProto($methodName);
     $response = $this->_sendRequest($methodName, array('protoMessage' => $proto));
     $this->_checkGetResponse($response, true);
     if ($response->getData() === null) {
         $rows = array();
         $count = 0;
     } else {
         $rows = $response->getData()->getPage();
     }
     $items = array();
     $codec = new \DrSlump\Protobuf\Codec\PhpArray();
     foreach ($rows as $row) {
         $creationDate = $row->getCreationDate();
         $prebills = $row->getPrebillBillingcycleList();
         foreach ($prebills as $prebill) {
             $itemData = $codec->encode($prebill);
             $itemData['creationDate'] = $creationDate;
             $itemData = $this->_mapEricssonModelToModel($itemData);
             //Workaround: Ericsson doesn't provide if prebill is published but we need to check permisions
             $itemData = array_merge($itemData, array('published' => true));
             $items[] = $itemData;
         }
     }
     return array('count' => count($items), 'items' => $items);
 }
 function getTripUpdatesAsArray($filter_class = '', $filter_id = '')
 {
     $codec = new DrSlump\Protobuf\Codec\PhpArray();
     return $codec->encode(getTripUpdates($filter_class, $filter_id));
 }
 protected function _findAllEricsson($data = array())
 {
     $methodName = self::METHOD_NAME_LIST;
     $filterList = $data['filterList'];
     if (!($groupFilter = $filterList->getOneFilterByFieldName(ReportFilterFields::REPORT_GROUP))) {
         throw new InvalidArgumentException("No report group defined");
     }
     if ($groupFilter->getValue() === ReportModel::REPORT_GROUPS_SUPERVISION) {
         $service = $this->getAmpliaService();
     } else {
         $service = $this->getEricssonService();
     }
     $filterMapperClass = self::FILTER_MAPPER_CLASS;
     $filterMapper = new $filterMapperClass();
     $filterMessage = $filterMapper->mapListFiltersToMessages($filterList);
     try {
         $proto = $this->_createProto($methodName, $service);
         $proto->setFilter($filterMessage);
         $response = $this->_sendRequest($methodName, array('protoMessage' => $proto), $service);
     } catch (Exception $e) {
         \App::log()->CRIT($e);
         throw $e;
     }
     $isOk = $this->_checkGetResponse($response);
     if ($isOk) {
         $protoData = $response->getData();
         if ($protoData === null) {
             $rows = array();
         } else {
             $rows = $protoData->getPageList();
         }
         $items = array();
         $codec = new \DrSlump\Protobuf\Codec\PhpArray();
         foreach ($rows as $row) {
             $itemData = $codec->encode($row);
             $items[] = $this->_mapEricssonModelToModel($itemData);
         }
         return array('items' => $items);
     } else {
         return $isOk;
     }
 }
 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;
 }
 protected function _processList($rows, $count, $filterList = null, $paging = null)
 {
     $items = array();
     $codec = new \DrSlump\Protobuf\Codec\PhpArray();
     foreach ($rows as $row) {
         $itemData = $codec->encode($row);
         $items[] = $this->_mapEricssonModelToModel($itemData);
         //TODO $this->_model ? new $this->_model($itemData) : $itemData;
     }
     $result = array('count' => $count, 'items' => $items);
     $cursor = 'itemList';
     if (isset($filterList) && $filterList->getCursor()) {
         $cursor = $filterList->getCursor();
     }
     if ($paging && $paging->getPageSize()) {
         $id = $this->_getFetchPageCacheId($cursor, $paging->getPageSize(), $paging->getNpage());
     } else {
         $id = $this->_getFetchPageCacheId($cursor);
     }
     $this->getCache()->save($result, $id, array('list'));
     return $result;
 }
 public function findAll($filters = array(), $options = array())
 {
     $methodName = static::$_protoMethods['findAll'];
     $proto = $this->_createProto($methodName);
     if (isset($filters['filterList']) && $filters['filterList'] instanceof \App_ListFilter) {
         $filterList = $filters['filterList'];
         $filterMapperClass = static::$_orgFilterMapperClass;
         $filterMapper = new $filterMapperClass();
         $filterMessage = $filterMapper->mapListFiltersToMessages($filterList);
     }
     if (isset($filterMessage)) {
         $proto->setFilter($filterMessage);
     }
     $response = $this->_sendRequest($methodName, array('protoMessage' => $proto));
     $this->_checkGetResponse($response, true);
     $items = array();
     if ($response->getData() !== null) {
         $records = $response->getData()->getPageList();
         $codec = new \DrSlump\Protobuf\Codec\PhpArray();
         foreach ($records as $record) {
             $data = $codec->encode($record);
             $item = $this->_mapEricssonModelToModel($data);
             $items[] = OrgModelFactory::factory($item + array('type' => static::$_organizationType));
         }
     }
     $result = array('items' => $items, 'count' => $response->getData()->getRowCounter());
     return new ListResultModel($result);
 }