233 lines
6.1 KiB
Java
233 lines
6.1 KiB
Java
package it.acxent.anag;
|
|
|
|
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.BufferedReader;
|
|
import java.io.FileReader;
|
|
import java.io.Serializable;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.SQLException;
|
|
|
|
public class AbiCab extends DBAdapter implements Serializable {
|
|
private static final long serialVersionUID = 1460974609869L;
|
|
|
|
private long id_abiCab;
|
|
|
|
private String descrizione;
|
|
|
|
private String agenzia;
|
|
|
|
private String indirizzo;
|
|
|
|
private String cap;
|
|
|
|
private String abi;
|
|
|
|
private String cab;
|
|
|
|
private String bic;
|
|
|
|
private String codiceAlt;
|
|
|
|
private String localita;
|
|
|
|
private String provincia;
|
|
|
|
public AbiCab(ApplParmFull newApplParmFull) {
|
|
super(newApplParmFull);
|
|
}
|
|
|
|
public AbiCab() {}
|
|
|
|
public void setId_abiCab(long newId_abiCab) {
|
|
this.id_abiCab = newId_abiCab;
|
|
}
|
|
|
|
public void setDescrizione(String newDescrizione) {
|
|
this.descrizione = newDescrizione;
|
|
}
|
|
|
|
public void setAgenzia(String newAgenzia) {
|
|
this.agenzia = newAgenzia;
|
|
}
|
|
|
|
public void setIndirizzo(String newIndirizzo) {
|
|
this.indirizzo = newIndirizzo;
|
|
}
|
|
|
|
public void setCap(String newCapZona) {
|
|
this.cap = newCapZona;
|
|
}
|
|
|
|
public void setAbi(String newAbi) {
|
|
this.abi = newAbi;
|
|
}
|
|
|
|
public void setCab(String newCab) {
|
|
this.cab = newCab;
|
|
}
|
|
|
|
public void setBic(String newBic) {
|
|
this.bic = newBic;
|
|
}
|
|
|
|
public void setCodiceAlt(String newCodiceAlt) {
|
|
this.codiceAlt = newCodiceAlt;
|
|
}
|
|
|
|
public long getId_abiCab() {
|
|
return this.id_abiCab;
|
|
}
|
|
|
|
public String getDescrizione() {
|
|
return (this.descrizione == null) ? "" : this.descrizione.trim();
|
|
}
|
|
|
|
public String getAgenzia() {
|
|
return (this.agenzia == null) ? "" : this.agenzia.trim();
|
|
}
|
|
|
|
public String getIndirizzo() {
|
|
return (this.indirizzo == null) ? "" : this.indirizzo.trim();
|
|
}
|
|
|
|
public String getCap() {
|
|
return (this.cap == null) ? "" : this.cap.trim();
|
|
}
|
|
|
|
public String getAbi() {
|
|
return (this.abi == null) ? "" : this.abi.trim();
|
|
}
|
|
|
|
public String getCab() {
|
|
return (this.cab == null) ? "" : this.cab.trim();
|
|
}
|
|
|
|
public String getBic() {
|
|
return (this.bic == null) ? "" : this.bic.trim();
|
|
}
|
|
|
|
public String getCodiceAlt() {
|
|
return (this.codiceAlt == null) ? "" : this.codiceAlt.trim();
|
|
}
|
|
|
|
protected ResParm checkDeleteCascade() {
|
|
return new ResParm(true);
|
|
}
|
|
|
|
protected void deleteCascade() {}
|
|
|
|
public Vectumerator<AbiCab> findByCR(AbiCabCR CR, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from ABI_CAB 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 findByAbiCab(String l_abi, String l_cab) {
|
|
String s_Sql_Find = "select A.* from ABI_CAB AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.abi='" + l_abi + "'");
|
|
wc.addWc("A.cab='" + l_cab + "'");
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
findFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
removeCPConnection();
|
|
handleDebug(e);
|
|
}
|
|
}
|
|
|
|
public ResParm importAbiCab(String fileName) {
|
|
ResParm rp = new ResParm(true);
|
|
int i = 0;
|
|
int se1 = 10;
|
|
int se2 = 100;
|
|
StringBuffer msg = new StringBuffer();
|
|
try {
|
|
BufferedReader reader = new BufferedReader(new FileReader(fileName));
|
|
if (reader != null) {
|
|
reader.readLine();
|
|
String currentLine;
|
|
while ((currentLine = reader.readLine()) != null) {
|
|
StringTokenizer st = new StringTokenizer(currentLine, ";", '"');
|
|
String abi = st.getToken(0);
|
|
String cab = st.getToken(1);
|
|
String istituto = st.getToken(2);
|
|
String sportello = st.getToken(3);
|
|
String indirizzo = st.getToken(4);
|
|
String localita = st.getToken(5);
|
|
String cap = st.getToken(6);
|
|
String prov = st.getToken(7);
|
|
AbiCab bean = new AbiCab(getApFull());
|
|
bean.findByAbiCab(abi, cab);
|
|
bean.setAbi(abi);
|
|
bean.setCab(cab);
|
|
bean.setDescrizione(istituto);
|
|
bean.setAgenzia(sportello);
|
|
bean.setIndirizzo(indirizzo);
|
|
bean.setLocalita(localita);
|
|
bean.setCap(cap);
|
|
bean.setProvincia(prov);
|
|
rp = bean.save();
|
|
if (!rp.getStatus())
|
|
break;
|
|
i++;
|
|
if (se1 > 0 && i % se1 == 0)
|
|
System.out.print(".");
|
|
if (se2 > 0 && i % se2 == 0)
|
|
System.out.println(i);
|
|
}
|
|
if (rp.getStatus()) {
|
|
rp.setMsg("Inserite o aggiornate " + i + " records.");
|
|
} else {
|
|
rp.setMsg("ERRORE! " + rp.getMsg() + "\nRecord numero " + i);
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
rp.setStatus(false);
|
|
rp.setMsg(e);
|
|
}
|
|
return rp;
|
|
}
|
|
|
|
public String getLocalita() {
|
|
return (this.localita == null) ? "" : this.localita.trim();
|
|
}
|
|
|
|
public void setLocalita(String localita) {
|
|
this.localita = localita;
|
|
}
|
|
|
|
public String getProvincia() {
|
|
return (this.provincia == null) ? "" : this.provincia.trim();
|
|
}
|
|
|
|
public void setProvincia(String provincia) {
|
|
this.provincia = provincia;
|
|
}
|
|
}
|