package it.acxent.face; 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 FaceRecog extends DBAdapter implements Serializable { private static final long serialVersionUID = 1686063087766L; private long id_faceRecog; private long id_fotoFace1; private long id_fotoFace2; private double eDistance; private double cosineSim; private double confidenceLBPH; private double confidenceEigen; private double confidenceFish; private FotoFace fotoFace1; private FotoFace fotoFace2; public FaceRecog(ApplParmFull newApplParmFull) { super(newApplParmFull); } public FaceRecog() {} public void setId_faceRecog(long newId_faceRecog) { this.id_faceRecog = newId_faceRecog; } public void setId_fotoFace1(long newId_fotoFace1) { this.id_fotoFace1 = newId_fotoFace1; setFotoFace1(null); } public void setId_fotoFace2(long newId_fotoFace2) { this.id_fotoFace2 = newId_fotoFace2; setFotoFace2(null); } public void setEDistance(double newEDistance) { this.eDistance = newEDistance; } public void setCosineSim(double newCosineSim) { this.cosineSim = newCosineSim; } public long getId_faceRecog() { return this.id_faceRecog; } public long getId_fotoFace1() { return this.id_fotoFace1; } public long getId_fotoFace2() { return this.id_fotoFace2; } public double getEDistance() { return this.eDistance; } public double getCosineSim() { return this.cosineSim; } public void setFotoFace1(FotoFace newFotoFace1) { this.fotoFace1 = newFotoFace1; } public FotoFace getFotoFace1() { this.fotoFace1 = (FotoFace)getSecondaryObject(this.fotoFace1, FotoFace.class, getId_fotoFace1()); return this.fotoFace1; } public void setFotoFace2(FotoFace newFotoFace2) { this.fotoFace2 = newFotoFace2; } public FotoFace getFotoFace2() { this.fotoFace2 = (FotoFace)getSecondaryObject(this.fotoFace2, FotoFace.class, getId_fotoFace2()); return this.fotoFace2; } protected ResParm checkDeleteCascade() { return new ResParm(true); } protected void deleteCascade() {} public Vectumerator findByCR(FaceRecogCR CR, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from FACE_RECOG 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 findByFotoFace1FotoFace2(long id_fotoFace1, long id_fotoFace2) { try { String s_Sql_Find = "select A.* from FACE_RECOG AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("id_fotoFace1=" + id_fotoFace1); wc.addWc("id_fotoFace2=" + id_fotoFace2); PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); if (getId_faceRecog() == 0L) { wc = new WcString(); wc.addWc("id_fotoFace2=" + id_fotoFace1); wc.addWc("id_fotoFace1=" + id_fotoFace2); stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } } catch (SQLException e) { removeCPConnection(); handleDebug(e); } } public Vectumerator findByFoto1Foto2(long l_id_foto1, long l_id_foto2) { try { String s_Sql_Find = "select A.* from FACE_RECOG AS A inner join FOTO_FACE B1 on A.id_fotoFace1 =B1.id_fotoFace inner join FOTO_FACE B2 on A.id_fotoFace2 =B2.id_fotoFace "; String s_Sql_Order1 = " order by B2.faceTopVx"; String s_Sql_Order2 = " order by B1.faceTopVx"; WcString wc1 = new WcString(); wc1.addWc("B1.id_foto=" + l_id_foto1); wc1.addWc("B2.id_foto=" + l_id_foto2); WcString wc2 = new WcString(); wc2.addWc("B1.id_foto=" + l_id_foto2); wc2.addWc("B2.id_foto=" + l_id_foto1); PreparedStatement stmt = getConn().prepareStatement("(" + s_Sql_Find + wc1.toString() + s_Sql_Order1 + ") "); return findRows(stmt); } catch (SQLException e) { removeCPConnection(); handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public double getConfidenceLBPH() { return this.confidenceLBPH; } public void setConfidenceLBPH(double confidenceLBPH) { this.confidenceLBPH = confidenceLBPH; } public double getConfidenceEigen() { return this.confidenceEigen; } public void setConfidenceEigen(double confidenceEigen) { this.confidenceEigen = confidenceEigen; } public double getConfidenceFish() { return this.confidenceFish; } public void setConfidenceFish(double confidenceFish) { this.confidenceFish = confidenceFish; } }