www in docker support
This commit is contained in:
parent
539a848e95
commit
c227fce036
2145 changed files with 399596 additions and 58 deletions
|
|
@ -0,0 +1,462 @@
|
|||
package it.acxent.face.servlet.admin;
|
||||
|
||||
import it.acxent.common.Parm;
|
||||
import it.acxent.db.ApplParmFull;
|
||||
import it.acxent.db.CRAdapter;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.db.ResParm;
|
||||
import it.acxent.dm.FaceDetectionMethod;
|
||||
import it.acxent.face.Evento;
|
||||
import it.acxent.face.EventoCR;
|
||||
import it.acxent.face.FaceRecognizer;
|
||||
import it.acxent.face.PuntoFoto;
|
||||
import it.acxent.servlet.AblServletSvlt;
|
||||
import it.acxent.servlet.AddImgSvlt;
|
||||
import it.acxent.util.AbMessages;
|
||||
import java.io.File;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class EventoSvlt extends AblServletSvlt implements AddImgSvlt {
|
||||
private static final long serialVersionUID = 5676887616087638826L;
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
Evento bean = (Evento)beanA;
|
||||
req.setAttribute("listaPuntiFoto", bean.getPuntiFoto(0, 0));
|
||||
req.setAttribute("listaFaceRecognizer", new FaceRecognizer(getApFull()).findAll());
|
||||
req.setAttribute("listaFaceDetectionMethod", new FaceDetectionMethod(getApFull()).findAll());
|
||||
}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CRA, HttpServletRequest req, HttpServletResponse res) {
|
||||
req.setAttribute("listaFaceRecognizer", new FaceRecognizer(getApFull()).findAll());
|
||||
req.setAttribute("listaFaceDetectionMethod", new FaceDetectionMethod(getApFull()).findAll());
|
||||
}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new Evento(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new EventoCR(getApFull(req));
|
||||
}
|
||||
|
||||
public void _annullaModGara(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Parm parm = new Parm(apFull);
|
||||
parm.findByCodice("MODGARA");
|
||||
parm.setNumero(0.0D);
|
||||
ResParm rp = parm.save();
|
||||
apFull.resetCurrentApParms();
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _annullaModGaraCR(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Parm parm = new Parm(apFull);
|
||||
parm.findByCodice("MODGARA");
|
||||
parm.setNumero(0.0D);
|
||||
ResParm rp = parm.save();
|
||||
apFull.resetCurrentApParms();
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _faceIndex(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
long l_id = 0L;
|
||||
l_id = getRequestLongParameter(req, "id_puntoFotoIdx");
|
||||
PuntoFoto bean = new PuntoFoto(getApFull());
|
||||
bean.findByPrimaryKey(l_id);
|
||||
if (bean.getDBState() == 1) {
|
||||
ResParm rp = bean.startIndexFace();
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
sendMessage(req, "Impossibile importare: codice gara =0");
|
||||
}
|
||||
showBean(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
sendMessage(req, e.toString());
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void _faceIndexEvento(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
long l_id = 0L;
|
||||
l_id = getRequestLongParameter(req, "id_evento");
|
||||
Evento bean = new Evento(getApFull());
|
||||
bean.findByPrimaryKey(l_id);
|
||||
if (bean.getDBState() == 1) {
|
||||
ResParm rp = bean.startDetectFaceFoto();
|
||||
sendMessage(req, "thread foto face evento lanciato");
|
||||
} else {
|
||||
sendMessage(req, "Impossibile importare: codice evento =0");
|
||||
}
|
||||
showBean(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
sendMessage(req, e.toString());
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void _impostaModGara(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
long l_id = getRequestLongParameter(req, "id_evento");
|
||||
Evento bean = new Evento(apFull);
|
||||
bean.findByPrimaryKey(l_id);
|
||||
if (bean.getId_evento() > 0L) {
|
||||
Parm parm = new Parm(apFull);
|
||||
parm.findByCodice("MODGARA");
|
||||
parm.setNumero((double)l_id);
|
||||
ResParm rp = parm.save();
|
||||
apFull.resetCurrentApParms();
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
sendMessage(req, "ERRORE! Codice gara errato");
|
||||
}
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _indexFoto(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
long l_id = 0L;
|
||||
l_id = getRequestLongParameter(req, "id_puntoFotoIdx");
|
||||
PuntoFoto bean = new PuntoFoto(getApFull());
|
||||
bean.findByPrimaryKey(new Long(l_id));
|
||||
if (bean.getDBState() == 1) {
|
||||
ResParm rp = bean.startIndexFoto(getLoginUserId(req).longValue());
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
sendMessage(req, "Impossibile importare: codice gara =0");
|
||||
}
|
||||
showBean(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
sendMessage(req, "Errore: probabile dir errata: " + e.toString());
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void _creaPuntiFoto(HttpServletRequest req, HttpServletResponse res) {
|
||||
if (getLoginUserGrant(req, new Evento().getTableBeanName()) >= 3L) {
|
||||
ResParm rp = new ResParm(true, "");
|
||||
long l_id = 0L;
|
||||
Evento bean = null;
|
||||
l_id = getRequestLongParameter(req, "id_evento");
|
||||
bean = new Evento(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
if (bean.getId_evento() > 0L) {
|
||||
rp = bean.startCreaPuntiFoto(bean, false, getLoginUserId(req).longValue());
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
sendMessage(req, "Errore! Gara non valida.");
|
||||
}
|
||||
} else {
|
||||
sendGrantMessage(req, AbMessages.getMessage(getLocale(req), "GRANT_NO_RW"));
|
||||
showBean(req, res);
|
||||
}
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _indicizzaPuntiFoto(HttpServletRequest req, HttpServletResponse res) {
|
||||
if (getLoginUserGrant(req, new Evento().getTableBeanName()) >= 3L) {
|
||||
ResParm rp = new ResParm(true, "");
|
||||
long l_id = 0L;
|
||||
Evento bean = null;
|
||||
l_id = getRequestLongParameter(req, "id_evento");
|
||||
bean = new Evento(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
if (bean.getId_evento() > 0L) {
|
||||
rp = bean.startIndicizzaPuntiFoto(bean, getLoginUserId(req).longValue());
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
sendMessage(req, "Errore! Gara non valida.");
|
||||
}
|
||||
} else {
|
||||
sendGrantMessage(req, AbMessages.getMessage(getLocale(req), "GRANT_NO_RW"));
|
||||
showBean(req, res);
|
||||
}
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _addPuntoFoto(HttpServletRequest req, HttpServletResponse res) {
|
||||
if (getLoginUserGrant(req, new Evento().getTableBeanName()) >= 3L) {
|
||||
ResParm rp = new ResParm(true, "");
|
||||
long l_id = 0L;
|
||||
Evento bean = null;
|
||||
l_id = getRequestLongParameter(req, "id_evento");
|
||||
bean = new Evento(getApFull(req));
|
||||
try {
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
rp = bean.save();
|
||||
if (rp.getStatus() == true) {
|
||||
PuntoFoto beangr = new PuntoFoto(getApFull());
|
||||
fillObject(req, beangr);
|
||||
rp = bean.addPuntoFoto(beangr);
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
sendMessage(req, e.toString());
|
||||
showBean(req, res);
|
||||
}
|
||||
} else {
|
||||
sendGrantMessage(req, AbMessages.getMessage(getLocale(req), "GRANT_NO_RW"));
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void _delPuntoFoto(HttpServletRequest req, HttpServletResponse res) {
|
||||
if (getLoginUserGrant(req, new Evento().getTableBeanName()) >= 3L) {
|
||||
ResParm rp = new ResParm(true, "");
|
||||
long l_id = 0L;
|
||||
Evento bean = null;
|
||||
l_id = getRequestLongParameter(req, "id_evento");
|
||||
bean = new Evento(getApFull(req));
|
||||
try {
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
rp = bean.save();
|
||||
if (rp.getStatus() == true) {
|
||||
long l_id_puntoFoto = getRequestLongParameter(req, "id_puntoFoto");
|
||||
if (l_id_puntoFoto != 0L) {
|
||||
bean.delPuntoFoto(l_id_puntoFoto);
|
||||
sendMessage(req, "Cancellazione punto foto Effettuata");
|
||||
}
|
||||
showBean(req, res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
sendMessage(req, e.toString());
|
||||
showBean(req, res);
|
||||
}
|
||||
} else {
|
||||
sendGrantMessage(req, AbMessages.getMessage(getLocale(req), "GRANT_NO_RW"));
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void _modPuntoFoto(HttpServletRequest req, HttpServletResponse res) {
|
||||
if (getLoginUserGrant(req, new Evento().getTableBeanName()) >= 3L) {
|
||||
ResParm rp = new ResParm(true, "");
|
||||
long l_id = 0L;
|
||||
Evento bean = null;
|
||||
l_id = getRequestLongParameter(req, "id_evento");
|
||||
bean = new Evento(getApFull(req));
|
||||
try {
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
rp = bean.save();
|
||||
if (rp.getStatus() == true) {
|
||||
PuntoFoto beangr = new PuntoFoto(getApFull());
|
||||
long l_id_gr = getRequestLongParameter(req, "id_puntoFoto");
|
||||
beangr.findByPrimaryKey(l_id_gr);
|
||||
req.setAttribute("puntoFoto", beangr);
|
||||
sendMessage(req, AbMessages.getMessage(getLocale(req), "READ_OK"));
|
||||
showBean(req, res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
sendMessage(req, e.toString());
|
||||
showBean(req, res);
|
||||
}
|
||||
} else {
|
||||
sendGrantMessage(req, AbMessages.getMessage(getLocale(req), "GRANT_NO_RW"));
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
protected void search(HttpServletRequest req, HttpServletResponse res) {
|
||||
long l_id_evento = getId_eventoLte(req);
|
||||
if (l_id_evento > 0L) {
|
||||
req.setAttribute("id_evento", Long.valueOf(l_id_evento));
|
||||
showBean(req, res);
|
||||
} else {
|
||||
super.search(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
protected long getId_eventoLte(HttpServletRequest req) {
|
||||
return getParm("MODGARA").getNumeroLong();
|
||||
}
|
||||
|
||||
public void _creaFileExportIdx(HttpServletRequest req, HttpServletResponse res) {
|
||||
Evento bean = new Evento(getApFull());
|
||||
long l_id = getRequestLongParameter(req, "id_evento");
|
||||
bean.findByPrimaryKey(l_id);
|
||||
String targetDir = getPathTmpFull();
|
||||
bean.setFileNameExport("" + getLoginUserId(req) + "_export_" + getLoginUserId(req) + ".txt");
|
||||
ResParm rp = bean.exportFileIdx(targetDir + targetDir);
|
||||
req.setAttribute("fileExportOk", (rp.getStatus() == true) ? "true" : "false");
|
||||
req.setAttribute("fileNameExport", String.valueOf(bean.getFileNameExport()));
|
||||
req.setAttribute("act", "refresh");
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _indexCsv(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
long l_id = 0L;
|
||||
l_id = getRequestLongParameter(req, "id_evento");
|
||||
Evento bean = new Evento(getApFull());
|
||||
bean.findByPrimaryKey(new Long(l_id));
|
||||
String filename = bean.getImpCsvFileName();
|
||||
if (bean.getDBState() == 1) {
|
||||
ResParm rp = bean.indexFotoByCsv(filename, "IMPORT CSV");
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
sendMessage(req, "Impossibile importare: codice gara =0");
|
||||
}
|
||||
showBean(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void _salvaFileCsv(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Evento bean = new Evento(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_evento");
|
||||
bean.findByPrimaryKey(l_id);
|
||||
String tmpDir = getPathTmpFull();
|
||||
checkAndMakeDir(tmpDir);
|
||||
String l_fileName = tmpDir + tmpDir;
|
||||
if (new File(l_fileName).exists()) {
|
||||
String targetDir = getDocBase() + "csv/";
|
||||
checkAndMakeDir(tmpDir);
|
||||
if (!new File(targetDir).exists())
|
||||
new File(targetDir).mkdirs();
|
||||
String targetFile = targetDir + targetDir + ".csv";
|
||||
try {
|
||||
DBAdapter.copyFile(l_fileName, targetFile);
|
||||
} catch (Exception e) {
|
||||
sendMessage(req, "ERRORE! File csv NON caricato");
|
||||
}
|
||||
new File(l_fileName).delete();
|
||||
sendMessage(req, "File csv caricato");
|
||||
} else {
|
||||
sendMessage(req, "Errore! File csv non trovato!");
|
||||
}
|
||||
req.setAttribute("act", "refresh");
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _noIndexFoto(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
long l_id = 0L;
|
||||
l_id = getRequestLongParameter(req, "id_puntoFotoIdx");
|
||||
PuntoFoto bean = new PuntoFoto(getApFull());
|
||||
bean.findByPrimaryKey(new Long(l_id));
|
||||
if (bean.getDBState() == 1) {
|
||||
ResParm rp = bean.noIndexFoto();
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
sendMessage(req, "Impossibile importare: codice gara =0");
|
||||
}
|
||||
showBean(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
sendMessage(req, e.toString());
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void _buildModel(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
ResParm rp = new ResParm();
|
||||
Evento bean = new Evento(apFull);
|
||||
long l_id_evento = getRequestLongParameter(req, "id_evento");
|
||||
bean.findByPrimaryKey(l_id_evento);
|
||||
if (bean.getId_evento() > 0L) {
|
||||
int fase = (int)getRequestLongParameter(req, "faseScoring");
|
||||
rp = bean.startBuildModel(bean, fase);
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Evento nullo o non trovato!");
|
||||
}
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _indicizzaConModello(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
ResParm rp = new ResParm();
|
||||
Evento bean = new Evento(apFull);
|
||||
long l_id_evento = getRequestLongParameter(req, "id_evento");
|
||||
bean.findByPrimaryKey(l_id_evento);
|
||||
if (bean.getId_evento() > 0L) {
|
||||
rp = bean.startBuildIndicizzaConModello(bean);
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Evento nullo o non trovato!");
|
||||
}
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _stopScoringEvento(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Evento bean = new Evento(apFull);
|
||||
ResParm rp = bean.stopScoring();
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _stopBuildModel(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Evento bean = new Evento(apFull);
|
||||
ResParm rp = bean.stopBuildModel();
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _scoringEvento(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
ResParm rp = new ResParm();
|
||||
Evento bean = new Evento(apFull);
|
||||
long l_id_evento = getRequestLongParameter(req, "id_evento");
|
||||
bean.findByPrimaryKey(l_id_evento);
|
||||
if (bean.getId_evento() > 0L) {
|
||||
int fase = (int)getRequestLongParameter(req, "faseScoring");
|
||||
rp = bean.startEventoScoring(bean, fase);
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Evento nullo o non trovato!");
|
||||
}
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _stopIndicizzaConModello(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Evento bean = new Evento(apFull);
|
||||
ResParm rp = bean.stopIndicizzaConModello();
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _startProcessing(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Evento bean = new Evento(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_evento");
|
||||
bean.findByPrimaryKey(l_id);
|
||||
ResParm rp = bean.startProcessing();
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _stopProcessing(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Evento bean = new Evento(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_evento");
|
||||
bean.findByPrimaryKey(l_id);
|
||||
ResParm rp = bean.stopProcessing();
|
||||
sendMessage(req, rp.getMsg());
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package it.acxent.face.servlet.admin;
|
||||
|
||||
import it.acxent.db.ApplParmFull;
|
||||
import it.acxent.db.CRAdapter;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.db.ResParm;
|
||||
import it.acxent.dm.FaceDetectionMethod;
|
||||
import it.acxent.dm.FaceDetectionMethodCR;
|
||||
import it.acxent.face.api.FaceRecognitionApi;
|
||||
import it.acxent.face.api.FaceRecognitionApiResult;
|
||||
import it.acxent.servlet.AblServletSvlt;
|
||||
import it.acxent.servlet.AddImgSvlt;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class FaceDetectionMethodSvlt extends AblServletSvlt implements AddImgSvlt {
|
||||
private static final long serialVersionUID = 5676887616087638826L;
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CRA, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new FaceDetectionMethod(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new FaceDetectionMethodCR(getApFull(req));
|
||||
}
|
||||
|
||||
protected void search(HttpServletRequest req, HttpServletResponse res) {
|
||||
super.search(req, res);
|
||||
}
|
||||
|
||||
public void _syncFaceDetectionMethod(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
String userFR = apFull.getParm("FACE_RECOGNITION_API_USER").getTesto();
|
||||
String pwdFR = apFull.getParm("FACE_RECOGNITION_API_PWD").getTesto();
|
||||
FaceRecognitionApi bean = new FaceRecognitionApi(apFull, userFR, pwdFR);
|
||||
FaceRecognitionApiResult resF = bean.__syncFaceDetectionMethods();
|
||||
if (resF.isOk()) {
|
||||
JSONObject jRes = (JSONObject)resF.getResult();
|
||||
FaceDetectionMethod fdm = new FaceDetectionMethod(getApFull());
|
||||
fdm.syncJson(jRes.getJSONArray("faceDetectionMethods"));
|
||||
}
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _cambiaBtn(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FaceDetectionMethod bean = new FaceDetectionMethod(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_faceDetectionMethod");
|
||||
System.out.println("_cambiaBtn: id: " + l_id);
|
||||
bean.findByPrimaryKey(l_id);
|
||||
bean.setFlgBtn((bean.getFlgBtn() == 1L) ? 0L : 1L);
|
||||
ResParm rp = bean.save();
|
||||
System.out.println("_cambiaBtn: rp: " + rp.getMsg());
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Aggiornamento Effettuato");
|
||||
} else {
|
||||
sendMessage(req, "Errore! " + rp.getMsg());
|
||||
}
|
||||
search(req, res);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package it.acxent.face.servlet.admin;
|
||||
|
||||
import it.acxent.db.ApplParmFull;
|
||||
import it.acxent.db.CRAdapter;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.db.ResParm;
|
||||
import it.acxent.face.FaceRecognizer;
|
||||
import it.acxent.face.FaceRecognizerCR;
|
||||
import it.acxent.servlet.AblServletSvlt;
|
||||
import it.acxent.servlet.AddImgSvlt;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class FaceRecognizerSvlt extends AblServletSvlt implements AddImgSvlt {
|
||||
private static final long serialVersionUID = 5676887616087638826L;
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CRA, HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new FaceRecognizer(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new FaceRecognizerCR(getApFull(req));
|
||||
}
|
||||
|
||||
protected void search(HttpServletRequest req, HttpServletResponse res) {
|
||||
super.search(req, res);
|
||||
}
|
||||
|
||||
protected long getId_eventoLte(HttpServletRequest req) {
|
||||
return getParm("MODGARA").getNumeroLong();
|
||||
}
|
||||
|
||||
public void _resetInvioTraining(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FaceRecognizer bean = new FaceRecognizer(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_faceRecognizer");
|
||||
ResParm rp = new ResParm();
|
||||
bean.findByPrimaryKey(l_id);
|
||||
rp = bean.resetInvioTraining();
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Reset training ok");
|
||||
} else {
|
||||
sendMessage(req, "Errore! " + rp.getMsg());
|
||||
}
|
||||
showBean(req, res);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,301 @@
|
|||
package it.acxent.face.servlet.admin;
|
||||
|
||||
import it.acxent.db.ApplParmFull;
|
||||
import it.acxent.db.CRAdapter;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.db.ResParm;
|
||||
import it.acxent.face.Evento;
|
||||
import it.acxent.face.EventoCR;
|
||||
import it.acxent.face.FaceRecognizer;
|
||||
import it.acxent.face.Foto;
|
||||
import it.acxent.face.FotoCR;
|
||||
import it.acxent.face.FotoFace;
|
||||
import it.acxent.face.FotoFaceCR;
|
||||
import it.acxent.face.PuntoFoto;
|
||||
import it.acxent.face.PuntoFotoCR;
|
||||
import it.acxent.servlet.AblServletSvlt;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class FotoFaceSvlt extends AblServletSvlt {
|
||||
private static final long serialVersionUID = -3103317957544235586L;
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
Foto bean = (Foto)beanA;
|
||||
req.setAttribute("listFotoFace", bean.findFotoFace());
|
||||
}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CRA, HttpServletRequest req, HttpServletResponse res) {
|
||||
EventoCR CREvento = new EventoCR();
|
||||
PuntoFotoCR CRpf = new PuntoFotoCR();
|
||||
if (getId_eventoLte(req) == 0L) {
|
||||
CRpf.setId_evento(getRequestLongParameter(req, "id_evento"));
|
||||
} else {
|
||||
CREvento.setId_evento(getId_eventoLte(req));
|
||||
CRpf.setId_evento(getId_eventoLte(req));
|
||||
}
|
||||
req.setAttribute("listaEvento", new Evento(getApFull()).findByCR(CREvento, 0, 0));
|
||||
req.setAttribute("listaFaceRecognizer", new FaceRecognizer(getApFull()).findAll());
|
||||
CRpf.setTipoPuntoFoto(getRequestParameter(req, "tipoPuntoFoto"));
|
||||
if (CRpf.getId_evento() > 0L)
|
||||
req.setAttribute("listaPuntiFoto", new PuntoFoto(getApFull()).findByCR(CRpf, 0, 0));
|
||||
}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new FotoFace(getApFull());
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new FotoFaceCR(getApFull());
|
||||
}
|
||||
|
||||
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {
|
||||
super.prepareNewRecord(req, res);
|
||||
}
|
||||
|
||||
protected void sqlActions(HttpServletRequest req, HttpServletResponse res) {
|
||||
super.sqlActions(req, res);
|
||||
}
|
||||
|
||||
protected void print(HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void search(HttpServletRequest req, HttpServletResponse res) {
|
||||
FotoFaceCR CR = new FotoFaceCR(getApFull());
|
||||
if (getAct(req).equals("_searchSelfie"))
|
||||
Foto foto = (Foto)req.getSession().getAttribute("_SELFIE_FOTO");
|
||||
if (!getAct(req).equals("del") || !getAct(req).equals("back"))
|
||||
fillObject(req, CR);
|
||||
if (getAct(req).equals("back") &&
|
||||
req.getSession().getAttribute(getATTR_CRBEAN(req)) != null) {
|
||||
CR = (FotoFaceCR)req.getSession().getAttribute(getATTR_CRBEAN(req));
|
||||
req.setAttribute("id_evento", Long.valueOf(CR.getId_evento()));
|
||||
}
|
||||
if (getId_eventoLte(req) == 0L) {
|
||||
CR.setId_evento(getRequestLongParameter(req, "id_evento"));
|
||||
} else {
|
||||
CR.setId_evento(getId_eventoLte(req));
|
||||
}
|
||||
req.setAttribute("CR", CR);
|
||||
req.getSession().setAttribute(getATTR_CRBEAN(req), CR);
|
||||
if (CR.getId_evento() > 0L || CR.getId_fotoFaceS() > 0L)
|
||||
if (CR.getFlgReport().equals("")) {
|
||||
req.setAttribute("list", new FotoFace(getApFull()).findByCR(CR, getPageNumber(req), getPageRow(req)));
|
||||
} else {
|
||||
req.setAttribute("list", new FotoFace(getApFull()).findByCR(CR, 0, 0));
|
||||
}
|
||||
req.setAttribute("list", new FotoFace(getApFull()).findByCR(CR, getPageNumber(req), getPageRow(req)));
|
||||
fillComboAfterSearch(CR, req, res);
|
||||
callJsp(req, res);
|
||||
}
|
||||
|
||||
protected ResParm afterSave(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
Foto bean = (Foto)beanA;
|
||||
long l_id = bean.getId_foto();
|
||||
if (!getAct2(req).isEmpty()) {
|
||||
FotoCR CR = new FotoCR(getApFull());
|
||||
CR = (FotoCR)req.getSession().getAttribute(getATTR_CRBEAN(req));
|
||||
if (CR == null)
|
||||
CR = new FotoCR(getApFull());
|
||||
if (getAct2(req).equals("next")) {
|
||||
l_id = bean.getNextId_foto(CR);
|
||||
} else if (getAct2(req).equals("prev")) {
|
||||
l_id = bean.getPrevId_foto(CR);
|
||||
}
|
||||
bean.findByPrimaryKey(l_id);
|
||||
req.setAttribute("id_foto", Long.valueOf(l_id));
|
||||
req.setAttribute("bean", bean);
|
||||
}
|
||||
return super.afterSave(beanA, req, res);
|
||||
}
|
||||
|
||||
protected long getId_eventoLte(HttpServletRequest req) {
|
||||
return getParm("MODGARA").getNumeroLong();
|
||||
}
|
||||
|
||||
public void _switchTrainingOk(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1) {
|
||||
String icon;
|
||||
String l_label = getRequestParameter(req, "label_" + l_id);
|
||||
if (ff.getFlgTrainingOk() == 0L) {
|
||||
ff.setFlgTrainingOk(1L);
|
||||
icon = "<i class=\"fa fa-check-circle-o fa-2x\" style=\"color:darkgreen\" title=\"Training OK. PREMI PER ANNULLARE TRAINING\">";
|
||||
} else {
|
||||
ff.setFlgTrainingOk(0L);
|
||||
icon = "<i class=\"fa fa-ban fa-2x\" style=\"color:darkred\" title=\"NO TRAINING. PREMI PER ATTIVARE TRAINING\"></i>";
|
||||
}
|
||||
rp = ff.save();
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", rp.getMsg());
|
||||
jo.put("id_fotoFace", l_id);
|
||||
jo.put("icon", icon);
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
} else {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", "Errore! FotoFace non trovato: " + l_id);
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void _recognizeFotoFaceCR(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoCR CR = new FotoCR(apFull);
|
||||
fillObject(req, CR);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1)
|
||||
rp = ff.recognize(CR.getFaceRecognizer());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _ricalcolaSelfieFotoFace(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Foto bean = new Foto(apFull);
|
||||
ResParm rp = bean._ricalcolaFotoFacesSelfie();
|
||||
sendMessage(req, "Ricalcolati feature vector dei selfie caricati in sessione..." + rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _saveFotoFaceLabel(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1) {
|
||||
String icon;
|
||||
long l_label = getRequestLongParameter(req, "label_" + l_id);
|
||||
ff.setLabel(l_label);
|
||||
ff.setLabelMd5(null);
|
||||
if (l_label == 0L) {
|
||||
ff.setPettorale("");
|
||||
ff.setFlgTrainingOk(0L);
|
||||
icon = "<i class=\"fa fa-ban fa-2x\" style=\"color:darkred\" title=\"NO TRAINING. PREMI PER ATTIVARE TRAINING\"></i>";
|
||||
} else {
|
||||
ff.setFlgTrainingOk(1L);
|
||||
icon = "<i class=\"fa fa-check-circle-o fa-2x\" style=\"color:darkgreen\" title=\"Training OK. PREMI PER ANNULLARE TRAINING\">";
|
||||
}
|
||||
rp = ff.save();
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", rp.getMsg());
|
||||
jo.put("id_fotoFace", l_id);
|
||||
jo.put("icon", icon);
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
} else {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", "Errore! FotoFace non trovato: " + l_id);
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void _saveFotoFacePettorale(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1) {
|
||||
String icon;
|
||||
String l_pettorale = getRequestParameter(req, "pettorale_" + l_id);
|
||||
ff.setPettorale(l_pettorale);
|
||||
if (l_pettorale.isEmpty()) {
|
||||
ff.setPettorale("");
|
||||
ff.setFlgTrainingOk(0L);
|
||||
icon = "<i class=\"fa fa-ban fa-2x\" style=\"color:darkred\" title=\"NO TRAINING. PREMI PER ATTIVARE TRAINING\"></i>";
|
||||
} else {
|
||||
ff.setFlgTrainingOk(1L);
|
||||
icon = "<i class=\"fa fa-check-circle-o fa-2x\" style=\"color:darkgreen\" title=\"Training OK. PREMI PER ANNULLARE TRAINING\">";
|
||||
}
|
||||
rp = ff.save();
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", rp.getMsg());
|
||||
jo.put("pettorali", ff.getFoto().getPettorali());
|
||||
jo.put("label", ff.getLabel());
|
||||
jo.put("id_fotoFace", l_id);
|
||||
jo.put("icon", icon);
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
} else {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", "Errore! FotoFace non trovato: " + l_id);
|
||||
jo.put("pettorali", ff.getFoto().getPettorali());
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void _searchSelfie(HttpServletRequest req, HttpServletResponse res) {
|
||||
req.setAttribute("act", "_searchSelfie");
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _startBuildRecognizer(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoCR CR = new FotoCR(apFull);
|
||||
fillObject(req, CR);
|
||||
CR.setPageRow(getPageRow(req));
|
||||
FotoFace bean = new FotoFace(apFull);
|
||||
ResParm rp = bean.startBuildRecognizer(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _startRecognizer(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoCR CR = new FotoCR(apFull);
|
||||
fillObject(req, CR);
|
||||
CR.setPageRow(getPageRow(req));
|
||||
Foto bean = new Foto(apFull);
|
||||
ResParm rp = bean.startRecognizer(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _startTraining(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoCR CR = new FotoCR(apFull);
|
||||
fillObject(req, CR);
|
||||
CR.setPageRow(getPageRow(req));
|
||||
Foto bean = new Foto(apFull);
|
||||
ResParm rp = bean.startTraining(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _deleteFotoFaceCR(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1) {
|
||||
rp = ff.delete();
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Errore! FotoFace non trovato: " + l_id);
|
||||
}
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Cancellazione foto face effettuata");
|
||||
} else {
|
||||
sendMessage(req, "Errore! " + rp.getMsg());
|
||||
}
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _stopBuildRecognizer(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace bean = new FotoFace(apFull);
|
||||
ResParm rp = bean.stopBuildRecognizer();
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,916 @@
|
|||
package it.acxent.face.servlet.admin;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import it.acxent.db.ApplParmFull;
|
||||
import it.acxent.db.CRAdapter;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.db.ResParm;
|
||||
import it.acxent.dm.FaceDetectionMethod;
|
||||
import it.acxent.face.Evento;
|
||||
import it.acxent.face.EventoCR;
|
||||
import it.acxent.face.FaceRecognizer;
|
||||
import it.acxent.face.FaceScore;
|
||||
import it.acxent.face.Foto;
|
||||
import it.acxent.face.FotoCR;
|
||||
import it.acxent.face.FotoFace;
|
||||
import it.acxent.face.PuntoFoto;
|
||||
import it.acxent.face.PuntoFotoCR;
|
||||
import it.acxent.face.Selfie;
|
||||
import it.acxent.servlet.AblServletSvlt;
|
||||
import it.acxent.util.ImageDimension;
|
||||
import it.acxent.util.Vectumerator;
|
||||
import java.io.File;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class FotoSvlt extends AblServletSvlt {
|
||||
public static final String _ID_EVENTO_S = "_id_evento_s";
|
||||
|
||||
private static final long serialVersionUID = -3103317969344235586L;
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
System.out.println(getCmd(req));
|
||||
if (getCmd(req).equals("searchSelfie")) {
|
||||
_searchSelfiex(req, res);
|
||||
} else {
|
||||
search(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
Foto bean = (Foto)beanA;
|
||||
req.setAttribute("listFotoFace", bean.findFotoFace());
|
||||
req.setAttribute("listaFaceRecognizer", new FaceRecognizer(getApFull()).findAll());
|
||||
req.setAttribute("listaFaceDetectionMethod", new FaceDetectionMethod(getApFull()).findAll());
|
||||
Vectumerator<FaceDetectionMethod> vecFDM = new FaceDetectionMethod(getApFull()).findByBtn();
|
||||
req.setAttribute("listFDM", vecFDM);
|
||||
}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CRA, HttpServletRequest req, HttpServletResponse res) {
|
||||
EventoCR CREvento = new EventoCR();
|
||||
PuntoFotoCR CRpf = new PuntoFotoCR();
|
||||
if (getId_eventoLte(req) == 0L) {
|
||||
CRpf.setId_evento(getRequestLongParameter(req, "id_evento"));
|
||||
} else {
|
||||
CREvento.setId_evento(getId_eventoLte(req));
|
||||
CRpf.setId_evento(getId_eventoLte(req));
|
||||
}
|
||||
req.setAttribute("listaEvento", new Evento(getApFull()).findByCR(CREvento, 0, 0));
|
||||
req.setAttribute("listaFaceRecognizer", new FaceRecognizer(getApFull()).findAll());
|
||||
req.setAttribute("listaFaceDetectionMethod", new FaceDetectionMethod(getApFull()).findAll());
|
||||
CRpf.setTipoPuntoFoto(getRequestParameter(req, "tipoPuntoFoto"));
|
||||
if (CRpf.getId_evento() > 0L)
|
||||
req.setAttribute("listaPuntiFoto", new PuntoFoto(getApFull()).findByCR(CRpf, 0, 0));
|
||||
}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new Foto(getApFull());
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new FotoCR(getApFull());
|
||||
}
|
||||
|
||||
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {
|
||||
super.prepareNewRecord(req, res);
|
||||
}
|
||||
|
||||
protected void sqlActions(HttpServletRequest req, HttpServletResponse res) {
|
||||
super.sqlActions(req, res);
|
||||
}
|
||||
|
||||
protected void print(HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void search(HttpServletRequest req, HttpServletResponse res) {
|
||||
FotoCR CR = new FotoCR(getApFull());
|
||||
boolean debug = false;
|
||||
if (getId_eventoLte(req) == 0L) {
|
||||
CR.setId_evento(getRequestLongParameter(req, "id_evento"));
|
||||
} else {
|
||||
CR.setId_evento(getId_eventoLte(req));
|
||||
}
|
||||
Selfie selfie = (Selfie)req.getSession().getAttribute("selfie");
|
||||
if (selfie != null && selfie.getId_evento() == CR.getId_evento()) {
|
||||
CR.setId_selfie(selfie.getId_selfie());
|
||||
CR.setSelfie(selfie);
|
||||
searchSelfie(req, res);
|
||||
} else {
|
||||
if (selfie != null)
|
||||
req.getSession().removeAttribute("selfie");
|
||||
if (!getAct(req).equals("del") || !getAct(req).equals("back"))
|
||||
fillObject(req, CR);
|
||||
if (getAct(req).equals("back") &&
|
||||
req.getSession().getAttribute(getATTR_CRBEAN(req)) != null) {
|
||||
CR = (FotoCR)req.getSession().getAttribute(getATTR_CRBEAN(req));
|
||||
req.setAttribute("id_evento", Long.valueOf(CR.getId_evento()));
|
||||
}
|
||||
req.setAttribute("CR", CR);
|
||||
req.getSession().setAttribute(getATTR_CRBEAN(req), CR);
|
||||
if (CR.getId_evento() > 0L || CR.getId_fotoS() > 0L) {
|
||||
if (CR.getFlgReport().equals("")) {
|
||||
req.setAttribute("list", new Foto(getApFull()).findByCR(CR, getPageNumber(req), getPageRow(req)));
|
||||
} else {
|
||||
req.setAttribute("list", new Foto(getApFull()).findByCR(CR, 0, 0));
|
||||
}
|
||||
} else {
|
||||
req.setAttribute("list", new Foto(getApFull()).findByCR(CR, getPageNumber(req), getPageRow(req)));
|
||||
}
|
||||
fillComboAfterSearch(CR, req, res);
|
||||
callJsp(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
protected ResParm afterSave(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
Foto bean = (Foto)beanA;
|
||||
long l_id = bean.getId_foto();
|
||||
if (!getAct2(req).isEmpty()) {
|
||||
FotoCR CR = new FotoCR(getApFull());
|
||||
CR = (FotoCR)req.getSession().getAttribute(getATTR_CRBEAN(req));
|
||||
if (CR == null)
|
||||
CR = new FotoCR(getApFull());
|
||||
if (getAct2(req).equals("next")) {
|
||||
l_id = bean.getNextId_foto(CR);
|
||||
} else if (getAct2(req).equals("prev")) {
|
||||
l_id = bean.getPrevId_foto(CR);
|
||||
}
|
||||
bean.findByPrimaryKey(l_id);
|
||||
req.setAttribute("id_foto", Long.valueOf(l_id));
|
||||
req.setAttribute("bean", bean);
|
||||
}
|
||||
return super.afterSave(beanA, req, res);
|
||||
}
|
||||
|
||||
public void _elaboraSelfie(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Selfie selfie = (Selfie)req.getSession().getAttribute("selfie");
|
||||
ResParm rp = new ResParm();
|
||||
FotoCR CR = new FotoCR(apFull);
|
||||
fillObject(req, CR);
|
||||
if (selfie != null) {
|
||||
Foto foto = new Foto(apFull);
|
||||
rp = foto.startSelfieScoring(selfie, CR);
|
||||
}
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _searchSelfiex(HttpServletRequest req, HttpServletResponse res) {
|
||||
req.setAttribute("act", "_searchSelfie");
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _caricaSelfieOld(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
ResParm rp = new ResParm();
|
||||
String fileName = getRequestParameter(req, "fileNameOnServer_1");
|
||||
if (!fileName.isEmpty()) {
|
||||
String targetFileName = getPathTmpFull() + getPathTmpFull() + "_" + req.getSession().getId();
|
||||
String targetFile = getDocBase() + getDocBase();
|
||||
String sourceFile = getPathTmpFull() + getPathTmpFull();
|
||||
new File(sourceFile).renameTo(new File(targetFile));
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
rp = ff.loadSelfieByGoogleVision(targetFile);
|
||||
if (rp.getStatus()) {
|
||||
req.getSession().setAttribute("_SELFIE_FACE_FILENAME", targetFileName);
|
||||
req.getSession().setAttribute("_SELFIE_FACE_ORIG_FILENAME", fileName);
|
||||
sendMessage(req, "Selfie caricato correttamente!!");
|
||||
} else {
|
||||
req.getSession().removeAttribute("_SELFIE_FACE_FILENAME");
|
||||
sendMessage(req, rp.getErrMsg());
|
||||
}
|
||||
}
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _cancellaSelfie(HttpServletRequest req, HttpServletResponse res) {
|
||||
req.getSession().removeAttribute("selfie");
|
||||
req.setAttribute("label", "-1");
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _ricalcolaSelfieFotoFace(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Foto bean = new Foto(apFull);
|
||||
ResParm rp = bean._ricalcolaFotoFacesSelfie();
|
||||
sendMessage(req, "Ricalcolati feature vector dei selfie caricati in sessione..." + rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
private long getId_eventoSess(HttpServletRequest req) {
|
||||
Long id_eventoSess = (Long)req.getSession().getAttribute("_id_evento_s");
|
||||
if (id_eventoSess != null)
|
||||
return id_eventoSess;
|
||||
return 0L;
|
||||
}
|
||||
|
||||
private void setId_eventoSess(HttpServletRequest req, long value) {
|
||||
if (value == 0L)
|
||||
req.getSession().removeAttribute("_id_evento_s");
|
||||
req.getSession().setAttribute("_id_evento_s", Long.valueOf(value));
|
||||
}
|
||||
|
||||
protected long getId_eventoLte(HttpServletRequest req) {
|
||||
return getParm("MODGARA").getNumeroLong();
|
||||
}
|
||||
|
||||
public void _deleteFotoFaceCR(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1) {
|
||||
rp = ff.delete();
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Errore! FotoFace non trovato: " + l_id);
|
||||
}
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Cancellazione foto face effettuata");
|
||||
} else {
|
||||
sendMessage(req, "Errore! " + rp.getMsg());
|
||||
}
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _deleteFotoFace(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1) {
|
||||
rp = ff.delete();
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Errore! FotoFace non trovato: " + l_id);
|
||||
}
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Cancellazione foto face effettuata");
|
||||
} else {
|
||||
sendMessage(req, "Errore! " + rp.getMsg());
|
||||
}
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _fotoFaceFr(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Foto bean = new Foto(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_foto");
|
||||
bean.findByPrimaryKey(l_id);
|
||||
if (bean.getId_foto() > 0L) {
|
||||
fillObject(req, bean);
|
||||
ResParm rp = bean.save();
|
||||
if (rp.getStatus())
|
||||
rp = Foto.loadFacesByFaceRecognition(bean, true, true);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, rp.getMsg());
|
||||
} else {
|
||||
sendMessage(req, rp.getErrMsg());
|
||||
}
|
||||
showBean(req, res);
|
||||
} else {
|
||||
search(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void _calcolaPettorali(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Evento bean = new Evento(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_evento");
|
||||
FotoCR CR = new FotoCR(getApFull());
|
||||
fillObject(req, CR);
|
||||
bean.findByPrimaryKey(l_id);
|
||||
ResParm rp = bean.calcolaQuantitaPettorali(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
if (rp.getStatus()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String temp = (String)rp.getReturnObj();
|
||||
sb.append(rp.getMsg() + " <a href='../../" + rp.getMsg() + getPathTmp() + "' download>File " + temp + "</a><br>");
|
||||
sendHtmlMsgResponse(req, res, sb.toString());
|
||||
} else {
|
||||
sendHtmlMsgResponse(req, res, "ERRORE! " + rp.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
public void _cambiaFlgLock(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1) {
|
||||
long l_flgLock = getRequestLongParameter(req, "flgLock_" + l_id);
|
||||
ff.setFlgLock(l_flgLock);
|
||||
rp = ff.save();
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", rp.getMsg());
|
||||
jo.put("id_fotoFace", l_id);
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
} else {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", "Errore! FotoFace non trovato: " + l_id);
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void _switchTrainingOk(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1) {
|
||||
String icon;
|
||||
String l_label = getRequestParameter(req, "label_" + l_id);
|
||||
if (ff.getFlgTrainingOk() == 0L) {
|
||||
ff.setFlgTrainingOk(1L);
|
||||
icon = "<i class=\"fa fa-check-circle-o fa-2x\" style=\"color:darkgreen\" title=\"Training OK. PREMI PER ANNULLARE TRAINING\">";
|
||||
} else {
|
||||
ff.setFlgTrainingOk(0L);
|
||||
icon = "<i class=\"fa fa-ban fa-2x\" style=\"color:darkred\" title=\"NO TRAINING. PREMI PER ATTIVARE TRAINING\"></i>";
|
||||
}
|
||||
rp = ff.save();
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", rp.getMsg());
|
||||
jo.put("id_fotoFace", l_id);
|
||||
jo.put("icon", icon);
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
} else {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", "Errore! FotoFace non trovato: " + l_id);
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void _startTraining(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoCR CR = new FotoCR(apFull);
|
||||
fillObject(req, CR);
|
||||
CR.setPageRow(getPageRow(req));
|
||||
Foto bean = new Foto(apFull);
|
||||
ResParm rp = bean.startTraining(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _startRecognizer(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoCR CR = new FotoCR(apFull);
|
||||
fillObject(req, CR);
|
||||
CR.setPageRow(getPageRow(req));
|
||||
Foto bean = new Foto(apFull);
|
||||
ResParm rp = bean.startRecognizer(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _startBuildRecognizer(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoCR CR = new FotoCR(apFull);
|
||||
fillObject(req, CR);
|
||||
CR.setPageRow(getPageRow(req));
|
||||
FotoFace bean = new FotoFace(apFull);
|
||||
ResParm rp = bean.startBuildRecognizer(CR);
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _cancellaLegameFaceScore(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FaceScore fs = new FaceScore(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_faceScore");
|
||||
ResParm rp = new ResParm();
|
||||
fs.findByPrimaryKey(l_id);
|
||||
if (fs.getDBState() == 1) {
|
||||
rp = fs.delete();
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Legame Face Score Cancellato");
|
||||
} else {
|
||||
sendMessage(req, "ERRORE! " + rp.getMsg());
|
||||
}
|
||||
} else {
|
||||
sendMessage(req, "ERRORE! Face Score id " + l_id + " NON trovato!");
|
||||
}
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _saveFotoFacePettorale(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1) {
|
||||
String icon;
|
||||
String l_pettorale = getRequestParameter(req, "pettorale_" + l_id);
|
||||
ff.setPettorale(l_pettorale);
|
||||
if (l_pettorale.isEmpty()) {
|
||||
ff.setPettorale("");
|
||||
ff.setFlgTrainingOk(0L);
|
||||
icon = "<i class=\"fa fa-ban fa-2x\" style=\"color:darkred\" title=\"NO TRAINING. PREMI PER ATTIVARE TRAINING\"></i>";
|
||||
} else {
|
||||
ff.setFlgTrainingOk(1L);
|
||||
icon = "<i class=\"fa fa-check-circle-o fa-2x\" style=\"color:darkgreen\" title=\"Training OK. PREMI PER ANNULLARE TRAINING\">";
|
||||
}
|
||||
rp = ff.save();
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", rp.getMsg());
|
||||
jo.put("pettorali", ff.getFoto().getPettorali());
|
||||
jo.put("label", ff.getLabel());
|
||||
jo.put("id_fotoFace", l_id);
|
||||
jo.put("icon", icon);
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
} else {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", "Errore! FotoFace non trovato: " + l_id);
|
||||
jo.put("pettorali", ff.getFoto().getPettorali());
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void _recognizeFotoFace(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoCR CR = new FotoCR(apFull);
|
||||
fillObject(req, CR);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1)
|
||||
rp = ff.recognize(CR.getFaceRecognizer());
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _addNewLabel(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
long l_id_evento = getRequestLongParameter(req, "id_evento");
|
||||
Evento evento = new Evento(apFull);
|
||||
evento.findByPrimaryKey(l_id_evento);
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1 && evento.getId_faceRecognizer() > 0L) {
|
||||
rp = ff.addNewLabelFr(evento.getFaceRecognizer().getCodice());
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", rp.getMsg());
|
||||
jo.put("id_fotoFace", l_id);
|
||||
if (rp.getStatus()) {
|
||||
String iconLock, icon;
|
||||
jo.put("label", ff.getLabel());
|
||||
if (ff.getFlgTrainingLock() == 0L) {
|
||||
iconLock = "<i class=\"fa fa-unlock fa-2x\" style=\"color:darkred\" title=\"NO TRAINING LOCK. METTI LABEL >0 PER ATTIVARE IL LOCK\"></i>";
|
||||
} else {
|
||||
iconLock = "<i class=\"fa fa-lock fa-2x\" style=\"color:darkgreen\" title=\"Training LOCK. METTI LABEL =0 PER ANNULLARE IL LOCK\">";
|
||||
}
|
||||
if (ff.getFlgTrainingOk() == 0L) {
|
||||
icon = "<i class=\"fa fa-ban fa-2x\" style=\"color:darkred\" title=\"NO TRAINING. PREMI PER ATTIVARE TRAINING\"></i>";
|
||||
} else {
|
||||
icon = "<i class=\"fa fa-check-circle-o fa-2x\" style=\"color:darkgreen\" title=\"Training OK. PREMI PER ANNULLARE TRAINING\">";
|
||||
}
|
||||
jo.put("icon", icon);
|
||||
jo.put("iconLock", iconLock);
|
||||
}
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
} else {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", "Errore! FotoFace o Recognizer legato all'evento non trovato: " + l_id);
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void _addFace(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_foto");
|
||||
long l_id_fotoFace = getRequestLongParameter(req, "id_fotoFace");
|
||||
long l_centerX = getRequestLongParameter(req, "centerX");
|
||||
long l_centerY = getRequestLongParameter(req, "centerY");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id_fotoFace);
|
||||
ff.setId_foto(l_id);
|
||||
rp = ff.addFace(l_centerX, l_centerY);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Aggiunto nuovo viso");
|
||||
} else {
|
||||
sendMessage(req, "Errore! " + rp.getMsg());
|
||||
}
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _moveFaceX(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id_fotoFace = getRequestLongParameter(req, "id_fotoFace");
|
||||
long l_moveXYBy = getRequestLongParameter(req, "moveXYBy");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id_fotoFace);
|
||||
if (ff.getDBState() == 1) {
|
||||
rp = ff.moveFace(l_moveXYBy, 0L);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Viso spostato su X correttamente");
|
||||
} else {
|
||||
sendMessage(req, "Errore! " + rp.getMsg());
|
||||
}
|
||||
} else {
|
||||
sendMessage(req, "Errore! Foto Face non trovata");
|
||||
}
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _resizeFace(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id_fotoFace = getRequestLongParameter(req, "id_fotoFace");
|
||||
long l_resizeBy = getRequestLongParameter(req, "resizeBy");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id_fotoFace);
|
||||
if (ff.getDBState() == 1) {
|
||||
rp = ff.resizeFace(l_resizeBy);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Viso ridimensionato correttamente");
|
||||
} else {
|
||||
sendMessage(req, "Errore! " + rp.getMsg());
|
||||
}
|
||||
} else {
|
||||
sendMessage(req, "Errore! Foto Face non trovata");
|
||||
}
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _moveFaceY(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id_fotoFace = getRequestLongParameter(req, "id_fotoFace");
|
||||
long l_moveXYBy = getRequestLongParameter(req, "moveXYBy");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id_fotoFace);
|
||||
if (ff.getDBState() == 1) {
|
||||
rp = ff.moveFace(0L, l_moveXYBy);
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Viso spostato su Y correttamente");
|
||||
} else {
|
||||
sendMessage(req, "Errore! " + rp.getMsg());
|
||||
}
|
||||
} else {
|
||||
sendMessage(req, "Errore! Foto Face non trovata");
|
||||
}
|
||||
showBean(req, res);
|
||||
}
|
||||
|
||||
public void _changeAllLabel(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
long l_changeLabel = getRequestLongParameter(req, "changeLabel");
|
||||
long l_id_evento = getRequestLongParameter(req, "id_evento");
|
||||
Evento evento = new Evento(apFull);
|
||||
evento.findByPrimaryKey(l_id_evento);
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1 && evento.getId_faceRecognizer() > 0L) {
|
||||
rp = ff.changeAllLabel(l_changeLabel, evento.getFaceRecognizer().getCodice());
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Errore! FotoFace non trovato: " + l_id);
|
||||
}
|
||||
if (rp.getStatus()) {
|
||||
sendMessage(req, "Label foto face aggiornata");
|
||||
} else {
|
||||
sendMessage(req, "Errore! " + rp.getMsg());
|
||||
}
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _saveFotoFaceLabel(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
long l_id_evento = getRequestLongParameter(req, "id_evento");
|
||||
Evento evento = new Evento(apFull);
|
||||
evento.findByPrimaryKey(l_id_evento);
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1 && evento.getId_faceRecognizer() > 0L) {
|
||||
long l_newLabel = getRequestLongParameter(req, "label_" + l_id);
|
||||
rp = ff.updateLabel(l_newLabel, evento.getFaceRecognizer().getCodice());
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", rp.getMsg());
|
||||
jo.put("id_fotoFace", l_id);
|
||||
if (rp.getStatus()) {
|
||||
String icon, iconLock;
|
||||
if (ff.getFlgTrainingLock() == 0L) {
|
||||
iconLock = "<i class=\"fa fa-unlock fa-2x\" style=\"color:darkred\" title=\"NO TRAINING LOCK. METTI LABEL >0 PER ATTIVARE IL LOCK\"></i>";
|
||||
} else {
|
||||
iconLock = "<i class=\"fa fa-lock fa-2x\" style=\"color:darkgreen\" title=\"Training LOCK. METTI LABEL =0 PER ANNULLARE IL LOCK\">";
|
||||
}
|
||||
if (ff.getFlgTrainingOk() == 0L) {
|
||||
icon = "<i class=\"fa fa-ban fa-2x\" style=\"color:darkred\" title=\"NO TRAINING. PREMI PER ATTIVARE TRAINING\"></i>";
|
||||
} else {
|
||||
icon = "<i class=\"fa fa-check-circle-o fa-2x\" style=\"color:darkgreen\" title=\"Training OK. PREMI PER ANNULLARE TRAINING\">";
|
||||
}
|
||||
jo.put("icon", icon);
|
||||
jo.put("iconLock", iconLock);
|
||||
}
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
} else {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", "Errore! FotoFace non trovato: " + l_id);
|
||||
sendHtmlMsgResponse(req, res, jo.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void _stopElaboraSelfie(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Foto bean = new Foto(apFull);
|
||||
ResParm rp = bean.stopSelfieScoring();
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _caricaSelfieOld2(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
ResParm rp = new ResParm();
|
||||
String fileName = getRequestParameter(req, "fileNameOnServer_1");
|
||||
if (!fileName.isEmpty()) {
|
||||
String sourceFile = getPathTmpFull() + getPathTmpFull();
|
||||
String targetFileName = req.getSession().getId() + "_" + req.getSession().getId();
|
||||
String targetDir = getDocBase() + "_selfie/";
|
||||
File targetDirFile = new File(targetDir);
|
||||
if (!targetDirFile.exists())
|
||||
targetDirFile.mkdirs();
|
||||
String targetFile = targetDir + targetDir;
|
||||
new File(sourceFile).renameTo(new File(targetFile));
|
||||
String fotoMd5 = DBAdapter.getFileMd5(targetFile);
|
||||
Foto foto = new Foto(apFull);
|
||||
foto.findByMd5(fotoMd5);
|
||||
if (foto.getId_foto() == 0L) {
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
rp = ff.loadSelfieByGoogleVision(targetFile);
|
||||
if (rp.getStatus()) {
|
||||
foto.setMd5(fotoMd5);
|
||||
foto.setFileName(targetFileName);
|
||||
foto.setFlgFotoSearch(1L);
|
||||
rp = foto.save();
|
||||
if (rp.getStatus());
|
||||
if (rp.getStatus())
|
||||
sendMessage(req, "Selfie caricato correttamente!!");
|
||||
} else {
|
||||
new File(targetFile).delete();
|
||||
req.getSession().removeAttribute("_SELFIE_FACE_FILENAME");
|
||||
sendMessage(req, rp.getErrMsg());
|
||||
}
|
||||
}
|
||||
if (foto.getId_foto() > 0L) {
|
||||
req.getSession().setAttribute("_SELFIE_FACE_FILENAME", "_selfie/" + targetFileName);
|
||||
req.getSession().setAttribute("_SELFIE_FACE_ORIG_FILENAME", fileName);
|
||||
req.getSession().setAttribute("_SELFIE_FOTO", foto);
|
||||
}
|
||||
search(req, res);
|
||||
} else {
|
||||
sendMessage(req, "File name non trovato!!");
|
||||
sendMessage(req, rp.getErrMsg());
|
||||
}
|
||||
}
|
||||
|
||||
public void _elaboraSelfieOld(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
Foto fotoSelfie = (Foto)req.getSession().getAttribute("_SELFIE_FOTO");
|
||||
ResParm rp = new ResParm();
|
||||
FotoCR CR = new FotoCR(apFull);
|
||||
fillObject(req, CR);
|
||||
if (fotoSelfie != null) {
|
||||
Foto foto = new Foto(apFull);
|
||||
Vectumerator<Foto> vec = foto.findByCR(CR, 0, 0);
|
||||
rp = fotoSelfie.elaboraFaceRecog(vec);
|
||||
}
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _stopBuildRecognizer(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoFace bean = new FotoFace(apFull);
|
||||
ResParm rp = bean.stopBuildRecognizer();
|
||||
sendMessage(req, rp.getMsg());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _recognizeFotoFaceCR(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
FotoCR CR = new FotoCR(apFull);
|
||||
fillObject(req, CR);
|
||||
FotoFace ff = new FotoFace(apFull);
|
||||
long l_id = getRequestLongParameter(req, "id_fotoFace");
|
||||
ResParm rp = new ResParm();
|
||||
ff.findByPrimaryKey(l_id);
|
||||
if (ff.getDBState() == 1)
|
||||
rp = ff.recognize(CR.getFaceRecognizer());
|
||||
search(req, res);
|
||||
}
|
||||
|
||||
public void _caricaSelfieXxx(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
ResParm rp = new ResParm();
|
||||
String fileName = getRequestParameter(req, "fileNameOnServer_1");
|
||||
if (!fileName.isEmpty()) {
|
||||
String sourceFile = getPathTmpFull() + getPathTmpFull();
|
||||
String md5 = DBAdapter.getFileMd5(sourceFile);
|
||||
Selfie selfie = new Selfie(apFull);
|
||||
selfie.findByMd5(md5);
|
||||
if (selfie.getId_selfie() == 0L) {
|
||||
selfie.setMd5(md5);
|
||||
rp = selfie.save();
|
||||
if (rp.getStatus()) {
|
||||
String targetDir = selfie.getPathCompletoSelfie();
|
||||
File targetDirFile = new File(targetDir);
|
||||
if (!targetDirFile.exists())
|
||||
targetDirFile.mkdirs();
|
||||
String targetFile = selfie.getFullFileNameSelfie();
|
||||
System.out.println("############################### _caricaSelfie ###################\n" + sourceFile + " -->\n" + targetFile);
|
||||
DBAdapter.moveFile(sourceFile, targetFile);
|
||||
}
|
||||
}
|
||||
if (selfie.getId_selfie() > 0L) {
|
||||
req.getSession().setAttribute("selfie", selfie);
|
||||
} else {
|
||||
sendMessage(req, "Impossibile salvare il selfie: " + rp.getMsg());
|
||||
}
|
||||
search(req, res);
|
||||
} else {
|
||||
sendMessage(req, "File name non trovato!!");
|
||||
sendMessage(req, rp.getErrMsg());
|
||||
}
|
||||
}
|
||||
|
||||
protected void searchSelfie(HttpServletRequest req, HttpServletResponse res) {
|
||||
try {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
boolean doSearch = false;
|
||||
boolean debug = true;
|
||||
DBAdapter.printDebug(true, "searchSelfie doSearch: " + doSearch);
|
||||
long l_id_evento = getId_eventoLte(req);
|
||||
FotoCR CR = new FotoCR(apFull);
|
||||
if (getAct(req).equals("back")) {
|
||||
CR = (FotoCR)req.getSession().getAttribute("CR");
|
||||
if (CR.getPageNumber() > 0)
|
||||
req.setAttribute("pageNumber", String.valueOf(CR.getPageNumber()));
|
||||
} else {
|
||||
fillObject(req, CR);
|
||||
}
|
||||
CR.setId_evento(l_id_evento);
|
||||
Selfie selfie = new Selfie(apFull);
|
||||
if (req.getSession().getAttribute("selfie") != null) {
|
||||
selfie = (Selfie)req.getSession().getAttribute("selfie");
|
||||
selfie.findByPrimaryKey(selfie.getId_selfie());
|
||||
long resetSelfie = getRequestLongParameter(req, "resetSelfie");
|
||||
if (resetSelfie == 1L)
|
||||
selfie.resetSelfie();
|
||||
DBAdapter.printDebug(debug, "searchSelfie selfie: " + selfie.getId_selfie());
|
||||
if (selfie.getId_selfie() > 0L) {
|
||||
selfie.setApFull(apFull);
|
||||
selfie.findByPrimaryKey(selfie.getId_selfie());
|
||||
DBAdapter.printDebug(debug, "searchSelfie selfie.getCodGara(): " +
|
||||
selfie.getCodGara() + " l_id_evento: " + l_id_evento);
|
||||
if (selfie.getId_evento() == l_id_evento)
|
||||
doSearch = true;
|
||||
}
|
||||
}
|
||||
DBAdapter.printDebug(debug, "searchSelfie doSearch: " + doSearch);
|
||||
if (doSearch) {
|
||||
req.getSession().setAttribute("selfie", selfie);
|
||||
if (selfie.getElencoFoto().isEmpty()) {
|
||||
if (selfie.getFlgStatus() == 0L) {
|
||||
DBAdapter.printDebug(debug, "searchSelfie STATUS_DA_ELABORARE_0");
|
||||
selfie.startThreadUpdateElencoFotoScoring();
|
||||
} else if (selfie.getFlgStatus() == 99L) {
|
||||
DBAdapter.printDebug(debug, "searchSelfie STATUS_ELABORAZIONE_CONCLUSA");
|
||||
selfie.startThreadUpdateElencoFotoScoring();
|
||||
sendMessage(req, "Elaborazione conclusa. Recupero risultati");
|
||||
}
|
||||
} else {
|
||||
DBAdapter.printDebug(debug, "searchSelfie CR.getId_evento(): " +
|
||||
CR.getId_evento() + " selfie.getElencoFoto(): " + selfie.getElencoFotoExt());
|
||||
if (CR.getId_evento() != 0L && !selfie.getElencoFotoExt().isEmpty()) {
|
||||
int l_pageRow = CR.getPageRow();
|
||||
req.getSession().setAttribute("id_evento", String.valueOf(CR.getId_evento()));
|
||||
CR.setElencoFoto(selfie.getElencoFotoExt());
|
||||
req.getSession().setAttribute("CR", CR);
|
||||
req.setAttribute("CR", CR);
|
||||
FotoCR CREvento = new FotoCR();
|
||||
CREvento.setId_evento(CR.getId_evento());
|
||||
CREvento.setElencoFoto(selfie.getElencoFotoExt());
|
||||
CREvento.setFlgOrderBy(99L);
|
||||
DBAdapter.printDebug(debug, "searchSelfie lista: " + doSearch);
|
||||
Vectumerator<Foto> vec = new Foto(apFull).findByCR(CREvento, getPageNumber(req), l_pageRow);
|
||||
req.setAttribute("list", vec);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
req.getSession().setAttribute("CR", CR);
|
||||
req.setAttribute("CR", CR);
|
||||
}
|
||||
callJsp(req, res);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void _caricaSelfie(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
ResParm rp = new ResParm();
|
||||
String fileName = getRequestParameter(req, "fileNameOnServer_1");
|
||||
if (!fileName.isEmpty()) {
|
||||
String sourceFile = getPathTmpFull() + getPathTmpFull();
|
||||
String md5 = DBAdapter.getFileMd5(sourceFile);
|
||||
Selfie selfie = new Selfie(apFull);
|
||||
selfie.findByMd5(md5);
|
||||
if (selfie.getId_selfie() > 0L)
|
||||
if (selfie.getFlgStatus() == 99L) {
|
||||
selfie.updateFlgStatus(0L);
|
||||
DBAdapter.printDebug(" _caricaSelfie STATUS SELFIE IMPOSTATO A 0 ####00000000000000000000000");
|
||||
}
|
||||
long l_id_gara = getId_eventoLte(req);
|
||||
if (selfie.getId_selfie() == 0L && l_id_gara > 0L) {
|
||||
selfie.setMd5(md5);
|
||||
selfie.setId_evento(l_id_gara);
|
||||
selfie.setCodGara(selfie.getEvento().getCodeGara());
|
||||
rp = selfie.save();
|
||||
if (rp.getStatus()) {
|
||||
String targetDir = selfie.getPathCompletoSelfieWww();
|
||||
DBAdapter.checkAndMakeDir(targetDir);
|
||||
String targetFile = selfie.getFullFileNameSelfieWww();
|
||||
DBAdapter.printDebug("############################### _caricaSelfie ###################\n" + sourceFile + " -->\n" + targetFile);
|
||||
ImageDimension dim = ImageDimension.getImageDimensions(sourceFile);
|
||||
DBAdapter.printDebug("" + dim.getWidth() + " x " + dim.getWidth());
|
||||
DBAdapter.moveFile(sourceFile, targetFile);
|
||||
rp = selfie.detectFaceWww(true);
|
||||
if (!rp.getStatus()) {
|
||||
new File(targetFile).delete();
|
||||
selfie.delete();
|
||||
sendMessage(req, "Non sono riuscito ad estrarre il selfie. Prova con una foto nuova!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selfie.getId_selfie() > 0L) {
|
||||
req.getSession().setAttribute("selfie", selfie);
|
||||
} else if (l_id_gara == 0L) {
|
||||
sendMessage(req, "Il selfie deve essere associato ad un solo evento. Evento non selezionato. ");
|
||||
} else {
|
||||
sendMessage(req, "Impossibile salvare il selfie: " + rp.getMsg());
|
||||
}
|
||||
search(req, res);
|
||||
} else {
|
||||
sendMessage(req, "File name non trovato!!");
|
||||
sendMessage(req, rp.getErrMsg());
|
||||
}
|
||||
}
|
||||
|
||||
public void _checkSelfie(HttpServletRequest req, HttpServletResponse res) {
|
||||
boolean debug = true;
|
||||
ApplParmFull apFull = getApFull(req);
|
||||
JsonObject response = new JsonObject();
|
||||
FotoCR CR = new FotoCR(apFull);
|
||||
CR = (FotoCR)req.getSession().getAttribute("CR");
|
||||
DBAdapter.printDebug(debug, "CR elenco len:" + CR.getElencoFoto().length());
|
||||
if (req.getSession().getAttribute("selfie") != null) {
|
||||
Selfie selfie = (Selfie)req.getSession().getAttribute("selfie");
|
||||
selfie.findByPrimaryKey(selfie.getId_selfie());
|
||||
String currentSelfieElencoFoto = selfie.getElencoFotoExt();
|
||||
DBAdapter.printDebug(true, "selfie " +
|
||||
selfie.getId_selfie() + " stato:" + selfie.getStatus() + " ELENCOext LEN: " + selfie.getElencoFotoExt().length());
|
||||
if (selfie.getFlgStatus() == 0L) {
|
||||
DBAdapter.printDebug(debug, "start STATUS_DA_ELABORARE_0:");
|
||||
selfie.startThreadUpdateElencoFotoScoring();
|
||||
} else if (selfie.getFlgStatus() != 99L) {
|
||||
DBAdapter.printDebug(debug, "CHECK STATUS_ IN ELABORAZIONE");
|
||||
selfie.startThreadUpdateElencoFotoScoring();
|
||||
} else {
|
||||
DBAdapter.printDebug(debug, "CHECK STATUS_ ===================> STATUS_ELABORAZIONE_CONCLUSA");
|
||||
}
|
||||
DBAdapter.printDebug(debug, "currentSelfieElencoFoto len: " + currentSelfieElencoFoto.length() + " CR.getElencoFoto() len: " +
|
||||
CR.getElencoFoto().length());
|
||||
if (!currentSelfieElencoFoto.isEmpty() && !CR.getElencoFoto().equals(currentSelfieElencoFoto)) {
|
||||
response.addProperty("searchAgain", Boolean.valueOf(true));
|
||||
response.addProperty("msg", "Ricerca in corso.... Refresh.");
|
||||
} else {
|
||||
response.addProperty("searchAgain", Boolean.valueOf(false));
|
||||
if (selfie.getFlgStatus() == 99L) {
|
||||
response.addProperty("msg", "Ricerca Conclusa!");
|
||||
} else {
|
||||
response.addProperty("msg", "Ricerca in corso.... nessuna nuova foto.");
|
||||
}
|
||||
}
|
||||
response.addProperty("status", Long.valueOf(selfie.getFlgStatus()));
|
||||
response.addProperty("statusMsg", selfie.getStatus());
|
||||
} else {
|
||||
response.addProperty("searchAgain", Boolean.valueOf(true));
|
||||
response.addProperty("msg", "Attenzione! selfie non trovato!");
|
||||
response.addProperty("status", Integer.valueOf(0));
|
||||
response.addProperty("statusMsg", "no selfie");
|
||||
}
|
||||
sendHtmlMsgResponse(req, res, response.toString());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,179 @@
|
|||
package it.acxent.face.servlet.admin;
|
||||
|
||||
import it.acxent.db.ApplParmFull;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.db.ResParm;
|
||||
import it.acxent.face.FaceRemota;
|
||||
import it.acxent.face.Foto;
|
||||
import it.acxent.face.FotoFace;
|
||||
import it.acxent.face.Selfie;
|
||||
import it.acxent.servlet.AcStndSvlt;
|
||||
import it.acxent.util.ScaleImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.OutputStream;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class GetFileSvlt extends AcStndSvlt {
|
||||
private static final long serialVersionUID = -3037980260742696647L;
|
||||
|
||||
protected boolean checkLoginProfile(HttpServletRequest req) {
|
||||
try {
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getLoginPage(HttpServletRequest req, HttpServletResponse res) {
|
||||
return "/documentoCR.jsp";
|
||||
}
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
chiamaJsp(req, res);
|
||||
}
|
||||
|
||||
protected void chiamaJsp(HttpServletRequest req, HttpServletResponse res) {
|
||||
ApplParmFull appFull = getApFull(req);
|
||||
try {
|
||||
String fileName = "";
|
||||
long l_id_selfie = getRequestLongParameter(req, "id_selfie");
|
||||
long l_id_foto = getRequestLongParameter(req, "id_foto");
|
||||
long l_id_fotoFace = getRequestLongParameter(req, "id_fotoFace");
|
||||
long l_label = getRequestLongParameter(req, "label");
|
||||
String l_labelMd5 = getRequestParameter(req, "labelMd5");
|
||||
if (l_id_selfie > 0L) {
|
||||
Selfie selfie = new Selfie(appFull);
|
||||
selfie.findByPrimaryKey(l_id_selfie);
|
||||
if (selfie.getId_selfie() > 0L)
|
||||
fileName = selfie.getRealSelfieImgPath();
|
||||
} else if (!l_labelMd5.isEmpty()) {
|
||||
FotoFace ff = new FotoFace(appFull);
|
||||
ff.findByMd5(l_labelMd5);
|
||||
if (ff.getDBState() == 1) {
|
||||
fileName = ff.getFullFaceImgPath();
|
||||
} else {
|
||||
FaceRemota fr = new FaceRemota(appFull);
|
||||
fr.findByMd5(l_labelMd5);
|
||||
if (fr.getDBState() == 1)
|
||||
fileName = fr.getFullFaceImgPath();
|
||||
}
|
||||
} else if (l_label > 0L) {
|
||||
FaceRemota fr = new FaceRemota(appFull);
|
||||
fr.findByLabel(l_label);
|
||||
if (fr.getDBState() == 1)
|
||||
fileName = fr.getFullFaceImgPath();
|
||||
} else if (l_id_fotoFace > 0L) {
|
||||
FotoFace ff = new FotoFace(appFull);
|
||||
ff.findByPrimaryKey(l_id_fotoFace);
|
||||
if (ff.getDBState() == 1)
|
||||
fileName = ff.getFullFaceImgPath();
|
||||
} else if (l_id_foto == 0L) {
|
||||
setJspPage("fileNonTrovato.jsp", req);
|
||||
res.sendRedirect(getJspPage(req));
|
||||
} else {
|
||||
Foto bean = new Foto(appFull);
|
||||
bean.findByPrimaryKey(l_id_foto);
|
||||
if (bean.getDBState() == 1) {
|
||||
long flgPV = getRequestLongParameter(req, "flgPV");
|
||||
if (bean.getFlgVideo() == 0L) {
|
||||
fileName = bean.getFileNameFullPath();
|
||||
} else {
|
||||
long numFoto = getRequestLongParameter(req, "n");
|
||||
fileName = bean.getFileNameFullPath() + "_" + bean.getFileNameFullPath() + ".jpg";
|
||||
}
|
||||
int scaledWidth = (int)bean.getPuntoFoto().getEvento().getFrImageWidth();
|
||||
int scaledHeigth = 0;
|
||||
if (scaledWidth <= 0)
|
||||
scaledWidth = 1280;
|
||||
if (flgPV == 9L) {
|
||||
if (bean.getFlgVideo() == 0L) {
|
||||
flgPV = 0L;
|
||||
} else {
|
||||
fileName = bean.getPuntoFoto().getPathCompletoFoto() + "/" + bean.getPuntoFoto().getPathCompletoFoto() + ".gif";
|
||||
}
|
||||
} else {
|
||||
if (flgPV == 0L) {
|
||||
if (bean.getFlgVideo() == 0L) {
|
||||
ScaleImage si;
|
||||
if (scaledHeigth == 0) {
|
||||
si = new ScaleImage(fileName, "_" + scaledWidth + "W/", 0L, scaledWidth, 0, false, false);
|
||||
} else {
|
||||
si = new ScaleImage(fileName, "_" + scaledHeigth + "H/", 0L, 0, scaledHeigth, false, false);
|
||||
}
|
||||
handleDebug("*** Scaling " + l_id_foto, 1);
|
||||
si.setAutoRotate(true);
|
||||
ResParm rp = si.scaleIt();
|
||||
handleDebug("###SCALED " + l_id_foto, 1);
|
||||
if (rp.getStatus())
|
||||
fileName = si.getTheScaledImageName();
|
||||
} else {
|
||||
ScaleImage si;
|
||||
if (scaledHeigth == 0) {
|
||||
si = new ScaleImage(fileName, "_" + scaledWidth + "/", 0L, scaledWidth, 0, false, false);
|
||||
} else {
|
||||
si = new ScaleImage(fileName, "_" + scaledWidth + "/", 0L, 0, scaledHeigth, false, false);
|
||||
}
|
||||
String targetBrandFile = ScaleImage.getFullScaledImagename(bean.getEvento().getImgWmSlomoFilename(), "" + scaledWidth + "/");
|
||||
if (!new File(targetBrandFile).exists())
|
||||
ScaleImage.scalePngImageToFile(bean.getEvento().getImgWmSlomoFilename(), targetBrandFile, scaledWidth);
|
||||
if (!new File(targetBrandFile).exists())
|
||||
targetBrandFile = bean.getEvento().getImgWmSlomoFilename();
|
||||
si.setBrandFileName(targetBrandFile);
|
||||
handleDebug("*** Scaling " + l_id_foto, 1);
|
||||
ResParm rp = si.scaleIt();
|
||||
handleDebug("###SCALED " + l_id_foto, 1);
|
||||
if (rp.getStatus())
|
||||
fileName = si.getTheScaledImageName();
|
||||
}
|
||||
} else if (flgPV == 1L) {
|
||||
|
||||
}
|
||||
if (flgPV == 2L)
|
||||
fileName = bean.getPuntoFoto().getPathCompletoFoto() + bean.getPuntoFoto().getPathCompletoFoto() + "/" + scaledWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
File theFile = new File(fileName);
|
||||
if (theFile.exists())
|
||||
if (fileName.toLowerCase().endsWith("gif")) {
|
||||
System.out.println("Getfile www gifs-->>>>");
|
||||
res.setContentType("image/gif");
|
||||
ByteArrayOutputStream ba = DBAdapter.getByteArrayFromFile(fileName);
|
||||
res.setContentLength(ba.size());
|
||||
try {
|
||||
ServletOutputStream out = res.getOutputStream();
|
||||
ba.writeTo((OutputStream)out);
|
||||
out.flush();
|
||||
} catch (Exception e) {
|
||||
handleDebug(e, 0);
|
||||
}
|
||||
} else {
|
||||
theFile = new File(fileName);
|
||||
if (theFile.exists()) {
|
||||
res.setContentType("image/jpg");
|
||||
ByteArrayOutputStream ba = DBAdapter.getByteArrayFromFile(fileName);
|
||||
res.setContentLength(ba.size());
|
||||
try {
|
||||
ServletOutputStream out = res.getOutputStream();
|
||||
ba.writeTo((OutputStream)out);
|
||||
out.flush();
|
||||
} catch (Exception e) {
|
||||
handleDebug(e, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void mostraDettaglio(HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void accessiSql(HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected void search(HttpServletRequest req, HttpServletResponse res) {}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package it.acxent.face.servlet.admin;
|
||||
|
||||
public class InitUpdateDbSvlt extends it.acxent.servlet.InitUpdateDbSvlt {
|
||||
private static final long serialVersionUID = 2009630171796732636L;
|
||||
|
||||
protected String getProjectVersionTag() {
|
||||
return "acxent-face";
|
||||
}
|
||||
|
||||
protected long getDatabaseVersionNumber() {
|
||||
return 21L;
|
||||
}
|
||||
|
||||
protected String getSubVersionNumber() {
|
||||
return "251114";
|
||||
}
|
||||
|
||||
protected boolean shouldInitCore() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package it.acxent.face.servlet.admin;
|
||||
|
||||
import it.acxent.db.CRAdapter;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.face.Users;
|
||||
import it.acxent.face.UsersCR;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet(urlPatterns = {"/admin/config/Users.abl"})
|
||||
public class UsersSvlt extends it.acxent.anag.servlet.UsersSvlt {
|
||||
protected void fillComboAfterDetail(DBAdapter bean, HttpServletRequest req, HttpServletResponse res) {
|
||||
super.fillComboAfterDetail(bean, req, res);
|
||||
}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {
|
||||
super.fillComboAfterSearch(CR, req, res);
|
||||
}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new Users(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
UsersCR CR = new UsersCR();
|
||||
CR.setPolicy(getLoginUser(req).getUserProfile().getPolicy());
|
||||
return (CRAdapter)CR;
|
||||
}
|
||||
|
||||
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {
|
||||
super.prepareNewRecord(req, res);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
package it.acxent.face.servlet.admin;
|
||||
Loading…
Add table
Add a link
Reference in a new issue