/** * (non-PHPdoc) * @see Application\Model\Mapper\FilterMapperAbstract::_mapSimpleValue() */ protected function _mapSimpleValue(\DrSlump\Protobuf\Field $descriptor, \App_ListFilter_Interface $filter, \App_ListFilter $filterList) { if ($filter->getFieldName() === ReportFilterFields::ORGANIZATION) { return OrganizationMapper::cleanOrgId(parent::_mapSimpleValue($descriptor, $filter, $filterList)); } return parent::_mapSimpleValue($descriptor, $filter, $filterList); }
protected function _mapSimpleValue(\DrSlump\Protobuf\Field $descriptor, \App_ListFilter_Interface $filter, \App_ListFilter $filterList) { switch ($filter->getFieldName()) { case PreBillFilterFields::CUSTOMER: return OrganizationMapper::cleanOrgId(parent::_mapSimpleValue($descriptor, $filter, $filterList)); } return parent::_mapSimpleValue($descriptor, $filter, $filterList); }
protected function _mapSimpleValue(\DrSlump\Protobuf\Field $descriptor, \App_ListFilter_Interface $filter, \App_ListFilter $filterList) { switch ($filter->getFieldName()) { case CommercialGroupFilterFields::AGGREGATOR_ID: return OrganizationMapper::cleanOrgId(parent::_mapSimpleValue($descriptor, $filter, $filterList)); } return parent::_mapSimpleValue($descriptor, $filter, $filterList); }
protected function _mapSimpleValue(\DrSlump\Protobuf\Field $descriptor, \App_ListFilter_Interface $filter, \App_ListFilter $filterList) { switch ($filter->getFieldName()) { case StockFilterFields::SERVICE_PROVIDER_ENABLER: case StockFilterFields::SERVICE_PROVIDER_COMM: return OrganizationMapper::cleanOrgId(parent::_mapSimpleValue($descriptor, $filter, $filterList)); } return parent::_mapSimpleValue($descriptor, $filter, $filterList); }
protected function _mapSimpleValue(\DrSlump\Protobuf\Field $descriptor, \App_ListFilter_Interface $filter, \App_ListFilter $filterList) { switch ($filter->getFieldName()) { // case OrgFilterFields::ID: case ServiceProviderFilterFields::SERVICE_PROVIDER_ID_FOR_COMMERCIALS: case ServiceProviderFilterFields::SERVICE_PROVIDER_ID_FOR_ENABLERS: return OrganizationMapper::cleanOrgId(parent::_mapSimpleValue($descriptor, $filter, $filterList)); } return parent::_mapSimpleValue($descriptor, $filter, $filterList); }
/** * (non-PHPdoc) * @see Application\Model\Mapper\FilterMapperAbstract::_mapSimpleValue() */ protected function _mapMessageValue(\DrSlump\Protobuf\Field $descriptor, \App_ListFilter_Interface $filter, \App_ListFilter $filterList) { switch ($filter->getFieldName()) { case AlarmFilterFields::SIM_ICC: return array('type' => Proto\SubscriptionId\IdType::ICC, 'id' => $filter->getValue()); case AlarmFilterFields::SIM_ID: return array('type' => Proto\SubscriptionId\IdType::ID, 'id' => $filter->getValue()); case AlarmFilterFields::SIM_IMSI: return array('type' => Proto\SubscriptionId\IdType::IMSI, 'id' => $filter->getValue()); case AlarmFilterFields::SIM_MSISDN: return array('type' => Proto\SubscriptionId\IdType::MSISDN, 'id' => $filter->getValue()); case AlarmFilterFields::CUSTOMER: return OrganizationMapper::cleanOrgId(parent::_mapSimpleValue($descriptor, $filter, $filterList)); } return parent::_mapMessageValue($descriptor, $filter, $filterList); }
public function findAll($filters = array(), $options = array()) { $orgId = isset($filters['customerId']) ? $filters['customerId'] : self::$organizationId; $filters['extraFields'] = array('customer_id' => OrganizationMapper::cleanOrgId($orgId)); $itemData = $this->_findAllEricsson($filters); $items = array(); foreach ($itemData['items'] as $id => $data) { $items[$id] = new Model\CommercialGroupModel($data); } $result = new Model\ListResultModel(); $result->setItems($items); if (isset($itemData['count'])) { $result->setCount($itemData['count']); } return $result; }
public function _findOneById($orgId) { $proto = $this->_createProto(self::METHOD_NAME_GETDATA); $proto->setServiceProviderId(OrganizationMapper::cleanOrgId($orgId)); try { // Return the transaction ID $response = $this->_sendRequest(self::METHOD_NAME_GETDATA, array('protoMessage' => $proto)); if ($this->_checkGetResponse($response)) { $data = $response->serialize(new \DrSlump\Protobuf\Codec\PhpArray()); $data = $this->_mapEricssonModelToModel($data); return new $this->_model($data); } } catch (\Exception $e) { //Nothing to do } return NULL; }
protected function _mapModelToEricssonModel(array $data) { if (isset($data['shippingAddressIsCompanyAddress']) && $data['shippingAddressIsCompanyAddress'] && isset($data['shippingAddress'])) { unset($data['shippingAddress']); } if (isset($data['billingAddressIsCompanyAddress']) && $data['billingAddressIsCompanyAddress'] && isset($data['billingAddress'])) { unset($data['billingAddress']); } //Workaround: ericsson must accept orgId as serviceProviderEnablerId on enabler serviceProvider if (isset($data['id']) && isset($data['isEnabler']) && $data['isEnabler']) { $data['serviceProviderEnablerId'] = $data['id']; } if (isset($data['serviceProviderEnablerId'])) { $data['serviceProviderEnablerId'] = OrganizationMapper::cleanOrgId($data['serviceProviderEnablerId']); } return parent::_mapModelToEricssonModel($data); }
public function testNotifyBusinessAction() { $orgId = \App_Test_PHPUnit_Framework_TestCase::CUSTOMER_ORG_ID; $proto = new \Application\Proto\AsyncNotification\Service\BusinessRuleResponse(); $proto->setAlarmRuleCondition(\Application\Proto\AlarmRuleCondition::CONSUMPTION_D_DATA_THR_1); $proto->setAlarmRuleId('alarmRuleId1'); $proto->setAlarmRuleName('pepito'); $businessRule = new \Application\Proto\BusinessRule(); $businessRule->setBusinessRuleType(\Application\Proto\BusinessRuleType::DISABLE_DATA); $proto->setBusinessRule($businessRule); $subscription = new \Application\Proto\SubscriptionId(); $subscription->setType(\Application\Proto\SubscriptionId\IdType::ID); $subscription->setId('1'); $failed = new \Application\Proto\FailedSubscription(); $failed->setSubscription($subscription); $failed->setReason('Reason in da mix'); $proto->setFailed(array($failed)); $proto->setOrganizationId(\Application\Model\Mapper\OrganizationMapper::cleanOrgId($orgId)); $result = new \Application\Proto\Result(); $result->setCode(0); $proto->setResult($result); $proto->setTotalSubscriptions(1); return $this->_testNotify($proto, 'business.service.asyncnotification.BusinessRuleResponse'); }
/** * Creates a organization proto message from organizationId * * @param \Application\Proto\Organization $orgId */ protected function _createOrganization($orgId) { $orgTypeMap = array(OrgSuperModel::ORG_TYPE => Organization\OrgType::MASTER, OrgMasterModel::ORG_TYPE => Organization\OrgType::MASTER, OrgServiceProviderModel::ORG_TYPE => Organization\OrgType::SERVICE_PROVIDER, OrgCustomerModel::ORG_TYPE => Organization\OrgType::CUSTOMER, OrgAggregatorModel::ORG_TYPE => Organization\OrgType::AGGREGATOR); $type = OrganizationMapper::getTypeByOrgId($orgId); if (!isset($orgTypeMap[$type])) { return null; } $orgType = $orgTypeMap[$type]; if ($type != OrgSuperModel::ORG_TYPE) { $orgId = OrganizationMapper::cleanOrgId($orgId); } else { $orgId = substr($orgId, 0, 32); if (strlen($orgId) < 32) { $orgId .= str_repeat('0', 32 - strlen($orgId)); } } $org = new Organization(); $org->setType($orgType); $org->setId($orgId); return $org; }
/** * Delegate a set of subscriptions to a SPC * * @param array $sims * @param type $spCommercialId * @return type * @throws InvalidArgumentException */ public function delegateSims($sims, $spCommercialId) { if (!$sims || !$spCommercialId) { throw new InvalidArgumentException("Invalid Arguments given"); } $methodName = self::METHOD_NAME_DELEGATE_SIMS; $watcher = $this->_constructWatcherToTransaction(); $watcher->params->action = "stockDelegate"; $watcher->params->serviceProviderCommercialId = $spCommercialId; /** @var ServiceProviderCommercialData $proto */ $proto = $this->_createProto($methodName); $proto->setSubscriptions($this->_generateSubscriptionSelect($sims, IdType::ICC, $watcher)); $proto->setServiceProviderCommercialId(OrganizationMapper::cleanOrgId($spCommercialId)); return $this->_sendAsyncRequestFake($methodName, $proto, $sims, array(), $watcher); }
/** * Maps Model fields to Ericsson proto message fields * @param array $data * @return array */ protected function _mapModelToEricssonModel(array $data) { if (isset($data['commercialGroupId'])) { $data['universeType'] = AlarmUniverse::COMMERCIAL_GROUP; $data['universeId'] = $data['commercialGroupId']; } else { if (isset($data['supervisionGroupId'])) { $data['universeType'] = AlarmUniverse::SUBSCRIPTIONS_OF_SUPERVISION_GROUP; $data['universeId'] = $data['supervisionGroupId']; } } if (isset($data['universeType']) && ($data['universeType'] === AlarmRuleModel::UNIVERSE_CUSTOMER || $data['universeType'] === AlarmRuleModel::UNIVERSE_BILLING_ACCOUNT)) { $data['universeId'] = OrganizationMapper::cleanOrgId($data['universeId']); } if (isset($data['universeType'])) { $data['universeType'] = $this->mapUniverseToEricsson($data['universeType']); } if (isset($data['customerId'])) { $data['customerId'] = OrganizationMapper::cleanOrgId($data['customerId']); } if (isset($data['rules']) && is_array($data['rules'])) { $rules = array(); foreach ($data['rules'] as $rule) { if (is_array($rule)) { $rules[] = $this->_mapRuleToEricsson($rule); } } $data['rules'] = $rules; } $data = parent::_mapModelToEricssonModel($data); return $data; }
public function testDelete() { $this->_parentModel->save(); $this->_addUser(OrganizationMapper::cleanOrgId($this->_parentModel->getId()), OrgMasterModel::ORG_TYPE); $this->_model->setParentId($this->_parentModel->getId()); $this->_model->save(); $this->_mapper->delete($this->_model->getId()); $provider = $this->_mapper->findOneById($this->_model->getId()); $this->assertNull($provider); }
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 _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(); }
public function changeBillingCycleStartDay($id, $billingId, $day) { $methodName = static::$_protoMethods['changeBillingCycleStartDay']; $proto = $this->_createProto($methodName); $proto->setCustomerId(OrganizationMapper::cleanOrgId($id)); $proto->setBillingAccountId($billingId); $proto->setBillingCycleStartDay($day); $resp = $this->_sendRequest($methodName, array('protoMessage' => $proto)); return $this->_checkPostResponse($resp); }
/** * @param $orgId * @return SupProvision\Customer\CustomerId */ protected function _generateCustomerId($orgId = null) { $customerId = new SupProvision\Customer\CustomerId(); $customerId->setName(OrganizationMapper::cleanOrgId($orgId ?: self::$organizationId)); return $customerId; }
protected function _constructProtoKpiReportEricsson($params, $proto) { $orgId = OrganizationMapper::cleanOrgId($params['orgId']); // Optional if (!isset($params['groupBy'])) { $params['groupBy'] = Target\KPITarget\KPIGroupBy::NONE; } switch ($params['groupBy']) { case ReportModel::KPI_SECTOR: $params['groupBy'] = Target\KPITarget\KPIGroupBy::SECTOR; break; case ReportModel::KPI_COMPANY_TYPE: $params['groupBy'] = Target\KPITarget\KPIGroupBy::COMPANY_TYPE; break; default: $params['groupBy'] = Target\KPITarget\KPIGroupBy::NONE; } $target = new PbReport\Target\KPITarget(); $target->setServiceProviderId($orgId); $target->setGroupBy($params['groupBy']); $proto->setTarget($target); $proto->setDateMonthlyStart($params['start']); $proto->setDateMonthlyEnd($params['end']); return $proto; }
public function removeCustomer($ssId, $orgId) { $methodName = self::METHOD_NAME_REMOVE_CUSTOMER; $proto = $this->_createProto($methodName); $proto->setSupplservicesId($ssId); $proto->setCustomerId(OrganizationMapper::cleanOrgId($orgId)); $this->getCache()->remove($ssId); $response = $this->_sendRequest($methodName, array('protoMessage' => $proto)); $this->_checkDeleteResponse($response); $this->getCache()->remove($ssId); $this->getCache()->clean(array('list')); return true; }
/** * Returns true if and only if the assertion conditions are met * * This method is passed the ACL, Role, Resource, and privilege to which * the authorization query applies. If the $role, $resource, or $privilege * parameters are null, it means that the query applies to all Roles, * Resources, or privileges, respectively. * * @param Zend_Acl $acl * @param Zend_Acl_Role_Interface $role * @param Zend_Acl_Resource_Interface $resource * @param string $privilege * @return boolean */ public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null) { // We need specific objects to check against each other if (NULL === $role || NULL === $resource) { return false; } // Ensure we're handled User models if (!$role instanceof UserModel) { throw new Exception('Role must be an instance of UserModel'); } $orgId = $role->getOrganizationId(); switch (true) { case $resource instanceof OrgModelAbstract: return $orgId === $resource->getId(); case $resource instanceof UserModel: case $resource instanceof TemplateModel: return $orgId === $resource->getOrganizationId(); case $resource instanceof Async\Model\AsyncResponse: $cOrgId = \Application\Model\Mapper\OrganizationMapper::cleanOrgId($orgId); return $orgId === $resource->getOrganizationId() || $cOrgId === $resource->getOrganizationId(); case $resource instanceof Model\TariffPlanLifeCycleModel: case $resource instanceof Model\TariffPlanServicesModel: case $resource instanceof Model\RestrictionModel: case $resource instanceof Model\ServicePackModel: $orgType = Model\Mapper\OrganizationMapper::getTypeByOrgId($orgId); switch ($orgType) { case Model\Organization\OrgServiceProviderModel::ORG_TYPE: return $orgId === $resource->getServiceProviderId(); case Model\Organization\OrgCustomerModel::ORG_TYPE: // $spList = Service\ServicePackService::getInstance()->listAll(); // foreach ($spList->getItems() as $sp) { // if ($sp->getId() === $resource->getId()) { // return true; // } // } /* * There is no way to know if only one ServicePack is assigned to a customer, * only retrieving all servicePacks assigned. It is too much slow. In Ericsson we trust. */ return true; default: return false; } case $resource instanceof Model\SupplServicesModel: return $orgId === $resource->getServiceProviderId() || $orgId === $resource->getCustomerId(); case $resource instanceof Model\CommercialGroupModel: case $resource instanceof Model\SupervisionGroupModel: return $orgId === $resource->getCustomerId(); case $resource instanceof SimModel: /** @var $resource \Application\Model\SimModel */ return $orgId === $resource->getMasterId() || $orgId === $resource->getServiceProviderCommercialId() || $orgId === $resource->getServiceProviderEnablerId() || $orgId === $resource->getAggregatorId() || $orgId === $resource->getCustomerId() || $orgId === $resource->getEndUserId(); case $resource instanceof Model\ReportModel: $params = $resource->getParams(); if (isset($params['orgId']) && !empty($params['orgId'])) { return $orgId === $params['orgId']; } else { return true; } } throw new Exception('Resource must be an instance of OrgModelAbstract, UserModel or SimModel'); }
private function _processResponse($methodName, $sp = null) { // Build proto (injects accounting and organization) $proto = $this->_createProto($methodName); // Inject service_provider (optional) $method = $this->getEricssonService()->getRestMethod($methodName); $opmc = $method->outputProtoMessageClass; if ($opmc::descriptor()->getFieldByName('service_provider') !== null && ($opmc::descriptor()->getFieldByName('service_provider')->isRequired() || $sp) && (!empty($sp) || !empty(static::$organizationId))) { $orgId = OrganizationMapper::cleanOrgId($sp ?: static::$organizationId); $proto->setServiceProvider($orgId); } $response = $this->_sendRequest($methodName, array('protoMessage' => $proto)); if ($this->_checkGetResponse($response)) { if ($response->getData()) { $data = $response->getData()->serialize(new \DrSlump\Protobuf\Codec\PhpArray()); $data = $this->_mapEricssonModelToModel($data); } return isset($data) && array_key_exists('rows', $data) ? $data['rows'] : array(); } return NULL; }
/** * Maps a range message value. * @param \App_ListFilter_Interface $filter * @return array */ protected function _mapOrganizationValue(\App_ListFilter_Interface $filter, \App_ListFilter $filterList) { $orgTypeMap = array(OrgSuperModel::ORG_TYPE => Organization\OrgType::MASTER, OrgMasterModel::ORG_TYPE => Organization\OrgType::MASTER, OrgServiceProviderModel::ORG_TYPE => Organization\OrgType::SERVICE_PROVIDER, OrgCustomerModel::ORG_TYPE => Organization\OrgType::CUSTOMER); $data = array(); switch (get_class($filter)) { case 'App_ListFilter_EqualFilter': $data['type'] = $orgTypeMap[OrganizationMapper::getTypeByOrgId($filter->getValue())]; $data['id'] = OrganizationMapper::cleanOrgId($filter->getValue()); break; default: return; } return $data; }