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 FaceFaceRecognizer extends DBAdapter implements Serializable { private static final long serialVersionUID = 1724847547826L; private long id_faceFaceRecognizer; private long id_faceRecognizer; private long id_face; private long id_faceLabel; private long flgLock; private FaceRecognizer faceRecognizer; private Face face; private Face faceLabel; public FaceFaceRecognizer(ApplParmFull newApplParmFull) { super(newApplParmFull); } public FaceFaceRecognizer() {} public void setId_faceFaceRecognizer(long newId_faceFaceRecognizer) { this.id_faceFaceRecognizer = newId_faceFaceRecognizer; } public void setId_faceRecognizer(long newId_faceRecognizer) { this.id_faceRecognizer = newId_faceRecognizer; setFaceRecognizer(null); } public void setId_face(long newId_face) { this.id_face = newId_face; setFace(null); } public void setId_faceLabel(long newId_faceLabel) { this.id_faceLabel = newId_faceLabel; setFaceLabel(null); } public void setFlgLock(long newFlgLock) { this.flgLock = newFlgLock; } public long getId_faceFaceRecognizer() { return this.id_faceFaceRecognizer; } public long getId_faceRecognizer() { return this.id_faceRecognizer; } public long getId_face() { return this.id_face; } public long getId_faceLabel() { return this.id_faceLabel; } public long getFlgLock() { return this.flgLock; } public void setFaceRecognizer(FaceRecognizer newFaceRecognizer) { this.faceRecognizer = newFaceRecognizer; } public FaceRecognizer getFaceRecognizer() { this.faceRecognizer = (FaceRecognizer)getSecondaryObject(this.faceRecognizer, FaceRecognizer.class, getId_faceRecognizer()); return this.faceRecognizer; } public void setFace(Face newFace) { this.face = newFace; } public Face getFace() { this.face = (Face)getSecondaryObject(this.face, Face.class, getId_face()); return this.face; } public void setFaceLabel(Face newFaceLabel) { this.faceLabel = newFaceLabel; } public Face getFaceLabel() { this.faceLabel = (Face)getSecondaryObject(this.faceLabel, Face.class, getId_faceLabel()); return this.faceLabel; } protected ResParm checkDeleteCascade() { return new ResParm(true); } protected void deleteCascade() {} public Vectumerator findByCR(FaceFaceRecognizerCR CR, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from FACE_FACE_RECOGNIZER 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 boolean isLabelPrincipale() { if (getId_faceFaceRecognizer() > 0L && getId_face() == getId_faceLabel()) return true; return false; } public ResParm resetTrainingByFaceRecognizer(long l_id_facerecognizer) { return update("update FACE_FACE_RECOGNIZER SET id_facelabel=null where id_faceRecognizer=" + l_id_facerecognizer); } public void findByRecognizerLabel(long l_id_faceRecognizer, long l_label) { String s_Sql_Find = "select A.* from FACE_FACE_RECOGNIZER AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.id_faceRecognizer=" + l_id_faceRecognizer); 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); } } public long getTotFaceByFaceRecognizer(long l_id_faceRecognizer) { String s_Sql_Find = "select count(*) as tot from FACE_FACE_RECOGNIZER AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.id_faceRecognizer=" + l_id_faceRecognizer); wc.addWc("A.id_faceLabel>0"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); return (long)getTots(stmt); } catch (SQLException e) { removeCPConnection(); handleDebug(e); return 0L; } } public Vectumerator findByFaceRecognizer(long l_id_faceRecognizer, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from FACE_FACE_RECOGNIZER AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.id_faceRecognizer=" + l_id_faceRecognizer); wc.addWc("A.id_faceLabel>0"); 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; } } }