From 6f2614350bbba0ff0a55d5ad87cf7ea5c3d3b62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Wed, 21 Mar 2012 00:23:49 +0100 Subject: [PATCH] implemented switching device --- .../java/de/ctdo/bunti/dao/RoomsDAOImpl.java | 6 +---- .../bunti/model/BuntiSwitchingDevice.java | 23 ++++++++++++++++++- src/main/java/de/ctdo/bunti/model/Room.java | 4 ---- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/main/java/de/ctdo/bunti/dao/RoomsDAOImpl.java b/src/main/java/de/ctdo/bunti/dao/RoomsDAOImpl.java index faa1b78..b3359a2 100644 --- a/src/main/java/de/ctdo/bunti/dao/RoomsDAOImpl.java +++ b/src/main/java/de/ctdo/bunti/dao/RoomsDAOImpl.java @@ -9,13 +9,9 @@ import java.util.List; public final class RoomsDAOImpl extends HibernateDaoSupport implements RoomsDAO { public RoomsDAOImpl() { - addDummyRooms(); + } - private void addDummyRooms() { - - - } @Override public List getRooms() { diff --git a/src/main/java/de/ctdo/bunti/model/BuntiSwitchingDevice.java b/src/main/java/de/ctdo/bunti/model/BuntiSwitchingDevice.java index 1dfe65d..949c0f2 100644 --- a/src/main/java/de/ctdo/bunti/model/BuntiSwitchingDevice.java +++ b/src/main/java/de/ctdo/bunti/model/BuntiSwitchingDevice.java @@ -3,17 +3,38 @@ package de.ctdo.bunti.model; import java.util.Map; public abstract class BuntiSwitchingDevice extends BuntiDevice { + private static final String OPTION_STATE = "state"; + private boolean state = false; public BuntiSwitchingDevice(int deviceId, String deviceName) { super(deviceId, deviceName); } + @Override public final boolean setValuesFromOptions(Map options) { - // TODO Auto-generated method stub + + if(options.containsKey(OPTION_STATE)) { + + try { + boolean value = Boolean.parseBoolean(options.get(OPTION_STATE).toString()); + setState(value); + return true; + } catch (Exception e) { + return false; + } + + } return false; } + public boolean isState() { + return state; + } + + public void setState(boolean state) { + this.state = state; + } } diff --git a/src/main/java/de/ctdo/bunti/model/Room.java b/src/main/java/de/ctdo/bunti/model/Room.java index be7d472..8eed3d3 100644 --- a/src/main/java/de/ctdo/bunti/model/Room.java +++ b/src/main/java/de/ctdo/bunti/model/Room.java @@ -5,10 +5,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -/** - * @author: lucas - * @date: 15.03.12 21:51 - */ public final class Room { private int id;