Merge branch 'maint/lp'

This commit is contained in:
Lucas Pleß 2012-03-21 19:52:44 +01:00
commit 351f1b1816
4 changed files with 52 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package de.ctdo.bunti.control; package de.ctdo.bunti.control;
import de.ctdo.bunti.model.BuntiDevice; import de.ctdo.bunti.model.BuntiDevice;
import de.ctdo.bunti.model.Room;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
@ -12,4 +13,7 @@ public interface BuntiController {
boolean updateDeviceData(int deviceId, Map<String, Object> options); boolean updateDeviceData(int deviceId, Map<String, Object> options);
Collection<Room> getAllRooms();
Room getRoomById(int roomId);
} }

View File

@ -54,6 +54,16 @@ public class BuntiControllerImpl implements BuntiController, ApplicationEventPub
return false; return false;
} }
@Override
public Collection<Room> getAllRooms() {
return roomsDAO.getRooms();
}
@Override
public Room getRoomById(int roomId) {
return roomsDAO.getRoom(roomId);
}
@Override @Override
public Collection<BuntiDevice> getAllDevices() { public Collection<BuntiDevice> getAllDevices() {
return devicesDAO.getAllDevices(); return devicesDAO.getAllDevices();

View File

@ -10,7 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Validator;
import java.util.*; import java.util.*;
@Controller @Controller

View File

@ -0,0 +1,38 @@
package de.ctdo.bunti.web;
import de.ctdo.bunti.control.BuntiController;
import de.ctdo.bunti.model.Room;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.Collection;
@Controller
@RequestMapping(value = "/rooms")
public class RoomsController {
private static final Logger LOGGER = LoggerFactory.getLogger(RoomsController.class);
private BuntiController controller;
@Autowired
public final void setController(BuntiController controller) {
this.controller = controller;
}
@RequestMapping(value = "", method = RequestMethod.GET)
public @ResponseBody Collection<Room> getAll() {
LOGGER.info("handle GET /rooms/" + " request");
return controller.getAllRooms();
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public @ResponseBody
Room getDeviceById(@PathVariable("id") int id) {
LOGGER.info("handle GET /rooms/id" + id + " request");
return controller.getRoomById(id);
}
}