예제 #1
0
 public static function performUpgrade()
 {
     \App::log()->info("Retriving life cycle templates.");
     $mapper = TemplateMapper::getInstance();
     try {
         $templateList = self::retrieveLifeCycleTemplates();
     } catch (Exception $e) {
         \App::log()->info($e->getMessage());
         \App::log()->info("Error retriving life cycle templates. Aborting templates upgrade.");
         return;
     }
     \App::log()->info($templateList->getCount() . " templates to upgrade.");
     foreach ($templateList->getItems() as $template) {
         try {
             \App::log()->info("Upgrading life cycle template " . $template->id . "...");
             $lifeCycle = self::upgradeLifeCycle($template);
             $mapper->update(self::upgradeLifeCycleTemplate($template, $lifeCycle));
             \App::log()->info("Template " . $template->id . " upgraded succefully.");
         } catch (App_MigrationTool_TemplatesTo24_Exception $e) {
             \App::log()->info($e->getMessage());
         }
     }
     \App::log()->info("Life cycle templates upgraded succefully.");
     return true;
 }
 public function setUp()
 {
     $this->_mapper = TemplateMapper::getInstance();
     $this->_template = new TemplateModel(array('id' => 'testId'));
     $this->_template->organizationId = self::PROVIDER_ENABLER_ORG_ID;
 }
 public function setUp()
 {
     $this->_mapper = TemplateMapper::getInstance();
     $this->_template = new TemplateModel(Zend_Json::decode($this->_oldTemplateData));
     $this->_template->organizationId = self::PROVIDER_ENABLER_ORG_ID;
 }
 public static function performUpgrade($orgId, $fileName, $zoneNamesfileName = null, $separator = null, &$log = array())
 {
     $internalLog = function ($message) use(&$log) {
         \App::log()->info($message);
         $log[] = $message;
     };
     $internalLog("Upgrading Service Tariff templates for organization {$orgId}");
     $internalLog("Parsing file \"{$fileName}\"...");
     try {
         $fileData = self::parseFile($fileName, $separator);
     } catch (Exception $e) {
         $internalLog($e->getMessage());
         $internalLog("Error parsing file. Aborting templates upgrade.");
         return;
     }
     $internalLog("File \"{$fileName}\" parsed succefully.");
     if ($zoneNamesfileName) {
         $internalLog("Parsing zone names file \"{$zoneNamesfileName}\"...");
         try {
             $zoneNames = self::parseZoneNamesFile($zoneNamesfileName, $separator);
         } catch (Exception $e) {
             $internalLog($e->getMessage());
             $internalLog("Error parsing zone names file. Aborting templates upgrade.");
             return;
         }
         $internalLog("Zone names file \"{$zoneNamesfileName}\" parsed succefully.");
     } else {
         $internalLog("No zone names file defined.");
     }
     $relations = array();
     $internalLog("Creating Zone plan template...");
     try {
         $zonePlan = self::createZonePlan($fileData, $zoneNames, $relations);
         $internalLog("Relations:\n" . var_export($relations, true));
         $template = self::createZonePlanTemplate($orgId, $zonePlan);
         $mapper = TemplateMapper::getInstance();
         $mapper->insert($template);
     } catch (Exception $e) {
         $internalLog($e->getMessage());
         $internalLog("Error creating Zone Plan. Aborting templates upgrade.");
         return;
     }
     $internalLog("Zone plan template create succefully: " . $template->id . ".");
     $internalLog("Zone plan template:\n" . var_export($template->exportData(), true));
     try {
         $templateList = self::retrieveTariffPlanTemplates($orgId);
     } catch (Exception $e) {
         $internalLog($e->getMessage());
         $internalLog("Error retriving tariff templates. Aborting templates upgrade.");
         return;
     }
     $internalLog($templateList->getCount() . " templates to upgrade.");
     foreach ($templateList->getItems() as $template) {
         try {
             $internalLog("Upgrading Service Tariff plan template " . $template->id . "...");
             $tariffPlan = self::upgradeTariffPlan($template, $zonePlan, $relations);
             $mapper->update(self::upgradeTariffPlanTemplate($template->id, $orgId, $tariffPlan));
             $internalLog("Template " . $template->id . " upgraded succefully.");
         } catch (App_MigrationTool_TemplatesTo20_Exception $e) {
             $internalLog($e->getMessage());
         }
     }
     $internalLog("Service Tariff templates for organization {$orgId} upgraded succefully.");
     return true;
 }
예제 #5
0
 /**
  * @param  string    $userId
  * @return UserModel
  */
 public static function find($userId)
 {
     return TemplateMapper::getInstance()->findOneById($userId);
 }
 /**
  * @expectedException Application\Exceptions\NotFoundException
  */
 public function testDeleteNonExistingTemplate()
 {
     $this->template->setId('NoExistsId');
     $this->templateMapper->delete($this->template->getId());
 }