public function testInvalidRestrictionsType()
 {
     $restrictions = new RestrictionModel($this->_data);
     $result = $this->_validator->isValid($restrictions->getId());
     $this->assertFalse($result);
     $messages = $this->_validator->getMessages();
     $this->assertArrayHasKey(App_Validate_Ericsson_RestrictionsExistsById::ERROR_INVALID_TYPE, $messages);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof RestrictionModel || $this->_acceptArrayAsModel && is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_RESTRICTIONS] = $this->_messageTemplatesUser[self::NOT_RESTRICTIONS];
         return false;
     }
     if (!parent::isValid($data, $context, $removeNotPresentFields)) {
         return false;
     }
     if (!$data instanceof RestrictionModel) {
         $data = new RestrictionModel($data);
     }
     $contracts = ContractService::getInstance()->getContractsByServiceType('csrm')->getItems();
     if (!empty($contracts)) {
         $validator = new \Zend_Validate_NotEmpty();
     } else {
         $validator = new \App_Validate_Empty();
     }
     if (!$validator->isValid($data->steering)) {
         $this->_messages['steering'] = $validator->getMessages();
         return false;
     }
     // If Voice HOME = SMS HOME, roaming is linked
     if ($data->getVoice() && $data->getVoice()->getMo() && $data->getSms() && $data->getSms()->getMo() && $data->getVoice()->getMo()->getHome() === $data->getSms()->getMo()->getHome() && $data->getVoice()->getMo()->getRoaming() !== $data->getSms()->getMo()->getRoaming()) {
         $this->_messages = array();
         $this->_messages[self::NOT_SYNC_VOICE_SMS_ROAMING] = $this->_messageTemplatesUser[self::NOT_SYNC_VOICE_SMS_ROAMING];
         return false;
     }
     //      https://jira.tid.es/browse/GLOBALPORTAL-115352
     //         if ($data->getSms() && $data->getSms()->getMo() &&
     //             // If HOME is disabled and Roaming Enabled
     //             (($data->getSms()->getMo()->getHome() &&  !$data->getSms()->getMo()->getRoaming()) ||
     //                 // If HOME is enabled and Roaming !== International
     //                 (isset($data->getSms()->getMo()->roaming) &&
     //                     $data->getSms()->getMo()->getRoaming() !== $data->getSms()->getMo()->getInternational()))) {
     //             $this->_messages = array();
     //             $this->_messages[self::NOT_ROAMING_INTERNATIONAL_SAME_VALUE] =
     //                 $this->_messageTemplatesUser[self::NOT_ROAMING_INTERNATIONAL_SAME_VALUE];
     //             return false;
     //         }
     // Validate leading/commercial OB
     $org = \App::getOrgUserLogged();
     $orgProvider = OrgService::getInstance()->getParentByType($org->id, OrgServiceProviderModel::ORG_TYPE);
     if ($orgProvider && \Application\Service\OrgService::getInstance()->isCommercial($orgProvider)) {
         $validator = new RestrictionsCommercialValidate();
         if (!$validator->isValid($data, $context, $removeNotPresentFields)) {
             $this->_messages = $validator->getMessages();
             return false;
         }
     }
     return true;
 }
 protected function _updateEricsson(Model\RestrictionModel $restrictions)
 {
     $methodName = self::METHOD_NAME_UPDATE;
     try {
         $proto = $this->_createProto($methodName);
         $createData = new Restrictions\RestrictionsData();
         $proto->setData($createData);
         $mappedData = $this->_mapModelToEricssonModel($restrictions->exportData());
         $createData->parse($mappedData, new \DrSlump\Protobuf\Codec\PhpArray());
         $proto->setId($mappedData['id']);
         $response = $this->_sendRequest($methodName, array('protoMessage' => $proto));
     } catch (Exception $e) {
         \App::log()->CRIT($e);
     }
     $this->_checkPostResponse($response);
     if ($response->getResult()->getCode() == 0 && $response->getResult()->getReasonCode()) {
         $data = array('reason' => $response->getResult()->getReason(), 'code' => $response->getResult()->getReasonCode() ?: $response->getResult()->getCode());
         throw new EricssonException($response->getResult()->getReason(), $data, null, 304);
     }
     $restrictions->setId($mappedData['id']);
     return $restrictions->getId();
 }
Exemplo n.º 4
0
 protected function _changeRestriction(\Application\Proto\SubscriptionSelect $sims, \Application\Model\RestrictionModel $restriction, $watcher)
 {
     $methodName = self::METHOD_NAME_CHANGE_RESTRICTION;
     /**
      * @var  $proto \Application\Proto\Inventory\ChangeRestrictionsQuery
      */
     $proto = $this->_createProto($methodName);
     $proto->setSubscriptions($sims);
     $restrictionMapper = RestrictionMapper::getInstance();
     $mappedData = $restrictionMapper->_mapModelToEricssonModel($restriction->exportData());
     $proto->parse($mappedData, new \DrSlump\Protobuf\Codec\PhpArray());
     // Return the transaction ID
     return $this->_sendAsyncRequest($methodName, $proto, $sims, array(), $watcher);
 }