1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.grubusiness.business.mock;
35
36 import java.util.ArrayList;
37 import java.util.Collection;
38 import java.util.HashMap;
39 import java.util.Map;
40
41 import fr.paris.lutece.plugins.grubusiness.business.demand.Demand;
42 import fr.paris.lutece.plugins.grubusiness.business.demand.IDemandDAO;
43 import fr.paris.lutece.plugins.grubusiness.business.notification.NotificationFilter;
44
45 import java.util.List;
46
47
48
49
50 public class MockDemandDAO implements IDemandDAO
51 {
52 private final Map<String, Demand> _mapMockDemand = new HashMap<String, Demand>( );
53
54
55
56
57 @Override
58 public Collection<Demand> loadByCustomerId( String strCustomerId )
59 {
60 Collection<Demand> listResult = new ArrayList<Demand>( );
61 for ( Demand demand : _mapMockDemand.values( ) )
62 {
63 if ( demand.getCustomer( ) != null && demand.getCustomer( ).getId( ).equals( strCustomerId ) )
64 {
65 listResult.add( demand );
66 }
67 }
68 return listResult;
69 }
70
71
72
73
74 @Override
75 public Collection<Demand> loadByReference( String strReference )
76 {
77 Collection<Demand> listResult = new ArrayList<Demand>( );
78 for ( Demand demand : _mapMockDemand.values( ) )
79 {
80 if ( demand.getReference( ).equals( strReference ) )
81 {
82 listResult.add( demand );
83 }
84 }
85 return listResult;
86 }
87
88
89
90
91 @Override
92 public Demand load( int nId )
93 {
94
95
96 return null;
97 }
98
99
100
101
102
103 @Override
104 public Demand loadByDemandIdAndTypeId( String strDemandId, String strDemandTypeId )
105 {
106 return _mapMockDemand.get( strDemandTypeId + "|" + strDemandId );
107 }
108
109
110
111
112 @Override
113 public Demand insert( Demand demand )
114 {
115 _mapMockDemand.put( demand.getTypeId( ) + "|" + demand.getId( ), demand );
116 return demand;
117 }
118
119
120
121
122 @Override
123 public Demand store( Demand demand )
124 {
125 _mapMockDemand.put( demand.getTypeId( ) + "|" + demand.getId( ), demand );
126 return demand;
127 }
128
129
130
131
132 @Override
133 public void delete( String strDemandId, String strDemandTypeId )
134 {
135 _mapMockDemand.remove( strDemandTypeId + "|" + strDemandId );
136 }
137
138
139
140
141 @Override
142 public List<String> loadAllIds( )
143 {
144 return new ArrayList<>( _mapMockDemand.keySet( ) );
145 }
146
147
148
149
150 @Override
151 public Demand loadByDemandId( String strId )
152 {
153 return null;
154 }
155
156 @Override
157 public Collection<Demand> loadByFilter( NotificationFilter filter )
158 {
159 return _mapMockDemand.values( );
160 }
161
162 @Override
163 public List<Integer> loadIdsByFilter( NotificationFilter filter )
164 {
165
166 return null;
167 }
168
169 @Override
170 public List<Demand> loadByIds( List<Integer> listIds )
171 {
172 List<Demand> listDemands = new ArrayList<>( );
173 listDemands.addAll( _mapMockDemand.values( ) );
174
175 return listDemands;
176 }
177
178 @Override
179 public List<Integer> loadIdsByCustomerIdAndIdDemandType( String strCustomerId, String strNotificationType, String strIdDemandType )
180 {
181 return null;
182 }
183
184 @Override
185 public List<Integer> loadIdsByStatus( String strCustomerId, List<String> listStatus, String strNotificationType, String strIdDemandType )
186 {
187 return null;
188 }
189
190 }