121 lines
3.5 KiB
Java
121 lines
3.5 KiB
Java
package model;
|
|
|
|
import workers.MachineWorker;
|
|
|
|
import java.io.File;
|
|
import java.text.DateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Calendar;
|
|
|
|
public class SOMConfig {
|
|
|
|
// important Paths
|
|
public static File PICTURES_PATH = new File("images");
|
|
public static String UPLOAD_PATH = getEventPicDir();
|
|
|
|
// The Box's ID
|
|
public static String BOX_ID = MachineWorker.getHostName();
|
|
|
|
// Number of pictures in series mode
|
|
public static int SERIES_COUNTER;
|
|
// Seconds before image is taken
|
|
public static int COUNTDOWN_COUNTER;
|
|
|
|
// Session has Printer support
|
|
public static boolean PRINTER;
|
|
|
|
// Images per Page in the Gallery
|
|
public static final int IMAGES_PER_PAGE = 9;
|
|
|
|
// Cloud
|
|
public static String CLOUD_CREDENTIALS = "upload:geheim";
|
|
public static String CLOUD_ADDRESS = "https://cloud.selfomat.de/remote.php/webdav/";
|
|
// Limit of Parallel Uploads
|
|
public static int PARALLEL_UPLOADS;
|
|
|
|
// Make the Scaling Algorithm switchable
|
|
public static final int SCALING_GRAPHICS_2D = 0;
|
|
public static final int SCALING_JAVAFX = 1;
|
|
public static int SCALING_ALGORITHM = SCALING_GRAPHICS_2D;
|
|
|
|
// Path to configfile
|
|
static final File configfile = new File(("config/config.xml"));
|
|
|
|
// Instance
|
|
// @XmlElement(name = "config")
|
|
private static SOMConfig config = null;
|
|
|
|
|
|
// Constructor
|
|
private SOMConfig() {
|
|
// get the default Displays' dimensions
|
|
// System.out.println("Creating Configuration. Sreen Size: " + SOMLayout.SCREEN_WIDTH + "x" + SOMLayout.SCREEN_HEIGHT);
|
|
|
|
// important Paths
|
|
PICTURES_PATH = new File("images");
|
|
UPLOAD_PATH = getEventPicDir();
|
|
|
|
// The Box's ID
|
|
BOX_ID = MachineWorker.getHostName();
|
|
|
|
// Number of pictures in series mode
|
|
SERIES_COUNTER = 4;
|
|
// Seconds before image is taken
|
|
COUNTDOWN_COUNTER = 4;
|
|
|
|
// Cloud
|
|
CLOUD_CREDENTIALS = "upload:geheim";
|
|
CLOUD_ADDRESS = "https://cloud.selfomat.de/remote.php/webdav/";
|
|
// Limit of Parallel Uploads
|
|
PARALLEL_UPLOADS = 3;
|
|
|
|
// Make the Scaling Algorithm switchable
|
|
SCALING_ALGORITHM = SCALING_GRAPHICS_2D;
|
|
}
|
|
|
|
// Instance
|
|
public static SOMConfig getInstance() {
|
|
// Singleton Pattern
|
|
if (config == null) {
|
|
config = new SOMConfig();
|
|
SOMConfigFileHandler handler = new SOMConfigFileHandler();
|
|
handler.readConfig();
|
|
}
|
|
return config;
|
|
}
|
|
|
|
/**
|
|
* Gets the Directory for the Event and Creates the Folders
|
|
*
|
|
* @return
|
|
*/
|
|
public static String getEventPicDir() {
|
|
// get current Date in String for Upload-dir
|
|
Calendar cal = Calendar.getInstance();
|
|
DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
|
|
String timeString = df.format(cal.getTime());
|
|
|
|
File picturesPath = SOMConfig.PICTURES_PATH;
|
|
|
|
String eventPicDir = picturesPath.toString() + "/" + timeString
|
|
+ "/" + MachineWorker.getHostName();
|
|
|
|
return eventPicDir;
|
|
}
|
|
|
|
|
|
|
|
// return the current Timestamp
|
|
public long getCurrentTimestamp() {
|
|
// 1) create a java calendar instance
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
// 2) get a java.util.Date from the calendar instance.
|
|
// this date will represent the current instant, or "now".
|
|
java.util.Date now = calendar.getTime();
|
|
|
|
// 3) a java current time (now) instance
|
|
java.sql.Timestamp c = new java.sql.Timestamp(now.getTime());
|
|
return c.getTime();
|
|
}
|
|
} |