Пример #1
0
 protected function _mapEricssonModelToModel(array $data)
 {
     $data = parent::_mapEricssonModelToModel($data);
     // Transformations after "lowercamelcasing" names
     if (isset($data['lifeCycleState'])) {
         $data['lifeCycleStatus'] = $this->_mapEricssonEnumToEnum($data['lifeCycleState'], $this->_lifeCycleStatusMap);
         unset($data['lifeCycleState']);
     }
     if (isset($data['simType'])) {
         $this->_mapEricssonEnumToEnum($data['simType'], $this->_simTypeMap);
     }
     if (isset($data['gprsStatus']) && isset($data['gprsStatus']['status'])) {
         $this->_mapEricssonEnumToEnum($data['gprsStatus']['status'], $this->_connStatusMap);
     }
     if (isset($data['ipStatus']) && isset($data['ipStatus']['status'])) {
         $this->_mapEricssonEnumToEnum($data['ipStatus']['status'], $this->_connStatusMap);
     }
     if (isset($data['billingAccount'])) {
         $this->_mapReference($data, 'billingAccount');
     }
     if (isset($data['servicePack'])) {
         $this->_mapReference($data, 'servicePack');
     }
     if (isset($data['commercialGroup'])) {
         $this->_mapReference($data, 'commercialGroup');
     }
     if (isset($data['supervisionGroup '])) {
         $this->_mapReference($data, 'supervisionGroup');
     }
     // Ericsson issue
     if (!isset($data['apns']) && isset($data['apn'])) {
         $data['apns'] = $data['apn'];
     }
     if (isset($data['apns'])) {
         $data['apns'] = array_values($data['apns']);
     }
     //Invalid 0 as index... strange ericsson behaivor
     if (isset($data['staticIpApnIndex']) && !$data['staticIpApnIndex']) {
         unset($data['staticIpApnIndex']);
     }
     if (isset($data['customerId']) && ($customer = OrgService::getInstance()->load($data['customerId']))) {
         $data['customerCurrency'] = $customer->getCurrency();
         if ($currency = EnumeratedService::getInstance()->findCurrencyById($customer->getCurrency())) {
             $data['customerCurrencyName'] = $currency['name'];
         }
     }
     if (isset($data['restrictions'])) {
         $data['restrictions'] = RestrictionMapper::getInstance()->mapEricssonModelToModel(array('restrictions' => $data['restrictions']));
     }
     if (isset($data['isLegacy'])) {
         $data['legacy'] = $data['isLegacy'];
         unset($data['isLegacy']);
     }
     if (isset($data['logisticsProfile'])) {
         $data['logistics'] = $data['logisticsProfile'];
         unset($data['logisticsProfile']);
     }
     return $data;
 }
 /**
  * TODO Rename all _mapXxxModelToModel to _mapProtoModelToModel like here
  *
  * Maps proto message fields to application model fields
  * @param  array $data
  * @return array
  */
 protected function _mapProtoModelToModel(array $data)
 {
     if (isset($data['id'])) {
         if (isset($data['id']['customer']) && isset($data['id']['customer']['name'])) {
             $data['customer_id'] = $data['id']['customer']['name'];
         }
         if (isset($data['id']['name'])) {
             $data['id'] = $data['name'] = $data['id']['name'];
         }
     }
     $data = parent::_mapEricssonModelToModel($data);
     return $data;
 }
Пример #3
0
 protected function _mapEricssonModelToModel(array $data)
 {
     $model = parent::_mapEricssonModelToModel($data);
     if (!empty($model['zoneGroups'])) {
         foreach ($model['zoneGroups'] as &$zoneGroup) {
             if (!isset($zoneGroup['isDeleted'])) {
                 $zoneGroup['isDeleted'] = false;
             }
         }
     }
     if (isset($model['zonePlanModified']) && !$model['zonePlanModified']) {
         unset($model['zonePlanModified']);
     }
     return $model;
 }
 /**
  * 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'];
     }
     if (isset($data['restrictions'])) {
         $restrictions = $data['restrictions'];
         unset($data['restrictions']);
         $data += $restrictions;
     }
     $data = parent::_mapEricssonModelToModel($data);
     $data = $this->mapEricssonModelToModel($data);
     if (isset($data['restrictionsModified']) && $data['restrictionsModified'] && isset($data['restrictionsModified']['restrictions'])) {
         $restrictions = $this->mapEricssonModelToModel(array('restrictions' => $data['restrictionsModified']['restrictions']));
         unset($data['restrictionsModified']['restrictions']);
         $data['restrictionsModified'] += $restrictions;
     }
     if (isset($data['result'])) {
         unset($data['result']);
     }
     return $data;
 }
 /**
  * Maps Ericsson proto message fields to application model fields
  * @param  array $data
  * @return array
  */
 protected function _mapEricssonModelToModel(array $data)
 {
     $data = parent::_mapEricssonModelToModel($data);
     if (isset($data['responseData'])) {
         $data = $data['responseData'];
     }
     if (isset($data['data'])) {
         $aux = $data['data'];
         unset($data['data']);
         $data += $aux;
     }
     //Default Tariff
     $defaultTariff = array('defaultData', 'defaultOrigVoice', 'defaultTermVoice', 'defaultSms');
     foreach ($defaultTariff as $field) {
         if (isset($data[$field])) {
             $data[$field] = $this->_mapEricssonTariffToModel($data[$field]);
             if (isset($data[$field]['destinationId'])) {
                 unset($data[$field]['destinationId']);
             }
             if (isset($data[$field]['zoneGroupId'])) {
                 unset($data[$field]['zoneGroupId']);
             }
         }
     }
     //Tariff lists
     $tariffLists = array('data', 'origVoice', 'termVoice', 'sms');
     foreach ($tariffLists as $field) {
         if (isset($data[$field]) && is_array($data[$field])) {
             $tariffs = array();
             foreach ($data[$field] as $tariff) {
                 if ($field == 'termVoice' || $field == 'data') {
                     unset($tariff['destination']);
                 }
                 $newTariff = $this->_mapEricssonTariffToModel($tariff);
                 $tariffs[] = $newTariff;
             }
             $data[$field] = $tariffs;
         }
     }
     return $data;
 }
 protected function _mapEricssonModelToModel(array $data)
 {
     if (isset($data['response_data'])) {
         $data = $data['response_data'];
     }
     $mappedData = array();
     if (isset($data['name'])) {
         $mappedData['name'] = $data['name'];
         unset($data['name']);
     }
     if (isset($data['description'])) {
         $mappedData['description'] = $data['description'];
         unset($data['description']);
     }
     if (isset($data['data'])) {
         $mappedData += $data['data'];
     } else {
         $mappedData += $data;
     }
     $data = parent::_mapEricssonModelToModel($mappedData);
     if (isset($data['status']) && is_array($data['status'])) {
         $mappedStatus = array();
         foreach ($data['status'] as $status) {
             $mappedStatus[] = $this->_mapEricssonStatusToModel($status);
         }
         $data['status'] = $mappedStatus;
     }
     return $data;
 }
 protected function _mapPoolsFromEricssonModelToModel($data)
 {
     $poolInformationAttributes = array('dataPools', 'smsPools', 'voiceOriginatedPools', 'voiceTerminatedPools');
     $refDataAttributes = array('zoneGroup', 'destination');
     $result = parent::_mapEricssonModelToModel($data);
     $data = $result['data'] ? $result['data'] : null;
     foreach ($poolInformationAttributes as $poolInfoAttr) {
         if ($data && $data[$poolInfoAttr]) {
             $pools = array();
             foreach ($data[$poolInfoAttr] as $pool) {
                 foreach ($refDataAttributes as $refDataAttr) {
                     if ($pool[$refDataAttr]) {
                         if ($pool[$refDataAttr]['id']) {
                             $pool[$refDataAttr . 'Id'] = $pool[$refDataAttr]['id'];
                         }
                         if ($pool[$refDataAttr]['name']) {
                             $pool[$refDataAttr . 'Name'] = $pool[$refDataAttr]['name'];
                         }
                         unset($pool[$refDataAttr]);
                     }
                 }
                 array_push($pools, $pool);
             }
             $data[$poolInfoAttr] = $pools;
         }
     }
     $result['data'] = $data;
     return $result;
 }
Пример #8
0
 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;
 }
 /**
  * Maps Ericsson proto message fields to application model fields
  * @param  array $data
  * @return array
  */
 protected function _mapEricssonModelToModel(array $data)
 {
     $data = parent::_mapEricssonModelToModel($data);
     if (isset($data['data'])) {
         if (isset($data['data']['states'])) {
             $data['status'] = $data['data']['states'];
             unset($data['data']['states']);
             foreach ($data['status'] as $key => $state) {
                 $data['status'][$key]['status'] = LifeCycleMapper::getInstance()->mapLifeCycleStatusFromEricsson($state['state']);
             }
         }
         if (isset($data['data']['transitions'])) {
             $data['transitions'] = $data['data']['transitions'];
             unset($data['data']['transitions']);
             foreach ($data['transitions'] as $key => $transition) {
                 $data['transitions'][$key]['statusStart'] = LifeCycleMapper::getInstance()->mapLifeCycleStatusFromEricsson($transition['stateStart']);
                 $data['transitions'][$key]['statusFinal'] = LifeCycleMapper::getInstance()->mapLifeCycleStatusFromEricsson($transition['stateFinal']);
             }
         }
         unset($data['data']);
     }
     return $data;
 }
 protected function _mapEricssonDiscountToModel($discount)
 {
     return parent::_mapEricssonModelToModel($discount);
 }
 protected function _mapEricssonModelToModel(array $data)
 {
     if (isset($data['response_data'])) {
         $data = $data['response_data'];
     }
     $mappedData = array();
     if (isset($data['data'])) {
         $mappedData += $data['data'];
     } else {
         $mappedData += $data;
     }
     $data = parent::_mapEricssonModelToModel($mappedData);
     switch ($data['published']) {
         case PublishedStatus::PUBLISHED:
             $data['published'] = SupplServicesModel::STATUS_PUBLISHED;
             break;
         case PublishedStatus::PUBLISHED_PENDING:
             $data['published'] = SupplServicesModel::STATUS_PUBLISHED_PENDING;
             break;
         case PublishedStatus::NOT_PUBLISHED:
             $data['published'] = SupplServicesModel::STATUS_NOT_PUBLISHED;
             break;
         default:
             $data['published'] = SupplServicesModel::STATUS_UNKNOWN;
     }
     if (isset($data['tariffs']) && isset($data['tariffs']['modifiedTariffs'])) {
         $data['tariffsModified'] = $data['tariffs']['modifiedTariffs'];
         unset($data['tariffs']['modifiedTariffs']);
     }
     if (isset($data['tariffs']) && isset($data['tariffs']['currentTariffs'])) {
         $data['tariffs'] = $data['tariffs']['currentTariffs'];
         unset($data['tariffs']['currentTariffs']);
     }
     if (isset($data['additionalMsisdn']) and is_array($data['additionalMsisdn'])) {
         foreach ($data['additionalMsisdn'] as $key => $value) {
             if (isset($value['number'])) {
                 $value['msisdn'] = $value['number'];
                 $value['id'] = $value['number'];
                 unset($value['number']);
             }
             $data['additionalMsisdn'][$key] = $value;
         }
     }
     return $data;
 }
 protected function _mapEricssonModelToModel(array $data)
 {
     $data = parent::_mapEricssonModelToModel($data);
     if (isset($data['id'])) {
         $data['id'] = static::buildOrgId($data['id']);
     }
     if (isset($data['status'])) {
         $ercStatus = array_keys(static::$_statusMap, $data['status']);
         if (!empty($ercStatus)) {
             $data['status'] = current($ercStatus);
         } else {
             $data['status'] = StatusType::INACTIVE;
         }
     }
     return $data;
 }