// Path: src/main/java/org/chorem/ecd/dao/SettingsDao.java
// @ApplicationScoped
// public class SettingsDao extends AbstractDao<Settings, Integer> {
// 
//     public SettingsDao() {
//         super(Settings.class, SETTINGS, SETTINGS.ID::eq);
//     }
// 
//     public TvTimes getTvTimes() {
//         DSLContext create = dataSource.getSqlContext();
//         TvTimes result = create.select(SETTINGS.TV_TIMES).from(SETTINGS).where(SETTINGS.ID.eq(1))
//                 .fetchOptionalInto(String.class)
//                 .map(json -> gson.fromJson(json, TvTimes.class))
//                 .orElse(new TvTimes());
//         return result;
//     }
// 
//     public Location getLocation() {
//         DSLContext create = dataSource.getSqlContext();
//         Location result = create.select(SETTINGS.LOCATION).from(SETTINGS).where(SETTINGS.ID.eq(1))
//                 .fetchOptionalInto(String.class)
//                 .map(json -> gson.fromJson(json, Location.class))
//                 .orElse(new Location());
//         return result;
//     }
// 
//     public void setTvTimes(TvTimes tvTimes) {
//         Object value = DSL.cast(gson.toJson(tvTimes), PostgresDataType.JSON);
//         DSLContext create = dataSource.getSqlContext();
//         create.insertInto(SETTINGS, SETTINGS.ID, SETTINGS.TV_TIMES)
//                 .values(1, value)
//                 .onDuplicateKeyUpdate()
//                 .set(SETTINGS.TV_TIMES, value)
//                 .execute();
//     }
// 
//     public void setLocation(Location location) {
//         Object value = DSL.cast(gson.toJson(location), PostgresDataType.JSON);
//         DSLContext create = dataSource.getSqlContext();
//         create.insertInto(SETTINGS, SETTINGS.ID, SETTINGS.LOCATION)
//                 .values(1, value)
//                 .onDuplicateKeyUpdate()
//                 .set(SETTINGS.LOCATION, value)
//                 .execute();
//     }
// 
//     @Override
//     protected RecordMapper<Record, Settings> getRecordMapper() {
//         throw new UnsupportedOperationException();
//     }
// 
// }
// 
// Path: src/main/java/org/chorem/ecd/exception/InvalidArgumentException.java
// public class InvalidArgumentException extends RuntimeException {
// 
//     public InvalidArgumentException(String msg) {
//         super(msg);
//     }
// 
// }
// 
// Path: src/main/java/org/chorem/ecd/model/settings/TvTimes.java
// public class TvTimes {
// 
//     private String wakeupTime;
// 
//     private String sleepTime;
// 
//     public TvTimes() {
// 
//     }
// 
//     public TvTimes(String wakeupTime, String sleepTime) {
//         this.wakeupTime = wakeupTime;
//         this.sleepTime = sleepTime;
//     }
// 
//     public String getWakeupTime() {
//         return wakeupTime;
//     }
// 
//     public void setWakeupTime(String wakeupTime) {
//         this.wakeupTime = wakeupTime;
//     }
// 
//     public String getSleepTime() {
//         return sleepTime;
//     }
// 
//     public void setSleepTime(String sleepTime) {
//         this.sleepTime = sleepTime;
//     }
// 
// }


import org.chorem.ecd.dao.SettingsDao;
import org.chorem.ecd.dao.TransactionRequired;
import org.chorem.ecd.exception.InvalidArgumentException;
import org.chorem.ecd.model.settings.TvTimes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import java.time.LocalTime;
import java.time.format.DateTimeParseException;
package org.chorem.ecd.service;



/**
 * @author Julien Gaston (gaston@codelutin.com)
 */
@ApplicationScoped
public class PowerManagementService {

    private static final Logger logger = LoggerFactory.getLogger(PowerManagementService.class);

// Path: src/main/java/org/chorem/ecd/dao/SettingsDao.java
// @ApplicationScoped
// public class SettingsDao extends AbstractDao<Settings, Integer> {
// 
//     public SettingsDao() {
//         super(Settings.class, SETTINGS, SETTINGS.ID::eq);
//     }
// 
//     public TvTimes getTvTimes() {
//         DSLContext create = dataSource.getSqlContext();
//         TvTimes result = create.select(SETTINGS.TV_TIMES).from(SETTINGS).where(SETTINGS.ID.eq(1))
//                 .fetchOptionalInto(String.class)
//                 .map(json -> gson.fromJson(json, TvTimes.class))
//                 .orElse(new TvTimes());
//         return result;
//     }
// 
//     public Location getLocation() {
//         DSLContext create = dataSource.getSqlContext();
//         Location result = create.select(SETTINGS.LOCATION).from(SETTINGS).where(SETTINGS.ID.eq(1))
//                 .fetchOptionalInto(String.class)
//                 .map(json -> gson.fromJson(json, Location.class))
//                 .orElse(new Location());
//         return result;
//     }
// 
//     public void setTvTimes(TvTimes tvTimes) {
//         Object value = DSL.cast(gson.toJson(tvTimes), PostgresDataType.JSON);
//         DSLContext create = dataSource.getSqlContext();
//         create.insertInto(SETTINGS, SETTINGS.ID, SETTINGS.TV_TIMES)
//                 .values(1, value)
//                 .onDuplicateKeyUpdate()
//                 .set(SETTINGS.TV_TIMES, value)
//                 .execute();
//     }
// 
//     public void setLocation(Location location) {
//         Object value = DSL.cast(gson.toJson(location), PostgresDataType.JSON);
//         DSLContext create = dataSource.getSqlContext();
//         create.insertInto(SETTINGS, SETTINGS.ID, SETTINGS.LOCATION)
//                 .values(1, value)
//                 .onDuplicateKeyUpdate()
//                 .set(SETTINGS.LOCATION, value)
//                 .execute();
//     }
// 
//     @Override
//     protected RecordMapper<Record, Settings> getRecordMapper() {
//         throw new UnsupportedOperationException();
//     }
// 
// }
// 
// Path: src/main/java/org/chorem/ecd/exception/InvalidArgumentException.java
// public class InvalidArgumentException extends RuntimeException {
// 
//     public InvalidArgumentException(String msg) {
//         super(msg);
//     }
// 
// }
// 
// Path: src/main/java/org/chorem/ecd/model/settings/TvTimes.java
// public class TvTimes {
// 
//     private String wakeupTime;
// 
//     private String sleepTime;
// 
//     public TvTimes() {
// 
//     }
// 
//     public TvTimes(String wakeupTime, String sleepTime) {
//         this.wakeupTime = wakeupTime;
//         this.sleepTime = sleepTime;
//     }
// 
//     public String getWakeupTime() {
//         return wakeupTime;
//     }
// 
//     public void setWakeupTime(String wakeupTime) {
//         this.wakeupTime = wakeupTime;
//     }
// 
//     public String getSleepTime() {
//         return sleepTime;
//     }
// 
//     public void setSleepTime(String sleepTime) {
//         this.sleepTime = sleepTime;
//     }
// 
// }


// Path: src/main/java/org/chorem/ecd/service/PowerManagementService.java
import org.chorem.ecd.dao.SettingsDao;
import org.chorem.ecd.dao.TransactionRequired;
import org.chorem.ecd.exception.InvalidArgumentException;
import org.chorem.ecd.model.settings.TvTimes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import java.time.LocalTime;
import java.time.format.DateTimeParseException;

package org.chorem.ecd.service;



/**
 * @author Julien Gaston (gaston@codelutin.com)
 */
@ApplicationScoped
public class PowerManagementService {

    private static final Logger logger = LoggerFactory.getLogger(PowerManagementService.class);

    @Inject