package it.acxent.art; import it.acxent.db.ApplParmFull; import it.acxent.db.WcString; import it.acxent.util.Vectumerator; import java.io.Serializable; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.SQLException; public class CaratteristicaArticolo extends _ArtAdapter implements Serializable { private Caratteristica caratteristica; private long id_caratteristica; private long id_lista; private Lista lista; private Date valD; private long valI; private double valDouble; private String valS; private long valSN; private long id_articolo; public CaratteristicaArticolo() {} public CaratteristicaArticolo(ApplParmFull newApplParmFull) { super(newApplParmFull); } protected void deleteCascade() {} public Vectumerator findByCR(CaratteristicaArticoloCR CR, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from caratteristica_articolo AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + String.valueOf(wc)); return findRows(stmt, pageNumber, pageRows); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public Vectumerator findById_articolo(long l_id_articolo, int pageNumber, int pageRows) { String s_Sql_Find = "select A.*, B.ordine from CARATTERISTICA_ARTICOLO AS A, CARATTERISTICA AS B"; String s_Sql_Order = " order by B.ordine"; WcString wc = new WcString(); wc.addWc("A.id_caratteristica=B.id_caratteristica"); wc.addWc("id_articolo=" + l_id_articolo); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + String.valueOf(wc)); return findRows(stmt, pageNumber, pageRows); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public void findById_articoloId_caratteristica(long l_id_articolo, long l_id_caratteristica) { String s_Sql_Find = "select A.* from CARATTERISTICA_ARTICOLO AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("id_articolo=" + l_id_articolo); wc.addWc("id_caratteristica=" + l_id_caratteristica); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + String.valueOf(wc)); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public Caratteristica getCaratteristica() { this.caratteristica = (Caratteristica)getSecondaryObject(this.caratteristica, Caratteristica.class, new Long(getId_caratteristica())); return this.caratteristica; } public long getId_articolo() { return this.id_articolo; } public long getId_caratteristica() { return this.id_caratteristica; } public long getId_lista() { return this.id_lista; } public Lista getLista() { this.lista = (Lista)getSecondaryObject(this.lista, Lista.class, new Long(getId_lista())); return this.lista; } public String getVal() { if (getId_articolo() == 0L) return ""; if (getCaratteristica().getFlgTipoVal() == 3L) return getValS(); if (getCaratteristica().getFlgTipoVal() == 1L) return getNf().format(getValI()); if (getCaratteristica().getFlgTipoVal() == 2L) return getNf().format(getValDouble()); if (getCaratteristica().getFlgTipoVal() == 5L) return getDataFormat().format(getValD()); if (getCaratteristica().getFlgTipoVal() == 4L) return (getValSN() == 0L) ? "No" : "Si"; if (getCaratteristica().getFlgTipoVal() == 6L) return getLista().getValore(); return "??"; } public Date getValD() { return this.valD; } public long getValI() { return this.valI; } public String getValS() { return (this.valS == null) ? "" : this.valS; } public long getValSN() { return this.valSN; } public void setCaratteristica(Caratteristica caratteristica) { this.caratteristica = caratteristica; } public void setId_articolo(long newId_articolo) { this.id_articolo = newId_articolo; } public void setId_caratteristica(long newId_caratteristica) { this.id_caratteristica = newId_caratteristica; setCaratteristica(null); } public void setId_lista(long newId_lista) { this.id_lista = newId_lista; setLista(null); } public void setLista(Lista newLista) { this.lista = newLista; } public void setValD(Date newValD) { this.valD = newValD; } public void setValI(long newValI) { this.valI = newValI; } public void setValS(String newValS) { this.valS = newValS; } public void setValSN(long newValSN) { this.valSN = newValSN; } public double getValDouble() { return this.valDouble; } public void setValDouble(double d) { this.valDouble = d; } public String getVal(String lang) { if (getId_articolo() == 0L) return ""; if (getCaratteristica().getFlgTipoVal() == 3L) return getValS(); if (getCaratteristica().getFlgTipoVal() == 1L) return getNf().format(getValI()); if (getCaratteristica().getFlgTipoVal() == 2L) return getNf().format(getValDouble()); if (getCaratteristica().getFlgTipoVal() == 5L) return getDataFormat().format(getValD()); if (getCaratteristica().getFlgTipoVal() == 4L) return (getValSN() == 0L) ? "No" : "Si"; if (getCaratteristica().getFlgTipoVal() == 6L) return getLista().getValore(lang); return "??"; } }