/** * @expectedException \Application\Exceptions\InvalidArgumentException */ public function testDeleteInvalidArgument() { $this->_mapper->delete(null); }
protected function _mapSubscriptionBaseTarget($data) { switch ($data['type']) { case Target\SubscriptionBaseTarget\OrgType::MASTER: $mapper = \Application\Model\Mapper\Organization\OrgMasterMapper::getInstance(); break; case Target\SubscriptionBaseTarget\OrgType::SERVICE_PROVIDER: $mapper = \Application\Model\Mapper\Organization\OrgServiceProviderMapper::getInstance(); break; case Target\SubscriptionBaseTarget\OrgType::CUSTOMER: $mapper = \Application\Model\Mapper\Organization\OrgCustomerMapper::getInstance(); break; default: return array(); } return array('organization' => $mapper::buildOrgId($data['id'])); }
protected function _filterServiceProviderData(&$data, $sp) { // Remove no service provider data foreach ($data as $k => &$v) { if (isset($v['serviceProviderId'])) { $v['serviceProviderId'] = OrgServiceProviderMapper::buildOrgId($v['serviceProviderId']); if ($v['serviceProviderId'] !== $sp) { unset($data[$k]); } } } // Reset array keys $data = array_values($data); }
protected function _mapEricssonModelToModel(array $data) { \App_Util_Array::changePropertyName($data, 'customer', 'customerData'); $data = parent::_mapEricssonModelToModel($data); \App_Util_Array::changePropertyName($data, 'customerData.fiscalNumber', 'customerData.defaultBillingAccount.fiscalNumber'); if (isset($data['customerData'])) { $data['customer'] = OrgCustomerMapper::getInstance()->mapToModel($data['customerData']); unset($data['customerData']); } if (isset($data['serviceProviderData'])) { $data['serviceProvider'] = OrgServiceProviderMapper::getInstance()->mapToModel($data['serviceProviderData']); unset($data['serviceProviderData']); } if (isset($data['billingAccountData'])) { $data['billingAccountName'] = $data['billingAccountData']['name']; if (isset($data['billingAccountData']['region'])) { $data['billingAccountRegion'] = $data['billingAccountData']['region']; } unset($data['billingAccountData']); } \App_Util_Array::changePropertyName($data, 'prebillBillingcycle', 'billingCycle'); if (isset($data['billingCycle'])) { foreach ($data['billingCycle'] as &$bc) { $this->_mapReference($bc, 'billingAccount'); } } $this->_mapReference($data, 'billingAccount'); if (isset($data['datesData'])) { $data += $data['datesData']; unset($data['datesData']); } \App_Util_Array::changePropertiesNames($data, array('totalChargeData' => 'totalCharge', 'totalCharge.adjusts.adjustList' => 'totalCharge.adjusts', 'adjusts.adjustList' => 'adjusts', 'serviceGlobalCharges.basicServicesCustomerCharges' => 'serviceGlobalCharges.basicServices', 'serviceGlobalCharges.basicServices.commercialGroupData' => 'serviceGlobalCharges.basicServices.commercialGroup', 'serviceGlobalCharges.supplementaryServicesCustomerCharges' => 'serviceGlobalCharges.supplServices', 'subscriptionsChargesSummary.basicServices.commercialGroupData' => 'subscriptionsChargesSummary.basicServices.commercialGroup', 'subscriptionsChargesSummary.supplementaryServices' => 'subscriptionsChargesSummary.supplServices')); if (isset($data['serviceGlobalCharges']) && isset($data['serviceGlobalCharges']['basicServices']) && isset($data['serviceGlobalCharges']['basicServices']['commercialGroup'])) { foreach ($data['serviceGlobalCharges']['basicServices']['commercialGroup'] as &$item) { $this->_mapReference($item, 'aggregator'); } } if (isset($data['subscriptionsChargesSummary']) && isset($data['subscriptionsChargesSummary']['basicServices']) && isset($data['subscriptionsChargesSummary']['basicServices']['commercialGroup'])) { foreach ($data['subscriptionsChargesSummary']['basicServices']['commercialGroup'] as &$item) { \App_Util_Array::changePropertiesNames($item, array('oneTimeFee.lifecycleStateChangeEvent' => 'oneTimeFee.lifecycleStatusChangeEvent', 'monthlyFee.activeStateRecurrentFee' => 'monthlyFee.activeStatusRecurrentFee', 'monthlyFee.deactivatedStateRecurrentFee' => 'monthlyFee.deactivatedStatusRecurrentFee', 'monthlyFee.activationReadyRecurrentFee' => 'monthlyFee.activationReadyStatusRecurrentFee', 'monthlyFee.activationPendingRecurrentFee' => 'monthlyFee.activationPendingStatusRecurrentFee')); $this->_mapReference($item, 'aggregator'); } } if (!isset($data["published"])) { $data["published"] = isset($data["issuedDate"]) && $data["issuedDate"]; } $customerDiscounts = \App_Util_Array::getItem($data, 'totalCharge.discounts.customer'); if (empty($customerDiscounts)) { \App_Util_Array::unsetItem($data, 'totalCharge.discounts.customer'); } return $data; }
protected function _createTree() { if ($this->_masterOrg && $this->_masterOrg instanceof Model\PersistentAbstract && $this->_masterOrg->getId()) { $this->_masterOrg->delete(); } // if ($this->_providerOrg && // ($this->_providerOrg instanceof Model\PersistentAbstract) && // ($this->_providerOrg->getId())) { // $this->_providerOrg->delete(); // } $this->_masterOrg = new Model\Organization\OrgMasterModel(array('name' => 'ORG_TEST' . microtime(true), 'description' => "Description", 'status' => Model\Organization\OrgMasterModel::ORG_STATUS_ACTIVATED, 'defaultLanguage' => 'es', 'primaryContact' => array('firstName' => 'pcfn', 'lastName' => 'pcln', 'phone' => '933453212', 'email' => '*****@*****.**', 'mobile' => '665348765', 'fax' => '933453232'), 'companyAddress' => array('line1' => 'line1', 'line2' => 'line2', 'city' => 'Barcelona', 'state' => 'Catalunya', 'region' => 'Barcelona', 'country' => 'ES', 'postalCode' => '08005'))); // $this->_masterOrg->save(); // $this->_addUser(OrganizationMapper::cleanOrgId($this->_masterOrg->getId()), Model\Organization\OrgMasterModel::ORG_TYPE); $this->_providerOrg = new Model\Organization\OrgServiceProviderModel(array('name' => 'Service provider name ' . microtime(true), 'description' => "Description", 'parentId' => $this->_masterOrg->getId(), 'commercialName' => 'Service provider commercial name' . microtime(true), 'status' => Model\Organization\OrgServiceProviderModel::ORG_STATUS_ACTIVATED, 'defaultLanguage' => 'es', 'GGSNProvisioning' => true, 'pluralSIMProvisioning' => false, 'fiscalNumber' => 'X4543545643', 'countryVATNumber' => '45634556', 'brand' => '777', 'primaryContact' => array('firstName' => 'Pepe', 'lastName' => 'González', 'phone' => '934443344', 'email' => '*****@*****.**', 'mobile' => '655445533', 'fax' => '934443344'), 'billingAddress' => array('line1' => 'name line here', 'line2' => 'name line here', 'city' => 'Barcelona', 'state' => 'Catalonia', 'country' => 'ES', 'postalCode' => '08080'), 'shippingAddress' => array('line1' => 'line1', 'line2' => 'line2', 'city' => 'Barcelona', 'state' => 'Catalonia', 'country' => 'ES', 'postalCode' => '08080'), 'companyAddress' => array('line1' => 'line1', 'line2' => 'line2', 'city' => 'Barcelona', 'state' => 'Catalonia', 'country' => 'ES', 'postalCode' => '08080'))); // $this->_providerOrg->save(); $this->_providerOrg = OrgServiceProviderMapper::getInstance()->findOneById('provider-sp1 (commercial)1111111111111112'); $this->_addUser(OrganizationMapper::cleanOrgId($this->_providerOrg->getId()), Model\Organization\OrgServiceProviderModel::ORG_TYPE); return $this->_providerOrg->getId(); }
/** * Recieve the CORE async responses */ public function postAction() { \App::log()->debug("CORE notification of response of a async operation."); $message = new Request(); if (!$this->_request->isPost()) { throw new \Application\Exceptions\UnexpectedException("Post request expected"); } // Parse the first level of proto buffer $message->parse($this->getRequest()->getRawBody()); // Verify the transactionId if (!$message->hasToken()) { throw new \Application\Exceptions\InvalidArgumentException("Missing transactionId."); } // Verify the proto if (!$message->hasProto()) { throw new \Application\Exceptions\InvalidArgumentException("Missing proto type."); } $event = new EventModel(); $event->namespace = 'connectivity'; $event->entityType = 'transaction'; $event->entityId = $message->getToken(); $event->created = time(); $event->pushEventData = true; $protoType = $message->getProto(); $event->hiddenData = array('protoType' => $protoType); \App::log()->info('Start CORE notification of response of type ' . $protoType . ' from the async operation ' . $event->entityId ?: 'empty'); // Message decode $internalMessage = $this->_decodeMessage($protoType, $message->getMessage()); // Obtaining a PHP Array from proto $parser = new \DrSlump\Protobuf\Codec\PhpArray(); $data = $message->serialize($parser); $messageData = $internalMessage->serialize($parser); \App::log()->debug("Async message: " . Zend_Json::encode($messageData)); \App_Util_Array::filterKeyNames(new \App_Filter_UnderscoreToCamelCase(), $messageData); \App::log()->debug("Async message (filtered): " . Zend_Json::encode($messageData)); if (isset($data['proto'])) { unset($data['proto']); } if (isset($data['token'])) { unset($data['token']); } if (isset($messageData['result'])) { $data['result'] = $messageData['result']; unset($messageData['result']); } if (!empty($messageData['failed']) || @$data['result']['code'] != 0) { $data['hasFailures'] = true; } else { $data['hasFailures'] = false; } \App::log()->debug("Async message (after all): " . Zend_Json::encode($messageData)); $data['message'] = $messageData; $retries = 0; // Map data switch (true) { case $internalMessage instanceof AsyncNotification\Service\BusinessRuleResponse: $event->entityType = 'businessRule'; $event->pushEventData = false; $arMapper = \Application\Model\Mapper\AlarmRuleMapper::getInstance(); // Map alarm rule condition $value =& $data['message']['alarmRuleCondition']; $value = $arMapper->mapConditionFromEricsson($value); // Map business rule type $value =& $data['message']['businessRule']['businessRuleType']; $value = $arMapper->mapBusinessRuleTypeToModel($value); // Map life cycle state (optional) if (isset($data['message']['businessRule']['nextLifecycleState'])) { $value =& $data['message']['businessRule']['nextLifecycleState']; $lcMapper = \Application\Model\Mapper\LifeCycleMapper::getInstance(); $value = $lcMapper->mapLifeCycleStatusFromEricsson($value); } //Workaround: organization must include orgType if (isset($data['message']['organizationId'])) { $data['organizationId'] = OrgCustomerMapper::buildOrgId($data['message']['organizationId']); } break; case $internalMessage instanceof \Application\Proto\SupDiagnosisAsync\DiagnosisNotification: $event->entityType = 'diagnosis'; $retries = \App::config('watcher.event_retries.diagnosis', 10); break; case $internalMessage instanceof AsyncNotification\Service\ReportResponse: $event->entityType = 'report'; break; case $internalMessage instanceof AsyncNotification\Service\TariffSwitchResponse: $event->entityType = 'tariffSwitch'; $event->entityId = OrgServiceProviderMapper::buildOrgId($internalMessage->getServiceProviderId()); break; } $event->eventData = $data; $compressor = new AsyncResponseCompressorEvent(); $compressor->compress($event); \App::log()->debug('The content of the CORE notification of response of type ' . $protoType . ' from the async operation ' . ($event->entityId ?: 'empty') . ' is ' . \Zend_Json::encode($data)); // Invoke the service $result = AsyncService::getInstance()->publish($event, $retries); \App::log()->info('End CORE notification of response of type' . $protoType . ' from the async operation ' . $event->entityId ?: 'empty'); $this->_helper->output('proto'); $this->view->setClass('Application\\Proto\\AsyncNotification\\Service\\Response'); $this->view->code = Application\Proto\AsyncNotification\Service\Response\Code::OK; $this->view->reason = "Successful operation."; }