www in docker support

This commit is contained in:
MaddoScientisto 2026-04-22 18:41:37 +02:00
commit c227fce036
2145 changed files with 399596 additions and 58 deletions

View file

@ -0,0 +1,89 @@
package it.acxent.face.test;
import it.acxent.db.ApplParm;
import it.acxent.db.ApplParmFull;
import it.acxent.face.FotoFace;
import it.acxent.face.FotoFaceCR;
import it.acxent.util.DbConsole;
import it.acxent.util.Timer;
import it.acxent.util.Vectumerator;
import java.sql.Time;
import java.util.StringTokenizer;
public class SalvaImgFace extends DbConsole {
public static void main(String[] args) {
SalvaImgFace bean = new SalvaImgFace();
bean.doImport();
System.exit(0);
}
public void doImport() {
String db = "face";
int i = 0;
int se1 = 10;
int se2 = 100;
String hostname = "localhost:3308";
String temp = getCi().readLine("Hostname (" + hostname + "):");
if (!temp.isEmpty())
hostname = temp;
temp = getCi().readLine("Database name (" + db + "):");
if (!temp.isEmpty())
db = temp;
System.out.println("Db: " + db);
ApplParmFull apTarget = new ApplParmFull(new ApplParm(17, "//" + hostname + "/" + db, db, "root", "root", 1, 10, 300));
apTarget.setDebug(false);
long totNumberOfRecords = 0L;
StringBuffer msg = new StringBuffer();
try {
Timer timer = new Timer();
timer.start();
FotoFace ff = new FotoFace(apTarget);
FotoFaceCR CR = new FotoFaceCR();
System.out.println("ciclo foto face");
int page = 1;
Vectumerator<FotoFace> vec = ff.findAllNoMd5(0, 0);
if (page == 1) {
totNumberOfRecords = (long)vec.getTotNumberOfRecords();
System.out.println("Tot Record: " + totNumberOfRecords);
}
page++;
while (vec.hasMoreElements()) {
FotoFace row = (FotoFace)vec.nextElement();
if (row.getMd5().isEmpty())
row.save();
i++;
if (se1 > 0 && i % se1 == 0)
System.out.print(".");
if (se2 > 0 && i % se2 == 0)
System.out.println("" + i + " / " + i + " " + totNumberOfRecords);
}
System.out.println("fine ciclo \n" + msg.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
protected Time getTimeFromString(String theTime) {
try {
if (theTime.matches("[0-9][0-9][0-9][0-9]"))
theTime = theTime.substring(0, 2) + ":" + theTime.substring(0, 2);
if (theTime.matches("[0-9]{1,2}+:[0-9]{1,2}+")) {
StringTokenizer st = new StringTokenizer(theTime, ":");
int hour = Integer.parseInt(st.nextToken());
int min = Integer.parseInt(st.nextToken());
int sec = st.hasMoreElements() ? Integer.parseInt(st.nextToken()) : 0;
return new Time((long)((hour - 1) * 3600000 + min * 60000 + sec * 1000));
}
if (theTime.matches("[0-9]{1,2}+:[0-9]{1,2}+:[0-9]{1,2}+")) {
StringTokenizer st = new StringTokenizer(theTime, ":");
int hour = Integer.parseInt(st.nextToken());
int min = Integer.parseInt(st.nextToken());
int sec = st.hasMoreElements() ? Integer.parseInt(st.nextToken()) : 0;
return new Time((long)((hour - 1) * 3600000 + min * 60000 + sec * 1000));
}
return null;
} catch (Exception e) {
return null;
}
}
}

View file

@ -0,0 +1,84 @@
package it.acxent.face.test;
import it.acxent.db.ApplParm;
import it.acxent.db.ApplParmFull;
import it.acxent.face.FotoFace;
import it.acxent.face.FotoFaceCR;
import it.acxent.util.DbConsole;
import it.acxent.util.Vectumerator;
import java.sql.Time;
import java.util.StringTokenizer;
public class SalvaImgFaceOld extends DbConsole {
public static void main(String[] args) {
SalvaImgFaceOld bean = new SalvaImgFaceOld();
bean.doImport();
System.exit(0);
}
public void doImport() {
String db = "face";
int i = 0;
int se1 = 10;
int se2 = 100;
String hostname = "localhost:3308";
String temp = getCi().readLine("Hostname (" + hostname + "):");
if (!temp.isEmpty())
hostname = temp;
temp = getCi().readLine("Database name (" + db + "):");
if (!temp.isEmpty())
db = temp;
System.out.println("Db: " + db);
ApplParmFull apTarget = new ApplParmFull(new ApplParm(17, "//" + hostname + "/" + db, db, "root", "root", 1, 10, 300));
apTarget.setDebug(false);
StringBuffer msg = new StringBuffer();
try {
FotoFace ff = new FotoFace(apTarget);
FotoFaceCR CR = new FotoFaceCR();
System.out.println("ciclo foto face");
int page = 1;
Vectumerator<FotoFace> vec;
while ((vec = ff.findByCR(CR, page, 20)).hasMoreElements()) {
if (page == 1)
System.out.println("Tot Record: " + vec.getTotNumberOfRecords());
page++;
while (vec.hasMoreElements()) {
FotoFace row = (FotoFace)vec.nextElement();
row.save();
i++;
if (se1 > 0 && i % se1 == 0)
System.out.print(".");
if (se2 > 0 && i % se2 == 0)
System.out.println("" + i + " / " + i);
}
}
System.out.println("fine ciclo \n" + msg.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
protected Time getTimeFromString(String theTime) {
try {
if (theTime.matches("[0-9][0-9][0-9][0-9]"))
theTime = theTime.substring(0, 2) + ":" + theTime.substring(0, 2);
if (theTime.matches("[0-9]{1,2}+:[0-9]{1,2}+")) {
StringTokenizer st = new StringTokenizer(theTime, ":");
int hour = Integer.parseInt(st.nextToken());
int min = Integer.parseInt(st.nextToken());
int sec = st.hasMoreElements() ? Integer.parseInt(st.nextToken()) : 0;
return new Time((long)((hour - 1) * 3600000 + min * 60000 + sec * 1000));
}
if (theTime.matches("[0-9]{1,2}+:[0-9]{1,2}+:[0-9]{1,2}+")) {
StringTokenizer st = new StringTokenizer(theTime, ":");
int hour = Integer.parseInt(st.nextToken());
int min = Integer.parseInt(st.nextToken());
int sec = st.hasMoreElements() ? Integer.parseInt(st.nextToken()) : 0;
return new Time((long)((hour - 1) * 3600000 + min * 60000 + sec * 1000));
}
return null;
} catch (Exception e) {
return null;
}
}
}

View file

@ -0,0 +1,134 @@
package it.acxent.face.test;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.util.Deque;
import java.util.LinkedList;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
public class Test {
public static void main(String[] args) {
testJson();
}
public static boolean unzip(String zipFileName, String location) {
boolean ok = true;
int BUFFERSIZE = 1024;
if (!location.endsWith("/"))
location = location + "/";
try {
FileInputStream fin = new FileInputStream(zipFileName);
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry ze = null;
ze = zin.getNextEntry();
while ((ze = zin.getNextEntry()) != null) {
String file2Unzip = location + location;
if (ze.isDirectory()) {
File f = new File(file2Unzip);
if (!f.isDirectory())
f.mkdirs();
continue;
}
String dir = file2Unzip;
dir = dir.substring(0, dir.lastIndexOf("/"));
File dirFile = new File(dir);
if (!dirFile.exists())
dirFile.mkdirs();
FileOutputStream fout = new FileOutputStream(file2Unzip);
BufferedInputStream in = new BufferedInputStream(zin);
BufferedOutputStream out = new BufferedOutputStream(fout);
byte[] buffer = new byte[BUFFERSIZE];
int n;
while ((n = in.read(buffer, 0, BUFFERSIZE)) >= 0)
out.write(buffer, 0, n);
zin.closeEntry();
out.close();
}
zin.close();
} catch (Exception e) {
e.printStackTrace();
}
if (!ok)
System.out.println("Unzip Error unzipping " + zipFileName + " on dir " + location);
return ok;
}
public static boolean zipDir(File directory, String zipfile, boolean saveOrixginalPath) {
boolean ok = true;
System.out.println("ZipDir: start zipping: " + directory.getName());
if (directory.isDirectory()) {
URI base = directory.toURI();
Deque<File> queue = new LinkedList<>();
queue.push(directory);
OutputStream out = null;
ZipOutputStream zout = null;
try {
out = new FileOutputStream(zipfile);
zout = new ZipOutputStream(out);
while (!queue.isEmpty()) {
directory = queue.pop();
for (File kid : directory.listFiles()) {
String name = base.relativize(kid.toURI()).getPath();
if (kid.isDirectory()) {
queue.push(kid);
name = name.endsWith("/") ? name : (name + "/");
zout.putNextEntry(new ZipEntry(name));
} else {
zout.putNextEntry(new ZipEntry(name));
System.out.println("ZipDir: adding file " + name + " - " + kid.getCanonicalPath());
InputStream in = new FileInputStream(kid);
try {
byte[] buffer = new byte[1024];
while (true) {
int readCount = in.read(buffer);
if (readCount < 0)
break;
zout.write(buffer, 0, readCount);
}
} finally {
in.close();
}
zout.closeEntry();
}
}
}
} catch (Exception e) {
ok = false;
e.printStackTrace();
} finally {
try {
if (zout != null)
zout.close();
} catch (Exception e2) {
ok = false;
e2.printStackTrace();
}
}
}
if (ok) {
System.out.println("ZipDir: " + directory.getName());
} else {
System.out.println("ZipDir: Error zipping " + directory.getName() + " on file " + zipfile);
}
return ok;
}
public static final void testJson() {
String test = "{\n \"md5\": \"ae80c15c084a6952a6bdb66fc8051025\",\n \"type\": \"face\",\n \"score\": 0.0025377847589993507,\n \"db\": \"false\"\n}";
JsonObject jo = JsonParser.parseString(test).getAsJsonObject();
System.out.println("MD5: " + jo.get("md5").getAsString());
System.out.println("Type: " + jo.get("type").getAsString());
System.out.println("Score: " + jo.get("score").getAsDouble());
System.out.println("DB: " + jo.get("db").getAsBoolean());
}
}

View file

@ -0,0 +1 @@
package it.acxent.face.test;