root / middleware / src / com / gonnatrak / middleware / ejb / DeviceSettingsWorkerBean.java @ 1

View | Annotate | Download

1
/**
2
 * Created by Andrey Khalzov
3
 * 01.10.2008 0:51:11
4
 */
5
package com.gonnatrak.middleware.ejb;
6
7
import com.gonnatrak.middleware.ejb.DeviceSettingsWorker;
8
import com.gonnatrak.middleware.entity.DeviceSettings;
9
import com.gonnatrak.middleware.entity.Subject;
10
import com.gonnatrak.middleware.exception.EntityNotFoundException;
11
import org.jetbrains.annotations.NotNull;
12
import org.jetbrains.annotations.Nullable;
13
14
import javax.ejb.Stateless;
15
16
@Stateless(name = DeviceSettingsWorker.JNDI_NAME)
17
public class DeviceSettingsWorkerBean extends AbstractWorkerBean implements DeviceSettingsWorker {
18
19
    @Nullable
20
    public DeviceSettings getDeviceSettings(@NotNull String deviceName) {
21
        try {
22
            final Subject subject = dao.findSingleResult(Subject.class, "e.deviceName = ?", deviceName);
23
            return subject.getDeviceSettings();
24
        } catch (EntityNotFoundException e) {
25
            throw new RuntimeException(e);
26
        }
27
    }
28
}