205 lines
6.1 KiB
Java
205 lines
6.1 KiB
Java
package it.acxent.anag;
|
|
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.WcString;
|
|
import it.acxent.util.StringTokenizer;
|
|
import it.acxent.util.Vectumerator;
|
|
import java.io.File;
|
|
import java.io.Serializable;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.SQLException;
|
|
|
|
public class AllegatoClifor extends _AnagAdapter implements Serializable {
|
|
private static final long serialVersionUID = 8911811275285647807L;
|
|
|
|
private long id_allegatoClifor;
|
|
|
|
private long id_clifor;
|
|
|
|
private long id_tipoAllegatoClifor;
|
|
|
|
private String nomeFile;
|
|
|
|
private Clifor clifor;
|
|
|
|
private TipoAllegatoClifor tipoAllegatoClifor;
|
|
|
|
private String descrizioneAllegato;
|
|
|
|
private long flgDefault;
|
|
|
|
public AllegatoClifor(ApplParmFull newApplParmFull) {
|
|
super(newApplParmFull);
|
|
}
|
|
|
|
public AllegatoClifor() {}
|
|
|
|
public void setId_allegatoClifor(long newId_allegatoClifor) {
|
|
this.id_allegatoClifor = newId_allegatoClifor;
|
|
}
|
|
|
|
public void setId_clifor(long newId_clifor) {
|
|
this.id_clifor = newId_clifor;
|
|
setClifor(null);
|
|
}
|
|
|
|
public void setId_tipoAllegatoClifor(long newId_tipoAllegatoClifor) {
|
|
this.id_tipoAllegatoClifor = newId_tipoAllegatoClifor;
|
|
setTipoAllegatoClifor(null);
|
|
}
|
|
|
|
public void setNomeFile(String newNomeFile) {
|
|
this.nomeFile = newNomeFile;
|
|
}
|
|
|
|
public long getId_allegatoClifor() {
|
|
return this.id_allegatoClifor;
|
|
}
|
|
|
|
public long getId_clifor() {
|
|
return this.id_clifor;
|
|
}
|
|
|
|
public long getId_tipoAllegatoClifor() {
|
|
return this.id_tipoAllegatoClifor;
|
|
}
|
|
|
|
public String getNomeFile() {
|
|
return (this.nomeFile == null) ? "" : this.nomeFile.trim();
|
|
}
|
|
|
|
public void setClifor(Clifor newClifor) {
|
|
this.clifor = newClifor;
|
|
}
|
|
|
|
public Clifor getClifor() {
|
|
this.clifor = (Clifor)getSecondaryObject(this.clifor, Clifor.class, getId_clifor());
|
|
return this.clifor;
|
|
}
|
|
|
|
public void setTipoAllegatoClifor(TipoAllegatoClifor newTipoAllegatoClifor) {
|
|
this.tipoAllegatoClifor = newTipoAllegatoClifor;
|
|
}
|
|
|
|
public TipoAllegatoClifor getTipoAllegatoClifor() {
|
|
this.tipoAllegatoClifor = (TipoAllegatoClifor)getSecondaryObject(this.tipoAllegatoClifor, TipoAllegatoClifor.class,
|
|
getId_tipoAllegatoClifor());
|
|
return this.tipoAllegatoClifor;
|
|
}
|
|
|
|
protected void deleteCascade() {
|
|
new File(getPathAllegato() + getPathAllegato()).delete();
|
|
}
|
|
|
|
public Vectumerator findByCR(AllegatoCliforCR CR, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from ALLEGATO_CLIFOR 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 findByCliforNomeFile(long l_id_clifor, String l_id_nomeFile) {
|
|
String s_Sql_Find = "select A.* from ALLEGATO_CLIFOR AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_clifor=" + l_id_clifor);
|
|
wc.addWc("A.nomeFile='" + l_id_nomeFile + "'");
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
findFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
}
|
|
}
|
|
|
|
public Vectumerator findByCliforTipo(long l_id_clifor, long l_id_tipoAllegatoClifor, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from ALLEGATO_CLIFOR AS A";
|
|
String s_Sql_Order = " order by A.nomeFile";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_clifor=" + l_id_clifor);
|
|
if (l_id_tipoAllegatoClifor > 0L)
|
|
wc.addWc("A.id_tipoAllegatoClifor=" + l_id_tipoAllegatoClifor);
|
|
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;
|
|
}
|
|
}
|
|
|
|
public String getNomeFileSuDisco() {
|
|
return "" + getId_clifor() + "_" + getId_clifor();
|
|
}
|
|
|
|
public String getDescrizioneAllegato() {
|
|
return (this.descrizioneAllegato == null) ? "" : this.descrizioneAllegato;
|
|
}
|
|
|
|
public void setDescrizioneAllegato(String descrizioneAllegato) {
|
|
this.descrizioneAllegato = descrizioneAllegato;
|
|
}
|
|
|
|
protected int getStringValueCase(String l_colomnName) {
|
|
return 0;
|
|
}
|
|
|
|
public long getFlgDefault() {
|
|
return this.flgDefault;
|
|
}
|
|
|
|
public void setFlgDefault(long flgDefault) {
|
|
this.flgDefault = flgDefault;
|
|
}
|
|
|
|
public void findByCliforDefault(long l_id_clifor) {
|
|
String s_Sql_Find = "select A.* from ALLEGATO_CLIFOR AS A";
|
|
String s_Sql_Order = " order by A.nomeFile";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_clifor = " + l_id_clifor);
|
|
wc.addWc("A.flgDefault = 1");
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
findFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
}
|
|
}
|
|
|
|
protected void prepareSave(PreparedStatement ps) throws SQLException {
|
|
if (getFlgDefault() == 1L) {
|
|
AllegatoClifor ac = new AllegatoClifor(getApFull());
|
|
Vectumerator<AllegatoClifor> vec = new Vectumerator();
|
|
vec = ac.findByCliforTipo(getId_clifor(), 0L, 0, 0);
|
|
while (vec.hasMoreElements()) {
|
|
ac = (AllegatoClifor)vec.nextElement();
|
|
ac.setFlgDefault(0L);
|
|
ac.save();
|
|
}
|
|
}
|
|
super.prepareSave(ps);
|
|
}
|
|
|
|
public String getNomeFileCompletoSuDisco() {
|
|
return getPathAllegato() + getPathAllegato();
|
|
}
|
|
}
|