Пример #1
0
 protected function _deleteAllEricsson($data = array())
 {
     $methodName = static::METHOD_NAME_DELETE;
     if (isset($data['filterList']) && $data['filterList'] instanceof \App_ListFilter) {
         $filterList = $data['filterList'];
         if (!$filterList->getCursor()) {
             $this->_findAllEricsson($data);
             $filterList->reset();
             if (!$filterList->getCursor()) {
                 throw new Exceptions\InvalidArgumentException('Deleting sims from stock: Invalid query.');
             }
         }
         $proto = $this->_createProto($methodName);
         $subs = new PB\SubscriptionSelect();
         $subs->setSelectionType(PB\SubscriptionSelect\SelType::HANDLER);
         $subs->addHandler($filterList->getCursor());
         $proto->setSelection($subs);
         $response = $this->_sendRequest($methodName, array('protoMessage' => $proto));
         $this->_checkDeleteResponse($response);
         return true;
     } else {
         throw new InvalidArgumentException("Deleting sims by query: Query must be defined.");
     }
 }
 protected function _generateSubscriptionSelect($data, $idType = SubscriptionId\IdType::ID, $watcher = null)
 {
     $subsSelect = new SubscriptionSelect();
     if ($data instanceof \App_ListFilter) {
         $subsSelect->setSelectionType(SubscriptionSelect\SelType::HANDLER);
         if (!$data->getCursor()) {
             $this->_findAllEricsson(array('filterList' => $data));
             $data->reset();
             if (!$data->getCursor()) {
                 throw new InvalidArgumentException('Invalid query.');
             }
         }
         $subsSelect->addHandler($data->getCursor());
         if ($watcher) {
             $watcher->params->count = $data->getOldCount();
         }
     } else {
         if (is_array($data)) {
             $subsSelect->setSelectionType(SubscriptionSelect\SelType::SUBSCRIPTION_LIST);
             foreach ($data as $id) {
                 if ($id instanceof \Application\Model\SimModel) {
                     if ($id->getId()) {
                         $id = $id->getId();
                         $type = SubscriptionId\IdType::ID;
                     } else {
                         if ($id->getIcc()) {
                             $id = $id->getIcc();
                             $type = SubscriptionId\IdType::ICC;
                         } else {
                             if ($id->getImsi()) {
                                 $id = $id->getImsi();
                                 $type = SubscriptionId\IdType::IMSI;
                             } else {
                                 if ($id->getMsisdn()) {
                                     $id = $id->getMsisdn();
                                     $type = SubscriptionId\IdType::MSISDN;
                                 }
                             }
                         }
                     }
                 } else {
                     $type = $idType;
                 }
                 $subscription = new SubscriptionId();
                 $subscription->setType($type);
                 $subscription->setId($id);
                 $subsSelect->addSubscriptions($subscription);
             }
             if ($watcher) {
                 $watcher->params->count = count($data);
             }
         } else {
             throw new InvalidArgumentException('Data must be an array or App_ListFilter');
         }
     }
     return $subsSelect;
 }