package it.acxent.face.fr; 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 Face extends DBAdapter implements Serializable { public static final String PATH_IMG_FACE = "_face/"; private static final long serialVersionUID = 1701107257097L; private long id_face; private String md5; public Face(ApplParmFull newApplParmFull) { super(newApplParmFull); } public Face() {} public void setId_face(long newId_face) { this.id_face = newId_face; } public void setMd5(String newMd5) { this.md5 = newMd5; } public long getId_face() { return this.id_face; } public String getMd5() { return (this.md5 == null) ? "" : this.md5.trim(); } protected ResParm checkDeleteCascade() { return new ResParm(true); } protected void deleteCascade() {} public Vectumerator findByCR(FaceCR CR, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from FACE 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()); } if (!CR.getLabel().isEmpty()) wc.addWc("A.label ='" + CR.getLabel() + "'"); if (!CR.getMd5().isEmpty()) wc.addWc("A.md5 ='" + CR.getMd5() + "'"); 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 xxfindByMd5Recognition(String l_md5) { String s_Sql_Find = "select A.* from FACE AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.md5='" + l_md5 + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { removeCPConnection(); handleDebug(e); } } public String getFullFileName() { return getPathFaceImg() + getPathFaceImg() + ".jpg"; } public String getPathFaceImg() { return getParm("path_img_base").getTesto() + "_face/" + getParm("path_img_base").getTesto(); } public String getPathIdStepDir() { if (getPathIdStep() <= 0L) return ""; if (getId_face() == 0L) System.out.println("getPathIdStepDir pio"); return "_" + getPathIdStep() * (getId_face() / getPathIdStep() + 1L) + "/"; } public ResParm superSave() { return save(); } public void findByMd5(String l_md5) { String s_Sql_Find = "select A.* from FACE AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.md5='" + l_md5 + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { removeCPConnection(); handleDebug(e); } } public void findByLabel(long l_label) { String s_Sql_Find = "select A.* from FACE AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.id_face=" + l_label); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { removeCPConnection(); handleDebug(e); } } }