Пример #1
0
 /**
  * Query for data by given channel or group
  */
 public function get(Model\Entity $entity)
 {
     $from = $this->view->request->getParameter('from');
     $to = $this->view->request->getParameter('to');
     $tuples = $this->view->request->getParameter('tuples');
     $groupBy = $this->view->request->getParameter('group');
     $class = $entity->getDefinition()->getInterpreter();
     return new $class($entity, $this->em, $from, $to, $tuples, $groupBy);
 }
Пример #2
0
 /**
  * Converts entity to array for json_encode()
  *
  * @param Model\Entity $entity
  * @return array
  */
 protected static function convertEntity(Model\Entity $entity, $chain = array())
 {
     $jsonEntity = array();
     $jsonEntity['uuid'] = (string) $entity->getUuid();
     $jsonEntity['type'] = $entity->getType();
     foreach ($entity->getProperties() as $key => $value) {
         $jsonEntity[$key] = $value;
     }
     if ($entity instanceof Model\Aggregator) {
         $chain[$entity->getUuid()] = 1;
         foreach ($entity->getChildren() as $child) {
             if (array_key_exists($child->getUuid(), $chain)) {
                 continue;
             }
             # don't ever loop back
             $jsonEntity['children'][] = self::convertEntity($child, $chain);
         }
     }
     return $jsonEntity;
 }
Пример #3
0
 /**
  * Constructor
  */
 public function __construct($type)
 {
     parent::__construct($type);
     $this->children = new ArrayCollection();
 }
Пример #4
0
 /**
  * Converts entity to DOMElement
  *
  * @param Model\Entity $entity
  * @return DOMElement
  */
 protected function convertEntity(Model\Entity $entity)
 {
     $xmlEntity = $this->xmlDoc->createElement('entity');
     $xmlEntity->appendChild($this->xmlDoc->createElement('uuid', $entity->getUuid()));
     $xmlEntity->appendChild($this->xmlDoc->createElement('type', $entity->getType()));
     foreach ($entity->getProperties() as $key => $value) {
         $xmlEntity->appendChild($this->xmlDoc->createElement($key, $value));
     }
     return $xmlEntity;
 }
 /**
  * Update/set/delete properties of entities
  */
 protected function setProperties(Model\Entity $entity, $parameters)
 {
     foreach ($parameters as $key => $value) {
         if (in_array($key, array('operation', 'type', 'debug'))) {
             continue;
             // skip generic parameters
         } else {
             if (!Definition\PropertyDefinition::exists($key)) {
                 throw new \Exception('Unknown property: \'' . $key . '\'');
             }
         }
         if ($value == '') {
             // dont use empty() because it also matches 0
             $entity->deleteProperty($key);
         } else {
             $entity->setProperty($key, $value);
         }
     }
     $entity->checkProperties();
 }
Пример #6
0
 /**
  * Constructor
  */
 public function __construct($type)
 {
     parent::__construct($type);
     $this->data = new ArrayCollection();
     $this->groups = new ArrayCollection();
 }
Пример #7
0
 /**
  * Converts entity to array for json_encode()
  *
  * @param Model\Entity $entity
  * @return array
  */
 protected static function convertEntity(Model\Entity $entity)
 {
     $jsonEntity = array();
     $jsonEntity['uuid'] = (string) $entity->getUuid();
     $jsonEntity['type'] = $entity->getType();
     foreach ($entity->getProperties() as $key => $value) {
         $jsonEntity[$key] = $value;
     }
     if ($entity instanceof Model\Aggregator) {
         foreach ($entity->getChildren() as $child) {
             $jsonEntity['children'][] = self::convertEntity($child);
         }
     }
     return $jsonEntity;
 }