168 lines
4.7 KiB
Java
168 lines
4.7 KiB
Java
package it.acxent.tarop;
|
|
|
|
import it.acxent.art.Articolo;
|
|
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.PreparedStatement;
|
|
import java.sql.SQLException;
|
|
|
|
public class OpzioneArticolo extends DBAdapter implements Serializable {
|
|
private long id_opzioneArticolo;
|
|
|
|
private long id_opzione;
|
|
|
|
private String descrizioneOA;
|
|
|
|
private long id_articolo;
|
|
|
|
private Opzione opzione;
|
|
|
|
private Articolo articolo;
|
|
|
|
public OpzioneArticolo(ApplParmFull newApplParmFull) {
|
|
super(newApplParmFull);
|
|
}
|
|
|
|
public OpzioneArticolo() {}
|
|
|
|
public void setId_opzioneArticolo(long newId_opzioneArticolo) {
|
|
this.id_opzioneArticolo = newId_opzioneArticolo;
|
|
}
|
|
|
|
public void setId_opzione(long newId_opzione) {
|
|
this.id_opzione = newId_opzione;
|
|
setOpzione(null);
|
|
}
|
|
|
|
public void setDescrizioneOA(String newDescrizioneTO) {
|
|
this.descrizioneOA = newDescrizioneTO;
|
|
}
|
|
|
|
public long getId_opzioneArticolo() {
|
|
return this.id_opzioneArticolo;
|
|
}
|
|
|
|
public long getId_opzione() {
|
|
return this.id_opzione;
|
|
}
|
|
|
|
public String getDescrizioneOA() {
|
|
return (this.descrizioneOA == null) ? "" :
|
|
this.descrizioneOA.trim();
|
|
}
|
|
|
|
public void setOpzione(Opzione newOpzione) {
|
|
this.opzione = newOpzione;
|
|
}
|
|
|
|
public Opzione getOpzione() {
|
|
this.opzione = (Opzione)getSecondaryObject(this.opzione, Opzione.class,
|
|
getId_opzione());
|
|
return this.opzione;
|
|
}
|
|
|
|
public void setArticolo(Articolo newArticolo) {
|
|
this.articolo = newArticolo;
|
|
}
|
|
|
|
public Articolo getArticolo() {
|
|
this.articolo = (Articolo)getSecondaryObject(this.articolo, Articolo.class,
|
|
getId_articolo());
|
|
return this.articolo;
|
|
}
|
|
|
|
protected ResParm checkDeleteCascade() {
|
|
return new ResParm(true);
|
|
}
|
|
|
|
protected void deleteCascade() {}
|
|
|
|
public Vectumerator findByCR(OpzioneArticoloCR CR, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from OPZIONE_ARTICOLO 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 findById_articoloId_opzione(long l_id_articolo, long l_id_opzione) {
|
|
String s_Sql_Find = "select A.* from OPZIONE_ARTICOLO AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_articolo=" + l_id_articolo);
|
|
wc.addWc("A.id_opzione=" + l_id_opzione);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find +
|
|
wc.toString());
|
|
findFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
removeCPConnection();
|
|
handleDebug(e);
|
|
}
|
|
}
|
|
|
|
public long getId_articolo() {
|
|
return this.id_articolo;
|
|
}
|
|
|
|
public void setId_articolo(long id_articolo) {
|
|
this.id_articolo = id_articolo;
|
|
setArticolo(null);
|
|
}
|
|
|
|
public Vectumerator findById_opzione(long l_id_opzione) {
|
|
String s_Sql_Find = "select A.* from OPZIONE_ARTICOLO AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_opzione=" + l_id_opzione);
|
|
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 findById_articolo(long l_id_articolo) {
|
|
String s_Sql_Find = "select A.* from OPZIONE_ARTICOLO AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_articolo=" + l_id_articolo);
|
|
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;
|
|
}
|
|
}
|
|
}
|