private StringBuilder Add() { var get = new StringBuilder(); get.Append($" public void Add({NomeTabela} entidade) throws Exception{N}"); get.Append($" {{{N}"); get.Append($" try{{{N}"); get.Append( $" PreparedStatement conn = BeginNewStatement(\"INSERT INTO {NomeTabela} ({string.Join(", ", ListaAtributosTabela.Where(e => e.FIELD_NAME != ListaAtributosTabela.First().FIELD_NAME).Select(e => e.FIELD_NAME))}) values ({string.Join(", ", ListaAtributosTabela.Where(e => e.FIELD_NAME != ListaAtributosTabela.First().FIELD_NAME).Select(q => "?"))})\");{N}"); for (var index = 1; index < ListaAtributosTabela.Count; index++) { var att = ListaAtributosTabela[index]; get.Append( $" conn.set{JavaTypesFirebird.GetTypeAtribute(att).ToFirstCharToUpper()}({index}, entidade.get{att.FIELD_NAME.ToFirstCharToUpper()}());{N}"); } get.Append($" conn.execute();{N}"); get.Append($" commit();{N}"); get.Append($" }}{N}"); get.Append($" catch (Exception ex){{{N}"); get.Append($" throw ex;{N}"); get.Append($" }}{N}"); get.Append($" finally {{{N}"); get.Append($" desconecta();{N}"); get.Append($" }}{N}"); get.Append($" }}{N}"); return(get); }
private StringBuilder GetById() { var get = new StringBuilder(); get.Append($" public {NomeTabela} GetById(int ID) throws Exception{N}"); get.Append($" {{{N}"); get.Append($" try{{{N}"); get.Append( $" PreparedStatement conn = BeginNewStatement(\"SELECT * FROM {NomeTabela} WHERE {ListaAtributosTabela.First().FIELD_NAME} =\"+ ID);{N}"); get.Append($" ResultSet rs = conn.executeQuery();{N}"); get.Append($" if(rs.next()){{{N}"); get.Append($" {NomeTabela} resposta = new {NomeTabela}();{N}"); foreach (var att in ListaAtributosTabela) { get.Append( $" resposta.set{att.FIELD_NAME.ToFirstCharToUpper()}(rs.get{JavaTypesFirebird.GetTypeAtribute(att).ToFirstCharToUpper()}(\"{att.FIELD_NAME}\"));{N}"); } get.Append($" return resposta;{N}"); get.Append($" }}{N}"); get.Append($" return null;{N}"); get.Append($" }}{N}"); get.Append($" catch (Exception ex){{{N}"); get.Append($" throw ex;{N}"); get.Append($" }}{N}"); get.Append($" finally {{{N}"); get.Append($" desconecta();{N}"); get.Append($" }}{N}"); get.Append($" }}{N}"); return(get); }
private StringBuilder GetAll() { var get = new StringBuilder(); get.Append($" public List<{NomeTabela}> GetAll() throws Exception{N}"); get.Append($" {{{N}"); get.Append($" try{{{N}"); get.Append($" List<{NomeTabela}> lista = new java.util.ArrayList<{NomeTabela}>();{N}{N}"); get.Append($" PreparedStatement conn = BeginNewStatement(\"SELECT * FROM {NomeTabela}\");{N}"); get.Append($" ResultSet rs = conn.executeQuery();{N}"); get.Append($" while(rs.next()){{{N}"); get.Append($" {NomeTabela} resposta = new {NomeTabela}();{N}"); foreach (var att in ListaAtributosTabela) { get.Append( $" resposta.set{att.FIELD_NAME.ToFirstCharToUpper()}(rs.get{JavaTypesFirebird.GetTypeAtribute(att).ToFirstCharToUpper()}(\"{att.FIELD_NAME}\"));{N}"); } get.Append($" lista.add(resposta);{N}"); get.Append($" }}{N}"); get.Append($" return lista;{N}"); get.Append($" }}{N}"); get.Append($" catch (Exception ex){{{N}"); get.Append($" throw ex;{N}"); get.Append($" }}{N}"); get.Append($" finally {{{N}"); get.Append($" desconecta();{N}"); get.Append($" }}{N}"); get.Append($" }}{N}"); return(get); }
private StringBuilder GetAll() { var nameProc = $"{ParamtersInput.Prefixos.Procedure}S_{NomeTabela.TratarNomeTabela().ToUpper()}"; var get = new StringBuilder(); get.Append($" public List<{NomeTabela}> GetAll() throws Exception{N}"); get.Append($" {{{N}"); get.Append($" try{{{N}"); get.Append($" List<{NomeTabela}> lista = new java.util.ArrayList<{NomeTabela}>();{N}{N}"); get.Append($" BeginNewStatement(Proc.{nameProc}, \"{ParamtersInput.DataBase}\");{N}"); get.Append($" ResultSet rs = super.ExecuteReader();{N}{N}"); get.Append($" while(rs.next()){{{N}"); get.Append($" {NomeTabela} resposta = new {NomeTabela}();{N}"); foreach (var att in ListaAtributosTabela) { get.Append( $" resposta.set{att.FIELD_NAME}(rs.get{JavaTypesFirebird.GetTypeAtribute(att)}(\"{att.FIELD_NAME}\"));{N}"); } get.Append($" lista.add(resposta);{N}"); get.Append($" }};{N}"); get.Append($" return lista;{N}"); get.Append($" }}{N}"); get.Append($" catch (Exception ex){{{N}"); get.Append($" throw ex;{N}"); get.Append($" }}{N}"); get.Append($" finally {{{N}"); get.Append($" desconecta();{N}"); get.Append($" }}{N}"); get.Append($" }}{N}"); return(get); }
private StringBuilder GetById() { var nameProc = $"{ParamtersInput.Prefixos.Procedure}S_{NomeTabela.TratarNomeTabela().ToUpper()}_ID"; var get = new StringBuilder(); get.Append($" public {NomeTabela} GetById(int id) throws Exception{N}"); get.Append($" {{{N}"); get.Append($" try{{{N}"); get.Append($" BeginNewStatement(Proc.{nameProc}, \"{ParamtersInput.DataBase}\");{N}"); get.Append( $" AddParamter(new Paramter(\"P_{ListaAtributosTabela.First().FIELD_NAME}\", java.sql.Types.NUMERIC, id));{N}{N}"); get.Append($" ResultSet rs = super.ExecuteReader();{N}{N}"); get.Append($" if(rs.next()){{{N}"); get.Append($" {NomeTabela} resposta = new {NomeTabela}();{N}"); foreach (var att in ListaAtributosTabela) { get.Append( $" resposta.set{att.FIELD_NAME}(rs.get{JavaTypesFirebird.GetTypeAtribute(att)}(\"{att.FIELD_NAME}\"));{N}"); } get.Append($" return resposta;{N}"); get.Append($" }};{N}"); get.Append($" return null;{N}"); get.Append($" }}{N}"); get.Append($" catch (Exception ex){{{N}"); get.Append($" throw ex;{N}"); get.Append($" }}{N}"); get.Append($" finally {{{N}"); get.Append($" desconecta();{N}"); get.Append($" }}{N}"); get.Append($" }}{N}"); return(get); }
private StringBuilder AtributosBody(List <FirebirdEntidadeTabela> entidadeTabela) { var atributoBody = new StringBuilder(); foreach (var att in entidadeTabela) { atributoBody.Append($" /** {N}"); atributoBody.Append($" * {N}"); atributoBody.Append($" * @return {N}"); atributoBody.Append($" * @Descrição {att.COLUMN_COMMENT} {N}"); atributoBody.Append($" */{N}"); atributoBody.Append( $" public {JavaTypesFirebird.GetTypeAtribute(att)} get{att.FIELD_NAME.ToFirstCharToUpper()}() {{{N}"); atributoBody.Append($" return {att.FIELD_NAME};{N}"); atributoBody.Append($" }}{N}"); atributoBody.Append($"{N}"); atributoBody.Append( $" public void set{att.FIELD_NAME.ToFirstCharToUpper()}({JavaTypesFirebird.GetTypeAtribute(att)} {att.FIELD_NAME}) {{{N}"); atributoBody.Append($" this.{att.FIELD_NAME} = {att.FIELD_NAME};{N}"); atributoBody.Append($" }}{N}"); atributoBody.Append($"{N}"); } return(atributoBody); }
private StringBuilder AtributosHeader(List <FirebirdEntidadeTabela> entidadeTabela) { var atributosHeader = new StringBuilder(); foreach (var att in entidadeTabela) { atributosHeader.Append($" private {JavaTypesFirebird.GetTypeAtribute(att)} {att.FIELD_NAME};{N}"); } atributosHeader.Append($"{N}"); return(atributosHeader); }
private StringBuilder Update() { var nameProc = $"{ParamtersInput.Prefixos.Procedure}U_{NomeTabela.TratarNomeTabela().ToUpper()}"; var get = new StringBuilder(); get.Append($" public void Update({NomeTabela} entidade) throws Exception{N}"); get.Append($" {{{N}"); get.Append($" try{{{N}"); get.Append($" BeginNewStatement(Proc.{nameProc}, \"{ParamtersInput.DataBase}\");{N}"); get.Append($" AddParamter(new Paramter(\"P_RESULT\", java.sql.Types.VARCHAR, null,\"OUT\"));{N}{N}"); foreach (var att in ListaAtributosTabela) { get.Append( $" AddParamter(new Paramter(\"P_{att.FIELD_NAME}\", java.sql.Types.{JavaTypesFirebird.GetTypeAtribute(att)}, entidade.get{att.FIELD_NAME}()));{N}"); } get.Append($" RequestProc();{N}"); get.Append($" }}{N}"); get.Append($" catch (Exception ex){{{N}"); get.Append($" throw ex;{N}"); get.Append($" }}{N}"); get.Append($" finally {{{N}"); get.Append($" desconecta();{N}"); get.Append($" }}{N}"); get.Append($" }}{N}"); return(get); }