public function insert(PersistentAbstract $object)
 {
     $this->getCache()->clean(array('list'));
     $data = $object->exportData();
     if (!empty($data)) {
         if ($this->_timestamps) {
             $data['created'] = $data['modified'] = time();
         }
         // HACK: Mongo driver will modify the $object->_data event if not passed as reference
         $data = array_merge($data, array());
         $data = $this->_mapModelToMongoModel($data);
         try {
             $newData = $this->getCollection()->findAndModify(array('servicePackId' => array('$exists' => false)), array('$set' => $data));
         } catch (\Exception $e) {
             throw new MongoException($e->getMessage());
         }
         if (empty($newData)) {
             throw new MongoException("No more resId available.");
         }
         $object->setId($newData['_id']);
         $object->setResId($newData['resId']);
         return $object->id;
     }
     throw new InvalidArgumentException(get_class($this) . ': Object ID not defined.');
 }
 public function __construct(array $data = null)
 {
     parent::__construct($data);
     $count = 0;
     if (is_numeric($this->subscriptionCountVpnService)) {
         $count += $this->subscriptionCountVpnService;
     }
     if (is_numeric($this->subscriptionCountAdvancedSupervision)) {
         $count += $this->subscriptionCountAdvancedSupervision;
     }
     if (is_numeric($this->subscriptionCountLocation)) {
         $count += $this->subscriptionCountLocation;
     }
     if (is_numeric($this->subscriptionCountDca)) {
         $count += $this->subscriptionCountDca;
     }
     if (is_numeric($this->subscriptionCountDim)) {
         $count += $this->subscriptionCountDim;
     }
     $this->subscriptionCount = $count;
 }