protected function connectToMiddleware($uuid)
 {
     try {
         $this->openController();
         $entity = EntityController::factory($this->em, $uuid);
         $class = $entity->getDefinition()->getInterpreter();
         $interpreter = new $class($entity, $this->em, null, null);
         return $interpreter;
     } catch (\Exception $e) {
         echo "Trying to subcribe to invalid topic " . $uuid . "\n";
         throw $e;
     }
 }
 /**
  * Get channel
  */
 public function get($identifier = NULL)
 {
     $channel = parent::get($identifier);
     if (is_array($channel)) {
         // filter public entities
         return array('channels' => array_values(array_filter($channel['entities'], function ($ch) {
             return $ch instanceof Model\Channel;
         })));
     } else {
         if ($channel instanceof Model\Channel) {
             return $channel;
         } else {
             throw new \Exception('Entity is not a channel: \'' . $identifier . '\'');
         }
     }
 }
 /**
  * Delete tuples from single or multiple channels
  *
  * @todo deduplicate Model\Channel code
  * @param string|array uuid
  */
 public function delete($uuids)
 {
     $from = null;
     $to = null;
     // parse interval
     if (null !== ($from = $this->getParameters()->get('from'))) {
         $from = Interpreter::parseDateTimeString($from);
         if (null !== ($to = $this->getParameters()->get('to'))) {
             $to = Interpreter::parseDateTimeString($to);
             if ($from > $to) {
                 throw new \Exception('From is larger than to');
             }
         }
     } elseif ($from = $this->getParameters()->get('ts')) {
         $to = $from;
     } else {
         throw new \Exception('Missing timestamp (ts, from, to)');
     }
     $rows = 0;
     foreach (self::makeArray($uuids) as $uuid) {
         $channel = EntityController::factory($this->em, $uuid, true);
         $rows += $channel->clearData($this->em->getConnection(), $from, $to);
     }
     return array('rows' => $rows);
 }
 /**
  * Delete Aggregator or remove entity from aggregator
  */
 public function delete($identifier)
 {
     if (!isset($identifier)) {
         return;
     }
     $aggregator = NULL;
     if ($uuids = self::makeArray($this->request->query->get('uuid'))) {
         // remove entity from aggregator
         $aggregator = $this->get($identifier);
         $ec = new EntityController($this->request, $this->em);
         foreach ($uuids as $uuid) {
             $aggregator->removeChild($ec->get($uuid));
         }
         $this->em->flush();
     } else {
         // remove aggregator
         parent::delete($identifier);
     }
     return $aggregator;
 }
 /**
  * Delete Aggregator or remove entity from aggregator
  */
 public function delete($identifier)
 {
     if (!isset($identifier)) {
         return;
     }
     $aggregator = NULL;
     if ($uuids = self::makeArray($this->getParameters()->get('uuid'))) {
         // remove entity from aggregator
         $aggregator = $this->get($identifier);
         foreach ($uuids as $uuid) {
             $aggregator->removeChild(EntityController::factory($this->em, $uuid));
         }
         $this->em->flush();
     } else {
         // remove aggregator
         parent::delete($identifier);
     }
     return $aggregator;
 }
 public function run($operation, array $identifiers = array())
 {
     $ec = new EntityController($this->view, $this->em);
     $entity = $ec->get($identifiers[0]);
     return $this->{$operation}($entity);
 }
 /**
  * Delete Aggregator or remove entity from aggregator
  */
 public function delete($identifier)
 {
     if (isset($identifier) && ($uuid = $this->view->request->getParameter('uuid'))) {
         // remove entity from aggregator
         $aggregator = $this->get($identifier);
         if ($uuid) {
             $ec = new EntityController($this->view, $this->em);
             $aggregator->removeChild($ec->get($uuid));
             $this->em->flush();
         } else {
             throw new \Exception('You have to specifiy a UUID to remove');
         }
     } else {
         // remove aggregator
         parent::delete($identifier);
     }
     return $aggregator;
 }
 protected static function getChannelByUUID($uuid)
 {
     $ec = new Controller\EntityController(null, self::$em);
     return $ec->get($uuid);
 }