Exemplo n.º 1
0
 protected function _mapModelToEricssonModel(array $data)
 {
     if (isset($data['zonePlanModified'])) {
         unset($data['zonePlanModified']);
     }
     if (isset($data['zoneGroups']) && empty($data['zoneGroups'])) {
         unset($data['zoneGroups']);
     }
     return parent::_mapModelToEricssonModel($data);
 }
 protected function _mapModelToEricssonModel(array $data)
 {
     if (!isset($data['customerId'])) {
         $data['customerId'] = OrganizationMapper::cleanOrgId(self::$organizationId);
     } else {
         $data['customerId'] = OrganizationMapper::cleanOrgId($data['customerId']);
     }
     if (isset($data['aggregatorId'])) {
         $data['aggregatorId'] = OrganizationMapper::cleanOrgId($data['aggregatorId']);
     }
     $data = $this->_mapListsToEricssonLists($data);
     $data = parent::_mapModelToEricssonModel($data);
     return $data;
 }
 /**
  * TODO Rename all _mapModelToXxxModel to _mapModelToProtoModel like here
  *
  * Maps application model fields to proto message fields
  * @param  array $data
  * @return array
  */
 protected function _mapModelToProtoModel(array $data)
 {
     $data = parent::_mapModelToEricssonModel($data);
     if (!isset($data['customer_id'])) {
         $data['customer_id'] = self::$organizationId;
     }
     $data['id'] = isset($data['id']) && is_array($data['id']) ? $data['id'] : array();
     if (isset($data['name'])) {
         $data['id']['name'] = $data['name'];
         unset($data['name']);
     }
     if (isset($data['customer_id'])) {
         $data['id']['customer']['name'] = OrganizationMapper::cleanOrgId($data['customer_id']);
         unset($data['customer_id']);
     }
     if (isset($data['subscriber_count'])) {
         unset($data['subscriber_count']);
         // Not in protos
     }
     return $data;
 }
 protected function _mapModelToEricssonModel(array $data)
 {
     $restrictions = array();
     $types = array('voice', 'sms', 'data');
     foreach ($types as $type) {
         if (isset($data[$type]) && is_array($data[$type])) {
             foreach ($data[$type] as $sector1 => $sector1Items) {
                 if (is_array($sector1Items)) {
                     foreach ($sector1Items as $sector2 => $value) {
                         $restrictions[$type . ucfirst($sector1) . ucfirst($sector2)] = $value;
                     }
                 } else {
                     $restrictions[$type . ucfirst($sector1)] = $sector1Items;
                 }
             }
         }
         unset($data[$type]);
     }
     unset($data['restrictionsModified']);
     $data['restrictions'] = $restrictions;
     $data = parent::_mapModelToEricssonModel($data);
     return $data;
 }
 protected function _mapModelToEricssonModel(array $data)
 {
     $aux = array();
     //Default Tariff
     $defaultTariff = array('defaultData', 'defaultOrigVoice', 'defaultTermVoice', 'defaultSms');
     foreach ($defaultTariff as $field) {
         if (isset($data[$field])) {
             $aux[$field] = $this->_mapTariffModelToEricsson($data[$field], isset($data['published']) ? $data['published'] : ServicePackModel::STATUS_NOT_PUBLISHED);
         }
         unset($data[$field]);
     }
     //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) {
                 $tariffs[] = $this->_mapTariffModelToEricsson($tariff, $data['published']);
             }
             if (!empty($tariffs)) {
                 $aux[$field] = $tariffs;
             }
         }
         unset($data[$field]);
     }
     $data['data'] = $aux;
     $data = parent::_mapModelToEricssonModel($data);
     return $data;
 }
 protected function _mapModelToEricssonModel(array $data)
 {
     $data['data'] = array();
     $data['data']['states'] = $data['status'];
     if (isset($data['status']) && is_array($data['status'])) {
         $mappedStatus = array();
         foreach ($data['status'] as $status) {
             $mappedStatus[] = $this->_mapModelStatusToEricsson($status);
         }
         $data['data']['states'] = $mappedStatus;
     }
     unset($data['status']);
     $data = parent::_mapModelToEricssonModel($data);
     return $data;
 }
Exemplo n.º 7
0
 protected function _mapModelToEricssonModel(array $data)
 {
     // Transformations before "underscoring" names
     if (isset($data['simType'])) {
         $this->_mapEnumToEricssonEnum($data['simType'], $this->_simTypeMap);
     }
     if (isset($data['gprsStatus']) && isset($data['gprsStatus']['status'])) {
         $this->_mapEnumToEricssonEnum($data['gprsStatus']['status'], $this->_connStatusMap);
     }
     if (isset($data['ipStatus']) && isset($data['ipStatus']['status'])) {
         $this->_mapEnumToEricssonEnum($data['ipStatus']['status'], $this->_connStatusMap);
     }
     if (isset($data['staticIpApnIndex']) && $data['staticIpApnIndex'] == '-') {
         $data['staticIpApnIndex'] = -1;
         $data['staticIpAddress'] = "";
     }
     if (isset($data['lteEnabled'])) {
         $data['isLteEnabled'] = $data['lteEnabled'];
         unset($data['lteEnabled']);
     }
     $erasableFields = array('alias', 'customField_1', 'customField_2', 'customField_3', 'customField_4');
     foreach ($erasableFields as $field) {
         if (isset($data[$field]) && $data[$field] == '-') {
             $data[$field] = "";
         }
     }
     if (isset($data['apns'])) {
         foreach ($data['apns'] as $key => $value) {
             $data['apn']['apn' . ($key + 1)] = $value;
             unset($data['apn'][$key]);
         }
     }
     // Ericsson issue
     if (isset($data['regionId']) && $data['regionId'] == -1) {
         unset($data['regionId']);
     }
     $data = parent::_mapModelToEricssonModel($data);
     if (isset($data['aggregator_id'])) {
         unset($data['aggregator_id']);
     }
     if (isset($data['end_user_id'])) {
         unset($data['end_user_id']);
     }
     return $data;
 }
Exemplo n.º 8
0
 /**
  * Maps application model fields to Ericsson proto message fields
  * @param array $data
  * @return array
  */
 protected function _mapModelToEricssonModel(array $data)
 {
     if (isset($data['adjusts'])) {
         $data['adjusts'] = array('adjustList' => $data['adjusts']);
     }
     if (isset($data['discounts']['addedDiscounts'])) {
         $data['discounts']['addedDiscounts'] = array('general' => $data['discounts']['addedDiscounts']);
     }
     return parent::_mapModelToEricssonModel($data);
 }
 protected function _mapModelToEricssonModel(array $data)
 {
     $data['data'] = array();
     if (isset($data['status'])) {
         $data['data']['states'] = $data['status'];
         unset($data['status']);
         foreach ($data['data']['states'] as $key => $state) {
             $data['data']['states'][$key]['state'] = LifeCycleMapper::getInstance()->mapLifeCycleStatusToEricsson($state['status']);
             unset($data['data']['states'][$key]['status']);
             if ($data['published'] !== ServicePackModel::STATUS_NOT_PUBLISHED && isset($data['data']['states'][$key]['cost'])) {
                 $data['data']['states'][$key]['cost_modified'] = $data['data']['states'][$key]['cost'];
                 unset($data['data']['states'][$key]['cost']);
             }
         }
     }
     if (isset($data['transitions'])) {
         $data['data']['transitions'] = $data['transitions'];
         unset($data['transitions']);
         foreach ($data['data']['transitions'] as $key => $transition) {
             $data['data']['transitions'][$key]['stateStart'] = LifeCycleMapper::getInstance()->mapLifeCycleStatusToEricsson($transition['statusStart']);
             $data['data']['transitions'][$key]['stateFinal'] = LifeCycleMapper::getInstance()->mapLifeCycleStatusToEricsson($transition['statusFinal']);
             if ($data['published'] !== ServicePackModel::STATUS_NOT_PUBLISHED && isset($data['data']['transitions'][$key]['cost'])) {
                 $data['data']['transitions'][$key]['cost_modified'] = $data['data']['transitions'][$key]['cost'];
                 unset($data['data']['transitions'][$key]['cost']);
             }
         }
     }
     $data = parent::_mapModelToEricssonModel($data);
     return $data;
 }
 protected function _mapModelDiscountToEricsson($discount)
 {
     $discount = parent::_mapModelToEricssonModel($discount);
     if (isset($discount['customer_id'])) {
         $discount['customer'] = array('id' => OrganizationMapper::cleanOrgId($discount['customer_id']), 'name' => '');
         unset($discount['customer_id']);
     }
     return $discount;
 }
 protected function _mapModelToEricssonModel(array $data)
 {
     $data = parent::_mapModelToEricssonModel($data);
     if (isset($data['tariffs'])) {
         $data['tariffs']['current_tariffs'] = $data['tariffs'];
     }
     if (isset($data['additional_msisdn'])) {
         unset($data['additional_msisdn']);
     }
     if (isset($data['ready_for_multiple_sms_oa'])) {
         unset($data['ready_for_multiple_sms_oa']);
     }
     if (isset($data['monthly_voucher_units_pending_to_update'])) {
         unset($data['monthly_voucher_units_pending_to_update']);
     }
     return $data;
 }