package it.acxent.news; import it.acxent.db.AddImgInterface; import it.acxent.db.ApplParmFull; import it.acxent.db.DBAdapter; import it.acxent.db.ResParm; import it.acxent.db.WcString; import it.acxent.util.StringTokenizer; import it.acxent.util.Vectumerator; import java.io.Serializable; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.SQLException; public class Newsletter extends DBAdapter implements Serializable, AddImgInterface { private long id_newsletter; private Date dataNewsletter; private String testo_it; private String testo_en; private String titolo_it; private String titolo_en; private String imgTmst; public static final String DEFAULT_NEWSLETTER_IMG_PATH = "_news/_newsletterImg/"; public static final String P_PATH_IMG_NEWSLETTER = "PATH_IMG_NEWSLETTER"; public Newsletter(ApplParmFull newApplParmFull) { super(newApplParmFull); } public Newsletter() {} public void setId_newsletter(long newId_newsletter) { this.id_newsletter = newId_newsletter; } public void setDataNewsletter(Date newDataNewsletter) { this.dataNewsletter = newDataNewsletter; } public void setTitolo_it(String newTitolo_it) { this.titolo_it = newTitolo_it; } public void setTitolo_en(String newTitolo_en) { this.titolo_en = newTitolo_en; } public void setImgTmst(String newImgTmst) { this.imgTmst = newImgTmst; } public long getId_newsletter() { return this.id_newsletter; } public Date getDataNewsletter() { return this.dataNewsletter; } public String getTitolo_it() { return (this.titolo_it == null) ? "" : this.titolo_it; } public String getTitolo_en() { return (this.titolo_en == null) ? "" : this.titolo_en; } public String getImgTmst() { return (this.imgTmst == null) ? "" : this.imgTmst; } protected ResParm checkDeleteCascade() { return new ResParm(true); } protected void deleteCascade() {} public Vectumerator findByCR(NewsletterCR CR, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from NEWSLETTER 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) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public String getPathImgNewsletter() { return getParm("PATH_IMG_NEWSLETTER").getTesto(); } public String getTitolo() { return getTitolo_it(); } public String getLinkPreview() { if (getApFull() != null) { String temp = getParm("SERVERNAME").getTesto(); try { return temp + "Newsletter.abl?id=" + temp; } catch (Exception e) { return "ERRORE encoding url"; } } return ""; } public String getTitolo(String lang) { return getLangField("titolo", lang); } public String getImgFileName(int imgNumber) { return getImgFileName(imgNumber, getImgTmst()); } public String getImgFileName(int imgNumber, String oldTmst) { return "" + getId_newsletter() + "_" + getId_newsletter() + "_" + oldTmst + ".jpg"; } public String getTesto_en() { return (this.testo_en == null) ? "" : this.testo_en; } public void setTesto_en(String testo_en) { this.testo_en = testo_en; } public String getTesto_it() { return (this.testo_it == null) ? "" : this.testo_it; } public void setTesto_it(String testo_it) { this.testo_it = testo_it; } public String getTesto() { return getTesto_it(); } public String getTesto(String lang) { return getLangField("testo", lang); } public String getPathImg() { return getPathImgNewsletter(); } }