bunti/src/main/java/de/ctdo/bunti/dao/BuntiDevicesDAOImpl.java

64 lines
1.6 KiB
Java
Raw Normal View History

2012-03-02 21:09:43 +00:00
package de.ctdo.bunti.dao;
import java.util.ArrayList;
import java.util.Collection;
2012-03-06 23:42:30 +00:00
import java.util.Collections;
2012-03-02 21:09:43 +00:00
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
2012-03-02 21:09:43 +00:00
import de.ctdo.bunti.model.*;
2012-03-07 18:17:48 +00:00
import org.springframework.stereotype.Repository;
2012-03-07 18:17:48 +00:00
@Repository
public final class BuntiDevicesDAOImpl implements BuntiDevicesDAO {
private static final Logger LOGGER = LoggerFactory.getLogger(BuntiDevicesDAOImpl.class);
private List<BuntiDevice> devices = new ArrayList<BuntiDevice>();
2012-03-02 21:09:43 +00:00
public BuntiDevicesDAOImpl() {
2012-03-25 14:23:45 +00:00
// addDummyDevices();
2012-03-02 21:09:43 +00:00
}
2012-03-25 14:23:45 +00:00
// private void addDummyDevices() {
// int deviceID = 0;
//
// devices.add(new Par56Spot(deviceID++, 1, "Par56 Lampe 1"));
// devices.add(new Par56Spot(deviceID++, 6, "Par56 Lampe 2"));
// devices.add(new Par56Spot(deviceID++, 11, "Par56 Lampe 3"));
// devices.add(new Par56Spot(deviceID++, 16, "Par56 Lampe 4"));
// devices.add(new Strobe1500(deviceID++, 21, "Stroboskop 1"));
// devices.add(new Par56Spot(deviceID, 508, "Par56 Lampe 5"));
// LOGGER.debug("added dummy devices in DAO");
// }
2012-03-02 21:09:43 +00:00
@Override
2012-03-08 00:22:31 +00:00
public Collection<BuntiDMXDevice> getAllDMXDevices() {
2012-03-06 23:42:30 +00:00
List<BuntiDMXDevice> list = new ArrayList<BuntiDMXDevice>();
2012-03-02 21:09:43 +00:00
for (BuntiDevice device : devices) {
if( device instanceof BuntiDMXDevice ) {
2012-03-06 23:42:30 +00:00
list.add((BuntiDMXDevice) device);
2012-03-02 21:09:43 +00:00
}
}
2012-03-06 23:42:30 +00:00
return list;
2012-03-02 21:09:43 +00:00
}
2012-03-06 23:42:30 +00:00
@Override
2012-03-08 00:22:31 +00:00
public Collection<BuntiDevice> getAllDevices() {
2012-03-06 23:42:30 +00:00
return Collections.unmodifiableCollection(devices);
}
@Override
2012-03-08 00:22:31 +00:00
public BuntiDevice getDeviceById(int deviceId) {
for (BuntiDevice dev : devices) {
2012-03-21 20:22:53 +00:00
if(dev.getId() == deviceId) {
return dev;
}
}
return null;
}
2012-03-02 21:09:43 +00:00
}