1074 lines
42 KiB
Java
1074 lines
42 KiB
Java
package it.acxent.face;
|
|
|
|
import com.drew.imaging.jpeg.JpegMetadataReader;
|
|
import com.drew.metadata.Directory;
|
|
import com.drew.metadata.Metadata;
|
|
import com.drew.metadata.exif.ExifImageDirectory;
|
|
import com.drew.metadata.exif.ExifSubIFDDirectory;
|
|
import it.acxent.common.StatusMsg;
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.DBAdapter;
|
|
import it.acxent.db.ResParm;
|
|
import it.acxent.db.WcString;
|
|
import it.acxent.dm.FaceDetectionMethod;
|
|
import it.acxent.face.callable.IndexFotoCallable;
|
|
import it.acxent.face.callable.IndexFotoFaceCallable;
|
|
import it.acxent.util.ImageConverter;
|
|
import it.acxent.util.StringTokenizer;
|
|
import it.acxent.util.Timer;
|
|
import it.acxent.util.Vectumerator;
|
|
import it.acxent.videoj.ManageVideoJ;
|
|
import java.io.File;
|
|
import java.io.Serializable;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.SQLException;
|
|
import java.sql.Time;
|
|
import java.util.Date;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Future;
|
|
|
|
public class PuntoFoto extends _FaceAdapter implements Serializable {
|
|
private static final long serialVersionUID = 3337523649993954283L;
|
|
|
|
private long id_evento;
|
|
|
|
private long colonnaImport = -1L;
|
|
|
|
private String pathRelativoFoto;
|
|
|
|
private String descrizione;
|
|
|
|
private Evento evento;
|
|
|
|
private long dimMinFotoFace;
|
|
|
|
private long id_puntoFoto;
|
|
|
|
private String pathRelativoFotoSrc;
|
|
|
|
private long id_puntoFotoExport;
|
|
|
|
private long id_faceDetectionMethod;
|
|
|
|
private FaceDetectionMethod faceDetectionMethod;
|
|
|
|
private long flgStatoScoring;
|
|
|
|
private String lastFotoFileScore1;
|
|
|
|
public static final long STATO_SCORING_ESCLUDI_M1 = -1L;
|
|
|
|
public static final long STATO_SCORING_DA_ELAB_0 = 0L;
|
|
|
|
public static final long STATO_SCORING_FASE1_ELAB = 11L;
|
|
|
|
public static final long STATO_SCORING_FASE1 = 1L;
|
|
|
|
public static final long STATO_SCORING_FASE2_ELAB = 22L;
|
|
|
|
public static final long STATO_SCORING_FASE2 = 2L;
|
|
|
|
public static boolean threadPuntoFoto = false;
|
|
|
|
public static boolean threadPuntoFotoFace = false;
|
|
|
|
class ThreadIndexFaceFoto extends Thread {
|
|
private PuntoFoto puntoFoto;
|
|
|
|
public ThreadIndexFaceFoto(PuntoFoto l_pf) {
|
|
this.puntoFoto = l_pf;
|
|
if (!PuntoFoto.isThreadFaceAttivo()) {
|
|
PuntoFoto.threadPuntoFotoFace = true;
|
|
start();
|
|
}
|
|
}
|
|
|
|
public void run() {
|
|
boolean debug = false;
|
|
String TAG_THREAD_MSG = "INDEX FACE PF";
|
|
Timer timer = new Timer();
|
|
timer.start();
|
|
ResParm rp = new ResParm(true);
|
|
StringBuffer err = new StringBuffer();
|
|
int i = 0;
|
|
int maxNumberOfThread = PuntoFoto.this.getParm("MAX_NUMBER_OF_THREAD_INDEXING_SCALING").getNumeroInt();
|
|
if (maxNumberOfThread <= 1)
|
|
maxNumberOfThread = 10;
|
|
if (this.puntoFoto.getId_evento() == 0L) {
|
|
rp.setMsg("Indicizzazione foto: Bean evento non caricato");
|
|
rp.setStatus(false);
|
|
PuntoFoto.this.handleDebug("Indicizzazione foto: Bean evento non caricato", 2);
|
|
} else {
|
|
boolean detectNumbers = (this.puntoFoto.getEvento().getFlgDetectNumbers() == 1L);
|
|
try {
|
|
StatusMsg.updateMsgByTag(PuntoFoto.this.getApFull(), "INDEX FACE PF", "...index FACE foto " + this.puntoFoto.getDescrizioneCompleta() + " ...");
|
|
if (debug)
|
|
System.out.println("INDEX FACE PFAttenzione! Thread INDEX FACE FOTO (faccina) punto foto " +
|
|
this.puntoFoto.getDescrizioneCompleta() + " in esecuzione!!! ");
|
|
StringBuffer errMsg = new StringBuffer();
|
|
Foto foto = new Foto(PuntoFoto.this.getApFull());
|
|
Vectumerator<Foto> vec = foto.findByPuntofoto(this.puntoFoto.getId_puntoFoto());
|
|
Foto row = new Foto();
|
|
ExecutorService pool = Executors.newFixedThreadPool(maxNumberOfThread);
|
|
Vectumerator<Future<ResParm>> vecF = new Vectumerator();
|
|
while (vec.hasMoreElements()) {
|
|
row = (Foto)vec.nextElement();
|
|
i++;
|
|
if (row.getNumOfFaces() == 0L) {
|
|
IndexFotoFaceCallable ifc = new IndexFotoFaceCallable(row, detectNumbers, false);
|
|
vecF.add(pool.submit(ifc));
|
|
if (i % 20 == 0)
|
|
StatusMsg.updateMsgByTag(PuntoFoto.this.getApFull(), "INDEX FACE PF", "max thread: " + maxNumberOfThread + " - SUBMIT ...index face foto - " +
|
|
row.getFileName() + " - " +
|
|
this.puntoFoto.getDescrizioneCompleta() + " - " + i + 1 + " su " +
|
|
vec.getTotNumberOfRecords() + " eta: " +
|
|
timer.getEta((long)vec.getTotNumberOfRecords(), (long)(i + 1)));
|
|
continue;
|
|
}
|
|
if (i % 20 == 0)
|
|
StatusMsg.updateMsgByTag(PuntoFoto.this.getApFull(), "INDEX FACE PF", "max thread: " + maxNumberOfThread + " - SKIP ...index face foto - " +
|
|
row.getFileName() + " - " +
|
|
this.puntoFoto.getDescrizioneCompleta() + " - " + i + 1 + " su " +
|
|
vec.getTotNumberOfRecords() + " eta: " +
|
|
timer.getEta((long)vec.getTotNumberOfRecords(), (long)(i + 1)));
|
|
}
|
|
for (int j = 0; j < vecF.getTotNumberOfRecords(); j++) {
|
|
Future<ResParm> currentFuture = (Future<ResParm>)vecF.nextElement();
|
|
rp = currentFuture.get();
|
|
if (!rp.getStatus())
|
|
errMsg.append(rp.getErrMsg() + "\n");
|
|
System.out.println(currentFuture.get().getMsg() + " ended");
|
|
if (j % 20 == 0)
|
|
StatusMsg.updateMsgByTag(PuntoFoto.this.getApFull(), "INDEX FACE PF", "max thread: " + maxNumberOfThread + " - face detected on foto " + j + " su " +
|
|
vec.getTotNumberOfRecords() + " eta: " + timer.getEta((long)vecF.getTotNumberOfRecords(), (long)(j + 1)));
|
|
}
|
|
rp.setMsg("Indicizzazione completata.<br>Numero foto indicizzate:" + i + "<br> - Errori rilevati: " +
|
|
errMsg.toString());
|
|
rp.setStatus(true);
|
|
pool.shutdown();
|
|
} catch (Exception e) {
|
|
err.append("ERRORE!! " + e.getMessage());
|
|
err.append("\n");
|
|
}
|
|
}
|
|
timer.stop();
|
|
System.out.println("INDEX FACE PF DURATA: " + timer.getDurata() + " " + rp.getMsg());
|
|
StatusMsg.updateMsgByTag(PuntoFoto.this.getApFull(), "INDEX FACE PF", "Index face foto concluso: DURATA: " +
|
|
timer.getDurata() + "\nRisultato: " + rp.getMsg());
|
|
try {
|
|
sleep(10000L);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
StatusMsg.deleteMsgByTag(PuntoFoto.this.getApFull(), "INDEX FACE PF");
|
|
PuntoFoto.threadPuntoFotoFace = false;
|
|
}
|
|
}
|
|
|
|
class ThreadIndexFoto extends Thread {
|
|
private PuntoFoto puntoFoto;
|
|
|
|
private long id_users;
|
|
|
|
public ThreadIndexFoto(PuntoFoto l_pf, long l_id_users) {
|
|
this.puntoFoto = l_pf;
|
|
this.id_users = l_id_users;
|
|
if (!PuntoFoto.isThreadAttivo()) {
|
|
PuntoFoto.threadPuntoFoto = true;
|
|
start();
|
|
}
|
|
}
|
|
|
|
public void run() {
|
|
String TAG_THREAD_MSG = "INDEX PUNTO FOTO";
|
|
Timer timer = new Timer();
|
|
timer.start();
|
|
ResParm rp = new ResParm(true);
|
|
if (this.puntoFoto.getId_evento() == 0L) {
|
|
rp.setMsg("Indicizzazione foto: Bean evento non caricato");
|
|
rp.setStatus(false);
|
|
PuntoFoto.this.handleDebug("Indicizzazione foto: Bean evento non caricato", 2);
|
|
} else {
|
|
rp = this.puntoFoto.indexFoto(this.id_users, "INDEX PUNTO FOTO");
|
|
}
|
|
timer.stop();
|
|
System.out.println("INDEX PUNTO FOTO DURATA: " + timer.getDurata() + " " + rp.getMsg());
|
|
StatusMsg.updateMsgByTag(PuntoFoto.this.getApFull(), "INDEX PUNTO FOTO", "Index foto concluso: DURATA: " + timer.getDurata() + "\nRisultato: " + rp.getMsg());
|
|
try {
|
|
sleep(1000L);
|
|
} catch (Exception e) {}
|
|
StatusMsg.deleteMsgByTag(PuntoFoto.this.getApFull(), "INDEX PUNTO FOTO");
|
|
PuntoFoto.threadPuntoFoto = false;
|
|
}
|
|
}
|
|
|
|
class ThreadIndexFotoOld extends Thread {
|
|
private PuntoFoto puntoFoto;
|
|
|
|
public ThreadIndexFotoOld(PuntoFoto l_pf) {
|
|
this.puntoFoto = l_pf;
|
|
if (!PuntoFoto.isThreadAttivo()) {
|
|
PuntoFoto.threadPuntoFoto = true;
|
|
start();
|
|
}
|
|
}
|
|
|
|
public void run() {
|
|
boolean debug = false;
|
|
String TAG_THREAD_MSG = "INDEX FOTO";
|
|
Timer timer = new Timer();
|
|
timer.start();
|
|
ResParm rp = new ResParm(true);
|
|
StringBuffer err = new StringBuffer();
|
|
StringBuilder sb = new StringBuilder();
|
|
int i = 0;
|
|
if (this.puntoFoto.getId_evento() == 0L) {
|
|
rp.setMsg("Indicizzazione foto: Bean evento non caricato");
|
|
rp.setStatus(false);
|
|
PuntoFoto.this.handleDebug("Indicizzazione foto: Bean evento non caricato", 2);
|
|
} else {
|
|
try {
|
|
StatusMsg.updateMsgByTag(PuntoFoto.this.getApFull(), "INDEX FOTO", "...index foto " + this.puntoFoto.getDescrizioneCompleta() + " ...");
|
|
if (debug)
|
|
System.out.println("INDEX FOTOAttenzione! Thread INDEX FOTO (PELLICOLA) punto foto " +
|
|
this.puntoFoto.getDescrizioneCompleta() + " in esecuzione!!! ");
|
|
int nuovefoto = 0;
|
|
int nuoviVideo = 0;
|
|
int fotoErrate = 0;
|
|
int totFoto = 0;
|
|
StringBuffer errMsg = new StringBuffer();
|
|
String dirFoto = this.puntoFoto.getParm("PATHFOTO_FACE").getTesto() + this.puntoFoto.getParm("PATHFOTO_FACE").getTesto() + this.puntoFoto.getEvento().getPathEvento();
|
|
File dir = new File(dirFoto);
|
|
File[] fotos = dir.listFiles();
|
|
Foto foto = new Foto(PuntoFoto.this.getApFull());
|
|
Foto currentFoto = new Foto(PuntoFoto.this.getApFull());
|
|
File theFoto = null;
|
|
sb = new StringBuilder();
|
|
String l_nomeFoto = "", l_nomeFotoMd5 = "", l_md5 = "";
|
|
String l_pettorali = "";
|
|
try {
|
|
for (int j = 0; j < fotos.length; j++) {
|
|
theFoto = fotos[j];
|
|
l_nomeFoto = theFoto.getName();
|
|
StatusMsg.updateMsgByTag(PuntoFoto.this.getApFull(), "INDEX FOTO", "...index foto - " + l_nomeFoto + " - " +
|
|
this.puntoFoto.getDescrizioneCompleta() + " - " + j + 1 + " su " + fotos.length + 1);
|
|
if (theFoto.getName().toLowerCase().endsWith(".jpg") && (float)theFoto.getName().toLowerCase().indexOf(".mp4") < 0.0F) {
|
|
if (l_nomeFoto.length() > 16) {
|
|
StringTokenizer st = new StringTokenizer(l_nomeFoto, "-");
|
|
if (st.countToken() == 3) {
|
|
l_nomeFotoMd5 = l_nomeFoto;
|
|
l_nomeFoto = st.getToken(0);
|
|
l_md5 = st.getToken(1);
|
|
l_pettorali = st.getToken(2).replace(".jpg", "");
|
|
}
|
|
} else {
|
|
l_nomeFotoMd5 = "";
|
|
l_md5 = "";
|
|
l_pettorali = "";
|
|
}
|
|
totFoto++;
|
|
foto.findByFilenamePuntoFoto(l_nomeFoto, this.puntoFoto.getId_puntoFoto());
|
|
if (foto.getDBState() == 0) {
|
|
nuovefoto++;
|
|
foto.setId_evento(this.puntoFoto.getId_evento());
|
|
foto.setId_puntoFoto(this.puntoFoto.getId_puntoFoto());
|
|
foto.setFileName(l_nomeFoto);
|
|
foto.setMd5(l_md5);
|
|
foto.setFileNameMd5(l_nomeFotoMd5);
|
|
if (!l_pettorali.isEmpty())
|
|
foto.setPettorali(l_pettorali);
|
|
File jpegFile = new File(theFoto.getCanonicalPath());
|
|
Metadata metadata = JpegMetadataReader.readMetadata(jpegFile);
|
|
ExifSubIFDDirectory exifSubIFDDirectory = (ExifSubIFDDirectory)metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
|
|
if (exifSubIFDDirectory.containsTag(36867)) {
|
|
Date theDate = exifSubIFDDirectory.getDate(36867);
|
|
foto.setTempo(new Time(theDate.getTime()));
|
|
} else {
|
|
fotoErrate++;
|
|
errMsg.append("<br>Attenzione " +
|
|
theFoto.getName() + ": impossibile determinare il tag data creazione!");
|
|
}
|
|
rp = foto.save();
|
|
if (!rp.getStatus()) {
|
|
errMsg.append("<br>Salvataggio fallito:" + rp.getMsg() + " foto:" + foto.getFileName());
|
|
fotoErrate++;
|
|
}
|
|
}
|
|
currentFoto = (Foto)foto.clone();
|
|
} else if (theFoto.getName().toLowerCase().endsWith(".mp4")) {
|
|
try {
|
|
boolean creaJpg = false;
|
|
l_nomeFotoMd5 = "";
|
|
l_md5 = "";
|
|
l_pettorali = "";
|
|
totFoto++;
|
|
foto.findByFilenamePuntoFoto(l_nomeFoto, this.puntoFoto.getId_puntoFoto());
|
|
if (foto.getDBState() == 0) {
|
|
nuoviVideo++;
|
|
creaJpg = true;
|
|
foto.setId_evento(this.puntoFoto.getId_evento());
|
|
foto.setId_puntoFoto(this.puntoFoto.getId_puntoFoto());
|
|
foto.setFileName(l_nomeFoto);
|
|
foto.setFlgVideo(1L);
|
|
foto.setMd5(l_md5);
|
|
foto.setFileNameMd5(l_nomeFotoMd5);
|
|
if (!l_pettorali.isEmpty())
|
|
foto.setPettorali(l_pettorali);
|
|
sb = new StringBuilder("inizio estrazione..");
|
|
LinkedHashSet<String> frames = ManageVideoJ.extractNFrames(dirFoto + dirFoto + DBAdapter.SEPARATOR, dirFoto + dirFoto, l_nomeFoto, 4);
|
|
sb = new StringBuilder("andata bene: " + frames.toString());
|
|
String[] source = (String[])frames.toArray(new String[0]);
|
|
String brandFileName = foto.getEvento().getImgWmSlomoFilename();
|
|
ImageConverter.creaGifAnimato(dirFoto + dirFoto + Foto.DIR_MP4_JPG + ".gif", source, 640, 1000, true, brandFileName);
|
|
rp = foto.save();
|
|
if (!rp.getStatus()) {
|
|
errMsg.append("<br>Salvataggio fallito:" + rp.getMsg() + " video:" + foto.getFileName() + " " +
|
|
sb.toString());
|
|
fotoErrate++;
|
|
}
|
|
}
|
|
currentFoto = (Foto)foto.clone();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
errMsg.append("<br>ECCEZIONE! Salvataggio fallito:" + rp.getMsg() + " video:" + foto.getFileName() + " " +
|
|
sb.toString());
|
|
fotoErrate++;
|
|
}
|
|
} else {
|
|
PuntoFoto.this.handleDebug("File non jpg:" + theFoto.getName(), 1);
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
PuntoFoto.this.handleDebug(e);
|
|
errMsg.append("\nIndicizzazione fallita sul file " + theFoto.getName() + "<br>" + e.getMessage());
|
|
}
|
|
rp.setMsg("Indicizzazione completata.<br>Numero foto indicizzate:" + totFoto + "<br>numero di foto nuove indicizzate: " + nuovefoto + " video: " + nuoviVideo + "<br>numero di foto ERRATE: " + fotoErrate + "<br>timestamp ultima foto: " +
|
|
|
|
String.valueOf(currentFoto.getTempo()) + "<br> - Errori rilevati: " + errMsg.toString());
|
|
rp.setStatus(true);
|
|
} catch (Exception e) {
|
|
err.append("ERRORE!! " + e.getMessage());
|
|
err.append("\n");
|
|
}
|
|
}
|
|
timer.stop();
|
|
System.out.println("INDEX FOTO DURATA: " + timer.getDurata() + " " + rp.getMsg());
|
|
StatusMsg.updateMsgByTag(PuntoFoto.this.getApFull(), "INDEX FOTO", "Index foto concluso: DURATA: " + timer.getDurata() + "\nRisultato: " + rp.getMsg());
|
|
try {
|
|
sleep(1000L);
|
|
} catch (Exception e) {}
|
|
StatusMsg.deleteMsgByTag(PuntoFoto.this.getApFull(), "INDEX FOTO");
|
|
PuntoFoto.threadPuntoFoto = false;
|
|
}
|
|
}
|
|
|
|
public PuntoFoto(ApplParmFull newApplParmFull) {
|
|
super(newApplParmFull);
|
|
}
|
|
|
|
public PuntoFoto() {}
|
|
|
|
public void setId_puntoFoto(long newId_puntoFoto) {
|
|
this.id_puntoFoto = newId_puntoFoto;
|
|
}
|
|
|
|
public void setId_evento(long newId_evento) {
|
|
this.id_evento = newId_evento;
|
|
setEvento(null);
|
|
}
|
|
|
|
public void setPathRelativoFoto(String newPathRelativoFoto) {
|
|
this.pathRelativoFoto = newPathRelativoFoto;
|
|
}
|
|
|
|
public long getId_puntoFoto() {
|
|
return this.id_puntoFoto;
|
|
}
|
|
|
|
public long getId_evento() {
|
|
return this.id_evento;
|
|
}
|
|
|
|
public String getPathRelativoFoto() {
|
|
return (this.pathRelativoFoto == null) ? "" : this.pathRelativoFoto;
|
|
}
|
|
|
|
public void setEvento(Evento newEvento) {
|
|
this.evento = newEvento;
|
|
}
|
|
|
|
public Evento getEvento() {
|
|
this.evento = (Evento)getSecondaryObject(this.evento, Evento.class, getId_evento());
|
|
return this.evento;
|
|
}
|
|
|
|
protected void deleteCascade() {}
|
|
|
|
public Vectumerator findByCR(PuntoFotoCR CR, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from PUNTO_FOTO AS A";
|
|
String s_Sql_Order = " order by A.pathRelativoFoto";
|
|
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 = prepareSqlString(st.nextToken());
|
|
txt.append("(A.descrizione like '%" + token + "%')");
|
|
if (st.hasMoreTokens())
|
|
txt.append(" and ");
|
|
}
|
|
txt.append(")");
|
|
wc.addWc(txt.toString());
|
|
}
|
|
if (CR.getId_puntoFoto() != 0L)
|
|
wc.addWc("A.id_puntoFoto=" + CR.getId_puntoFoto());
|
|
if (CR.getId_evento() != 0L)
|
|
wc.addWc("A.id_evento=" + CR.getId_evento());
|
|
if (CR.getFlgIndexOk() == 1L) {
|
|
wc.addWc("A.flgIndexOk=1");
|
|
} else if (CR.getFlgIndexOk() == 2L) {
|
|
wc.addWc("A.flgIndexOk >= 1");
|
|
}
|
|
if (CR.getFlgPreviewFoto() == 1L) {
|
|
s_Sql_Find = s_Sql_Find + ", GARA AS B";
|
|
wc.addWc("A.id_evento=B.id_evento");
|
|
wc.addWc("B.flgPreviewFoto=1");
|
|
}
|
|
if (!CR.getTipoPuntoFoto().isEmpty())
|
|
wc.addWc("A.tipoPuntoFoto='" + CR.getTipoPuntoFoto() + "'");
|
|
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 Vectumerator<PuntoFoto> findPuntiFotoByEventoTipoIdx(long l_id_evento, long l_flgIndexOk, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from PUNTO_FOTO AS A";
|
|
String s_Sql_Order = " order by A.pathRelativoFoto";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_evento=" + l_id_evento);
|
|
if (l_flgIndexOk == 1L) {
|
|
wc.addWc("A.flgIndexOk=1");
|
|
} else if (l_flgIndexOk == 2L) {
|
|
wc.addWc("A.flgIndexOk>=1");
|
|
}
|
|
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 getPathCompletoFoto() {
|
|
String temp = DBAdapter.convertPathToCurrentFileSystemSeparator(getPathBaseFoto() + getPathBaseFoto() + getEvento().getPathEvento());
|
|
if (!temp.endsWith(DBAdapter.SEPARATOR))
|
|
temp = temp + temp;
|
|
return temp;
|
|
}
|
|
|
|
public String getPathCompletoFotoFace() {
|
|
String temp = DBAdapter.convertPathToCurrentFileSystemSeparator(getPathBaseFace() + getPathBaseFace() + getEvento().getPathEventoFace());
|
|
if (!temp.endsWith(DBAdapter.SEPARATOR))
|
|
temp = temp + temp;
|
|
return temp;
|
|
}
|
|
|
|
public String getPathCompletoFotoSorgenti() {
|
|
String temp = getPathBaseFotoSorgenti() + getPathBaseFotoSorgenti();
|
|
if (!temp.endsWith(DBAdapter.SEPARATOR))
|
|
temp = temp + temp;
|
|
return temp;
|
|
}
|
|
|
|
public String getPathCompletoFotoWeb() {
|
|
String temp = getPathBaseFotoSorgenti() + "web/" + getPathBaseFotoSorgenti();
|
|
if (!temp.endsWith(DBAdapter.SEPARATOR))
|
|
temp = temp + temp;
|
|
return temp;
|
|
}
|
|
|
|
public ResParm noIndexFoto() {
|
|
ResParm rp = new ResParm();
|
|
if (getId_evento() == 0L || getId_puntoFoto() == 0L) {
|
|
rp.setMsg("Indicizzazione foto: Bean evento non caricato");
|
|
rp.setStatus(false);
|
|
handleDebug("Indicizzazione foto: Bean evento non caricato", 2);
|
|
return rp;
|
|
}
|
|
rp = new Foto(getApFull()).deleteFotoByPuntoFoto(getId_puntoFoto());
|
|
return rp;
|
|
}
|
|
|
|
protected void prepareSave(PreparedStatement ps) throws SQLException {
|
|
if (getPathRelativoFoto().isEmpty())
|
|
setPathRelativoFoto("" + getId_evento() + getId_evento());
|
|
setId_evento(getEvento().getId_evento());
|
|
super.prepareSave(ps);
|
|
}
|
|
|
|
public String getDescrizione() {
|
|
return (this.descrizione == null) ? "" : this.descrizione;
|
|
}
|
|
|
|
public String getDescrizioneCompleta() {
|
|
return getEvento().getDescrizioneEvento() + "-" + getEvento().getDescrizioneEvento();
|
|
}
|
|
|
|
public void setDescrizione(String descrizione) {
|
|
this.descrizione = descrizione;
|
|
}
|
|
|
|
protected String getHeaderFattura1() {
|
|
return getParm("HEADFT1").getTesto();
|
|
}
|
|
|
|
public long getColonnaImport() {
|
|
return this.colonnaImport;
|
|
}
|
|
|
|
public static final String getColonnaImportDesc(long l_ci) {
|
|
if (l_ci == 0L)
|
|
return "Arrivo";
|
|
return "Int. " + l_ci;
|
|
}
|
|
|
|
public String getColonnaImportDesc() {
|
|
return getColonnaImportDesc(getColonnaImport());
|
|
}
|
|
|
|
public void setColonnaImport(long colonnaImport) {
|
|
this.colonnaImport = colonnaImport;
|
|
}
|
|
|
|
public String getPathRelativoFotoSrc() {
|
|
return (this.pathRelativoFotoSrc == null) ? "" : this.pathRelativoFotoSrc.trim();
|
|
}
|
|
|
|
public void setPathRelativoFotoSrc(String pathRelativoFotoSrc) {
|
|
this.pathRelativoFotoSrc = pathRelativoFotoSrc;
|
|
}
|
|
|
|
public Vectumerator findTipiPuntoFoto(long l_id_evento) {
|
|
String s_Sql_Find = "select B.tipoPuntoFoto from (select A.tipoPuntoFoto, A.pathRelativoFoto from PUNTO_FOTO AS A ";
|
|
String s_Sql_OrderBy = " order by A.pathRelativoFoto, A.tipoPuntoFoto";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_evento=" + l_id_evento);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString() + ") as B");
|
|
return findRows(stmt);
|
|
} catch (Exception e) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public long getId_puntoFotoExport() {
|
|
return this.id_puntoFotoExport;
|
|
}
|
|
|
|
public void setId_puntoFotoExport(long id_puntoFotoExport) {
|
|
this.id_puntoFotoExport = id_puntoFotoExport;
|
|
}
|
|
|
|
public Vectumerator findPuntiFotoEsportatiByEvento(long l_id_evento) {
|
|
String s_Sql_Find = "select A.* from PUNTO_FOTO AS A";
|
|
String s_Sql_Order = " order by A.pathRelativoFoto";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_evento=" + l_id_evento);
|
|
wc.addWc("A.id_puntoFotoExport>0");
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
return findRows(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
protected void initFields() {
|
|
super.initFields();
|
|
setColonnaImport(-1L);
|
|
}
|
|
|
|
public String getQRCodeFileName() {
|
|
if (getId_evento() > 0L)
|
|
return getDocBase() + getDocBase();
|
|
return "";
|
|
}
|
|
|
|
public String getQRCodeFileNameRel() {
|
|
if (getId_evento() > 0L)
|
|
return getPathTmp() + "qr_" + getPathTmp() + "_" + getId_evento() + ".jpg";
|
|
return "";
|
|
}
|
|
|
|
public ResParm save() {
|
|
ResParm rp = super.save();
|
|
if (rp.getStatus());
|
|
return rp;
|
|
}
|
|
|
|
public final ResParm startIndexFoto(long l_id_users) {
|
|
if (!isThreadAttivo()) {
|
|
new ThreadIndexFoto(this, l_id_users);
|
|
return new ResParm(true, "Thread Index Foto avviato");
|
|
}
|
|
return new ResParm(false, "ATTENZIONE!! Thread Index Foto gia' in esecuzione!!!");
|
|
}
|
|
|
|
public final ResParm startIndexFace() {
|
|
if (!isThreadFaceAttivo()) {
|
|
new ThreadIndexFaceFoto(this);
|
|
return new ResParm(true, "Thread Index Face avviato");
|
|
}
|
|
return new ResParm(false, "ATTENZIONE!! Thread sul punto foto gia' in esecuzione!!!");
|
|
}
|
|
|
|
public static boolean isThreadAttivo() {
|
|
return threadPuntoFoto;
|
|
}
|
|
|
|
public static boolean isThreadFaceAttivo() {
|
|
return threadPuntoFotoFace;
|
|
}
|
|
|
|
public ResParm impostaFotoInviate(boolean inviate) {
|
|
if (getId_puntoFoto() == 0L)
|
|
return new ResParm(false, "Punto foto 0");
|
|
return update("update FOTO SET flgFotoInviata=" + (inviate ? "1" : "0") + " where id_puntoFoto=" + getId_puntoFoto());
|
|
}
|
|
|
|
public boolean hasFoto() {
|
|
if (getId_puntoFoto() == 0L)
|
|
return false;
|
|
return new Foto(getApFull()).hasPuntoFotoFoto(getId_puntoFoto());
|
|
}
|
|
|
|
public boolean isTutteInviate(boolean tutteInviate) {
|
|
if (getId_puntoFoto() == 0L)
|
|
return false;
|
|
return new Foto(getApFull()).isPuntoFotoInviata(getId_puntoFoto(), tutteInviate);
|
|
}
|
|
|
|
public void findByEventoPath(long l_id_evento, String l_pathRelativoFoto) {
|
|
String s_Sql_Find = "select A.* from PUNTO_FOTO AS A";
|
|
String s_Sql_Order = " order by A.pathRelativoFoto";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_evento=" + l_id_evento);
|
|
wc.addWc("A.pathRelativoFoto='" + l_pathRelativoFoto.trim() + "'");
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
findFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
}
|
|
}
|
|
|
|
public ResParm indexFotoNonMt(long l_id_user, String TAG_THREAD_MSG) {
|
|
ResParm rp = new ResParm();
|
|
boolean debug = false;
|
|
Timer timer = new Timer();
|
|
timer.start();
|
|
int nuovefoto = 0;
|
|
int fotoErrate = 0;
|
|
int nuoviVideo = 0;
|
|
int totFoto = 0;
|
|
StringBuffer errMsg = new StringBuffer();
|
|
StringBuilder sb = new StringBuilder();
|
|
int i = 0;
|
|
if (getId_evento() == 0L || getId_puntoFoto() == 0L) {
|
|
rp.setMsg("Indicizzazione foto: Bean gara o punto foto non caricato");
|
|
rp.setStatus(false);
|
|
handleDebug("Indicizzazione foto: Bean gara o punto foto non caricato", 2);
|
|
return rp;
|
|
}
|
|
try {
|
|
StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, "...index foto " + getDescrizioneCompleta() + " ...");
|
|
if (debug)
|
|
System.out.println(TAG_THREAD_MSG + "Attenzione! Thread INDEX FOTO (PELLICOLA) punto foto " + TAG_THREAD_MSG + ": in esecuzione!!! ");
|
|
String dirFoto = getParm("PATHFOTO_FACE").getTesto() + getParm("PATHFOTO_FACE").getTesto() + getEvento().getPathEvento();
|
|
File dir = new File(dirFoto);
|
|
if (new File(dirFoto).exists()) {
|
|
File[] fotos = dir.listFiles();
|
|
Foto foto = new Foto(getApFull());
|
|
Foto currentFoto = new Foto(getApFull());
|
|
File theFoto = null;
|
|
sb = new StringBuilder();
|
|
String l_nomeFoto = "", l_nomeFotoMd5 = "", l_md5 = "";
|
|
String l_pettorali = "";
|
|
try {
|
|
for (int j = 0; j < fotos.length; j++) {
|
|
theFoto = fotos[j];
|
|
l_nomeFoto = theFoto.getName();
|
|
StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, "...index foto - " + getDescrizioneCompleta() + ": " + l_nomeFoto + " - " + j + 1 + " su " + fotos.length + 1 + " eta: " +
|
|
timer.getEta((long)(fotos.length + 1), (long)(j + 1)));
|
|
if (theFoto.getName().toLowerCase().endsWith(".jpg") && (float)theFoto.getName().toLowerCase().indexOf(".mp4") < 0.0F) {
|
|
if (l_nomeFoto.length() > 16) {
|
|
StringTokenizer st = new StringTokenizer(l_nomeFoto, "-");
|
|
if (st.countToken() == 3) {
|
|
l_nomeFotoMd5 = l_nomeFoto;
|
|
l_nomeFoto = st.getToken(0);
|
|
l_md5 = st.getToken(1);
|
|
l_pettorali = st.getToken(2).replace(".jpg", "");
|
|
}
|
|
} else {
|
|
l_nomeFotoMd5 = "";
|
|
l_md5 = "";
|
|
l_pettorali = "";
|
|
}
|
|
totFoto++;
|
|
foto.findByFilenamePuntoFoto(l_nomeFoto, getId_puntoFoto());
|
|
if (foto.getDBState() == 0) {
|
|
nuovefoto++;
|
|
foto.setId_evento(getId_evento());
|
|
foto.setLastUpdId_user(l_id_user);
|
|
foto.setId_puntoFoto(getId_puntoFoto());
|
|
foto.setFileName(l_nomeFoto);
|
|
foto.setMd5(l_md5);
|
|
foto.setFileNameMd5(l_nomeFotoMd5);
|
|
if (!l_pettorali.isEmpty())
|
|
foto.setPettorali(l_pettorali);
|
|
try {
|
|
File jpegFile = new File(theFoto.getCanonicalPath());
|
|
Metadata metadata = JpegMetadataReader.readMetadata(jpegFile);
|
|
ExifSubIFDDirectory exifSubIFDDirectory = (ExifSubIFDDirectory)
|
|
metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
|
|
if (exifSubIFDDirectory.containsTag(36867)) {
|
|
Date theDate = exifSubIFDDirectory.getDate(36867);
|
|
foto.setTempo(new Time(theDate.getTime()));
|
|
} else {
|
|
fotoErrate++;
|
|
errMsg.append("<br>Attenzione " + theFoto.getName() + ": impossibile determinare il tag data creazione!");
|
|
}
|
|
} catch (Exception e) {
|
|
fotoErrate++;
|
|
errMsg.append("<br>Attenzione " + theFoto.getName() + ": impossibile determinare il tag data creazione. Eccezione: " +
|
|
e.getMessage());
|
|
}
|
|
rp = foto.save();
|
|
if (!rp.getStatus()) {
|
|
errMsg.append("<br>Salvataggio fallito:" + rp.getMsg() + " foto:" + foto.getFileName());
|
|
fotoErrate++;
|
|
}
|
|
}
|
|
currentFoto = (Foto)foto.clone();
|
|
} else if (theFoto.getName().toLowerCase().endsWith(".mp4")) {
|
|
try {
|
|
boolean creaJpg = false;
|
|
l_nomeFotoMd5 = "";
|
|
l_md5 = "";
|
|
l_pettorali = "";
|
|
totFoto++;
|
|
foto.findByFilenamePuntoFoto(l_nomeFoto, getId_puntoFoto());
|
|
if (foto.getDBState() == 0) {
|
|
nuoviVideo++;
|
|
creaJpg = true;
|
|
foto.setId_evento(getId_evento());
|
|
foto.setId_puntoFoto(getId_puntoFoto());
|
|
foto.setFileName(l_nomeFoto);
|
|
foto.setFlgVideo(1L);
|
|
foto.setMd5(l_md5);
|
|
foto.setFileNameMd5(l_nomeFotoMd5);
|
|
if (!l_pettorali.isEmpty())
|
|
foto.setPettorali(l_pettorali);
|
|
sb = new StringBuilder("inizio estrazione..");
|
|
LinkedHashSet<String> frames = ManageVideoJ.extractNFrames(dirFoto + dirFoto + DBAdapter.SEPARATOR, dirFoto + dirFoto, l_nomeFoto, 4);
|
|
sb = new StringBuilder("andata bene: " + frames.toString());
|
|
String[] source = (String[])frames.toArray(new String[0]);
|
|
String brandFileName = foto.getEvento().getImgWmSlomoFilename();
|
|
ImageConverter.creaGifAnimato(dirFoto + dirFoto + Foto.DIR_MP4_JPG + ".gif", source, 640, 1000, true, brandFileName);
|
|
rp = foto.save();
|
|
if (!rp.getStatus()) {
|
|
errMsg.append("<br>Salvataggio fallito:" + rp.getMsg() + " video:" + foto.getFileName() + " " +
|
|
sb.toString());
|
|
fotoErrate++;
|
|
}
|
|
}
|
|
currentFoto = (Foto)foto.clone();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
errMsg.append("<br>ECCEZIONE! Salvataggio foto MP4 fallito:" + rp.getMsg() + " video:" +
|
|
foto.getFileName() + " " + sb.toString());
|
|
fotoErrate++;
|
|
}
|
|
} else {
|
|
handleDebug("File non jpg:" + theFoto.getName(), 1);
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
handleDebug(e);
|
|
errMsg.append("\nIndicizzazione fallita sul file " + theFoto.getName() + "<br>" + e.getMessage());
|
|
}
|
|
rp.setMsg("Indicizzazione completata.<br>Numero foto indicizzate:" + totFoto + "<br>numero di foto nuove indicizzate: " + nuovefoto + " video: " + nuoviVideo + "<br>numero di foto ERRATE: " + fotoErrate + "<br>timestamp ultima foto: " +
|
|
|
|
String.valueOf(currentFoto.getTempo()) + "<br> - Errori rilevati: " + errMsg.toString());
|
|
rp.setStatus(true);
|
|
} else {
|
|
rp.setMsg("Errore! Percorso foto errato: " + dirFoto);
|
|
rp.setStatus(false);
|
|
}
|
|
} catch (Exception e) {
|
|
rp.setMsg("ERRORE!! " + e.getMessage());
|
|
rp.setStatus(false);
|
|
}
|
|
timer.stop();
|
|
if (debug)
|
|
System.out.println(TAG_THREAD_MSG + " indicizzazione foto " + TAG_THREAD_MSG + " completata. Durata: " + getDescrizioneCompleta());
|
|
return rp;
|
|
}
|
|
|
|
public ResParm indexFotoOLD(long l_id_user, String TAG_THREAD_MSG) {
|
|
ResParm rp = new ResParm();
|
|
int se1 = 10;
|
|
int se2 = 100;
|
|
int nuovefoto = 0;
|
|
int fotoErrate = 0;
|
|
int totFoto = 0;
|
|
StringBuffer errMsg = new StringBuffer();
|
|
if (getId_evento() == 0L) {
|
|
rp.setMsg("Indicizzazione foto: Bean gara non caricato");
|
|
rp.setStatus(false);
|
|
handleDebug("Indicizzazione foto: Bean gara non caricato", 2);
|
|
return rp;
|
|
}
|
|
String dirFoto = getPathCompletoFoto();
|
|
if (new File(dirFoto).exists()) {
|
|
File dir = new File(dirFoto);
|
|
File[] fotos = dir.listFiles();
|
|
Foto foto = new Foto(getApFull());
|
|
Foto currentFoto = new Foto(getApFull());
|
|
File theFoto = null;
|
|
try {
|
|
for (int i = 0; i < fotos.length; i++) {
|
|
theFoto = fotos[i];
|
|
if (!theFoto.getName().toLowerCase().startsWith("tn_") && theFoto.getName().toLowerCase().endsWith(".jpg")) {
|
|
totFoto++;
|
|
foto.findByFilenamePuntoFoto(theFoto.getName(), getId_puntoFoto());
|
|
if (foto.getDBState() == 0)
|
|
nuovefoto++;
|
|
foto.setId_evento(getId_evento());
|
|
foto.setId_puntoFoto(getId_puntoFoto());
|
|
foto.setFileName(theFoto.getName());
|
|
foto.setLastUpdId_user(l_id_user);
|
|
File jpegFile = new File(theFoto.getCanonicalPath());
|
|
Metadata metadata = JpegMetadataReader.readMetadata(jpegFile);
|
|
Directory exifDirectory = metadata.getFirstDirectoryOfType(ExifImageDirectory.class);
|
|
if (exifDirectory != null && exifDirectory.containsTag(36867)) {
|
|
Date theDate = exifDirectory.getDate(36867);
|
|
if (!rp.getStatus()) {
|
|
errMsg.append("<br>Salvataggio fallito:" + rp.getMsg() + " foto:" + foto.getFileName());
|
|
fotoErrate++;
|
|
}
|
|
} else {
|
|
fotoErrate++;
|
|
errMsg.append("<br>Attenzione " +
|
|
theFoto.getName() + ": impossibile determinare il tag data creazione!");
|
|
}
|
|
rp = foto.save();
|
|
if (!rp.getStatus()) {
|
|
System.out.println("ERRORE INDICIZZAZIONE: " + theFoto.getName() + ": " + rp.getMsg());
|
|
fotoErrate++;
|
|
errMsg.append("<br>Attenzione " + theFoto.getName() + ": " + rp.getMsg());
|
|
}
|
|
} else {
|
|
handleDebug("File non jpg:" + theFoto.getName(), 1);
|
|
}
|
|
}
|
|
System.out.println(" fine indicizzazione " + getDescrizione());
|
|
} catch (Exception e) {
|
|
handleDebug(e);
|
|
errMsg.append("\nIndicizzazione fallita sul file " + theFoto.getName() + "<br>" + e.getMessage());
|
|
}
|
|
rp.setMsg("Indicizzazione completata.<br>Numero foto indicizzate:" + totFoto + "<br>numero di foto nuove indicizzate: " + nuovefoto + "<br>numero di foto NON indicizzate: " + fotoErrate + "<br>" +
|
|
errMsg.toString());
|
|
rp.setStatus(true);
|
|
} else {
|
|
rp.setMsg("Errore! Percorso foto errato: " + dirFoto);
|
|
rp.setStatus(false);
|
|
}
|
|
return rp;
|
|
}
|
|
|
|
public FaceDetectionMethod getFaceDetectionMethodReal() {
|
|
if (getId_faceDetectionMethod() > 0L)
|
|
return getFaceDetectionMethod();
|
|
return getEvento().getFaceDetectionMethodEvento();
|
|
}
|
|
|
|
public long getDimMinFotoFace() {
|
|
return this.dimMinFotoFace;
|
|
}
|
|
|
|
public long getDimMinFotoFaceReal() {
|
|
if (getDimMinFotoFace() > 0L)
|
|
return getDimMinFotoFace();
|
|
return getEvento().getDimMinFotoFaceEvento();
|
|
}
|
|
|
|
public void setDimMinFotoFace(long dimMinFotoFace) {
|
|
this.dimMinFotoFace = dimMinFotoFace;
|
|
}
|
|
|
|
public long getId_faceDetectionMethod() {
|
|
return this.id_faceDetectionMethod;
|
|
}
|
|
|
|
public void setId_faceDetectionMethod(long id_faceDetectionMethod) {
|
|
this.id_faceDetectionMethod = id_faceDetectionMethod;
|
|
setFaceDetectionMethod(null);
|
|
}
|
|
|
|
public void setFaceDetectionMethod(FaceDetectionMethod faceDetectionMethod) {
|
|
this.faceDetectionMethod = faceDetectionMethod;
|
|
}
|
|
|
|
public FaceDetectionMethod getFaceDetectionMethod() {
|
|
this.faceDetectionMethod = (FaceDetectionMethod)getSecondaryObject(this.faceDetectionMethod, FaceDetectionMethod.class,
|
|
getId_faceDetectionMethod());
|
|
return this.faceDetectionMethod;
|
|
}
|
|
|
|
public ResParm indexFoto(long l_id_user, String TAG_THREAD_MSG) {
|
|
ResParm rp = new ResParm();
|
|
boolean debug = false;
|
|
Timer timer = new Timer();
|
|
timer.start();
|
|
int nuovefoto = 0;
|
|
int fotoErrate = 0;
|
|
int nuoviVideo = 0;
|
|
int totFoto = 0;
|
|
StringBuffer errMsg = new StringBuffer();
|
|
int maxNumberOfThread = getParm("MAX_NUMBER_OF_THREAD_INDEXING_SCALING").getNumeroInt();
|
|
if (maxNumberOfThread <= 1)
|
|
maxNumberOfThread = 10;
|
|
int i = 0;
|
|
if (getId_evento() == 0L || getId_puntoFoto() == 0L) {
|
|
rp.setMsg("Indicizzazione foto: Bean gara o punto foto non caricato");
|
|
rp.setStatus(false);
|
|
handleDebug("Indicizzazione foto: Bean gara o punto foto non caricato", 2);
|
|
return rp;
|
|
}
|
|
try {
|
|
StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, "...index foto " +
|
|
getDescrizioneCompleta() + "max thread: " + maxNumberOfThread + " ...");
|
|
if (debug)
|
|
System.out.println(TAG_THREAD_MSG + "Attenzione! Thread INDEX FOTO (PELLICOLA) punto foto " + TAG_THREAD_MSG + ": in esecuzione!!! max thread: " + getDescrizioneCompleta());
|
|
String dirFoto = getParm("PATHFOTO_FACE").getTesto() + getParm("PATHFOTO_FACE").getTesto() + getEvento().getPathEvento();
|
|
File dir = new File(dirFoto);
|
|
if (new File(dirFoto).exists()) {
|
|
File[] fotos = dir.listFiles();
|
|
Foto foto = new Foto(getApFull());
|
|
Foto currentFoto = new Foto(getApFull());
|
|
File theFoto = null;
|
|
String l_nomeFoto = "";
|
|
try {
|
|
ExecutorService pool = Executors.newFixedThreadPool(maxNumberOfThread);
|
|
Vectumerator<Future<ResParm>> vecF = new Vectumerator();
|
|
for (int k = 0; k < fotos.length; k++) {
|
|
theFoto = fotos[k];
|
|
l_nomeFoto = theFoto.getName();
|
|
if (k % 20 == 0)
|
|
StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, "...index foto - " +
|
|
getDescrizioneCompleta() + " max thread: " + maxNumberOfThread + ": " + l_nomeFoto + " - " + k + 1 + " su " + fotos.length + 1 + " eta: " +
|
|
|
|
timer.getEta((long)(fotos.length + 1), (long)(k + 1)));
|
|
IndexFotoCallable cfp = new IndexFotoCallable(foto, this, theFoto, l_id_user);
|
|
vecF.add(pool.submit(cfp));
|
|
}
|
|
for (int j = 0; j < vecF.getTotNumberOfRecords(); j++) {
|
|
Future<ResParm> currentFuture = (Future<ResParm>)vecF.nextElement();
|
|
try {
|
|
if (j % 20 == 0)
|
|
StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, "Risultati " +
|
|
getDescrizioneCompleta() + " max thread: " + maxNumberOfThread + " - index foto " + j + " indicizzazioni su " +
|
|
vecF.getTotNumberOfRecords() + "---> " +
|
|
currentFuture.get().getMsg() + " " +
|
|
timer.getEta((long)vecF.getTotNumberOfRecords(), (long)(j + 1)));
|
|
} catch (Exception ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
}
|
|
pool.shutdown();
|
|
} catch (Exception e) {
|
|
handleDebug(e);
|
|
errMsg.append("\nIndicizzazione fallita sul file " + theFoto.getName() + "<br>" + e.getMessage());
|
|
}
|
|
rp.setMsg("Indicizzazione completata.<br>Numero foto indicizzate:" + totFoto + "<br>numero di foto nuove indicizzate: " + nuovefoto + " video: " + nuoviVideo + "<br>numero di foto ERRATE: " + fotoErrate + "<br>timestamp ultima foto: " +
|
|
|
|
String.valueOf(currentFoto.getTempo()) + "<br> - Errori rilevati: " + errMsg.toString());
|
|
rp.setStatus(true);
|
|
} else {
|
|
rp.setMsg("Errore! Percorso foto errato: " + dirFoto);
|
|
rp.setStatus(false);
|
|
}
|
|
} catch (Exception e) {
|
|
rp.setMsg("ERRORE!! " + e.getMessage());
|
|
rp.setStatus(false);
|
|
}
|
|
timer.stop();
|
|
if (debug)
|
|
System.out.println(TAG_THREAD_MSG + " indicizzazione foto " + TAG_THREAD_MSG + " completata. Durata: " +
|
|
|
|
getDescrizioneCompleta());
|
|
return rp;
|
|
}
|
|
|
|
public long getFlgStatoScoring() {
|
|
return this.flgStatoScoring;
|
|
}
|
|
|
|
public void setFlgStatoScoring(long flgNoScoring1) {
|
|
this.flgStatoScoring = flgNoScoring1;
|
|
}
|
|
|
|
public static final String getStatoScoring(long l_flgStatoScoring) {
|
|
switch ((int)l_flgStatoScoring) {
|
|
case 0:
|
|
return "Da Elaborare";
|
|
case -1:
|
|
return "Escluso";
|
|
case 11:
|
|
return "Fase 1 in corso";
|
|
case 22:
|
|
return "Fase 2 in corso";
|
|
case 2:
|
|
return "Fase 2 ok";
|
|
case 1:
|
|
return "Fase 1 ok";
|
|
}
|
|
return "??";
|
|
}
|
|
|
|
public final String getStatoScoring() {
|
|
return getStatoScoring(getFlgStatoScoring());
|
|
}
|
|
|
|
@Deprecated
|
|
public String getLastFotoFileScore1() {
|
|
return (this.lastFotoFileScore1 == null) ? "" : this.lastFotoFileScore1.trim();
|
|
}
|
|
|
|
@Deprecated
|
|
public void setLastFotoFileScore1(String lastFotoFileScore1) {
|
|
this.lastFotoFileScore1 = lastFotoFileScore1;
|
|
}
|
|
|
|
public long getTotFoto() {
|
|
if (getId_puntoFoto() == 0L)
|
|
return -1L;
|
|
return new Foto(getApFull()).getTotFotoByPuntofoto(getId_puntoFoto(), false);
|
|
}
|
|
|
|
public long getTotJpgFiles() {
|
|
if (getId_puntoFoto() == 0L)
|
|
return -1L;
|
|
return (long)countJpgFiles(getPathCompletoFoto());
|
|
}
|
|
}
|