/** * @group EricssonInt */ public function testDelete() { $this->_org->setParentId($this->_createTree()); $this->_org->save(); $this->_mapper->delete($this->_org->getId()); $orgCustomer = $this->_mapper->findOneById($this->_org->getId()); $this->assertNull($orgCustomer); }
public function testChangeBillingCycleStartDay() { $result = $this->_mapper->changeBillingCycleStartDay(self::CUSTOMER_ORG_ID, "0", 1); $this->assertNotNull($result); }
/** * Maps Ericsson proto message fields to application model fields * @param array $data * @return array */ protected function _mapEricssonModelToModel(array $data) { if (isset($data['response_data'])) { $data = $data['response_data']; } $data = parent::_mapEricssonModelToModel($data); if (isset($data['universeType'])) { $data['universeType'] = $this->mapUniverseFromEricsson($data['universeType']); } if (isset($data['universe']['id']) && isset($data['universeType'])) { if (AlarmRuleModel::UNIVERSE_CUSTOMER === $data['universeType']) { $data['universeId'] = \Application\Model\Mapper\Organization\OrgCustomerMapper::buildOrgId($data['universe']['id']); } else { $data['universeId'] = $data['universe']['id']; } $data['universeName'] = $data['universe']['name']; unset($data['universe']); } if (isset($data['rules']) && is_array($data['rules'])) { $rules = array(); foreach ($data['rules'] as $rule) { if (is_array($rule)) { $rules[] = $this->_mapRuleToModel($rule); } } $data['rules'] = $rules; } return $data; }
/** * @param string $id * @return \Application\Model\SimModel */ public function load($id, $org = null, $idType = 'Id') { $mapper = $this->getMapper(); $idType = ucfirst(strtolower($idType)); $sim = $mapper->{'findOneBy' . $idType}($id); if (is_null($sim)) { return null; } //retrieve the restriction: $resMapper = \Application\Model\Mapper\RestrictionMapper::getInstance(); $restrictions = $resMapper->findOneBySubscriptionId($sim->getId()); if (!is_null($restrictions)) { $sim->setRestrictions($restrictions); } //retrive the customer supplservices if ($sim->getCustomer()) { $orgMapper = \Application\Model\Mapper\Organization\OrgCustomerMapper::getInstance(); $customer = $orgMapper->findOneById($sim->getCustomer()->getId()); $supplServicesMapper = \Application\Model\Mapper\SupplServicesMapper::getInstance(); if ($customer->getSupplementaryServicesId()) { $supplServices = $supplServicesMapper->findOneById($customer->getSupplementaryServicesId()); if (!is_null($supplServices)) { $supplServices->setTariffs(array()); $sim->setCustomerSupplServices($supplServices); } } } // Grow the model with additional data try { $mapper->getConsumption($sim); } catch (\Exception $e) { \App::log()->warn($e); } try { $mapper->getLifeCycle($sim); } catch (\Exception $e) { \App::log()->warn($e); } try { $mapper->getPresenceDetails($sim); } catch (\Exception $e) { \App::log()->warn($e); } try { $mapper->getLocationDetails($sim); } catch (\Exception $e) { \App::log()->warn($e); } try { $mapper->getTimeAndConsumptionVoucher($sim); } catch (\Exception $e) { \App::log()->warn($e); } return $sim; }
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 _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; }
public function setVoucherOnlyDiscounts($id, $discounts) { if ($id instanceof ServicePackModel) { $id = $id->getId(); } $this->getCache()->remove($id); $data = array(); foreach ($discounts as $discount) { $orgId = $discount->getCustomerId(); Organization\OrgCustomerMapper::getInstance()->getCache()->remove($orgId); $data[] = $this->_mapModelDiscountToEricsson($discount->exportData()); } return $this->_setVoucherOnlyDiscountsEricsson($id, $data); }
/** * 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."; }
protected function _mapEricssonModelToModel(array $data) { $data = parent::_mapEricssonModelToModel($data); if (isset($data['entity']) && isset($data['entity']['universeType']) && ($universeType = AlarmRuleMapper::getInstance()->mapUniverseFromEricsson($data['entity']['universeType']))) { $data['entity']['universeType'] = $universeType; if (isset($data['entity']['customer']['id'])) { $data['entity']['customerId'] = $data['entity']['customer']['id']; if (isset($data['entity']['customer']['name'])) { $data['entity']['customerName'] = $data['entity']['customer']['name']; } unset($data['entity']['customer']); } if (isset($data['entity']['billingAccount']['id'])) { $data['entity']['billingAccountId'] = $data['entity']['billingAccount']['id']; if (isset($data['entity']['billingAccount']['name'])) { $data['entity']['billingAccountName'] = $data['entity']['billingAccount']['name']; } unset($data['entity']['billingAccount']); } if (isset($data['entity']['commercialGroup']['id'])) { $data['entity']['commercialGroupId'] = $data['entity']['commercialGroup']['id']; if (isset($data['entity']['commercialGroup']['name'])) { $data['entity']['commercialGroupName'] = $data['entity']['commercialGroup']['name']; } unset($data['entity']['commercialGroup']); } if (isset($data['entity']['customerId'])) { $data['entity']['customerId'] = OrgCustomerMapper::buildOrgId($data['entity']['customerId']); } if (isset($data['entity']['subscriptionId'])) { foreach ($data['entity']['subscriptionId'] as &$simId) { if (isset($simId['type'])) { $idType = SimMapper::mapSubscriptionIdFromEricsson($simId['type']); $simId['type'] = $idType; } } } if (isset($data['businessRule'])) { foreach ($data['businessRule'] as &$businessRule) { $businessRule = AlarmRuleMapper::getInstance()->mapBusinessRuleToModel($businessRule); } } } if (isset($data['state']) && ($state = $this->_mapStateToModel($data['state']))) { $data['state'] = $state; } if (isset($data['alarmRule']['id'])) { $data['alarmRuleId'] = $data['alarmRule']['id']; if (isset($data['alarmRule']['name'])) { $data['alarmRuleName'] = $data['alarmRule']['name']; } unset($data['alarmRule']); } $alarmRuleMapper = AlarmRuleMapper::getInstance(); if (isset($data['severity']) && ($severity = $alarmRuleMapper->mapSeverityFromEricsson($data['severity']))) { $data['severity'] = $severity; } if (isset($data['condition']) && ($condition = $alarmRuleMapper->mapConditionFromEricsson($data['condition']))) { $data['condition'] = $condition; } return $data; }