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)
{
Calendar calendar = Calendar.getInstance();
// Specify the file path and name
File file = new File(filepath);
long lastModified = file.lastModified();
Date date = new Date(lastModified);
System.out.println(date);
calendar.setTime(date);
return calendar;
}

View File

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

View File

@ -3,6 +3,8 @@ import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Calendar;
public class Main
{
// read from UI later
@ -21,6 +23,9 @@ public class Main
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/
// -p /home/hendrik/Schreibtisch/ -o /home/hendrik/Schreibtisch/testeritis/
// -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")) {
i++;
rootFolderPath = args[i];
@ -71,7 +87,6 @@ public class Main
if (value.equals("-i")) {
i++;
if (args[i].equals("counter")) {
System.out.println("[Identify] Find images with counter");
imgF = new ImageFinderCounter(rootFolderPath);
@ -79,7 +94,6 @@ public class Main
System.out.println("[Identify] Find images with date and time");
imgF = new ImageFinderTimestamp(rootFolderPath);
}
}
if (value.equals("-n")) {
@ -92,7 +106,6 @@ public class Main
System.out.println(
"-log -m createDB -r /home/hendrik/FTP/camera01/ -p /home/hendrik/Schreibtisch/ -o /home/hendrik/Schreibtisch/testeritis/ -n 83584");
System.exit(1);
}
}
@ -141,9 +154,13 @@ public class Main
// gefunden
File f = new File(rootFolderPath + path);
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),
(calendar.get(Calendar.MONTH) + 1),
@ -176,7 +193,7 @@ public class Main
// 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);

View File

@ -50,7 +50,8 @@ public class QueryImages
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(
"SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE hour = "
@ -60,7 +61,6 @@ public class QueryImages
Image image = resultList.get(i);
if (image.getImageCounter() < startcounter) {
continue;
}
@ -79,7 +79,8 @@ public class QueryImages
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(
"SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE hour >= "
@ -89,7 +90,6 @@ public class QueryImages
Image image = resultList.get(i);
if (image.getImageCounter() < startcounter) {
continue;
}
@ -108,11 +108,14 @@ public class QueryImages
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(
// "SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE hour = "
// + hour + " AND minute >= ("+ (minute-3) +") AND minute <= ( "+ (minute+3) + ") ;");
// "SELECT imageCounter, path, day, month, year, hour, minute, size,
// brightness FROM images WHERE hour = "
// + hour + " AND minute >= ("+ (minute-3) +") AND minute <= ( "+
// (minute+3) + ") ;");
List<Image> resultList = db.query(
"SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE hour = "
@ -176,17 +179,18 @@ 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(
"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++) {
Image image = resultList.get(i);
if (image.getImageCounter() < startcounter) {
continue;
}