cleanup and extension
This commit is contained in:
parent
2535e98e41
commit
019c235ea5
|
@ -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<String, Object> options);
|
||||
Collection<BuntiDevice> getAllDevices();
|
||||
BuntiDevice getDeviceById(int deviceId);
|
||||
|
||||
boolean setDevice(int deviceId, Map<String, Object> options);
|
||||
|
||||
}
|
||||
|
|
|
@ -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,41 +25,29 @@ public class BuntiControllerImpl implements BuntiController, ApplicationEventPub
|
|||
this.devicesDAO = devicesDAO;
|
||||
}
|
||||
|
||||
public final void performJSONString(String json) {
|
||||
|
||||
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
|
||||
public Collection<BuntiDevice> getAllDevices() {
|
||||
return devicesDAO.getAllDevices();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean setDevice(int deviceId, Map<String, Object> 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
|
||||
public BuntiDevice getDeviceById(int deviceId) {
|
||||
return devicesDAO.getDeviceById(deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
|
||||
this.applicationEventPublisher = publisher;
|
||||
|
|
Loading…
Reference in New Issue