From 019c235ea5f2b3edb64a1fc7e6096d0cb97f0f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Wed, 7 Mar 2012 19:19:21 +0100 Subject: [PATCH] cleanup and extension --- .../ctdo/bunti/control/BuntiController.java | 10 ++++- .../bunti/control/BuntiControllerImpl.java | 38 +++++++------------ 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/main/java/de/ctdo/bunti/control/BuntiController.java b/src/main/java/de/ctdo/bunti/control/BuntiController.java index cbaa09d..3530ce1 100644 --- a/src/main/java/de/ctdo/bunti/control/BuntiController.java +++ b/src/main/java/de/ctdo/bunti/control/BuntiController.java @@ -1,9 +1,15 @@ package de.ctdo.bunti.control; +import de.ctdo.bunti.model.BuntiDevice; + +import java.util.Collection; import java.util.Map; public interface BuntiController { - - boolean setDevice(int deviceID, Map options); + + Collection getAllDevices(); + BuntiDevice getDeviceById(int deviceId); + + boolean setDevice(int deviceId, Map options); } diff --git a/src/main/java/de/ctdo/bunti/control/BuntiControllerImpl.java b/src/main/java/de/ctdo/bunti/control/BuntiControllerImpl.java index 2f84974..6814c10 100644 --- a/src/main/java/de/ctdo/bunti/control/BuntiControllerImpl.java +++ b/src/main/java/de/ctdo/bunti/control/BuntiControllerImpl.java @@ -1,5 +1,6 @@ package de.ctdo.bunti.control; +import java.util.Collection; import java.util.Map; import org.slf4j.Logger; @@ -9,14 +10,13 @@ import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisherAware; import org.springframework.stereotype.Component; -import net.sf.json.JSONObject; import de.ctdo.bunti.DeviceChangedEvent; import de.ctdo.bunti.dao.BuntiDevicesDAO; import de.ctdo.bunti.model.*; @Component public class BuntiControllerImpl implements BuntiController, ApplicationEventPublisherAware { - private Logger logger = LoggerFactory.getLogger(getClass()); + private static final Logger logger = LoggerFactory.getLogger(BuntiControllerImpl.class); private ApplicationEventPublisher applicationEventPublisher = null; private BuntiDevicesDAO devicesDAO; @@ -25,42 +25,30 @@ public class BuntiControllerImpl implements BuntiController, ApplicationEventPub this.devicesDAO = devicesDAO; } - public final void performJSONString(String json) { + @Override + public Collection getAllDevices() { + return devicesDAO.getAllDevices(); + } - JSONObject jsonobj = JSONObject.fromObject(json); - - if (jsonobj.containsKey("command")) { - - String command = jsonobj.get("command").toString(); - if (command.equals("setdmxchannels")) { - - } else if (command.equals("switchdevice")) { - - } - } - - } - - @Override + @Override public final boolean setDevice(int deviceId, Map options) { - BuntiDevice device = devicesDAO.getDeviceById(deviceId); if (device != null) { - this.applicationEventPublisher.publishEvent(new DeviceChangedEvent(this, device, options)); - logger.debug("publishEvent in BuntiController"); - return true; } - - return false; } - @Override + @Override + public BuntiDevice getDeviceById(int deviceId) { + return devicesDAO.getDeviceById(deviceId); + } + + @Override public final void setApplicationEventPublisher(ApplicationEventPublisher publisher) { this.applicationEventPublisher = publisher; }