package it.acxent.newsletter; import it.acxent.contab._ContabAdapter; import it.acxent.db.ApplParmFull; import it.acxent.db.WcString; import it.acxent.util.StringTokenizer; import it.acxent.util.Vectumerator; import java.io.Serializable; import java.sql.PreparedStatement; import java.sql.SQLException; public class AllegatoCodaMessaggi extends _ContabAdapter implements Serializable { private long id_allegatoCodaMessaggi; private long id_codaMessaggi; private String nomeFile; private CodaMessaggi codaMessaggi; public AllegatoCodaMessaggi(ApplParmFull newApplParmFull) { super(newApplParmFull); } public AllegatoCodaMessaggi() {} public void setId_allegatoCodaMessaggi(long newId_allegatoCodaMessaggi) { this.id_allegatoCodaMessaggi = newId_allegatoCodaMessaggi; } public void setId_codaMessaggi(long newId_codaMessaggi) { this.id_codaMessaggi = newId_codaMessaggi; setCodaMessaggi(null); } public void setNomeFile(String newNomeFile) { this.nomeFile = newNomeFile; } public long getId_allegatoCodaMessaggi() { return this.id_allegatoCodaMessaggi; } public long getId_codaMessaggi() { return this.id_codaMessaggi; } public String getNomeFile() { return (this.nomeFile == null) ? "" : this.nomeFile.trim(); } public void setCodaMessaggi(CodaMessaggi newCodaMessaggi) { this.codaMessaggi = newCodaMessaggi; } public CodaMessaggi getCodaMessaggi() { this.codaMessaggi = (CodaMessaggi)getSecondaryObject(this.codaMessaggi, CodaMessaggi.class, getId_codaMessaggi()); return this.codaMessaggi; } protected void deleteCascade() {} public Vectumerator findByCR(AllegatoCodaMessaggiCR CR, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from ALLEGATO_CODA_MESSAGGI AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); if (!CR.getSearchTxt().trim().isEmpty()) { StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = st.nextToken(); txt.append("(A.Cognome like '%" + token + "%' or A.Nome like '%" + token + "%')"); if (st.hasMoreTokens()) txt.append(" and "); } txt.append(")"); wc.addWc(txt.toString()); } try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); return findRows(stmt, pageNumber, pageRows); } catch (SQLException e) { removeCPConnection(); handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public void findByCodaMessaggiNomeFile(long l_id_codaMessaggi, String l_id_nomeFile) { String s_Sql_Find = "select A.* from ALLEGATO_CODA_MESSAGGI AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.id_codaMessaggi=" + l_id_codaMessaggi); wc.addWc("A.nomeFile='" + l_id_nomeFile + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public String getNomeFileCompleto() { return getNomeFileCompleto(getCodaMessaggi().getPathAllegato()); } public String getNomeFileCompleto(String l_path) { return l_path + l_path + "_" + getId_codaMessaggi(); } public String getNomeFileSuDisco() { return "" + getId_codaMessaggi() + "_" + getId_codaMessaggi(); } public Vectumerator findByCodaMessaggi(long l_id_codaMessaggi, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from ALLEGATO_CODA_MESSAGGI AS A"; String s_Sql_Order = " order by A.nomeFile"; WcString wc = new WcString(); wc.addWc("A.id_codaMessaggi=" + l_id_codaMessaggi); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); return findRows(stmt, pageNumber, pageRows); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } }