package art.servers.rtzserver.controller; import art.library.model.devices.colors.controller.RTZ32.information.RTZ32_Information_Program; import art.library.model.devices.colors.controller.RTZ32.information.RTZ32_Information_Programs; import art.library.model.devices.colors.controller.RTZ32.types.RTZ32_Persistent_Configuration; import art.library.model.devices.colors.controller.RTZ32.types.RTZ32_Persistent_Configurations; import art.servers.Shared; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; public class Controller_RTZ32_Database { // public static RTZ32_Information_Programs listPrograms(String deviceIdentifier) throws Exception { String where = "device = '" + deviceIdentifier + "'"; List result = Shared.controllerDatabase.historical_getObject_Summary(RTZ32_Information_Program.class.getName(), where); RTZ32_Information_Programs programs = new RTZ32_Information_Programs(); programs.programs = (List)(List)result; return programs; } public static RTZ32_Information_Program getProgram(String deviceIdentifier, String programNumber) throws Exception { String where = "device = '" + deviceIdentifier + "' AND program = " + programNumber; List result = Shared.controllerDatabase.historical_getObject(RTZ32_Information_Program.class.getName(), where); if (result.size() == 1) return (RTZ32_Information_Program)result.get(0); return null; } public static boolean addProgram(RTZ32_Information_Program program) throws Exception { Shared.controllerDatabase.historical_updateOrAddObject(program); return true; } public static boolean deleteProgram(String deviceIdentifier, String programNumber) throws Exception { String where = "device = '" + deviceIdentifier + "' AND program = " + programNumber; Shared.controllerDatabase.historical_deleteObject(RTZ32_Information_Program.class.getName(), where); return true; } // // public static RTZ32_Persistent_Configurations listConfigurations(String deviceIdentifier) throws Exception { String where = "device = '" + deviceIdentifier + "'"; List result = Shared.controllerDatabase.historical_getObject_Summary(RTZ32_Persistent_Configuration.class.getName(), where); RTZ32_Persistent_Configurations configurations = new RTZ32_Persistent_Configurations(); configurations.configurations = (List)(List)result; return configurations; } public static RTZ32_Persistent_Configurations listConfigurations(String deviceIdentifier, long timestamp1, long timestamp2) throws Exception { SimpleDateFormat formato1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String where = "device = '" + deviceIdentifier + "' AND datetime >= '" + formato1.format(timestamp1) + "' AND datetime < '" + formato1.format(timestamp2) + "'"; List result = Shared.controllerDatabase.historical_getObject_Summary(RTZ32_Persistent_Configuration.class.getName(), where); RTZ32_Persistent_Configurations configurations = new RTZ32_Persistent_Configurations(); configurations.configurations = (List)(List)result; return configurations; } public static RTZ32_Persistent_Configuration getConfiguration(String deviceIdentifier, long timestamp) throws Exception { SimpleDateFormat formato1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); String where = "device = '" + deviceIdentifier + "' AND datetime = '" + formato1.format(timestamp) + "'"; List result = Shared.controllerDatabase.historical_getObject(RTZ32_Persistent_Configuration.class.getName(), where); if (result.size() == 1) return (RTZ32_Persistent_Configuration)result.get(0); return null; } public static boolean addConfiguration (RTZ32_Persistent_Configuration configuration) throws Exception { configuration.datetime = new Date(); Shared.controllerDatabase.historical_addObject(configuration); return true; } public static boolean deleteConfiguration(String deviceIdentifier, long timestamp) throws Exception { SimpleDateFormat formato1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); String where = "device = '" + deviceIdentifier + "' AND datetime = '" + formato1.format(timestamp) + "'"; Shared.controllerDatabase.historical_deleteObject(RTZ32_Information_Program.class.getName(), where); return true; } // }