/** * @param WeLearn_DTO_IDTO $dto * @return void */ protected function _adicionar(WeLearn_DTO_IDTO &$dto) { $uuidObj = UUID::mint(); $dto->setId($uuidObj->string); $dto->setDataCriacao(time()); $dto->setStatus(WeLearn_Cursos_StatusSugestaoCurso::EM_ESPERA); $this->_cf->insert($uuidObj->bytes, $dto->toCassandra()); $this->_sugestaoPorAreaCF->insert($dto->getSegmento()->getArea()->getId(), array($uuidObj->bytes => '')); $this->_sugestaoPorSegmentoCF->insert($dto->getSegmento()->getId(), array($uuidObj->bytes => '')); $this->_sugestaoPorUsuarioCF->insert($dto->getCriador()->getId(), array($uuidObj->bytes => '')); $this->_sugestaoPorStatusCF->insert($dto->getStatus(), array($uuidObj->bytes => '')); get_instance()->db->insert($this->_mysql_tbl_name, $dto->toMySQL()); $dto->setPersistido(true); }
/** * @param WeLearn_DTO_IDTO $dto * @return boolean */ protected function _atualizar(WeLearn_DTO_IDTO $dto) { $UUID = CassandraUtil::import($dto->getId()); //Verifica se houve alteração no segmento e reconstroi os indexes. $segmentoAtual = $this->_cf->get($UUID->bytes, array('segmento')); if ($segmentoAtual['segmento'] != $dto->getSegmento()->getId()) { $segmentoAtual = $this->_segmentoDAO->recuperar($segmentoAtual['segmento']); $this->_cursosPorAreaCF->remove($segmentoAtual->getArea()->getId(), array($UUID->bytes)); $this->_cursosPorSegmentoCF->remove($segmentoAtual->getId(), array($UUID->bytes)); $this->_cursosPorAreaCF->insert($dto->getSegmento()->getArea()->getId(), array($UUID->bytes => '')); $this->_cursosPorSegmentoCF->insert($dto->getSegmento()->getId(), array($UUID->bytes => '')); } $this->_cf->insert($UUID->bytes, $dto->toCassandra()); if (!is_null($dto->getImagem())) { $this->_imagemDAO->salvar($dto->getImagem()); } if (!is_null($dto->getConfiguracao())) { $this->_configuracaoDAO->salvar($dto->getConfiguracao()); } get_instance()->db->where('id', $dto->getId())->update($this->_mysql_tbl_name, $dto->toMySQL()); }