Exemplo n.º 1
0
 /**
  * o primeiro param pode ser uma Query ou um objeto Entity. Se uma Entity for informado, então Config
  * torna-se-á obrigatório devido a necessidade de estabelecer a conexao com o respositorio de dados.
  * a fonte de dados poderá ser informado por meio de terceiro para ou omitido para ser utilizado
  * a fonte de dados padrao.
  *
  * @param DSLinkerReferenceable $target
  * @param Config $config
  * @param string $dsName
  * */
 public function __construct(DSLinkerReferenceable $target, Config $config = NULL, $dsName = 'default')
 {
     # se o target for uma referencia para Entity ou Query entao sera
     # necessario um objeto executor de consulta Persist
     if ($target instanceof Entity || $target instanceof QueryAbstract) {
         $info = $config->get($config->get($dsName));
         $target = QueryAbstract::factory($info->get('driver'), $target);
         PersistConfig::registerConfigs($config->toArray());
         $pConfig = $configPersist = PersistConfig::factory($config->get($dsName));
         $namespace = sprintf('br\\gov\\sial\\core\\persist\\%s\\Persist', $pConfig->get('adapter'));
         $executor = Persist::factory($namespace, $pConfig);
         $target = $executor->execute($target);
     }
     $this->_result = $target;
     /* necessario para tornar o */
     $this->next();
 }
Exemplo n.º 2
0
 /**
  * @param string $attrName
  * @param Entity $entity
  * @param string $defaultValue
  * @return ElementAbstract
  * */
 public function fieldForeign($attrName, Entity $entity, $defaultValue = NULL)
 {
     $info = $this->_FKConfig->get($attrName);
     return new Select($attrName, $this->_executor->execute(QueryAbstract::factory($this->_executor->getConfig()->get('driver'), $entity)), $info->value, $info->label, $defaultValue);
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  * @see br\gov\sial\core\persist.Persistable::getQuery()
  */
 public function getQuery($entity)
 {
     return QueryAbstract::factory(self::PERSIST_LEAF, $entity);
 }
Exemplo n.º 4
0
 /**
  * Representação textual da coluna.
  *
  * @return string
  * */
 public function render()
 {
     $column = QueryAbstract::quotesIf($this->_name);
     $entity = $this->entity();
     if ($entity instanceof Entity) {
         $entity = $this->toggle($entity->alias(), $entity->name());
     }
     $entity = $entity ? $entity . '.' : NULL;
     # esta verifica eh necessario por causa das Expression
     if ($this->_name instanceof Renderizable) {
         $column = $this->_name->render();
         $entity = NULL;
     }
     if ($this->_alias) {
         $column .= " AS {$this->_alias}";
     }
     return "{$entity}{$column}";
 }
Exemplo n.º 5
0
 /**
  * @return string
  * */
 public function name()
 {
     return QueryAbstract::quotesIf($this->_name);
 }