finished timestamp filesystem

This commit is contained in:
Hendrik Schutter 2019-02-22 19:55:34 +01:00
parent d0f3933574
commit fa7a0dbbff
4 changed files with 65 additions and 50 deletions

View File

@ -6,19 +6,13 @@ public class DateModified
{ {
public Calendar getDate(String filepath) public Calendar getDate(String filepath)
{ {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
// Specify the file path and name // Specify the file path and name
File file = new File(filepath); File file = new File(filepath);
long lastModified = file.lastModified(); long lastModified = file.lastModified();
Date date = new Date(lastModified); Date date = new Date(lastModified);
System.out.println(date);
calendar.setTime(date); calendar.setTime(date);
return calendar; return calendar;
} }

View File

@ -63,7 +63,7 @@ public class ImageFinderTimestamp extends ImageFinder
if ((filesindex < fileslenght) && (fileslenght != 0)) { if ((filesindex < fileslenght) && (fileslenght != 0)) {
path = files[filesindex].getAbsolutePath(); path = files[filesindex].getAbsolutePath();
filesindex++; filesindex++;
return path; return path.substring(lengthRootFolder);
} else { } else {
// System.out.println("sort new Images"); // System.out.println("sort new Images");
sortImages(); sortImages();
@ -74,7 +74,7 @@ public class ImageFinderTimestamp extends ImageFinder
path = files[filesindex].getAbsolutePath(); path = files[filesindex].getAbsolutePath();
filesindex++; filesindex++;
return path; return path.substring(lengthRootFolder);
} }
} }

View File

@ -3,6 +3,8 @@ import java.io.FileNotFoundException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.Calendar; import java.util.Calendar;
public class Main public class Main
{ {
// read from UI later // read from UI later
@ -21,6 +23,9 @@ public class Main
static boolean modi = true; // Create Database // False -> Copy/Link images static boolean modi = true; // Create Database // False -> Copy/Link images
static boolean modi_metadata = true; // true --> exif , false --> timestamp
// from filesystem
// java -jar TLC_PostSW.jar -log -m createDB -r /home/hendrik/FTP/camera01/ // java -jar TLC_PostSW.jar -log -m createDB -r /home/hendrik/FTP/camera01/
// -p /home/hendrik/Schreibtisch/ -o /home/hendrik/Schreibtisch/testeritis/ // -p /home/hendrik/Schreibtisch/ -o /home/hendrik/Schreibtisch/testeritis/
// -n 83584 // -n 83584
@ -51,6 +56,17 @@ public class Main
} }
} }
if (value.equals("-d")) {
i++;
if (args[i].equals("exif")) {
modi_metadata = true;
System.out.println("[Metadata] Use Exif for timestamp");
} else {
modi_metadata = false;
System.out.println("[Metadata] Use filesystem for timestamp");
}
}
if (value.equals("-r")) { if (value.equals("-r")) {
i++; i++;
rootFolderPath = args[i]; rootFolderPath = args[i];
@ -71,7 +87,6 @@ public class Main
if (value.equals("-i")) { if (value.equals("-i")) {
i++; i++;
if (args[i].equals("counter")) { if (args[i].equals("counter")) {
System.out.println("[Identify] Find images with counter"); System.out.println("[Identify] Find images with counter");
imgF = new ImageFinderCounter(rootFolderPath); imgF = new ImageFinderCounter(rootFolderPath);
@ -79,7 +94,6 @@ public class Main
System.out.println("[Identify] Find images with date and time"); System.out.println("[Identify] Find images with date and time");
imgF = new ImageFinderTimestamp(rootFolderPath); imgF = new ImageFinderTimestamp(rootFolderPath);
} }
} }
if (value.equals("-n")) { if (value.equals("-n")) {
@ -92,7 +106,6 @@ public class Main
System.out.println( System.out.println(
"-log -m createDB -r /home/hendrik/FTP/camera01/ -p /home/hendrik/Schreibtisch/ -o /home/hendrik/Schreibtisch/testeritis/ -n 83584"); "-log -m createDB -r /home/hendrik/FTP/camera01/ -p /home/hendrik/Schreibtisch/ -o /home/hendrik/Schreibtisch/testeritis/ -n 83584");
System.exit(1); System.exit(1);
} }
} }
@ -141,9 +154,13 @@ public class Main
// gefunden // gefunden
File f = new File(rootFolderPath + path); File f = new File(rootFolderPath + path);
int size = (int) f.length(); int size = (int) f.length();
// Calendar calendar = exif.getDate(rootFolderPath + path); Calendar calendar;
Calendar calendar = datemod.getDate(rootFolderPath + path); if (modi_metadata) {
calendar = exif.getDate(rootFolderPath + path);
} else {
calendar = datemod.getDate(rootFolderPath + path);
}
db.fillImages(i, path, calendar.get(Calendar.DAY_OF_MONTH), db.fillImages(i, path, calendar.get(Calendar.DAY_OF_MONTH),
(calendar.get(Calendar.MONTH) + 1), (calendar.get(Calendar.MONTH) + 1),
@ -176,7 +193,7 @@ public class Main
// qi.outputImagesFromHourToHour(0, 8, 19, "copy", false); // qi.outputImagesFromHourToHour(0, 8, 19, "copy", false);
qi.outputImagesEveryHour(0, 8, 19, "copy", false); qi.outputImagesEveryHour(0, 8, 18, "copy", false);
// qi.outputImagesFromHourAndMinute(40177, 8, 30, "copy", true); // qi.outputImagesFromHourAndMinute(40177, 8, 30, "copy", true);

View File

@ -49,22 +49,22 @@ public class QueryImages
} }
return false; return false;
} }
public void outputImagesFromHour(int startcounter, int hour, String method, boolean sunday) public void outputImagesFromHour(int startcounter, int hour, String method,
boolean sunday)
{ {
List<Image> resultList = db.query( List<Image> resultList = db.query(
"SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE hour = " "SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE hour = "
+ hour + " AND minute <= 5 AND minute > 0 ;"); + hour + " AND minute <= 5 AND minute > 0 ;");
for (int i = 0; i < resultList.size(); i++) { for (int i = 0; i < resultList.size(); i++) {
Image image = resultList.get(i); Image image = resultList.get(i);
if (image.getImageCounter() < startcounter) {
if(image.getImageCounter() < startcounter) {
continue; continue;
} }
if (!sunday) { if (!sunday) {
if (checkIfSunday(image.getDay(), image.getMonth(), if (checkIfSunday(image.getDay(), image.getMonth(),
image.getYear())) { image.getYear())) {
@ -76,24 +76,24 @@ public class QueryImages
op.outputMethod(method, rootFolderPath, image.getPath()); op.outputMethod(method, rootFolderPath, image.getPath());
} }
} }
resultList = null; //free resultList = null; // free
} }
public void outputImagesFromHourToHour(int startcounter, int starthour, int endhour, String method, boolean sunday) public void outputImagesFromHourToHour(int startcounter, int starthour,
int endhour, String method, boolean sunday)
{ {
List<Image> resultList = db.query( List<Image> resultList = db.query(
"SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE hour >= " "SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE hour >= "
+ starthour + " AND hour < " + endhour + ";"); + starthour + " AND hour < " + endhour + ";");
for (int i = 0; i < resultList.size(); i++) { for (int i = 0; i < resultList.size(); i++) {
Image image = resultList.get(i); Image image = resultList.get(i);
if (image.getImageCounter() < startcounter) {
if(image.getImageCounter() < startcounter) {
continue; continue;
} }
if (!sunday) { if (!sunday) {
if (checkIfSunday(image.getDay(), image.getMonth(), if (checkIfSunday(image.getDay(), image.getMonth(),
image.getYear())) { image.getYear())) {
@ -105,23 +105,26 @@ public class QueryImages
op.outputMethod(method, rootFolderPath, image.getPath()); op.outputMethod(method, rootFolderPath, image.getPath());
} }
} }
resultList = null; //free resultList = null; // free
} }
public void outputImagesFromHourAndMinute(int startcounter, int hour, int minute, String method, boolean sunday) public void outputImagesFromHourAndMinute(int startcounter, int hour,
int minute, String method, boolean sunday)
{ {
// List<Image> resultList = db.query( // List<Image> resultList = db.query(
// "SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE hour = " // "SELECT imageCounter, path, day, month, year, hour, minute, size,
// + hour + " AND minute >= ("+ (minute-3) +") AND minute <= ( "+ (minute+3) + ") ;"); // brightness FROM images WHERE hour = "
// + hour + " AND minute >= ("+ (minute-3) +") AND minute <= ( "+
// (minute+3) + ") ;");
List<Image> resultList = db.query( List<Image> resultList = db.query(
"SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE hour = " "SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE hour = "
+ hour + " AND minute = " + minute + ";"); + hour + " AND minute = " + minute + ";");
for (int i = 0; i < resultList.size(); i++) { for (int i = 0; i < resultList.size(); i++) {
Image image = resultList.get(i); Image image = resultList.get(i);
if(image.getImageCounter() < startcounter) { if (image.getImageCounter() < startcounter) {
//System.out.println(image.getImageCounter()); // System.out.println(image.getImageCounter());
continue; continue;
} }
if (!sunday) { if (!sunday) {
@ -135,7 +138,7 @@ public class QueryImages
op.outputMethod(method, rootFolderPath, image.getPath()); op.outputMethod(method, rootFolderPath, image.getPath());
} }
} }
resultList = null; //free resultList = null; // free
} }
public void outputImagesFromStartToEnd(int pStart, int pEnd, int pMinute, public void outputImagesFromStartToEnd(int pStart, int pEnd, int pMinute,
@ -175,22 +178,23 @@ public class QueryImages
} }
} }
} }
public void outputImagesEveryHour(int startcounter, int starthour, int endhour, String method, boolean sunday) public void outputImagesEveryHour(int startcounter, int starthour,
int endhour, String method, boolean sunday)
{ {
List<Image> resultList = db.query( List<Image> resultList = db.query(
"SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE (hour >= " "SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE (hour >= "
+ starthour + " AND hour <= " + endhour + ") AND minute <= 5 AND minute > 0 ;"); + starthour + " AND hour <= " + endhour
+ ") AND minute <= 5 AND minute > 0 ;");
for (int i = 0; i < resultList.size(); i++) { for (int i = 0; i < resultList.size(); i++) {
Image image = resultList.get(i); Image image = resultList.get(i);
if (image.getImageCounter() < startcounter) {
if(image.getImageCounter() < startcounter) {
continue; continue;
} }
if (!sunday) { if (!sunday) {
if (checkIfSunday(image.getDay(), image.getMonth(), if (checkIfSunday(image.getDay(), image.getMonth(),
image.getYear())) { image.getYear())) {
@ -202,7 +206,7 @@ public class QueryImages
op.outputMethod(method, rootFolderPath, image.getPath()); op.outputMethod(method, rootFolderPath, image.getPath());
} }
} }
resultList = null; //free resultList = null; // free
} }
} }