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.occupation;
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.ChantierOccupation;
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.FormulaireDemandeOccupationBoServiceImpl;
46  import fr.paris.lutece.plugins.ctv.service.FormulaireDemandeOccupationServiceImpl;
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/occupation/etapes", right = "DEMANDE_OCCUPATION" )
54  public class GestionConflitsJspBean extends AbstractGestionConflitsJspBean
55  {
56  
57      private static final long serialVersionUID = -374300118257976280L;
58  
59      private IFormulaireDemandeOccupationBoService formulaireServiceBo = FormulaireDemandeOccupationBoServiceImpl.getInstance( );
60  
61      // Template
62      private static final String TEMPLATE_GESTION_CONFLITS = "admin/plugins/ctv/etapes/gestion_conflits.html";
63  
64      @View( defaultView = true, value = VIEW_GESTION_CONFLITS )
65      public String getConflitsView( HttpServletRequest request )
66      {
67          Map<String, Object> model = getConflitsModel( request );
68          return getPage( GESTION_CONFLITS_TITLE, TEMPLATE_GESTION_CONFLITS, model );
69      }
70  
71      @Action( ACTION_SEARCH )
72      public String doSearchAction( HttpServletRequest request )
73      {
74          Map<String, Object> model = getSearchActionModel( request );
75          return getPage( GESTION_CONFLITS_TITLE, TEMPLATE_GESTION_CONFLITS, model );
76      }
77  
78      @Action( ACTION_SAVE )
79      public String saveButtonPress( HttpServletRequest request )
80      {
81          String nextStepPath = request.getParameter( PARAMETER_NEXT_STEP );
82          GestionConflitsFormBeanstionConflitsFormBean.html#GestionConflitsFormBean">GestionConflitsFormBean conflitBean = new GestionConflitsFormBean( );
83          populate( conflitBean, request );
84          if ( conflitBean.getHasConflits( ) )
85          {
86              addConflit( request );
87  
88          }
89          else
90          {
91              deleteConflit( request );
92          }
93  
94          if ( StringUtils.isNullOrEmpty( nextStepPath ) )
95          {
96              return redirect( request, "../demandeOccupation.jsp" );
97          }
98          return redirect( request, nextStepPath );
99      }
100 
101     @Action( ACTION_ABANDON )
102     public String abandon( HttpServletRequest request )
103     {
104         formulaireServiceBo.removeFilesFromSession( request );
105         String nextStepPath = request.getParameter( PARAMETER_NEXT_STEP );
106         if ( StringUtils.isNullOrEmpty( nextStepPath ) )
107         {
108             return redirect( request, "../demandeOccupation.jsp" );
109         }
110         return redirect( request, nextStepPath );
111     }
112 
113     @Override
114     protected IFormulaire getFormulaireService( )
115     {
116         return FormulaireDemandeOccupationServiceImpl.getInstance( );
117     }
118 
119     @Override
120     protected String getAdresseChantier( int numDemande )
121     {
122         ChantierOccupation chantier = chantierService.getChantierOccupationByNumDemande( numDemande );
123         return chantier.getChantierAdresse( );
124     }
125 
126     @Override
127     protected IFormulaireDemandeOccupationBoService getFormulaireServiceBo( )
128     {
129         return formulaireServiceBo;
130     }
131 
132 }