Regalamiunsorriso/decompiled-libs/www/acxent-common-1.0.1/it/acxent/tarop/Opzione.java

369 lines
10 KiB
Java

package it.acxent.tarop;
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.net.URLEncoder;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class Opzione extends DBAdapter implements Serializable {
private long id_opzione;
private long flgTipoOpzione;
private long flgFM = -1L;
private long flgPA = -1L;
private long flgAR = -1L;
private String descrizione;
private String titolo;
private String sottotitolo;
private String costo;
private String costoScontato;
private String descrizioneSconto;
private Date dataScadenza;
private String descrizioneCompatibilita;
private long id_categoriaOpzione;
private CategoriaOpzione categoriaOpzione;
public Opzione(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public Opzione() {}
public void setId_opzione(long newId_opzione) {
this.id_opzione = newId_opzione;
}
public void setFlgTipoOpzione(long newFlgTipoOpzione) {
this.flgTipoOpzione = newFlgTipoOpzione;
}
public void setFlgFM(long newFlgFM) {
this.flgFM = newFlgFM;
}
public void setFlgPA(long newFlgPA) {
this.flgPA = newFlgPA;
}
public void setFlgAR(long newFlgAR) {
this.flgAR = newFlgAR;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public void setTitolo(String newTitlo) {
this.titolo = newTitlo;
}
public void setSottotitolo(String newSottotitolo) {
this.sottotitolo = newSottotitolo;
}
public void setCosto(String newCosto) {
this.costo = newCosto;
}
public void setCostoScontato(String newCostoScontato) {
this.costoScontato = newCostoScontato;
}
public void setDescrizioneSconto(String newDescrizioneSconto) {
this.descrizioneSconto = newDescrizioneSconto;
}
public void setDataScadenza(Date newDataScadenza) {
this.dataScadenza = newDataScadenza;
}
public void setDescrizioneCompatibilita(String newDescrizioneCompatibilita) {
this.descrizioneCompatibilita = newDescrizioneCompatibilita;
}
public void setId_categoriaOpzione(long newId_categoriaOpzione) {
this.id_categoriaOpzione = newId_categoriaOpzione;
setCategoriaOpzione(null);
}
public long getId_opzione() {
return this.id_opzione;
}
public long getFlgTipoOpzione() {
return this.flgTipoOpzione;
}
public long getFlgFM() {
return this.flgFM;
}
public long getFlgPA() {
return this.flgPA;
}
public long getFlgAR() {
return this.flgAR;
}
public String getDescrizione() {
return (this.descrizione == null) ? "" :
this.descrizione.trim();
}
public String getTitolo() {
return (this.titolo == null) ? "" : this.titolo.trim();
}
public String getSottotitolo() {
return (this.sottotitolo == null) ? "" :
this.sottotitolo.trim();
}
public String getCosto() {
return (this.costo == null) ? "" : this.costo.trim();
}
public String getCostoScontato() {
return (this.costoScontato == null) ? "" :
this.costoScontato.trim();
}
public String getDescrizioneSconto() {
return (this.descrizioneSconto == null) ? "" :
this.descrizioneSconto.trim();
}
public Date getDataScadenza() {
return this.dataScadenza;
}
public String getDescrizioneCompatibilita() {
return (this.descrizioneCompatibilita == null) ? "" :
this.descrizioneCompatibilita.trim();
}
public long getId_categoriaOpzione() {
return this.id_categoriaOpzione;
}
public void setCategoriaOpzione(CategoriaOpzione newCategoriaOpzione) {
this.categoriaOpzione = newCategoriaOpzione;
}
public CategoriaOpzione getCategoriaOpzione() {
this.categoriaOpzione = (CategoriaOpzione)getSecondaryObject(this.categoriaOpzione, CategoriaOpzione.class,
getId_categoriaOpzione());
return this.categoriaOpzione;
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator findByCR(OpzioneCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from OPZIONE AS A, CATEGORIA_OPZIONE AS B";
String s_Sql_Order = " ORDER BY B.descrizione";
WcString wc = new WcString();
wc.addWc("A.id_categoriaOpzione=B.id_categoriaOpzione");
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.titolo like '%" + token + "%' or A.sottoTitolo like '%" + token + "%')");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
if (CR.getFlgAR() == 0L) {
wc.addWc("(A.flgAR is null or A.flgAR=0)");
} else if (CR.getFlgAR() > 0L) {
wc.addWc("A.flgAR =" + CR.getFlgAR());
}
if (CR.getFlgFM() == 0L) {
wc.addWc("(A.flgFM is null or A.flgFM=0)");
} else if (CR.getFlgFM() > 0L) {
wc.addWc("A.flgFM =" + CR.getFlgFM());
}
if (CR.getFlgPA() == 0L) {
wc.addWc("(A.flgPA is null or A.flgPA=0)");
} else if (CR.getFlgPA() > 0L) {
wc.addWc("A.flgPA =" + CR.getFlgPA());
}
if (CR.getFlgTipoOpzione() == 0L) {
wc.addWc("(A.flgTipoOpzione is null or A.flgTipoOpzione=0)");
} else if (CR.getFlgTipoOpzione() > 0L) {
wc.addWc("A.flgTipoOpzione =" + CR.getFlgTipoOpzione());
}
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 ResParm addOpzioneArticolo(OpzioneArticolo row) {
OpzioneArticolo bean = new OpzioneArticolo(getApFull());
if (row.getId_opzioneArticolo() != 0L) {
bean.findByPrimaryKey(row.getId_opzioneArticolo());
} else {
bean.findById_articoloId_opzione(row.getId_articolo(),
row.getId_opzione());
}
if (bean.getDBState() == 1) {
row.setDBState(bean.getDBState());
row.setId_opzioneArticolo(bean.getId_opzioneArticolo());
}
ResParm rp = row.save();
return rp;
}
public ResParm delOpzioneArticolo(OpzioneArticolo row) {
OpzioneArticolo bean = new OpzioneArticolo(getApFull());
bean.findByPrimaryKey(row.getId_opzioneArticolo());
return bean.delete();
}
public Vectumerator getOpzioniArticoli() {
return new OpzioneArticolo(getApFull()).findById_opzione(getId_opzione());
}
public String getAR() {
return Tariffa.getAR(getFlgAR());
}
public String getFM() {
return Tariffa.getFM(getFlgFM());
}
public String getPA() {
return Tariffa.getPA(getFlgPA());
}
public static String getTipoOpzione(long l_flgTipoOpzione) {
if (l_flgTipoOpzione == 0L)
return "Tariffa";
if (l_flgTipoOpzione == 1L)
return "Tel. Associati";
return "??";
}
public String getTipoOpzione() {
return getTipoOpzione(getFlgTipoOpzione());
}
public Vectumerator findWebByCR(OpzioneCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from OPZIONE AS A , CATEGORIA_OPZIONE AS B";
String s_Sql_Order = " ORDER BY B.descrizione";
WcString wc = new WcString();
wc.addWc("A.id_categoriaOpzione=B.id_categoriaOpzione");
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.titolo like '%" + token + "%' or A.sottoTitolo like '%" + token + "%')");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
if (CR.getFlgAR() == 0L) {
wc.addWc("(A.flgAR is null or A.flgAR=0 or A.flgAR=2)");
} else if (CR.getFlgAR() == 1L) {
wc.addWc("(A.flgAR =1 or A.flgAR=2)");
}
if (CR.getFlgFM() == 0L) {
wc.addWc("(A.flgFM is null or A.flgFM=0)");
} else if (CR.getFlgFM() > 0L) {
wc.addWc("A.flgFM =" + CR.getFlgFM());
}
if (CR.getFlgPA() == 0L) {
wc.addWc("(A.flgPA is null or A.flgPA=0)");
} else if (CR.getFlgPA() > 0L) {
wc.addWc("A.flgPA =" + CR.getFlgPA());
}
if (CR.getFlgTipoOpzione() == 0L) {
wc.addWc("(A.flgTipoOpzione is null or A.flgTipoOpzione=0)");
} else if (CR.getFlgTipoOpzione() > 0L) {
wc.addWc("A.flgTipoOpzione =" + CR.getFlgTipoOpzione());
}
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 Vectumerator findByTariffa(long l_id_tariffa, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from OPZIONE AS A , CATEGORIA_OPZIONE AS B";
String s_Sql_Order = " ORDER BY B.descrizione";
WcString wc = new WcString();
wc.addWc("A.id_categoriaOpzione=B.id_categoriaOpzione");
wc.addWc("A.id_tariffa =" + l_id_tariffa);
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 Vectumerator getTariffe(int pageNumber, int pageRows) {
TariffaCR CR = new TariffaCR();
CR.setFlgAR(getFlgAR());
CR.setFlgFM(getFlgFM());
CR.setFlgPA(getFlgPA());
return new Tariffa(getApFull()).findWebByCR(CR, 0, 0);
}
public String getTitoloUrl() {
try {
return URLEncoder.encode(getTitolo().replace("/", "-"), "utf-8");
} catch (Exception e) {
return getTitolo();
}
}
protected int getStringValueCase(String l_columnName) {
return 0;
}
}