Browse Source

finished timestamp filesystem

master
Hendrik Schutter 3 years ago
parent
commit
fa7a0dbbff
  1. 6
      src/DateModified.java
  2. 4
      src/ImageFinderTimestamp.java
  3. 31
      src/Main.java
  4. 74
      src/QueryImages.java

6
src/DateModified.java

@ -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;
}

4
src/ImageFinderTimestamp.java

@ -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);
}
}

31
src/Main.java

@ -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 = datemod.getDate(rootFolderPath + path);
Calendar calendar;
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);

74
src/QueryImages.java

@ -49,22 +49,22 @@ 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 = "
+ hour + " AND minute <= 5 AND minute > 0 ;");
for (int i = 0; i < resultList.size(); i++) {
Image image = resultList.get(i);
if(image.getImageCounter() < startcounter) {
if (image.getImageCounter() < startcounter) {
continue;
}
if (!sunday) {
if (checkIfSunday(image.getDay(), image.getMonth(),
image.getYear())) {
@ -76,24 +76,24 @@ public class QueryImages
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(
"SELECT imageCounter, path, day, month, year, hour, minute, size, brightness FROM images WHERE hour >= "
+ starthour + " AND hour < " + endhour + ";");
for (int i = 0; i < resultList.size(); i++) {
Image image = resultList.get(i);
if(image.getImageCounter() < startcounter) {
if (image.getImageCounter() < startcounter) {
continue;
}
if (!sunday) {
if (checkIfSunday(image.getDay(), image.getMonth(),
image.getYear())) {
@ -105,23 +105,26 @@ public class QueryImages
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(
// "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 = "
// + 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 = "
+ hour + " AND minute = " + minute + ";");
for (int i = 0; i < resultList.size(); i++) {
Image image = resultList.get(i);
if(image.getImageCounter() < startcounter) {
//System.out.println(image.getImageCounter());
if (image.getImageCounter() < startcounter) {
// System.out.println(image.getImageCounter());
continue;
}
if (!sunday) {
@ -135,7 +138,7 @@ public class QueryImages
op.outputMethod(method, rootFolderPath, image.getPath());
}
}
resultList = null; //free
resultList = null; // free
}
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(
"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) {
if (image.getImageCounter() < startcounter) {
continue;
}
if (!sunday) {
if (checkIfSunday(image.getDay(), image.getMonth(),
image.getYear())) {
@ -202,7 +206,7 @@ public class QueryImages
op.outputMethod(method, rootFolderPath, image.getPath());
}
}
resultList = null; //free
resultList = null; // free
}
}

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close