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.bo.controller.demandes.intervention;
35  
36  import java.util.Map;
37  
38  import javax.servlet.http.HttpServletRequest;
39  
40  import com.mysql.jdbc.StringUtils;
41  
42  import fr.paris.lutece.plugins.ctv.bo.ChantierIntervention;
43  import fr.paris.lutece.plugins.ctv.bo.controller.demandes.AbstractGestionConflitsJspBean;
44  import fr.paris.lutece.plugins.ctv.form.GestionConflitsFormBean;
45  import fr.paris.lutece.plugins.ctv.service.FormulaireDemandeIntentionServiceImpl;
46  import fr.paris.lutece.plugins.ctv.service.FormulaireDemandeInterventionServiceImpl;
47  import fr.paris.lutece.plugins.ctv.service.IFormulaire;
48  import fr.paris.lutece.plugins.ctv.service.IFormulaireDemandeOccupationBoService;
49  import fr.paris.lutece.portal.util.mvc.admin.annotations.Controller;
50  import fr.paris.lutece.portal.util.mvc.commons.annotations.Action;
51  import fr.paris.lutece.portal.util.mvc.commons.annotations.View;
52  
53  @Controller( controllerJsp = "gestion_conflits.jsp", controllerPath = "jsp/admin/plugins/ctv/gestionDemandes/intervention/etapes", right = "TABLEAU_DE_BORD" )
54  public class GestionConflitsJspBean extends AbstractGestionConflitsJspBean
55  {
56  
57      private static final long serialVersionUID = -374300118257976280L;
58      private IFormulaire formulaireService = FormulaireDemandeIntentionServiceImpl.getInstance( );
59  
60      // Template
61      private static final String TEMPLATE_GESTION_CONFLITS = "/admin/plugins/ctv/demandeIntervention/etapesIntervention/gestion_conflits.html";
62  
63      @View( defaultView = true, value = VIEW_GESTION_CONFLITS )
64      public String getConflitsView( HttpServletRequest request )
65      {
66          Map<String, Object> model = getConflitsModel( request );
67          return getPage( GESTION_CONFLITS_TITLE, TEMPLATE_GESTION_CONFLITS, model );
68      }
69  
70      @Action( ACTION_SEARCH )
71      public String doSearchAction( HttpServletRequest request )
72      {
73          Map<String, Object> model = getSearchActionModel( request );
74          return getPage( GESTION_CONFLITS_TITLE, TEMPLATE_GESTION_CONFLITS, model );
75      }
76  
77      @Action( ACTION_SAVE )
78      public String saveButtonPress( HttpServletRequest request )
79      {
80          String nextStepPath = request.getParameter( PARAMETER_NEXT_STEP );
81          GestionConflitsFormBeanstionConflitsFormBean.html#GestionConflitsFormBean">GestionConflitsFormBean conflitBean = new GestionConflitsFormBean( );
82          populate( conflitBean, request );
83          if ( conflitBean.getHasConflits( ) )
84          {
85              addConflit( request );
86  
87          }
88          else
89          {
90              deleteConflit( request );
91          }
92  
93          if ( StringUtils.isNullOrEmpty( nextStepPath ) )
94          {
95              return redirect( request, "../demandeIntervention.jsp" );
96          }
97          return redirect( request, nextStepPath );
98      }
99  
100     @Action( ACTION_ABANDON )
101     public String abandon( HttpServletRequest request )
102     {
103         formulaireService.removeFilesFromSession( request );
104         String nextStepPath = request.getParameter( PARAMETER_NEXT_STEP );
105         if ( StringUtils.isNullOrEmpty( nextStepPath ) )
106         {
107             return redirect( request, "../demandeIntervention.jsp" );
108         }
109         return redirect( request, nextStepPath );
110     }
111 
112     @Override
113     protected IFormulaire getFormulaireService( )
114     {
115         return FormulaireDemandeInterventionServiceImpl.getInstance( );
116     }
117 
118     @Override
119     protected String getAdresseChantier( int numDemande )
120     {
121         ChantierIntervention chantier = chantierService.getChantierInterventionByNumDemande( numDemande );
122         return chantier.getChantierAdresse( );
123     }
124 
125     @Override
126     protected IFormulaireDemandeOccupationBoService getFormulaireServiceBo( )
127     {
128         return null;
129     }
130 
131 }