source: ether_ndacc/trunk/service/implementation/com/ether/InstrumentServiceImpl.java @ 106

Last change on this file since 106 was 106, checked in by rboipsl, 13 years ago

Import du projet NDACC _ module service

File size: 3.0 KB
Line 
1package com.ether;
2
3import java.util.List;
4
5import org.jetbrains.annotations.NotNull;
6import org.jetbrains.annotations.Nullable;
7import org.springframework.beans.factory.annotation.Required;
8import org.springframework.transaction.annotation.Transactional;
9
10import com.ether.dao.instrument.InstrumentDAO;
11import com.ether.instrument.Instrument;
12import com.ether.instrument.InstrumentType;
13
14/**
15 * @author vmipsl
16 * @date 24 jan 2011
17 */
18public class InstrumentServiceImpl implements InstrumentService
19{
20    @NotNull
21    @Transactional(readOnly = true)
22    public Integer getNbInstruments() throws ServiceException
23    {
24        try
25        {
26            return _instrumentDAO.getNbInstruments();
27        }
28        catch (PersistenceException e)
29        {
30            throw new ServiceException(ServiceException.ServiceCode.INSTRUMENT_NOT_FOUND, e);
31        }
32    }
33
34    @Nullable
35    @Transactional(readOnly = true)
36    public List<Instrument> getAllInstruments() throws ServiceException
37    {
38        try
39        {
40            return _instrumentDAO.selectAll();
41        }
42        catch (PersistenceException e)
43        {
44            throw new ServiceException(ServiceException.ServiceCode.INSTRUMENT_NOT_FOUND, e);
45        }
46    }
47
48    @Nullable
49    @Transactional(readOnly = true)
50    public Instrument getInstrumentById(@NotNull final Long instrumentId) throws ServiceException
51    {
52        try
53        {
54            return _instrumentDAO.selectByPrimaryKey(instrumentId);
55        }
56        catch (PersistenceException e)
57        {
58            throw new ServiceException(ServiceException.ServiceCode.INSTRUMENT_NOT_FOUND, e);
59        }
60    }
61   
62    @NotNull
63    @Transactional(rollbackFor = ServiceException.class)
64    public Long createInstrument(@NotNull final Instrument instrument) throws ServiceException
65    {
66        try
67        {
68            return _instrumentDAO.insert(instrument);
69        }
70        catch (PersistenceException e)
71        {
72            throw new ServiceException(ServiceException.ServiceCode.PERSISTENCE, e);
73        }
74    }
75
76    @Transactional(rollbackFor = ServiceException.class)
77    public void removeInstrument(@NotNull final Long instrumentId) throws ServiceException
78    {
79        try
80        {
81            _instrumentDAO.deleteByPrimaryKey(instrumentId);
82        }
83        catch (PersistenceException e)
84        {
85            throw new ServiceException(ServiceException.ServiceCode.PERSISTENCE, e);
86        }
87    }
88   
89    @Nullable
90    @Transactional(readOnly = true)
91    public List<Instrument> getInstrumentsByStationId(@NotNull final Long stationId) throws ServiceException
92    {
93        try
94        {
95            return _instrumentDAO.getInstrumentsByStationId(stationId);
96        }
97        catch (PersistenceException e)
98        {
99            throw new ServiceException(ServiceException.ServiceCode.INSTRUMENT_BY_STATION_NOT_FOUND, e);
100        }
101    }
102
103    @Nullable
104    @Transactional(readOnly = true)
105    public List<Instrument> getInstrumentsByType(@NotNull final InstrumentType type) throws ServiceException
106    {
107        try
108        {
109            return _instrumentDAO.getInstrumentsByType(type);
110        }
111        catch (PersistenceException e)
112        {
113            throw new ServiceException(ServiceException.ServiceCode.INSTRUMENT_BY_STATION_NOT_FOUND, e);
114        }
115    }
116   
117    @Required
118    public void setInstrumentDAO(final InstrumentDAO instrumentDAO)
119    {
120        _instrumentDAO = instrumentDAO;
121    }
122
123    private InstrumentDAO _instrumentDAO;
124}
Note: See TracBrowser for help on using the repository browser.