View Javadoc
1   /*
2    * Copyright (c) 2002-2021, City of Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.ctv.service;
35  
36  import static fr.paris.lutece.plugins.ctv.bo.SearchBeanForAlertes.CategorieAlertes.CR_DE_VISITE_AJOUTE;
37  import static fr.paris.lutece.plugins.ctv.bo.SearchBeanForAlertes.CategorieAlertes.DEMANDES_SIGNEES;
38  import static fr.paris.lutece.plugins.ctv.bo.SearchBeanForAlertes.CategorieAlertes.FIN_DE_TRAVAUX_REFUSEE;
39  import static fr.paris.lutece.plugins.ctv.bo.SearchBeanForAlertes.CategorieAlertes.FIN_EMPRISE_DEPASSEE;
40  import static fr.paris.lutece.plugins.ctv.bo.SearchBeanForAlertes.CategorieAlertes.INTENTIONS_A_TRANSFORMER;
41  import static fr.paris.lutece.plugins.ctv.bo.SearchBeanForAlertes.CategorieAlertes.PJ_AJOUTEES;
42  import static fr.paris.lutece.plugins.ctv.bo.SearchBeanForAlertes.CategorieAlertes.PROLONGATION_REFUSEE;
43  import static fr.paris.lutece.plugins.ctv.bo.SearchBeanForAlertes.CategorieAlertes.REMISE_EN_CIRCULATION_ACCEPTEE;
44  import static fr.paris.lutece.plugins.ctv.bo.SearchBeanForAlertes.CategorieAlertes.ROC_PROCHE;
45  import static fr.paris.lutece.plugins.ctv.constants.CtvConstants.NATURES_CHANTIER;
46  import static fr.paris.lutece.plugins.ctv.constants.CtvConstants.PARAMETER_ADD;
47  
48  import java.util.ArrayList;
49  import java.util.Arrays;
50  import java.util.Date;
51  import java.util.LinkedHashMap;
52  import java.util.List;
53  import java.util.Map;
54  
55  import javax.servlet.http.HttpServletRequest;
56  
57  import org.apache.commons.beanutils.ConvertUtils;
58  import org.apache.commons.lang3.StringUtils;
59  
60  import fr.paris.lutece.plugins.ctv.bo.SearchBeanForAlertes;
61  import fr.paris.lutece.plugins.ctv.bo.SearchBeanForAlertes.CategorieAlertes;
62  import fr.paris.lutece.plugins.ctv.bo.SearchBeanForEmprises;
63  import fr.paris.lutece.plugins.ctv.business.IReferentielsService;
64  import fr.paris.lutece.plugins.ctv.constant.Constants;
65  import fr.paris.lutece.plugins.ctv.constant.StatutDemande;
66  import fr.paris.lutece.plugins.ctv.constant.StatutEmprise;
67  import fr.paris.lutece.plugins.ctv.constant.TypeDemande;
68  import fr.paris.lutece.plugins.ctv.constant.TypeProfileCtv;
69  import fr.paris.lutece.plugins.ctv.converter.CustomDateConverter;
70  import fr.paris.lutece.plugins.ctv.converter.EnumConverter;
71  import fr.paris.lutece.plugins.ctv.view.object.BanniereViewObject;
72  import fr.paris.lutece.plugins.ctv.view.object.SearchEmprisesViewObject;
73  import fr.paris.lutece.plugins.gismap.business.AddressParam;
74  import fr.paris.lutece.plugins.gismap.business.AddressParamHome;
75  import fr.paris.lutece.plugins.unittree.business.unit.Unit;
76  import fr.paris.lutece.plugins.unittree.business.unit.Unit.TypeUnit;
77  import fr.paris.lutece.portal.business.user.AdminUser;
78  import fr.paris.lutece.portal.service.datastore.DatastoreService;
79  import fr.paris.lutece.portal.service.spring.SpringContextService;
80  
81  public class TableauDeBordConcessionnaireControllerService extends AbstractTableauDeBordControllerService
82  {
83  
84      private static final String MARK_LISTE_DEMANDES = "list_demandes";
85  
86      private static IReferentielsService referentielsService = SpringContextService.getBean( "referentielsService" );
87  
88      private static final long serialVersionUID = -9021333749590087808L;
89  
90      private static ITableauDeBordControllerService tableauDeBordConcessionnaireControllerService = new TableauDeBordConcessionnaireControllerService( );
91  
92      public static ITableauDeBordControllerService getInstance( )
93      {
94          return tableauDeBordConcessionnaireControllerService;
95      }
96  
97      private TableauDeBordConcessionnaireControllerService( )
98      {
99      }
100 
101     @Override
102     protected String getPage( Map<String, Object> model )
103     {
104         return getPage( TABLEAU_BORD_PAGE_TITLE, TEMPLATE_TABLEAU_DE_BORD_CONCESSIONNAIRE, model );
105     }
106 
107     @Override
108     protected List<StatutDemande> getStatusByBlocs( SearchBeanForEmprises searchBean, HttpServletRequest request, List<StatutDemande> statusDemande,
109             AdminUser user, String elementSelected )
110     {
111 
112         List<BanniereViewObject> listeBanniere = new ArrayList<>( );
113 
114         StatutEmprise [ ] statutEmpriseBrouillon = new StatutEmprise [ ] {
115                 StatutEmprise.BROUILLON
116         };
117 
118         String blocSelected = request.getParameter( PARAMETER_STATUT );
119 
120         switch( blocSelected )
121         {
122 
123             case BLOC_BROUILLON:
124                 initStatutAndTypeBrouillon( listeBanniere, statutEmpriseBrouillon );
125                 searchBean.setStatutEmprise( StatutEmprise.BROUILLON );
126                 searchBean.setEmpriseTransformee( true );
127                 break;
128             case BLOC_A_TRAITER:
129                 initStatutAndTypeAtraiter( listeBanniere );
130                 initSearchBeanConcessionnaire( searchBean, elementSelected, listeBanniere );
131                 searchBean.setEmpriseTransformee( false );
132                 break;
133             case BLOC_EN_COURS:
134                 initStatutAndTypeEnCours( listeBanniere, TypeProfileCtv.CONCESSIONNAIRE );
135                 initSearchBeanConcessionnaire( searchBean, elementSelected, listeBanniere );
136                 searchBean.setEmpriseTransformee( false );
137                 break;
138             default:
139                 searchBean.setEmpriseTransformee( true );
140                 break;
141         }
142 
143         return getStatusBySearchCriteria( );
144     }
145 
146     @Override
147     protected List<StatutDemande> getStatusBySearchCriteria( )
148     {
149         return Arrays.asList( StatutDemande.values( ) );
150     }
151 
152     @Override
153     public String getTableauDeBord( HttpServletRequest request, AdminUser user )
154     {
155         Map<String, Object> model = getModel( );
156         putDemandes( request, model, user );
157         putCompteurs( model, user, request );
158         AddressParam addressParam = AddressParamHome.getAddressParameters( );
159         addressParam.setListType( "VOIE" );
160         model.put( PARAMETER_ADD, addressParam );
161         if ( request.getSession( ).getAttribute( "profile_default" ) != null )
162         {
163             model.put( "profileInSession", ( (TypeProfileCtv) request.getSession( ).getAttribute( "profile_default" ) ).getKey( ) );
164         }
165         return getPage( model );
166     }
167 
168     @Override
169     protected TypeDemande [ ] getTypesDemandes( )
170     {
171         return new TypeDemande [ ] {
172                 TypeDemande.INTENTION_TRAVAUX, TypeDemande.BARRAGE_US, TypeDemande.TRAVAUX_IMPERATIFS_NON_PROGRAMMES, TypeDemande.INTERVENTION
173         };
174     }
175 
176     @Override
177     protected SearchBeanForEmprises initSearchBean( AdminUser user )
178     {
179         SearchBeanForEmprises searchBean = new SearchBeanForEmprises( );
180         Unit concession = unitService.getUnitUserByType( user, TypeUnit.CONCESSIONNAIRE );
181         searchBean.setConcessionsId( unitService.getAllUnitsIdByUnit( concession ) );
182         searchBean.setConcession( concession.getLabel( ) );
183         searchBean.setTypeUser( TypeProfileCtv.CONCESSIONNAIRE );
184         return searchBean;
185     }
186 
187     private void initSearchBeanConcessionnaire( SearchBeanForEmprises searchBean, String elementSelected, List<BanniereViewObject> listeBanniere )
188     {
189         searchBean.setLibeleByBloc( elementSelected );
190         searchBean.setTypeUser( TypeProfileCtv.CONCESSIONNAIRE );
191         for ( BanniereViewObject bvo : listeBanniere )
192         {
193             if ( elementSelected.equals( bvo.getName( ) ) )
194             {
195                 searchBean.setStatutEmpriseArray( bvo.getStatutEmprise( ) );
196                 searchBean.setTypesDemande( bvo.getTypeDemande( ) );
197             }
198         }
199     }
200 
201     private void initStatutAndTypeAtraiter( List<BanniereViewObject> listeBanniere )
202     {
203         StatutEmprise [ ] statutEmpriseIntention = new StatutEmprise [ ] {
204                 StatutEmprise.A_MODIFIER
205         };
206         StatutEmprise [ ] statutEmpriseIntentionBU = new StatutEmprise [ ] {
207                 StatutEmprise.A_MODIFIER, StatutEmprise.A_COMPLETER
208         };
209         listeBanniere.add( new BanniereViewObject( TypeDemande.INTENTION_TRAVAUX.name( ), new TypeDemande [ ] {
210                 TypeDemande.INTENTION_TRAVAUX
211         }, statutEmpriseIntention ) );
212         listeBanniere.add( new BanniereViewObject( TypeDemande.BARRAGE_US.name( ), new TypeDemande [ ] {
213                 TypeDemande.BARRAGE_US
214         }, statutEmpriseIntentionBU ) );
215         listeBanniere.add( new BanniereViewObject( TypeDemande.TRAVAUX_IMPERATIFS_NON_PROGRAMMES.name( ), new TypeDemande [ ] {
216                 TypeDemande.TRAVAUX_IMPERATIFS_NON_PROGRAMMES
217         }, statutEmpriseIntention ) );
218         listeBanniere.add( new BanniereViewObject( TypeDemande.INTERVENTION.name( ), new TypeDemande [ ] {
219                 TypeDemande.INTERVENTION
220         }, new StatutEmprise [ ] {
221                 StatutEmprise.A_COMPLETER
222         } ) );
223         listeBanniere.add( new BanniereViewObject( Constants.FIN_TRAVAUX_RESEAUX, new TypeDemande [ ] {
224                 TypeDemande.INTERVENTION
225         }, new StatutEmprise [ ] {
226                 StatutEmprise.TRAVAUX_EN_COURS
227         } ) );
228         listeBanniere.add( new BanniereViewObject( Constants.FIN_TRAVAUX_VOIRIE, new TypeDemande [ ] {
229                 TypeDemande.INTERVENTION
230         }, new StatutEmprise [ ] {
231                 StatutEmprise.REFECTION_EN_COURS
232         } ) );
233         listeBanniere.add( new BanniereViewObject( Constants.REMISE_CIRCULATION, new TypeDemande [ ] {
234                 TypeDemande.INTERVENTION
235         }, new StatutEmprise [ ] {
236                 StatutEmprise.REFECTION_TERMINEE
237         } ) );
238     }
239 
240     private void initStatutAndTypeBrouillon( List<BanniereViewObject> listeBanniereBrouillon, StatutEmprise [ ] statutEmpriseBrouillon )
241     {
242         listeBanniereBrouillon.add( new BanniereViewObject( TypeDemande.INTENTION_TRAVAUX.name( ), new TypeDemande [ ] {
243                 TypeDemande.INTENTION_TRAVAUX
244         }, statutEmpriseBrouillon ) );
245         listeBanniereBrouillon.add( new BanniereViewObject( TypeDemande.BARRAGE_US.name( ), new TypeDemande [ ] {
246                 TypeDemande.BARRAGE_US
247         }, statutEmpriseBrouillon ) );
248         listeBanniereBrouillon.add( new BanniereViewObject( TypeDemande.TRAVAUX_IMPERATIFS_NON_PROGRAMMES.name( ), new TypeDemande [ ] {
249                 TypeDemande.TRAVAUX_IMPERATIFS_NON_PROGRAMMES
250         }, statutEmpriseBrouillon ) );
251         listeBanniereBrouillon.add( new BanniereViewObject( TypeDemande.INTERVENTION.name( ), new TypeDemande [ ] {
252                 TypeDemande.INTERVENTION
253         }, statutEmpriseBrouillon ) );
254     }
255 
256     private void initStatutAndTypeEnCours( List<BanniereViewObject> listeBanniere, TypeProfileCtv userType )
257     {
258         StatutEmprise [ ] statutEmpriseIntention = new StatutEmprise [ ] {
259                 StatutEmprise.A_COORDONNEE, StatutEmprise.COORDONNEE, StatutEmprise.A_MODIFIER
260         };
261         StatutEmprise [ ] statutEmpriseIntentionBU = new StatutEmprise [ ] {
262                 StatutEmprise.A_COORDONNEE, StatutEmprise.COORDONNEE, StatutEmprise.A_MODIFIER, StatutEmprise.A_TRAITER,
263                 StatutEmprise.A_VALIDER, StatutEmprise.A_COMPLETER, StatutEmprise.A_SIGNER, StatutEmprise.SIGNE
264         };
265         StatutEmprise [ ] statutEmpriseInterventionOccupation = new StatutEmprise [ ] {
266                 StatutEmprise.A_TRAITER, StatutEmprise.A_COMPLETER, StatutEmprise.A_VALIDER, StatutEmprise.A_SIGNER, StatutEmprise.SIGNE
267         };
268         listeBanniere.add( new BanniereViewObject( userType, TypeDemande.INTENTION_TRAVAUX.name( ), new TypeDemande [ ] {
269                 TypeDemande.INTENTION_TRAVAUX
270         }, statutEmpriseIntention ) );
271         listeBanniere.add( new BanniereViewObject( userType, TypeDemande.BARRAGE_US.name( ), new TypeDemande [ ] {
272                 TypeDemande.BARRAGE_US
273         }, statutEmpriseIntentionBU ) );
274         listeBanniere.add( new BanniereViewObject( userType, TypeDemande.TRAVAUX_IMPERATIFS_NON_PROGRAMMES.name( ), new TypeDemande [ ] {
275                 TypeDemande.TRAVAUX_IMPERATIFS_NON_PROGRAMMES
276         }, statutEmpriseIntention ) );
277         listeBanniere.add( new BanniereViewObject( TypeDemande.INTERVENTION.name( ), new TypeDemande [ ] {
278                 TypeDemande.INTERVENTION
279         }, statutEmpriseInterventionOccupation ) );
280         listeBanniere.add( new BanniereViewObject( userType, Constants.TRAVAUX_EN_COURS, new TypeDemande [ ] {
281                 TypeDemande.INTERVENTION
282         }, new StatutEmprise [ ] {
283                 StatutEmprise.TRAVAUX_EN_COURS, StatutEmprise.FIN_TRAVAUX_RESEAUX, StatutEmprise.FIN_TRAVAUX_VOIRIE, StatutEmprise.REFECTION_TERMINEE,
284                 StatutEmprise.REFECTION_EN_COURS, StatutEmprise.REMISE_EN_CIRCULATION, StatutEmprise.PROLONGATION
285         } ) );
286         listeBanniere.add( new BanniereViewObject( userType, Constants.GARANTIE, new TypeDemande [ ] {
287                 TypeDemande.INTERVENTION
288         }, new StatutEmprise [ ] {
289                 StatutEmprise.GARANTIE
290         } ) );
291     }
292 
293     @Override
294     protected void putCompteurs( Map<String, Object> model, AdminUser user, HttpServletRequest request )
295     {
296         putCompteursBrouillon( model, user );
297         putCompteursAtraiter( model, user );
298         putCompteursEnCours( model, user );
299         putCompteursAlertes( model, user, request );
300 
301         if ( request.getSession( ).getAttribute( "profile_default" ) != null )
302         {
303             model.put( "profileInSession", request.getSession( ).getAttribute( "profile_default" ) );
304         }
305     }
306 
307     private void putCompteursAlertes( Map<String, Object> model, AdminUser user, HttpServletRequest request )
308     {
309 
310         Map<String, Integer> compteursAlertes = new LinkedHashMap<String, Integer>( );
311         List<CategorieAlertes> categories = Arrays.asList( ROC_PROCHE, FIN_EMPRISE_DEPASSEE, INTENTIONS_A_TRANSFORMER, DEMANDES_SIGNEES, CR_DE_VISITE_AJOUTE,
312                 PJ_AJOUTEES, REMISE_EN_CIRCULATION_ACCEPTEE, FIN_DE_TRAVAUX_REFUSEE, PROLONGATION_REFUSEE );
313 
314         for ( CategorieAlertes categorie : categories )
315         {
316             int count = demandeService.countDemandesWithEmpriseByAlertesCriteria( getSearchBeanForAlert( categorie, user, request ) );
317             compteursAlertes.put( categorie.name( ), count );
318         }
319 
320         model.put( "compteurs_alertes", compteursAlertes );
321     }
322 
323     private void putCompteursAtraiter( Map<String, Object> model, AdminUser user )
324     {
325 
326         Map<String, Integer> compteursAtraiter = new LinkedHashMap<String, Integer>( );
327         List<BanniereViewObject> listeBanniereATraiter = new ArrayList<>( );
328         initStatutAndTypeAtraiter( listeBanniereATraiter );
329 
330         Unit concession = unitService.getUnitUserByType( user, TypeUnit.CONCESSIONNAIRE );
331         List<Integer> allUnitId = unitService.getAllUnitsIdByUnit( concession );
332         String allUnitIdList = StringUtils.join( allUnitId, "," );
333         for ( BanniereViewObject bvo : listeBanniereATraiter )
334         {
335             compteursAtraiter.put( bvo.getName( ), demandeService.getNombreTotalDemandes( user.getUserId( ), Arrays.asList( bvo.getStatutEmprise( ) ),
336                     getStatusBySearchCriteria( ), true, allUnitIdList, bvo.getName( ), TypeProfileCtv.CONCESSIONNAIRE, bvo.getTypeDemande( ) ) );
337         }
338 
339         model.put( "compteurs_a_traiter", compteursAtraiter );
340     }
341 
342     private void putCompteursBrouillon( Map<String, Object> model, AdminUser user )
343     {
344         TypeDemande [ ] dmdtype = new TypeDemande [ ] {
345                 TypeDemande.INTENTION_TRAVAUX, TypeDemande.BARRAGE_US, TypeDemande.TRAVAUX_IMPERATIFS_NON_PROGRAMMES, TypeDemande.INTERVENTION
346         };
347 
348         Map<String, Integer> compteursBrouillon = new LinkedHashMap<String, Integer>( );
349 
350         Unit concession = unitService.getUnitUserByType( user, TypeUnit.CONCESSIONNAIRE );
351         List<Integer> allUnitId = unitService.getAllUnitsIdByUnit( concession );
352         String allUnitIdList = StringUtils.join( allUnitId, "," );
353 
354         for ( TypeDemande typeDemande : dmdtype )
355         {
356             compteursBrouillon.put( typeDemande.name( ), demandeService.getNombreTotalDemandes( user.getUserId( ), Arrays.asList( StatutEmprise.BROUILLON ),
357                     getStatusBySearchCriteria( ), false, allUnitIdList, null, null, typeDemande ) );
358         }
359 
360         model.put( "compteurs_brouillon", compteursBrouillon );
361     }
362 
363     private void putCompteursEnCours( Map<String, Object> model, AdminUser user )
364     {
365 
366         Map<String, Integer> compteursEnCours = new LinkedHashMap<String, Integer>( );
367 
368         List<BanniereViewObject> listeBanniereEnCours = new ArrayList<>( );
369         initStatutAndTypeEnCours( listeBanniereEnCours, TypeProfileCtv.CONCESSIONNAIRE );
370 
371         Unit concession = unitService.getUnitUserByType( user, TypeUnit.CONCESSIONNAIRE );
372         List<Integer> allUnitId = unitService.getAllUnitsIdByUnit( concession );
373         String allUnitIdList = StringUtils.join( allUnitId, "," );
374 
375         for ( BanniereViewObject bvo : listeBanniereEnCours )
376         {
377             compteursEnCours.put( bvo.getName( ), demandeService.getNombreTotalDemandes( user.getUserId( ), Arrays.asList( bvo.getStatutEmprise( ) ),
378                     getStatusBySearchCriteria( ), true, allUnitIdList, bvo.getName( ), TypeProfileCtv.CONCESSIONNAIRE, bvo.getTypeDemande( ) ) );
379         }
380         model.put( "compteurs_dossiers_en_cours", compteursEnCours );
381     }
382 
383     private void putDemandes( HttpServletRequest request, Map<String, Object> model, AdminUser user )
384     {
385         String typeAlerteParam = request.getParameter( "typeAlerte" );
386         List<SearchEmprisesViewObject> listeDemandes = new ArrayList<SearchEmprisesViewObject>( );
387         model.put( NATURES_CHANTIER, referentielsService.getNatureTravauxIntentionIntervention( ) );
388         if ( typeAlerteParam != null )
389         {
390             listeDemandes = demandeService
391                     .getListDemandesWithEmpriseByAlertesCriteria( getSearchBeanForAlert( CategorieAlertes.valueOf( typeAlerteParam ), user, request ) );
392             putPathDemande( model );
393             model.put( MARK_LISTE_DEMANDES, listeDemandes );
394         }
395         else
396             if ( "displayDemandes".equals( request.getParameter( "action" ) ) )
397             {
398 
399                 SearchBeanForEmprises searchBean = initSearchBean( user );
400                 List<StatutDemande> statusDemande = new ArrayList<StatutDemande>( );
401 
402                 if ( request.getParameter( "statut" ) != null )
403                 {
404                     if ( request.getParameter( "typeDeDemande" ) != null )
405                     {
406                         String typeDeDemande = request.getParameter( "typeDeDemande" );
407                         if ( !( typeDeDemande.equals( Constants.FIN_TRAVAUX_VOIRIE ) ) && !( typeDeDemande.equals( Constants.FIN_TRAVAUX_RESEAUX ) )
408                                 && !( typeDeDemande.equals( Constants.REMISE_CIRCULATION ) ) && !( typeDeDemande.equals( Constants.TRAVAUX_EN_COURS ) )
409                                 && !( typeDeDemande.equals( Constants.GARANTIE ) ) )
410                         {
411                             searchBean.setTypesDemande( new TypeDemande [ ] {
412                                     ( TypeDemande.valueOf( typeDeDemande ) )
413                             } );
414                         }
415                         statusDemande = getStatusByBlocs( searchBean, request, statusDemande, user, typeDeDemande );
416                     }
417 
418                     StatutDemande [ ] array = new StatutDemande [ statusDemande.size( )];
419                     statusDemande.toArray( array );
420                     searchBean.setStatuts( array );
421                     searchBean.setAlert( true );
422                 }
423                 else
424                 {
425 
426 
427                     if(( request.getParameter( "typeDemande" ) != null ) && !"".equals( request.getParameter( "typeDemande" ) ))
428                     {
429                         searchBean.setTypesDemande( new TypeDemande [ ] {
430                                 TypeDemande.valueOf( request.getParameter( "typeDemande" ) )
431                         } );
432                     }
433                     else
434                     {
435                         searchBean.setTypesDemande( getTypesDemandes( ) );
436                     }
437 
438 
439                     statusDemande.addAll( getStatusBySearchCriteria( ) );
440                     ConvertUtils.register( new CustomDateConverter( ), Date.class );
441                     ConvertUtils.register( new EnumConverter( ), StatutEmprise.class );
442 
443                     populate( searchBean, request );
444                     if ( searchBean.getNomIntervenant( ) != null )
445                     {
446                         String nomIntervenant = searchBean.getNomIntervenant( );
447                         nomIntervenant = nomIntervenant.replace( "\"", "&quot;" );
448                         searchBean.setNomIntervenant( nomIntervenant );
449                     }
450 
451                     if ( searchBean.getNumProjetIntervenant( ) != null )
452                     {
453                         String numIntervenant = searchBean.getNumProjetIntervenant( );
454                         numIntervenant = numIntervenant.replace( "\"", "&quot;" );
455                         searchBean.setNumProjetIntervenant( numIntervenant );
456                     }
457 
458                     if ( searchBean.getNomVoie( ) != null )
459                     {
460                         String nomVoie = searchBean.getNomVoie( );
461                         nomVoie = nomVoie.replace( "\"", "&quot;" );
462                         searchBean.setNomVoie( nomVoie );
463                     }
464 
465                     model.put( "searchCriteria", searchBean );
466 
467                     StatutDemande [ ] array = new StatutDemande [ statusDemande.size( )];
468                     getStatusBySearchCriteria( ).toArray( array );
469                     searchBean.setStatuts( array );
470                 }
471 
472                 listeDemandes = demandeService.getListDemandesWithEmpriseByCriteria( searchBean );
473                 putPathDemande( model );
474                 model.put( NATURES_CHANTIER, referentielsService.getNatureTravauxIntentionIntervention( ) );
475                 model.put( MARK_LISTE_DEMANDES, listeDemandes );
476             }
477 
478         insertListDemandesForExcel( model, listeDemandes );
479 
480         displaySectorTree( model, request );
481         model.put( "statutEmprises", StatutEmprise.values( ) );
482 
483     }
484 
485     @Override
486     protected void putPathDemande( Map<String, Object> model )
487     {
488         model.put( MARK_PATH_DEMANDE_INTENTION, PATH_DEMANDE_INTENTION );
489         model.put( MARK_PATH_DEMANDE_INTERVENTION, PATH_DEMANDE_INTERVENTION );
490     }
491 
492     @Override
493     protected SearchBeanForAlertes getSearchBeanForAlert( CategorieAlertes catgeorie, AdminUser user, HttpServletRequest request )
494     {
495         Unit concession = unitService.getUnitUserByType( user, TypeUnit.CONCESSIONNAIRE );
496         List<Integer> allUnitId = unitService.getAllUnitsIdByUnit( concession );
497         String delaiRocProche = DatastoreService.getDataValue( "parametre.numeric.alerte.date.roc.proche", "7" );
498         SearchBeanForAlertes searchBeanForAlertes = new SearchBeanForAlertes( catgeorie, delaiRocProche, concession.getLabel( ) );
499         searchBeanForAlertes.setConcessionsId( allUnitId );
500         return searchBeanForAlertes;
501     }
502 
503     /**
504      * Ne filtre pas par défault sur les Subdivisions de l'utilisateur connecté
505      */
506     @Override
507     protected String getDefaultUserUnits (HttpServletRequest request )
508     {
509         return "";
510     }
511 
512 }