88 lines
2.3 KiB
Java
88 lines
2.3 KiB
Java
package it.acxent.art;
|
|
|
|
import it.acxent.db.ApplParmFull;
|
|
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 Modello extends _ArtAdapter implements Serializable {
|
|
private long id_modello;
|
|
|
|
private String descrizione;
|
|
|
|
private long id_marca;
|
|
|
|
private Marca marca;
|
|
|
|
public Modello(ApplParmFull newApplParmFull) {
|
|
super(newApplParmFull);
|
|
}
|
|
|
|
public Modello() {}
|
|
|
|
public void setId_modello(long newId_modello) {
|
|
this.id_modello = newId_modello;
|
|
}
|
|
|
|
public void setDescrizione(String newDescrizione) {
|
|
this.descrizione = newDescrizione;
|
|
}
|
|
|
|
public void setId_marca(long newId_marca) {
|
|
this.id_marca = newId_marca;
|
|
setMarca(null);
|
|
}
|
|
|
|
public long getId_modello() {
|
|
return this.id_modello;
|
|
}
|
|
|
|
public String getDescrizione() {
|
|
return (this.descrizione == null) ? "" : this.descrizione.trim();
|
|
}
|
|
|
|
public long getId_marca() {
|
|
return this.id_marca;
|
|
}
|
|
|
|
public void setMarca(Marca newMarca) {
|
|
this.marca = newMarca;
|
|
}
|
|
|
|
public Marca getMarca() {
|
|
this.marca = (Marca)getSecondaryObject(this.marca, Marca.class,
|
|
|
|
getId_marca());
|
|
return this.marca;
|
|
}
|
|
|
|
protected void deleteCascade() {}
|
|
|
|
public Vectumerator findByCR(ModelloCR CR, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from MODELLO AS A";
|
|
String s_Sql_Order = " order by A.descrizione";
|
|
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;
|
|
}
|
|
}
|
|
}
|