source: ether_megapoli/trunk/service/implementation/com/ether/EtherServiceImpl.java @ 191

Last change on this file since 191 was 191, checked in by vmipsl, 13 years ago

Servlet _ Contour en cours

File size: 5.6 KB
Line 
1package com.ether;
2
3import com.ether.dao.ParameterDAO;
4import com.ether.dao.PlateformDAO;
5import com.ether.dao.ValueDAO;
6import com.medias.database.objects.Parametre;
7import com.medias.database.objects.Plateforme;
8import org.apache.commons.logging.Log;
9import org.apache.commons.logging.LogFactory;
10import org.jetbrains.annotations.NotNull;
11import org.jetbrains.annotations.Nullable;
12import org.springframework.beans.factory.annotation.Required;
13import org.springframework.transaction.annotation.Transactional;
14
15import java.util.Date;
16import java.util.List;
17
18/**
19 * @author vmipsl
20 * @date 07 mar 2011
21 */
22public class EtherServiceImpl
23        implements EtherService
24{
25    @Nullable
26    @Transactional(readOnly = true)
27    public List<Plateforme> getAllPlateforms()
28            throws ServiceException
29    {
30        try
31        {
32            return _plateformDAO.getAllPlateforms();
33        }
34        catch( PersistenceException e )
35        {
36            throw new ServiceException( ServiceException.ServiceCode.PLATEFORM_NOT_FOUND, e );
37        }
38    }
39
40    @Nullable
41    @Transactional(readOnly = true)
42    public Plateforme getPlateformById( @Nullable final Integer plateformId )
43            throws ServiceException
44    {
45        if( null == plateformId )
46            return null;
47        try
48        {
49            return _plateformDAO.getPlateformById( plateformId );
50        }
51        catch( PersistenceException e )
52        {
53            throw new ServiceException( ServiceException.ServiceCode.PLATEFORM_NOT_FOUND, e );
54        }
55    }
56
57    @Nullable
58    @Transactional(readOnly = true)
59    public Parametre getParameterById( @Nullable final Integer parameterId )
60            throws ServiceException
61    {
62        if( null == parameterId )
63            return null;
64        try
65        {
66            return _parameterDAO.getParameterById( parameterId );
67        }
68        catch( PersistenceException e )
69        {
70            throw new ServiceException( ServiceException.ServiceCode.PARAMETER_NOT_FOUND, e );
71        }
72    }
73
74    @Nullable
75    @Transactional(readOnly = true)
76    public List<Parametre> getParametersByPlateformId( @NotNull final Integer plateformId )
77            throws ServiceException
78    {
79        try
80        {
81            return _parameterDAO.getParametersByPlateformId( plateformId );
82        }
83        catch( PersistenceException e )
84        {
85            throw new ServiceException( ServiceException.ServiceCode.PARAMETER_NOT_FOUND, e );
86        }
87    }
88
89    @NotNull
90    @Transactional(readOnly = true)
91    public <T1, T2, T3> Data<T1[], T2[], T3[]> getListsByPlateformByParameterByPeriodForTimeSerie( @NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd )
92            throws ServiceException
93    {
94        try
95        {
96            return _valueDAO.getListsByPlateformByParameterByPeriodForTimeSerie( plateformId, parameterId, dateBegin, dateEnd );
97        }
98        catch( PersistenceException e )
99        {
100            throw new ServiceException( ServiceException.ServiceCode.VALUE_NOT_FOUND, e );
101        }
102    }
103
104    @NotNull
105    @Transactional(readOnly = true)
106    public <T1, T2, T3> Data<List<T1>, List<T2>, List<T3>> getListsByPlateformByParameterByPeriodFor2D( @NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd )
107            throws ServiceException
108    {
109        try
110        {
111            return _valueDAO.getListsByPlateformByParameterByPeriodFor2D( plateformId, parameterId, dateBegin, dateEnd );
112        }
113        catch( PersistenceException e )
114        {
115            throw new ServiceException( ServiceException.ServiceCode.VALUE_NOT_FOUND, e );
116        }
117    }
118
119
120    @NotNull
121    @Transactional(readOnly = true)
122    public <T1, T2, T3> Data<T1[], T2[], T3[]> getArraysByPlateformByParameterByPeriodFor2D( @NotNull final Integer plateformId, @NotNull final Integer parameterId, @Nullable final Date dateBegin, @Nullable final Date dateEnd )
123            throws ServiceException
124    {
125        try
126        {
127            return _valueDAO.getArraysByPlateformByParameterByPeriodFor2D( plateformId, parameterId, dateBegin, dateEnd );
128        }
129        catch( PersistenceException e )
130        {
131            throw new ServiceException( ServiceException.ServiceCode.VALUE_NOT_FOUND, e );
132        }
133    }
134
135    @NotNull
136    @Transactional(readOnly = true)
137    public Integer getNumberValuesByPlateformByParameterByPeriod( @NotNull final List<Pair> pairs, @Nullable final Date beginDate, @Nullable final Date endDate )
138            throws ServiceException
139    {
140        try
141        {
142            Integer number = 0;
143            for( final Pair pair : pairs )
144                number += _valueDAO.getNumberValuesByPlateformByParameterByPeriod( (Integer) pair.getFirstValue(), (Integer) pair.getSecondValue(), beginDate, endDate );
145
146            return number;
147        }
148        catch( PersistenceException e )
149        {
150            throw new ServiceException( ServiceException.ServiceCode.VALUE_NOT_FOUND, e );
151        }
152    }
153
154    @Required
155    public void setPlateformDAO( final PlateformDAO plateformDAO )
156    {
157        _plateformDAO = plateformDAO;
158    }
159
160    @Required
161    public void setParameterDAO( final ParameterDAO parameterDAO )
162    {
163        _parameterDAO = parameterDAO;
164    }
165
166    @Required
167    public void setValueDAO( final ValueDAO valueDAO )
168    {
169        _valueDAO = valueDAO;
170    }
171
172    private static final Log LOGGER = LogFactory.getLog( EtherServiceImpl.class );
173
174    private PlateformDAO _plateformDAO;
175    private ParameterDAO _parameterDAO;
176    private ValueDAO _valueDAO;
177}
Note: See TracBrowser for help on using the repository browser.