public function init()
 {
     $this->_alarmSrv = \Application\Service\AlarmService::getInstance();
 }
 /**
  * Add alarms list to sim
  *
  * @param SimModel $sim
  */
 protected function _addAlarms(SimModel $sim)
 {
     try {
         // Aggregators cannot list alarms, but they can retrieve
         // alarm list for a sim. Strange behavior, I know.
         // GLOBALPORTAL-94024
         //             $dumbModel = new AlarmModel();
         //             $this->_helper->allowed('list', $dumbModel);
         $result = array();
         /**
          * @var $alarmService \Application\Service\AlarmService
          */
         $alarmService = \Application\Service\AlarmService::getInstance();
         //prepare filter
         $filterValues = array();
         $filterValues[AlarmFilterFields::SIM_ICC] = $sim->getIcc();
         $filterValues[AlarmFilterFields::STATE] = "!" . AlarmModel::STATE_CLOSED;
         $filterValues['sortBy'] = AlarmSortingFields::OPEN_TIME;
         if (\App::getOrgUserLogged()->type == OrgAggregatorModel::ORG_TYPE) {
             $filterValues[AlarmFilterFields::ALARM_TYPE] = "!" . AlarmModel::TYPE_SUPERVISION;
         }
         $filterList = $alarmService->buildFilterList($filterValues);
         $alarms = $alarmService->listAll($filterList);
         $alarms->getIterator()->addPlugin(new Stream\Plugin\Allowed(array('permission' => 'read')));
         $alarms->getIterator()->addPlugin(new Stream\Plugin\FilterNotAllowedFields(array('permission' => 'read_field')));
         // Add list to sim response
         $sim->setAlarms($alarms->getItems());
     } catch (\Exception $e) {
         App::log()->err("An exception occurred while retrieving alarms: " . $e->getMessage());
         // No, do nothing
     }
 }