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

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

Servlet _ TimeSerie? :

  • 1 paramètre ok
  • même paramètre sur différentes plateformes ok
File size: 4.9 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<T1[], T2[], 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    @NotNull
120    @Transactional(readOnly = true)
121    public Integer getNumberValuesByPlateformByParameterByPeriod( @NotNull final List<Pair> pairs, @Nullable final Date beginDate, @Nullable final Date endDate )
122            throws ServiceException
123    {
124        try
125        {
126            Integer number = 0;
127            for( final Pair pair : pairs )
128                number += _valueDAO.getNumberValuesByPlateformByParameterByPeriod( (Integer) pair.getFirstValue(), (Integer) pair.getSecondValue(), beginDate, endDate );
129
130            return number;
131        }
132        catch( PersistenceException e )
133        {
134            throw new ServiceException( ServiceException.ServiceCode.VALUE_NOT_FOUND, e );
135        }
136    }
137
138    @Required
139    public void setPlateformDAO( final PlateformDAO plateformDAO )
140    {
141        _plateformDAO = plateformDAO;
142    }
143
144    @Required
145    public void setParameterDAO( final ParameterDAO parameterDAO )
146    {
147        _parameterDAO = parameterDAO;
148    }
149
150    @Required
151    public void setValueDAO( final ValueDAO valueDAO )
152    {
153        _valueDAO = valueDAO;
154    }
155
156    private static final Log LOGGER = LogFactory.getLog( EtherServiceImpl.class );
157
158    private PlateformDAO _plateformDAO;
159    private ParameterDAO _parameterDAO;
160    private ValueDAO _valueDAO;
161}
Note: See TracBrowser for help on using the repository browser.