void ConversaoTipo::definirTipoDado(unsigned idx_tipo, TipoPgSQL tipo_dado) { //Verifica se o índice do tipo de dado é válido if(idx_tipo<=CONV_TIPO_DESTINO) { /* Caso o tipo de dado que está sendo atribuido seja nulo (vazio) é disparada uma exceção, pois um tipo de dado nulo não deve participar de uma conversão */ if((*tipo_dado)=="") throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRTIPONULO) .arg(QString::fromUtf8(this->obterNome())) .arg(ObjetoBase::obterNomeTipoObjeto(OBJETO_CONV_TIPO)), ERR_PGMODELER_ATRTIPONULO,__PRETTY_FUNCTION__,__FILE__,__LINE__); /* Atribui o tipo de dado ao índice especifico de tipos de dados envolvidos na conversão */ this->tipos[idx_tipo]=tipo_dado; } else /* Caso o índice usado para referenciar o tipo de dado seja inválido é disparada um exceção */ throw Excecao(ERR_PGMODELER_REFTIPOIDXINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); this->nome=QString("cast(%1,%2)").arg(~tipos[CONV_TIPO_ORIGEM]).arg(~tipos[CONV_TIPO_DESTINO]); }
//----------------------------------------------------------- void ConexaoBD::executarComandoDML(const QString &sql, Resultado &resultado) { Resultado *novo_res=NULL; PGresult *res_sql=NULL; //Dispara um erro caso o usuário tente reiniciar uma conexão não iniciada if(!conexao) throw Excecao(ERR_CONEXBD_OPRCONEXNAOALOC, __PRETTY_FUNCTION__, __FILE__, __LINE__); //Aloca um novo resultado para receber o result-set vindo da execução do comando sql res_sql=PQexec(conexao, sql.toStdString().c_str()); if(strlen(PQerrorMessage(conexao))>0) { throw Excecao(QString(Excecao::obterMensagemErro(ERR_CONEXBD_CMDSQLNAOEXECUTADO)) .arg(PQerrorMessage(conexao)), ERR_CONEXBD_CMDSQLNAOEXECUTADO, __PRETTY_FUNCTION__, __FILE__, __LINE__, NULL, QString(PQresultErrorField(res_sql, PG_DIAG_SQLSTATE))); } novo_res=new Resultado(res_sql); //Copia o novo resultado para o resultado do parâmetro resultado=*(novo_res); //Desaloca o resultado criado delete(novo_res); }
//----------------------------------------------------------- Papel *Papel::obterPapel(unsigned tipo_papel, unsigned idx_papel) { Papel *papel=NULL; vector<Papel *> *lista=NULL; //Selecionando a lista de papéis de acordo com o tipo passado switch(tipo_papel) { case PAPEL_REF: lista=&papeis_refs; break; case PAPEL_MEMBRO: lista=&papeis_membros; break; case PAPEL_ADMIN: lista=&papeis_admins; break; default: //Dispara um erro caso se referencie um tipo inválido de lista de papéis throw Excecao(ERR_PGMODELER_REFPAPELINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); break; } /* Caso o índice do papel a ser obtido seja inválido, um erro é gerado */ if(idx_papel > lista->size()) throw Excecao(ERR_PGMODELER_REFPAPELIDXINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); else //Obtém o papel na posição especificada papel=lista->at(idx_papel); return(papel); }
//----------------------------------------------------------- void Gatilho::definirFuncao(Funcao *funcao) { //Caso a função a ser atribuida ao gatilho esteja nula if(!funcao) //Dispara exceção relatando o erro throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRFUNCNAOALOC) .arg(QString::fromUtf8(this->obterNome())) .arg(ObjetoBase::obterNomeTipoObjeto(OBJETO_GATILHO)), ERR_PGMODELER_ATRFUNCNAOALOC,__PRETTY_FUNCTION__,__FILE__,__LINE__); else { //Caso a função não possua tipo de retorno 'trigger', ela não pode ser usada em um gatilho if(funcao->obterTipoRetorno()!="trigger") //Dispara exceção relatando o erro throw Excecao(ERR_PGMODELER_ATRFUNCGATINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); //Caso a função não possua parâmetros, ela não pode ser usada em um gatilho else if(funcao->obterNumParams()==0) //Dispara exceção relatando o erro throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRFUNCNUMPARAMINV) .arg(QString::fromUtf8(this->obterNome())) .arg(ObjetoBase::obterNomeTipoObjeto(OBJETO_GATILHO)), ERR_PGMODELER_ATRFUNCNUMPARAMINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); else this->funcao=funcao; } }
//---------------------------------------------------------- void ParserXML::carregarBufferXML(const QString &buf_xml) { try { int pos1=-1, pos2=-1, tam=0; if(buf_xml.isEmpty()) throw Excecao(ERR_PARSERS_ATRIBBUFXMLVAZIO,__PRETTY_FUNCTION__,__FILE__,__LINE__); pos1=buf_xml.find("<?xml"); pos2=buf_xml.find("?>"); buffer_xml=buf_xml; if(pos1 >= 0 && pos2 >= 0) { tam=(pos2-pos1)+3; decl_xml=buffer_xml.mid(pos1, tam); buffer_xml.replace(pos1,tam,""); } else decl_xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; removerDTD(); interpretarBuffer(); } catch(Excecao &e) { throw Excecao(e.obterMensagemErro(), e.obterTipoErro(), __PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void Sequencia::definirPossuidora(Tabela *tabela, const QString &nome_coluna) { if(!tabela || nome_coluna=="") this->coluna=NULL; else if(tabela) { // Verifica se a tabela não pertence ao mesmo esquema da sequencia. // Caso não pertença, dispara uma exceção. if(tabela->obterEsquema()!=this->esquema) throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRESQDIFTAB) .arg(QString::fromUtf8(this->obterNome(true))), ERR_PGMODELER_ATRESQDIFTAB,__PRETTY_FUNCTION__,__FILE__,__LINE__); /* Verifica se a tabela não pertence ao mesmo dono da sequencia. Caso não pertença, dispara uma exceção. */ if(tabela->obterDono()!=this->dono) throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRDONODIFTAB) .arg(QString::fromUtf8(this->obterNome(true))), ERR_PGMODELER_ATRDONODIFTAB,__PRETTY_FUNCTION__,__FILE__,__LINE__); //Obtém a coluna da tabela com base no nome passado this->coluna=tabela->obterColuna(nome_coluna); if(this->coluna && this->coluna->incluidoPorRelacionamento() && this->coluna->obterIdObjeto() > this->id_objeto) this->id_objeto=ObjetoBase::obterIdGlobal(); //Caso a coluna não exista if(!this->coluna) throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRCOLPOSINDEF) .arg(QString::fromUtf8(this->obterNome(true))), ERR_PGMODELER_ATRCOLPOSINDEF,__PRETTY_FUNCTION__,__FILE__,__LINE__); } }
void Sequencia::definirValores(QString vmin, QString vmax, QString inc, QString inicio, QString cache) { vmin=formatarValor(vmin); vmax=formatarValor(vmax); inc=formatarValor(inc); inicio=formatarValor(inicio); cache=formatarValor(cache); /* Caso algum atributo após a formatação esteja vazio quer dizer que seu valor é invalido, sendo assim uma exceção é disparada*/ if(vmin=="" || vmax=="" || inc=="" || inicio=="" || cache=="") throw Excecao(ERR_PGMODELER_ATRESQVALORINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); else if(compararValores(vmin,vmax) > 0) throw Excecao(ERR_PGMODELER_ATRESQVALORMININV,__PRETTY_FUNCTION__,__FILE__,__LINE__); else if(compararValores(inicio, vmin) < 0 || compararValores(inicio, vmax) > 0) throw Excecao(ERR_PGMODELER_ATRESQVALORINIINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); else if(valorNulo(inc)) throw Excecao(ERR_PGMODELER_ATRESQINCNULO,__PRETTY_FUNCTION__,__FILE__,__LINE__); else if(valorNulo(cache)) throw Excecao(ERR_PGMODELER_ATRESQCACHENULO,__PRETTY_FUNCTION__,__FILE__,__LINE__); this->valor_min=vmin; this->valor_max=vmax; this->incremento=inc; this->cache=cache; this->inicio=inicio; }
//----------------------------------------------------------- void ConversaoCodificacao::definirFuncaoConversao(Funcao *funcao_conv) { //Caso a função de conversão passada seja nula, dispara uma exceção if(!funcao_conv) throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRFUNCNAOALOC) .arg(QString::fromUtf8(this->obterNome(true))) .arg(ObjetoBase::obterNomeTipoObjeto(OBJETO_CONV_CODIFICACAO)), ERR_PGMODELER_ATRFUNCNAOALOC,__PRETTY_FUNCTION__,__FILE__,__LINE__); //A função de conversão deve obrigatoriamente possuir 5 parâmetros else if(funcao_conv->obterNumParams()!=5) throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRFUNCNUMPARAMINV) .arg(QString::fromUtf8(this->obterNome(true))) .arg(ObjetoBase::obterNomeTipoObjeto(OBJETO_CONV_CODIFICACAO)), ERR_PGMODELER_ATRFUNCNUMPARAMINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); /* Verifica os tipos dos parâmetros da função de conversão. Os mesmos devem ser, em ordem, do tipo integer, integer, cstring, internal, integer */ else if(funcao_conv->obterParametro(0).obterTipo()!="integer" || funcao_conv->obterParametro(1).obterTipo()!="integer" || funcao_conv->obterParametro(2).obterTipo()!="cstring" || funcao_conv->obterParametro(3).obterTipo()!="internal" || funcao_conv->obterParametro(4).obterTipo()!="integer") throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRFUNCPARAMINV) .arg(QString::fromUtf8(this->obterNome(true))) .arg(ObjetoBase::obterNomeTipoObjeto(OBJETO_CONV_CODIFICACAO)), ERR_PGMODELER_ATRFUNCPARAMINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); //O tipo de retorno da função de conversão deve ser 'void' else if(funcao_conv->obterTipoRetorno()!="void") throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRFUNCRETINV) .arg(QString::fromUtf8(this->obterNome(true))) .arg(ObjetoBase::obterNomeTipoObjeto(OBJETO_CONV_CODIFICACAO)), ERR_PGMODELER_ATRFUNCRETINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); this->funcao_conv=funcao_conv; }
//---------------------------------------------------------- void ParserXML::restaurarPosicao(const xmlNode *elem) { if(!elem) throw Excecao(ERR_PARSERS_OPRELEMNAOALOC,__PRETTY_FUNCTION__,__FILE__,__LINE__); else if(elem->doc!=doc_xml) throw Excecao(ERR_PARSERS_OPRELEMINVARVDOC,__PRETTY_FUNCTION__,__FILE__,__LINE__); reiniciarNavegacao(); elem_atual=const_cast<xmlNode *>(elem); }
//---------------------------------------------------------- void ParserXML::definirArquivoDTD(const QString &arq_dtd, const QString &nome_dtd) { if(arq_dtd.isEmpty()) throw Excecao(ERR_PARSERS_ATRIBARQDTDVAZIO,__PRETTY_FUNCTION__,__FILE__,__LINE__); if(nome_dtd.isEmpty()) throw Excecao(ERR_PARSERS_ATRIBNOMEDTDVAZIO,__PRETTY_FUNCTION__,__FILE__,__LINE__); decl_dtd="<!DOCTYPE " + nome_dtd + " SYSTEM " + "\"" + arq_dtd + "\">\n"; }
//---------------------------------------------------------- void TabelaWidget::aplicarConfiguracao(void) { try { Tabela *tabela=NULL; if(!this->novo_obj) { //Adiciona o relacionamento à lista de operações antes de ser modificado lista_op->adicionarObjeto(this->objeto, Operacao::OBJETO_MODIFICADO); } tabela=dynamic_cast<Tabela *>(this->objeto); tabela->definirAceitaOids(aceita_oids_chk->isChecked()); //Aplica as configurações básicas ObjetoBaseWidget::aplicarConfiguracao(); try { if(modelo->obterRelacionamento(tabela, NULL)) /* Faz a validação dos relacionamentos para refletir a nova configuração da tabela */ modelo->validarRelacionamentos(); } catch(Excecao &e) { /* O único erro que é desconsiderado é o de invalidação de objetos, pois, mesmo com a restauração do estado original da tabela estes objetos não são recuperados */ if(e.obterTipoErro()==ERR_PGMODELER_REFCOLUNAINVTABELA) //Exibe uma mensagem de erro com o conteúdo da exceção caixa_msg->show(e); //Para os demais erros a exceção é encaminhada else throw Excecao(e.obterMensagemErro(),e.obterTipoErro(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } //Finaliza o encademanto de operações aberto lista_op->finalizarEncadeamentoOperacoes(); //Finaliza a configuração da tabela finalizarConfiguracao(); } catch(Excecao &e) { /* Cancela a configuração o objeto removendo a ultima operação adicionada referente ao objeto editado/criado e desaloca o objeto caso o mesmo seja novo */ lista_op->anularEncadeamentoOperacoes(true); this->cancelarConfiguracao(); lista_op->anularEncadeamentoOperacoes(false); throw Excecao(e.obterMensagemErro(),e.obterTipoErro(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
//----------------------------------------------------------- void Operador::definirNome(const QString &nome) { if(nome=="") throw Excecao(ERR_PGMODELER_ATRNOMEOBJVAZIO,__PRETTY_FUNCTION__,__FILE__,__LINE__); else { if(!nomeValido(nome)) throw Excecao(ERR_PGMODELER_ATRNOMEOBJINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); else this->nome=nome; } }
//----------------------------------------------------------- void TipoBase::definirTipo(unsigned tipo,unsigned offset,unsigned qtd_tipos) { /* Caso a quantidade de tipos seja nula ou maior do que o tamanho da lista de tipos da classe base, dispara um exceção indicando o fato */ if(qtd_tipos==0 || qtd_tipos > this->qtd_tipos) throw Excecao(ERR_PGMODELER_OBTQTDTIPOINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); //Caso o tipo a ser atribuido não seja pertecente a classe de tipo atual else if(!tipoValido(tipo,offset,qtd_tipos)) throw Excecao(ERR_PGMODELER_ATRTIPOINVOBJ,__PRETTY_FUNCTION__,__FILE__,__LINE__); else idx_tipo=tipo; }
//----------------------------------------------------------- void ConfBaseWidget::salvarConfiguracao(const QString &id_conf) { QString buf, //Configura o nome do arquivo de modelo (esquema) de configuração nome_arq_sch=AtributosGlobais::DIR_CONFIGURACOES + AtributosGlobais::SEP_DIRETORIO + AtributosGlobais::DIR_ESQUEMAS + AtributosGlobais::SEP_DIRETORIO + id_conf + AtributosGlobais::EXT_ESQUEMA, //Configura o nome do arquivo de configuração nome_arq=AtributosGlobais::DIR_CONFIGURACOES + AtributosGlobais::SEP_DIRETORIO + id_conf + AtributosGlobais::EXT_CONFIGURACAO; QFile saida(nome_arq); map<QString, QString> atribs; map<QString, map<QString, QString> >::iterator itr, itr_end; try { itr=params_config.begin(); itr_end=params_config.end(); while(itr!=itr_end) { atribs.insert((itr->second).begin(), (itr->second).end()); itr++; } //Gera o modelo de configuração com base nos parâmetros atuais buf=ParserEsquema::obterDefinicaoObjeto(nome_arq_sch, atribs); //Abre o arquivo de configuração para gravação saida.open(QFile::WriteOnly); //Caso não consiga abrir o arquivo para gravação if(!saida.isOpen()) throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ARQNAOGRAVADO).arg(QString::fromUtf8(nome_arq)), ERR_PGMODELER_ARQNAOGRAVADO,__PRETTY_FUNCTION__,__FILE__,__LINE__); //Grava o buffer gerado no arquivo saida.write(buf.toStdString().c_str(), buf.size()); saida.close(); } catch(Excecao &e) { if(saida.isOpen()) saida.close(); throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ARQNAOGRAVADODEFINV).arg(QString::fromUtf8(nome_arq)), ERR_PGMODELER_ARQNAOGRAVADODEFINV,__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
//----------------------------------------------------------- void Tipo::definirElemento(TipoPgSQL elemento) { if(TipoPgSQL::obterIndiceTipoUsuario(this->obterNome(true), this) == !elemento) throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_TIPOUSRAUTOREF).arg(this->obterNome(true)), ERR_PGMODELER_TIPOUSRAUTOREF,__PRETTY_FUNCTION__,__FILE__,__LINE__); else if(elemento!="any" && (elemento.tipoOID() || elemento.pseudoTipo() || elemento.tipoUsuario() || elemento.tipoArray())) throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRELEMENTOINVTIPO).arg(this->obterNome(true)), ERR_PGMODELER_ATRELEMENTOINVTIPO,__PRETTY_FUNCTION__,__FILE__,__LINE__); this->elemento=elemento; }
void ConversaoTipo::definirFuncaoConversao(Funcao *funcao_conv) { unsigned qtd_param; bool erro=false; if(!funcao_conv) throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRFUNCNAOALOC) .arg(QString::fromUtf8(this->obterNome())) .arg(ObjetoBase::obterNomeTipoObjeto(OBJETO_CONV_TIPO)), ERR_PGMODELER_ATRFUNCNAOALOC,__PRETTY_FUNCTION__,__FILE__,__LINE__); //Obtém o número de parâmetros da função para validações específicas qtd_param=funcao_conv->obterNumParams(); //A função deve possuir número de parâmetros de 1 a 3 if(qtd_param==0 || qtd_param > 3) throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRFUNCNUMPARAMINV) .arg(QString::fromUtf8(this->obterNome())) .arg(ObjetoBase::obterNomeTipoObjeto(OBJETO_CONV_TIPO)), ERR_PGMODELER_ATRFUNCNUMPARAMINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); else { /* Verifica se o tipo do primeiro parâmetro é diferente do tipo do tipo de dado de origem da conversão */ erro=(funcao_conv->obterParametro(0).obterTipo()!=this->tipos[CONV_TIPO_ORIGEM]); //Verifica se o tipo do segundo parâmetro é diferente do tipo integer if(!erro && qtd_param>=2) erro=(funcao_conv->obterParametro(1).obterTipo()!="integer"); //Verifica se o tipo do terceiro parâmetro é diferente do tipo boolean if(!erro && qtd_param==3) erro=(funcao_conv->obterParametro(2).obterTipo()!="boolean"); //Caso alguma das validações acima falhe dispara-se uma exceção if(erro) throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRFUNCPARAMINV) .arg(QString::fromUtf8(this->obterNome())) .arg(ObjetoBase::obterNomeTipoObjeto(OBJETO_CONV_TIPO)), ERR_PGMODELER_ATRFUNCPARAMINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); } //Verifica se o tipo de retorno da função é diferente do tipo de destino da conversão if(funcao_conv->obterTipoRetorno()!=this->tipos[CONV_TIPO_DESTINO]) throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_ATRFUNCRETINV) .arg(QString::fromUtf8(this->obterNome())) .arg(ObjetoBase::obterNomeTipoObjeto(OBJETO_CONV_TIPO)), ERR_PGMODELER_ATRFUNCRETINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); this->funcao_conv=funcao_conv; }
//----------------------------------------------------------- void TipoPgSQL::definirPrecisao(int prec) { //Caso o usuário tente definir uma precisao maior que o comprimento do tipo if(((TipoBase::tipos[idx_tipo]=="numeric" || TipoBase::tipos[idx_tipo]=="decimal") && prec > static_cast<int>(comprimento))) throw Excecao(ERR_PGMODELER_ATRPRECISAOINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); else if(((TipoBase::tipos[idx_tipo]=="time" || TipoBase::tipos[idx_tipo]=="timestamp" || TipoBase::tipos[idx_tipo]=="interval") && prec > 6)) throw Excecao(ERR_PGMODELER_ATRPRECTIPOTIMEINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); else //Define a precisão do tipo da coluna this->precisao=prec; }
//----------------------------------------------------------- void Tipo::adicionarAtributo(Parametro atrib) { //O atributo não pode ter o nome vazio nem tipo nulo if(atrib.obterNome()=="" || atrib.obterTipo()==TipoPgSQL::nulo) throw Excecao(ERR_PGMODELER_INSATRIBTIPOINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); else if(TipoPgSQL::obterIndiceTipoUsuario(this->obterNome(true), this) == !atrib.obterTipo()) throw Excecao(Excecao::obterMensagemErro(ERR_PGMODELER_TIPOUSRAUTOREF).arg(this->obterNome(true)), ERR_PGMODELER_TIPOUSRAUTOREF,__PRETTY_FUNCTION__,__FILE__,__LINE__); //Verifica se o atributo com mesmo nome já não foi inserido no tipo else if(atributoExiste(atrib.obterNome())) throw Excecao(ERR_PGMODELER_INSATRIBTIPODUPLIC,__PRETTY_FUNCTION__,__FILE__,__LINE__); atributos.push_back(atrib); }
//----------------------------------------------------------- void Gatilho::adicionarColuna(Coluna *coluna) { if(!coluna) throw Excecao(QString(Excecao::obterMensagemErro(ERR_PGMODELER_ATRCOLNAOALOC)) .arg(this->obterNome(true)) .arg(this->obterNomeTipoObjeto()), ERR_PGMODELER_ATRCOLNAOALOC,__PRETTY_FUNCTION__,__FILE__,__LINE__); else if(coluna->obterTabelaPai() != this->obterTabelaPai()) throw Excecao(QString(Excecao::obterMensagemErro(ERR_PGMODELER_ATRCOLINVGATILHO)) .arg(coluna->obterNome(true)) .arg(this->obterNome(true)), ERR_PGMODELER_ATRCOLINVGATILHO,__PRETTY_FUNCTION__,__FILE__,__LINE__); colunas_upd.push_back(coluna); }
//----------------------------------------------------------- void Tipo::adicionarEnumeracao(const QString &enumer) { //Verifica se a enumeração é vazia if(enumer=="") throw Excecao(ERR_PGMODELER_INSENUMTIPOINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); /* Verifica se o nome da enumeração é válida de acordo com com a regra de nomenclatura de identificadores no PostgreSQL */ else if(!ObjetoBase::nomeValido(enumer)) throw Excecao(ERR_PGMODELER_ATRNOMEOBJINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); //Verifica se uma enumeração com mesmo nome já não foi inserido no tipo else if(enumeracaoExiste(enumer)) throw Excecao(ERR_PGMODELER_INSENUMTIPODUPLIC,__PRETTY_FUNCTION__,__FILE__,__LINE__); enumeracoes.push_back(enumer); }
//---------------------------------------------------------- void GatilhoWidget::atualizarComboColunas(void) { Coluna *coluna=NULL; unsigned i, qtd_col=0; try { qtd_col=tabela->obterNumColunas(); coluna_cmb->clear(); for(i=0; i < qtd_col; i++) { coluna=tabela->obterColuna(i); /* Insere a coluna no combo somente a mesma não existir na tabela, essa checagem é feita tentando se obter o índice da linha na tabela a qual possui a coluna, caso esse índice seja negativo indica que a coluna não está presente na tabela */ if(tab_colunas->obterIndiceLinha(QVariant::fromValue<void *>(coluna)) < 0) { coluna_cmb->addItem(QString::fromUtf8(coluna->obterNome()) + " (" + ~coluna->obterTipo() +")", QVariant::fromValue<void *>(coluna)); } } //Desabilita o obtão de inserir itens na tabela caso não hajam itens no combobox tab_colunas->habilitarBotoes(TabelaObjetosWidget::BTN_INSERIR_ITEM, (coluna_cmb->count()!=0)); } catch(Excecao &e) { throw Excecao(e.obterMensagemErro(),e.obterTipoErro(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void CaixaTextoWidget::aplicarConfiguracao(void) { try { CaixaTexto *caixa=NULL; iniciarConfiguracao<CaixaTexto>(); caixa=dynamic_cast<CaixaTexto *>(this->objeto); //caixa->definirPosicaoObjeto(QPointF(this->px_objeto, this->py_objeto)); caixa->definirComentario(texto_txt->toPlainText()); caixa->definirAtributoTexto(CaixaTexto::TEXTO_ITALICO, italico_chk->isChecked()); caixa->definirAtributoTexto(CaixaTexto::TEXTO_NEGRITO, negrito_chk->isChecked()); caixa->definirAtributoTexto(CaixaTexto::TEXTO_SUBLINHADO, sublinhado_chk->isChecked()); caixa->definirCorTexto(sel_cor_tb->palette().color(QPalette::Button)); ObjetoBaseWidget::aplicarConfiguracao(); finalizarConfiguracao(); } catch(Excecao &e) { /* Cancela a configuração o objeto removendo a ultima operação adicionada referente ao objeto editado/criado e desaloca o objeto caso o mesmo seja novo */ cancelarConfiguracao(); throw Excecao(e.obterMensagemErro(),e.obterTipoErro(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
bool Restricao::colunaExistente(Coluna *coluna, unsigned tipo_coluna) { vector<Coluna *>::iterator itr, itr_end; Coluna *col_aux=NULL; bool enc=false; //Caso a coluna a ser buscada não esteja aloca, dispara uma exceção if(!coluna) throw Excecao(ERR_PGMODELER_OPROBJNAOALOC,__PRETTY_FUNCTION__,__FILE__,__LINE__); if(tipo_coluna==COLUNA_ORIGEM) { itr=colunas.begin(); itr_end=colunas.end(); } else { itr=colunas_ref.begin(); itr_end=colunas_ref.end(); } /* Varre a lista de colunas selecionada verificando se o nome da coluna é igual ao nome de uma das colunas da lista ou mesmo se os endereços das colunas envolvidas são iguais */ while(itr!=itr_end && !enc) { col_aux=(*itr); enc=(col_aux==coluna || col_aux->obterNome()==coluna->obterNome()); itr++; } return(enc); }
void Restricao::definirEspacoTabela(EspacoTabela *espacotabela) { try { if(espacotabela && tipo!=TipoRestricao::primary_key && tipo!=TipoRestricao::unique) throw Excecao(ERR_PGMODELER_ATRESPTABRESTTIPOINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); ObjetoBase::definirEspacoTabela(espacotabela); } catch(Excecao &e) { throw Excecao(e.obterMensagemErro(),e.obterTipoErro(),__PRETTY_FUNCTION__,__FILE__,__LINE__,&e); } }
//----------------------------------------------------------- Funcao *Tipo::obterFuncao(unsigned conf_func) { if(conf_func > FUNCAO_ANALYZE) throw Excecao(ERR_PGMODELER_REFFUNCTIPOINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); return(funcoes[conf_func]); }
//----------------------------------------------------------- QString Tipo::obterEnumeracao(unsigned idx_enum) { if(idx_enum >= enumeracoes.size()) throw Excecao(ERR_PGMODELER_REFENUMTIPOIDXINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); return(enumeracoes[idx_enum]); }
//----------------------------------------------------------- Parametro Tipo::obterAtributo(unsigned idx_atrib) { if(idx_atrib >= atributos.size()) throw Excecao(ERR_PGMODELER_REFATRIBTIPOIDXINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); return(atributos[idx_atrib]); }
//----------------------------------------------------------- void Tipo::definirConfiguracao(unsigned conf) { unsigned idx; /* Ao se definir uma configuração de tipo os atributos não pertinentes a esta serão limpos. */ //Verifica se a configuração a ser atribuída ao tipo é válida if(conf < TIPO_BASE || conf > TIPO_COMPOSTO) throw Excecao(ERR_PGMODELER_ATRCONFTIPOINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); if(conf!=TIPO_BASE) { if(conf==TIPO_ENUMERACAO) atributos.clear(); else enumeracoes.clear(); for(idx=0; idx < 7; idx++) funcoes[idx]=NULL; valor_padrao=""; elemento="any"; delimitador='\0'; por_valor=false; comp_interno=0; } else { atributos.clear(); enumeracoes.clear(); } this->config=conf; }
//----------------------------------------------------------- void Tipo::removerEnumeracao(unsigned idx_enum) { if(idx_enum >= enumeracoes.size()) throw Excecao(ERR_PGMODELER_REFENUMTIPOIDXINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); enumeracoes.erase(enumeracoes.begin() + idx_enum); }
//----------------------------------------------------------- Referencia::Referencia(const QString &expressao, const QString &alias_exp) { if(expressao=="") throw Excecao(ERR_PGMODELER_ATREXPRINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); /* Caso o alias da expressão seja inválido de acordo com as regras de nomenclatura do PostgreSQL */ else if(!ObjetoBase::nomeValido(alias_exp)) throw Excecao(ERR_PGMODELER_ATRNOMEOBJINV,__PRETTY_FUNCTION__,__FILE__,__LINE__); tabela=NULL; coluna=NULL; //Atribui os parâmetros aos atributos do objeto alias=alias_exp; this->expressao=expressao; }