public function __construct($params = array())
 {
     $this->_listFilter = isset($params['filterList']) ? $params['filterList'] : new \App_ListFilter();
     $this->_page = isset($params['paging']['page']) ? $params['paging']['page'] : 1;
     $this->_count = isset($params['paging']['count']) ? $params['paging']['count'] : 0;
     if ($this->_count > 300) {
         set_time_limit(0);
     }
     if (isset($params['totalCount'])) {
         $this->_totalCount = $params['totalCount'];
     }
     if ($this->_listFilter instanceof \App_ListFilter && is_null($this->_totalCount) && $this->_listFilter->getOldCount() !== null) {
         $this->_totalCount = $this->_listFilter->getOldCount();
     }
 }
 public function deleteAll(\App_ListFilter $filterList = NULL)
 {
     $filters = array();
     if ($filterList !== null) {
         $filters['filterList'] = $filterList;
     }
     $mapper = StockMapper::getInstance();
     try {
         $result = $mapper->deleteAll($filters);
     } catch (EricssonException $e) {
         if (!($result = $e->getErrorMessages())) {
             throw $e;
         }
     }
     \App::audit('Deleting all sims from handler ' . $filterList->getCursor(), null);
     $watcher = $mapper->constructWatcherToTransaction();
     $watcher->params->action = 'stockDelete';
     $watcher->params->count = $filterList ? $filterList->getOldCount() : null;
     $txId = uniqid('stockdelete');
     $watcher->entityIds = array($txId);
     WatcherService::getInstance()->create($watcher);
     $event = $mapper->constructEventToTransaction();
     $event->entityId = $txId;
     $eventData = array('hasFailures' => false, 'message' => array());
     if ($result !== true && !empty($result)) {
         $eventData['hasFailures'] = true;
         $eventData['message']['failed'] = $result;
     }
     $event->eventData = $eventData;
     WatcherService::getInstance()->publishEvent($event);
     return $watcher;
 }