302 lines
10 KiB
Java
302 lines
10 KiB
Java
package it.acxent.tex.anag;
|
|
|
|
import it.acxent.art.Articolo;
|
|
import it.acxent.art.ArticoloVariante;
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.DBAdapter;
|
|
import it.acxent.db.ResParm;
|
|
import it.acxent.db.WcString;
|
|
import it.acxent.util.DoubleOperator;
|
|
import it.acxent.util.Vectumerator;
|
|
import java.io.Serializable;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.SQLException;
|
|
|
|
public class ArticoloArticoloTessuto extends DBAdapter implements Serializable {
|
|
private static final long serialVersionUID = 1553527279921L;
|
|
|
|
private long id_articoloArticoloTessuto;
|
|
|
|
private long id_articolo;
|
|
|
|
private long id_articoloTessuto;
|
|
|
|
private ArticoloVariante articoloVariante;
|
|
|
|
private ArticoloTessuto articoloTessuto;
|
|
|
|
private long id_articoloVariante;
|
|
|
|
private Articolo articolo;
|
|
|
|
private long bordaturaMm;
|
|
|
|
private ArticoloTessutoColore articoloTessutoColore;
|
|
|
|
private long flgPrincipale;
|
|
|
|
private long mmATT;
|
|
|
|
private long id_articoloTessutoColore;
|
|
|
|
public ArticoloArticoloTessuto(ApplParmFull newApplParmFull) {
|
|
super(newApplParmFull);
|
|
}
|
|
|
|
public ArticoloArticoloTessuto() {}
|
|
|
|
public void setId_articoloArticoloTessuto(long newId_articoloArticoloTessuto) {
|
|
this.id_articoloArticoloTessuto = newId_articoloArticoloTessuto;
|
|
}
|
|
|
|
public void setId_articolo(long newId_articolo) {
|
|
this.id_articolo = newId_articolo;
|
|
setArticolo(null);
|
|
}
|
|
|
|
public void setId_articoloTessuto(long newId_articoloTessuto) {
|
|
this.id_articoloTessuto = newId_articoloTessuto;
|
|
setArticoloTessuto(null);
|
|
}
|
|
|
|
public long getId_articoloArticoloTessuto() {
|
|
return this.id_articoloArticoloTessuto;
|
|
}
|
|
|
|
public long getId_articolo() {
|
|
return this.id_articolo;
|
|
}
|
|
|
|
public long getId_articoloTessuto() {
|
|
return this.id_articoloTessuto;
|
|
}
|
|
|
|
public double getMtATT() {
|
|
DoubleOperator dop = new DoubleOperator((float)getMmATT());
|
|
dop.setScale(4, 1);
|
|
dop.divide(1000.0F);
|
|
return dop.getResult();
|
|
}
|
|
|
|
public void setArticolo(Articolo newArticolo) {
|
|
this.articolo = newArticolo;
|
|
}
|
|
|
|
public Articolo getArticolo() {
|
|
this.articolo = (Articolo)getSecondaryObject(this.articolo, Articolo.class, getId_articolo());
|
|
return this.articolo;
|
|
}
|
|
|
|
public void setArticoloTessuto(ArticoloTessuto newArticoloTessuto) {
|
|
this.articoloTessuto = newArticoloTessuto;
|
|
}
|
|
|
|
public ArticoloTessuto getArticoloTessuto() {
|
|
this.articoloTessuto = (ArticoloTessuto)getSecondaryObject(this.articoloTessuto, ArticoloTessuto.class, getId_articoloTessuto());
|
|
return this.articoloTessuto;
|
|
}
|
|
|
|
protected ResParm checkDeleteCascade() {
|
|
return new ResParm(true);
|
|
}
|
|
|
|
protected void deleteCascade() {}
|
|
|
|
public Vectumerator<ArticoloArticoloTessuto> findByCR(ArticoloArticoloTessutoCR CR, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from ARTICOLO_ARTICOLO_TESSUTO AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
if (CR.getId_articoloTessuto() > 0L)
|
|
wc.addWc("A.id_articoloTessuto=" + CR.getId_articoloTessuto());
|
|
if (CR.getId_articoloVariante() > 0L) {
|
|
wc.addWc("A.id_articoloVariante=" + CR.getId_articoloVariante());
|
|
} else if (CR.getId_articoloVariante() == 0L) {
|
|
wc.addWc("(A.id_articoloVariante is null or A.id_articoloVariante=0)");
|
|
}
|
|
if (CR.getId_articolo() > 0L)
|
|
wc.addWc("A.id_articolo=" + CR.getId_articolo());
|
|
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 ArticoloVariante getArticoloVariante() {
|
|
this.articoloVariante = (ArticoloVariante)getSecondaryObject(this.articoloVariante, ArticoloVariante.class, getId_articoloVariante());
|
|
return this.articoloVariante;
|
|
}
|
|
|
|
public void setArticoloVariante(ArticoloVariante articoloVariante) {
|
|
this.articoloVariante = articoloVariante;
|
|
}
|
|
|
|
public long getId_articoloVariante() {
|
|
return this.id_articoloVariante;
|
|
}
|
|
|
|
public void setId_articoloVariante(long id_articoloVariante) {
|
|
this.id_articoloVariante = id_articoloVariante;
|
|
setArticoloVariante(null);
|
|
}
|
|
|
|
public Vectumerator<ArticoloArticoloTessuto> findByArticolo(long l_id_articolo) {
|
|
String s_Sql_Find = "select A.* from ARTICOLO_ARTICOLO_TESSUTO AS A inner join ARTICOLO_TESSUTO as B ON A.id_articoloTessuto= B.id_articoloTessuto";
|
|
String s_Sql_Order = " order by B.descrizione";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_articolo=" + l_id_articolo);
|
|
wc.addWc("A.id_articoloVariante is null");
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
return findRows(stmt);
|
|
} catch (SQLException e) {
|
|
removeCPConnection();
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public Vectumerator<ArticoloArticoloTessuto> findByArticoloVariante(long l_id_articoloVariante) {
|
|
String s_Sql_Find = "select A.* from ARTICOLO_ARTICOLO_TESSUTO AS A inner join ARTICOLO_TESSUTO as B ON A.id_articoloTessuto= B.id_articoloTessuto";
|
|
String s_Sql_Order = " order by B.descrizione";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_articoloVariante=" + l_id_articoloVariante);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
return findRows(stmt);
|
|
} catch (SQLException e) {
|
|
removeCPConnection();
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public long getId_articoloTessutoColore() {
|
|
return this.id_articoloTessutoColore;
|
|
}
|
|
|
|
public void setId_articoloTessutoColore(long id_articoloTessutoColore) {
|
|
this.id_articoloTessutoColore = id_articoloTessutoColore;
|
|
setArticoloTessutoColore(null);
|
|
}
|
|
|
|
public ArticoloTessutoColore getArticoloTessutoColore() {
|
|
this.articoloTessutoColore = (ArticoloTessutoColore)getSecondaryObject(this.articoloTessutoColore, ArticoloTessutoColore.class,
|
|
getId_articoloTessutoColore());
|
|
return this.articoloTessutoColore;
|
|
}
|
|
|
|
public void setArticoloTessutoColore(ArticoloTessutoColore articoloTessutoColore) {
|
|
this.articoloTessutoColore = articoloTessutoColore;
|
|
}
|
|
|
|
public void findByArticoloVarianteArticoloTessutoColore(long l_id_articoloVariante, long l_id_articolotessuto, long l_id_articolotessutoColore) {
|
|
String s_Sql_Find = "select A.* from ARTICOLO_ARTICOLO_TESSUTO AS A inner join ARTICOLO_TESSUTO as B ON A.id_articoloTessuto= B.id_articoloTessuto";
|
|
String s_Sql_Order = " order by B.descrizione";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_articoloVariante=" + l_id_articoloVariante);
|
|
if (l_id_articolotessuto > 0L)
|
|
wc.addWc("A.id_articoloTessuto=" + l_id_articolotessuto);
|
|
if (l_id_articolotessutoColore > 0L)
|
|
wc.addWc("A.id_articoloTessutoColore=" + l_id_articolotessutoColore);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
findFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
removeCPConnection();
|
|
handleDebug(e);
|
|
}
|
|
}
|
|
|
|
public void findByArticoloArticoloTessutoBase(long l_id_articolo, long l_id_articolotessuto) {
|
|
String s_Sql_Find = "select A.* from ARTICOLO_ARTICOLO_TESSUTO AS A inner join ARTICOLO_TESSUTO as B ON A.id_articoloTessuto= B.id_articoloTessuto";
|
|
String s_Sql_Order = " order by B.descrizione";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_articolo=" + l_id_articolo);
|
|
wc.addWc("A.id_articoloTessuto=" + l_id_articolotessuto);
|
|
wc.addWc("(A.id_articoloTessutoColore is null or A.id_articoloTessutoColore=0) ");
|
|
wc.addWc("A.id_articoloVariante is null");
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
findFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
removeCPConnection();
|
|
handleDebug(e);
|
|
}
|
|
}
|
|
|
|
public void findByArticoloArticoloTessutoColoreBase(long l_id_articolo, long l_id_articolotessutoColore) {
|
|
String s_Sql_Find = "select A.* from ARTICOLO_ARTICOLO_TESSUTO AS A inner join ARTICOLO_TESSUTO as B ON A.id_articoloTessuto= B.id_articoloTessuto";
|
|
String s_Sql_Order = " order by B.descrizione";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_articolo=" + l_id_articolo);
|
|
wc.addWc("A.id_articoloTessutoColore=" + l_id_articolotessutoColore);
|
|
wc.addWc("A.id_articoloVariante is null");
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
findFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
removeCPConnection();
|
|
handleDebug(e);
|
|
}
|
|
}
|
|
|
|
public String getDescrizioneTessuto(String lang) {
|
|
if (getId_articoloTessutoColore() > 0L)
|
|
return getArticoloTessutoColore().getDescrizioneCompleta(lang);
|
|
if (getId_articoloTessuto() > 0L)
|
|
return getArticoloTessuto().getDescrizioneCompleta(lang);
|
|
return "";
|
|
}
|
|
|
|
public String getDescrizioneArticolo(String lang) {
|
|
if (getId_articoloTessutoColore() > 0L)
|
|
return getArticoloVariante().getDescrizioneCompleta(lang);
|
|
if (getId_articolo() > 0L)
|
|
return getArticolo().getDescrizioneCompleta(lang);
|
|
return "";
|
|
}
|
|
|
|
public long getFlgPrincipale() {
|
|
return this.flgPrincipale;
|
|
}
|
|
|
|
public void setFlgPrincipale(long flgPrincipale) {
|
|
this.flgPrincipale = flgPrincipale;
|
|
}
|
|
|
|
public ResParm save() {
|
|
if (getFlgPrincipale() == 1L)
|
|
resetPrincipaleByArticolo(getId_articolo(), getId_articoloVariante());
|
|
return super.save();
|
|
}
|
|
|
|
protected ResParm resetPrincipaleByArticolo(long l_id_articolo, long l_id_articoloVariante) {
|
|
String sql = "update ARTICOLO_ARTICOLO_TESSUTO set flgPrincipale = null where id_articolo=" + l_id_articolo;
|
|
if (l_id_articoloVariante > 0L) {
|
|
sql = sql + " and id_articoloVariante=" + sql;
|
|
} else {
|
|
sql = sql + " and (id_articoloVariante is null or id_articoloVariante=0)";
|
|
}
|
|
return update(sql);
|
|
}
|
|
|
|
public long getMmATT() {
|
|
return this.mmATT;
|
|
}
|
|
|
|
public void setMmATT(long mmATT) {
|
|
this.mmATT = mmATT;
|
|
}
|
|
|
|
public long getBordaturaMm() {
|
|
return this.bordaturaMm;
|
|
}
|
|
|
|
public void setBordaturaMm(long bordaturaMm) {
|
|
this.bordaturaMm = bordaturaMm;
|
|
}
|
|
}
|