149 lines
4.6 KiB
Java
149 lines
4.6 KiB
Java
package it.acxent.contab;
|
|
|
|
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 AllegatoDocumento extends _ContabAdapter implements Serializable {
|
|
private long id_allegatoDocumento;
|
|
|
|
private long id_documento;
|
|
|
|
private long id_tipoAllegatoDocumento;
|
|
|
|
private String nomeFile;
|
|
|
|
private Documento documento;
|
|
|
|
private TipoAllegatoDocumento tipoAllegatoDocumento;
|
|
|
|
public AllegatoDocumento(ApplParmFull newApplParmFull) {
|
|
super(newApplParmFull);
|
|
}
|
|
|
|
public AllegatoDocumento() {}
|
|
|
|
public void setId_allegatoDocumento(long newId_allegatoDocumento) {
|
|
this.id_allegatoDocumento = newId_allegatoDocumento;
|
|
}
|
|
|
|
public void setId_documento(long newId_documento) {
|
|
this.id_documento = newId_documento;
|
|
setDocumento(null);
|
|
}
|
|
|
|
public void setId_tipoAllegatoDocumento(long newId_tipoAllegatoDocumento) {
|
|
this.id_tipoAllegatoDocumento = newId_tipoAllegatoDocumento;
|
|
setTipoAllegatoDocumento(null);
|
|
}
|
|
|
|
public void setNomeFile(String newNomeFile) {
|
|
this.nomeFile = newNomeFile;
|
|
}
|
|
|
|
public long getId_allegatoDocumento() {
|
|
return this.id_allegatoDocumento;
|
|
}
|
|
|
|
public long getId_documento() {
|
|
return this.id_documento;
|
|
}
|
|
|
|
public long getId_tipoAllegatoDocumento() {
|
|
return this.id_tipoAllegatoDocumento;
|
|
}
|
|
|
|
public String getNomeFile() {
|
|
return (this.nomeFile == null) ? "" : this.nomeFile.trim();
|
|
}
|
|
|
|
public void setDocumento(Documento newDocumento) {
|
|
this.documento = newDocumento;
|
|
}
|
|
|
|
public Documento getDocumento() {
|
|
this.documento = (Documento)getSecondaryObject(this.documento, Documento.class,
|
|
getId_documento());
|
|
return this.documento;
|
|
}
|
|
|
|
public void setTipoAllegatoDocumento(TipoAllegatoDocumento newTipoAllegatoDocumento) {
|
|
this.tipoAllegatoDocumento = newTipoAllegatoDocumento;
|
|
}
|
|
|
|
public TipoAllegatoDocumento getTipoAllegatoDocumento() {
|
|
this.tipoAllegatoDocumento = (TipoAllegatoDocumento)getSecondaryObject(this.tipoAllegatoDocumento, TipoAllegatoDocumento.class,
|
|
|
|
getId_tipoAllegatoDocumento());
|
|
return this.tipoAllegatoDocumento;
|
|
}
|
|
|
|
protected void deleteCascade() {}
|
|
|
|
public Vectumerator findByCR(AllegatoDocumentoCR CR, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from ALLEGATO_DOCUMENTO 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 findByDocumentoNomeFile(long l_id_documento, String l_id_nomeFile) {
|
|
String s_Sql_Find = "select A.* from ALLEGATO_DOCUMENTO AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_documento=" + l_id_documento);
|
|
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 findByDocumentoTipo(long l_id_documento, long l_id_tipoAllegatoDocumento, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from ALLEGATO_DOCUMENTO AS A";
|
|
String s_Sql_Order = " order by A.nomeFile";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_documento=" + l_id_documento);
|
|
if (l_id_tipoAllegatoDocumento > 0L)
|
|
wc.addWc("A.id_tipoAllegatoDocumento=" + l_id_tipoAllegatoDocumento);
|
|
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_documento() + "_" + getId_documento();
|
|
}
|
|
}
|