View Javadoc
1   /*
2    * Copyright (c) 2002-2020, Mairie de 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.suggest.service;
35  
36  import fr.paris.lutece.api.user.User;
37  import fr.paris.lutece.plugins.suggest.business.CommentSubmit;
38  import fr.paris.lutece.plugins.suggest.business.Suggest;
39  import fr.paris.lutece.plugins.suggest.business.SuggestHome;
40  import fr.paris.lutece.plugins.suggest.business.SuggestSubmit;
41  import fr.paris.lutece.plugins.suggest.business.SuggestSubmitHome;
42  import fr.paris.lutece.plugins.suggest.business.SuggestSubmitStateHome;
43  import fr.paris.lutece.plugins.suggest.business.EntryFilter;
44  import fr.paris.lutece.plugins.suggest.business.EntryHome;
45  import fr.paris.lutece.plugins.suggest.business.IEntry;
46  import fr.paris.lutece.plugins.suggest.business.ImageResourceHome;
47  import fr.paris.lutece.plugins.suggest.business.Response;
48  import fr.paris.lutece.plugins.suggest.business.ResponseHome;
49  import fr.paris.lutece.plugins.suggest.business.SubmitFilter;
50  import fr.paris.lutece.plugins.suggest.service.search.SuggestIndexer;
51  import fr.paris.lutece.plugins.suggest.service.workflow.SuggestWorkflowService;
52  import fr.paris.lutece.plugins.suggest.utils.SuggestIndexerUtils;
53  import fr.paris.lutece.plugins.suggest.utils.SuggestUtils;
54  import fr.paris.lutece.portal.business.indexeraction.IndexerAction;
55  import fr.paris.lutece.portal.service.plugin.Plugin;
56  import fr.paris.lutece.portal.service.search.IndexationService;
57  import fr.paris.lutece.portal.service.spring.SpringContextService;
58  import fr.paris.lutece.portal.service.util.AppLogService;
59  import fr.paris.lutece.portal.service.util.AppPropertiesService;
60  import fr.paris.lutece.portal.service.workflow.WorkflowService;
61  
62  import java.util.ArrayList;
63  import java.util.HashMap;
64  import java.util.List;
65  import java.util.Locale;
66  import java.util.Map;
67  
68  import org.springframework.transaction.annotation.Transactional;
69  
70  public class SuggestSubmitService implements ISuggestSubmitService
71  {
72      public static final String BEAN_SERVICE = "suggest.suggestSubmitService";
73      private static ISuggestSubmitService _singleton;
74  
75      /**
76       * {@inheritDoc}
77       */
78      @Override
79      @Transactional( "suggest.transactionManager" )
80      public int create( SuggestSubmit suggestSubmit, Plugin plugin, Locale locale, User user )
81      {
82          // update creation date
83          suggestSubmit.setDateResponse( SuggestUtils.getCurrentDate( ) );
84  
85          // update suggest submit state
86          if ( suggestSubmit.getSuggest( ).isDisableNewSuggestSubmit( ) )
87          {
88              suggestSubmit.setSuggestSubmitState( SuggestSubmitStateHome.findByNumero( SuggestSubmit.STATE_WAITING_FOR_PUBLISH, plugin ) );
89          }
90          else
91          {
92              suggestSubmit.setSuggestSubmitState( SuggestSubmitStateHome.findByNumero( SuggestSubmit.STATE_PUBLISH, plugin ) );
93          }
94  
95          int nIdSuggestSubmit = SuggestSubmitHome.create( suggestSubmit, plugin );
96          suggestSubmit.setIdSuggestSubmit( nIdSuggestSubmit );
97  
98          if ( suggestSubmit.getSuggestSubmitState( ).getIdSuggestSubmitState( ) == SuggestSubmit.STATE_PUBLISH )
99          {
100             String strIdSuggestSubmit = Integer.toString( nIdSuggestSubmit );
101             IndexationService.addIndexerAction( strIdSuggestSubmit, AppPropertiesService.getProperty( SuggestIndexer.PROPERTY_INDEXER_NAME ),
102                     IndexerAction.TASK_CREATE );
103 
104             SuggestIndexerUtils.addIndexerAction( strIdSuggestSubmit, IndexerAction.TASK_CREATE );
105         }
106 
107         // store response
108         if ( suggestSubmit.getResponses( ) != null )
109         {
110             for ( Response response : suggestSubmit.getResponses( ) )
111             {
112                 if ( response.getImage( ) != null )
113                 {
114                     response.setIdImageResource( ImageResourceHome.create( response.getImage( ), plugin ) );
115                     // update Id Image ressource associate to the suggest
116                     suggestSubmit.setIdImageResource( response.getIdImageResource( ) );
117                 }
118 
119                 response.setSuggestSubmit( suggestSubmit );
120                 ResponseHome.create( response, plugin );
121             }
122         }
123 
124         // update SuggestSubmit
125         suggestSubmit.setSuggestSubmitValue( SuggestUtils.getHtmlSuggestSubmitValue( suggestSubmit, locale ) );
126         suggestSubmit.setSuggestSubmitValueShowInTheList( SuggestUtils.getHtmlSuggestSubmitValueShowInTheList( suggestSubmit, locale ) );
127         suggestSubmit.setSuggestSubmitTitle( SuggestUtils.getSuggestSubmitTitle( suggestSubmit, locale ) );
128         SuggestSubmitHome.update( suggestSubmit, plugin );
129 
130         // Execute potential workflow tasks on a SuggestSubmit's creation
131         executeSuggestSubmitWorkflowAction( suggestSubmit, user );
132 
133         return nIdSuggestSubmit;
134     }
135 
136     /**
137      * {@inheritDoc}
138      */
139     @Override
140     @Transactional( "suggest.transactionManager" )
141     public void update( SuggestSubmit suggestSubmit, Plugin plugin )
142     {
143         SuggestSubmitHome.update( suggestSubmit, plugin );
144     }
145 
146     /**
147      * {@inheritDoc}
148      */
149     @Override
150     @Transactional( "suggest.transactionManager" )
151     public void update( SuggestSubmit suggestSubmit, boolean bUpdateIndex, Plugin plugin )
152     {
153         SuggestSubmitHome.update( suggestSubmit, bUpdateIndex, plugin );
154     }
155 
156     /**
157      * {@inheritDoc}
158      * @deprecated use {@link #remove(int, int, Plugin, User)}
159      */
160     @Deprecated
161     @Override
162     @Transactional( "suggest.transactionManager" )
163     public void remove( int nIdSuggestSubmit, Plugin plugin )
164     {
165         SuggestSubmit suggestSubmit = SuggestSubmitHome.findByPrimaryKey( nIdSuggestSubmit, plugin );
166 
167         if ( suggestSubmit != null )
168         {
169             int nIdSuggest = suggestSubmit.getSuggest( ).getIdSuggest( );
170             // remove
171             SuggestSubmitHome.remove( nIdSuggestSubmit, plugin );
172             // update suggest submit order
173             updateSuggestSubmitOrder( null, null, nIdSuggest, suggestSubmit.isPinned( ), plugin );
174         }
175     }
176 
177     /**
178      * {@inheritDoc}
179      */
180     @Override
181     @Transactional( "suggest.transactionManager" )
182     public void remove( int nIdSuggestSubmit, Plugin plugin, User user )
183     {
184         SuggestSubmit suggestSubmit = SuggestSubmitHome.findByPrimaryKey( nIdSuggestSubmit, plugin );
185 
186         if ( suggestSubmit != null )
187         {
188             int nIdSuggest = suggestSubmit.getSuggest( ).getIdSuggest( );
189             // Remove the specified SuggestSubmit element
190             SuggestSubmitHome.remove( nIdSuggestSubmit, plugin );
191             // Update the order of the remaining SuggestSubmit elements
192             updateSuggestSubmitOrder( null, null, nIdSuggest, suggestSubmit.isPinned( ), plugin );
193             // Remove related workflow resources
194             removeWorkflowResources( nIdSuggestSubmit );
195         }
196     }
197 
198     /**
199      * {@inheritDoc}
200      */
201     @Override
202     @Transactional( "suggest.transactionManager" )
203     public void updateSuggestSubmitOrder( Integer nPositionElement, Integer nNewPositionElement, int nIdSuggest, boolean bListPinned, Plugin plugin )
204     {
205         SubmitFilterest/business/SubmitFilter.html#SubmitFilter">SubmitFilter filter = new SubmitFilter( );
206         filter.setIdSuggest( nIdSuggest );
207 
208         List<Integer> listSortByManually = new ArrayList<>( );
209         listSortByManually.add( SubmitFilter.SORT_MANUALLY );
210         filter.setSortBy( listSortByManually );
211         //
212         filter.setIdPinned( bListPinned ? SubmitFilter.ID_TRUE : SubmitFilter.ID_FALSE );
213 
214         List<Integer> listIdSuggestDubmit = getSuggestSubmitListId( filter, plugin );
215 
216         if ( ( listIdSuggestDubmit != null ) && ( !listIdSuggestDubmit.isEmpty( ) ) )
217         {
218             if ( ( nPositionElement != null ) && ( nNewPositionElement != null ) && ( !nPositionElement.equals( nNewPositionElement ) ) )
219             {
220                 if ( ( ( nPositionElement > 0 ) && ( nPositionElement <= ( listIdSuggestDubmit.size( ) + 1 ) ) )
221                         && ( ( nNewPositionElement > 0 ) && ( nNewPositionElement <= ( listIdSuggestDubmit.size( ) + 1 ) ) ) )
222                 {
223                     SuggestUtils.moveElement( nPositionElement, nNewPositionElement, (ArrayList<Integer>) listIdSuggestDubmit );
224                 }
225             }
226 
227             int nNewOrder = 1;
228 
229             // update all Suggest submit
230             for ( Integer nIdSuggestSubmit : listIdSuggestDubmit )
231             {
232                 SuggestSubmitHome.updateSuggestSubmitOrder( nNewOrder++, nIdSuggestSubmit, plugin );
233             }
234         }
235     }
236 
237     /**
238      * {@inheritDoc}
239      */
240     @Override
241     public SuggestSubmit findByPrimaryKey( int nKey, boolean bLoadCommentList, Plugin plugin )
242     {
243         return findByPrimaryKey( nKey, bLoadCommentList, null, plugin );
244     }
245 
246     /**
247      * {@inheritDoc}
248      */
249     @Override
250     public SuggestSubmit findByPrimaryKey( int nKey, boolean bLoadCommentList, Integer numberMaxCommentLoad, Plugin plugin )
251     {
252         SuggestSubmit suggestSubmit = SuggestSubmitHome.findByPrimaryKey( nKey, plugin );
253 
254         if ( ( suggestSubmit != null ) && !suggestSubmit.isDisableComment( ) && bLoadCommentList )
255         {
256             SubmitFilterubmitFilter.html#SubmitFilter">SubmitFilter submmitFilterComment = new SubmitFilter( );
257             submmitFilterComment.setIdSuggestSubmit( suggestSubmit.getIdSuggestSubmit( ) );
258             submmitFilterComment.setIdCommentSubmitState( CommentSubmit.STATE_ENABLE );
259             suggestSubmit.setComments( CommentSubmitService.getService( ).getCommentSubmitList( submmitFilterComment, numberMaxCommentLoad, plugin ) );
260         }
261 
262         return suggestSubmit;
263     }
264 
265     /**
266      * {@inheritDoc}
267      */
268     @Override
269     public SuggestSubmit findByPrimaryKey( int nKey, boolean bLoadCommentList, boolean bLoadResponseList, Plugin plugin )
270     {
271         SuggestSubmit suggestSubmit = findByPrimaryKey( nKey, bLoadCommentList, plugin );
272 
273         if ( ( suggestSubmit != null ) && bLoadResponseList )
274         {
275             SubmitFilteriness/SubmitFilter.html#SubmitFilter">SubmitFilter submmitFilter = new SubmitFilter( );
276             submmitFilter.setIdSuggestSubmit( suggestSubmit.getIdSuggestSubmit( ) );
277             suggestSubmit.setResponses( ResponseHome.getResponseList( submmitFilter, plugin ) );
278         }
279 
280         return suggestSubmit;
281     }
282 
283     /**
284      * {@inheritDoc}
285      */
286     @Override
287     public int findNextIdSuggestSubmitInTheList( int nIdCurrentSuggestSubmit, SubmitFilter filter, Plugin plugin )
288     {
289         List<Integer> suggestSubmitListId = getSuggestSubmitListId( filter, plugin );
290         Object [ ] suggestSubmitArrayId = suggestSubmitListId.toArray( );
291         int nIdSuggestSubmitNext = -1;
292 
293         for ( int cpt = 0; cpt < suggestSubmitArrayId.length; cpt++ )
294         {
295             if ( (Integer) suggestSubmitArrayId [cpt] == nIdCurrentSuggestSubmit )
296             {
297                 if ( cpt < ( suggestSubmitArrayId.length - 1 ) )
298                 {
299                     nIdSuggestSubmitNext = (Integer) suggestSubmitArrayId [cpt + 1];
300                 }
301 
302                 break;
303             }
304         }
305 
306         return nIdSuggestSubmitNext;
307     }
308 
309     /**
310      * {@inheritDoc}
311      */
312     @Override
313     public int findPrevIdSuggestSubmitInTheList( int nIdCurrentSuggestSubmit, SubmitFilter filter, Plugin plugin )
314     {
315         List<Integer> suggestSubmitListId = getSuggestSubmitListId( filter, plugin );
316         Object [ ] suggestSubmitArrayId = suggestSubmitListId.toArray( );
317         int nIdSuggestSubmitPrev = -1;
318 
319         for ( int cpt = 0; cpt < suggestSubmitArrayId.length; cpt++ )
320         {
321             if ( (Integer) suggestSubmitArrayId [cpt] == nIdCurrentSuggestSubmit )
322             {
323                 if ( cpt != 0 )
324                 {
325                     nIdSuggestSubmitPrev = (Integer) suggestSubmitArrayId [cpt - 1];
326                 }
327 
328                 break;
329             }
330         }
331 
332         return nIdSuggestSubmitPrev;
333     }
334 
335     /**
336      * {@inheritDoc}
337      */
338     @Override
339     public int getCountSuggestSubmit( SubmitFilter filter, Plugin plugin )
340     {
341         return SuggestSubmitHome.getCountSuggestSubmit( filter, plugin );
342     }
343 
344     /**
345      * {@inheritDoc}
346      */
347     @Override
348     public List<SuggestSubmit> getSuggestSubmitList( SubmitFilter filter, Plugin plugin )
349     {
350         if ( !filter.containsSortBy( ) )
351         {
352             // use default sort
353             SuggestUtils.initSubmitFilterBySort( filter, SuggestUtils.CONSTANT_ID_NULL );
354         }
355         else
356             if ( filter.containsSortBy( SubmitFilter.SORT_BY_PINNED_FIRST ) )
357             {
358                 SubmitFilter filterPinned = SuggestUtils.createPinnedFilter( filter );
359                 List<SuggestSubmit> listSuggestSubmitPinned = SuggestSubmitHome.getSuggestSubmitList( filterPinned, plugin );
360                 filter.setIdPinned( SubmitFilter.ID_FALSE );
361                 listSuggestSubmitPinned.addAll( SuggestSubmitHome.getSuggestSubmitList( filter, plugin ) );
362                 filter.setIdPinned( SubmitFilter.ALL_INT );
363 
364                 return listSuggestSubmitPinned;
365             }
366 
367         return SuggestSubmitHome.getSuggestSubmitList( filter, plugin );
368     }
369 
370     /**
371      * {@inheritDoc}
372      */
373     @Override
374     public List<SuggestSubmit> getSuggestSubmitList( SubmitFilter filter, Plugin plugin, int nNumberMaxSuggestSubmit )
375     {
376         if ( !filter.containsSortBy( ) )
377         {
378             // use default sort
379             SuggestUtils.initSubmitFilterBySort( filter, SuggestUtils.CONSTANT_ID_NULL );
380         }
381 
382         else
383             if ( filter.containsSortBy( SubmitFilter.SORT_BY_PINNED_FIRST ) )
384             {
385                 SubmitFilter filterPinned = SuggestUtils.createPinnedFilter( filter );
386                 List<SuggestSubmit> listSuggestSubmitPinned = SuggestSubmitHome.getSuggestSubmitList( filterPinned, plugin, nNumberMaxSuggestSubmit );
387                 filter.setIdPinned( SubmitFilter.ID_FALSE );
388                 listSuggestSubmitPinned.addAll( SuggestSubmitHome.getSuggestSubmitList( filterPinned, plugin,
389                         nNumberMaxSuggestSubmit - listSuggestSubmitPinned.size( ) ) );
390                 filter.setIdPinned( SubmitFilter.ALL_INT );
391 
392                 return listSuggestSubmitPinned;
393             }
394 
395         return SuggestSubmitHome.getSuggestSubmitList( filter, plugin, nNumberMaxSuggestSubmit );
396     }
397 
398     /**
399      * {@inheritDoc}
400      */
401     @Override
402     public List<Integer> getSuggestSubmitListId( SubmitFilter filter, Plugin plugin )
403     {
404         if ( !filter.containsSortBy( ) )
405         {
406             // use default sort
407             SuggestUtils.initSubmitFilterBySort( filter, SuggestUtils.CONSTANT_ID_NULL );
408         }
409         else
410             if ( filter.containsSortBy( SubmitFilter.SORT_BY_PINNED_FIRST ) )
411             {
412                 SubmitFilter filterPinned = SuggestUtils.createPinnedFilter( filter );
413                 List<Integer> listSuggestSubmitPinned = SuggestSubmitHome.getSuggestSubmitListId( filterPinned, plugin );
414                 filter.setIdPinned( SubmitFilter.ID_FALSE );
415                 listSuggestSubmitPinned.addAll( SuggestSubmitHome.getSuggestSubmitListId( filter, plugin ) );
416                 filter.setIdPinned( SubmitFilter.ALL_INT );
417 
418                 return listSuggestSubmitPinned;
419             }
420 
421         return SuggestSubmitHome.getSuggestSubmitListId( filter, plugin );
422     }
423 
424     /**
425      * {@inheritDoc}
426      */
427     @Override
428     public int getMaxOrderList( int nIdSuggest, boolean bListPinned, Plugin plugin )
429     {
430         // TODO Auto-generated method stub
431         return SuggestSubmitHome.getMaxOrderList( nIdSuggest, bListPinned, plugin );
432     }
433 
434     /**
435      * Returns the instance of the singleton
436      *
437      * @return The instance of the singleton
438      */
439     public static ISuggestSubmitService getService( )
440     {
441         if ( _singleton == null )
442         {
443             _singleton = SpringContextService.getBean( BEAN_SERVICE );
444         }
445 
446         return _singleton;
447     }
448 
449     /**
450      * {@inheritDoc}
451      */
452     @Override
453     public void updateAllDisplayOfSuggestSubmit( Integer nIdSuggest, Plugin plugin, Locale locale )
454     {
455         Suggest suggest = SuggestHome.findByPrimaryKey( nIdSuggest, plugin );
456         HashMap<Integer, IEntry> mapEntry = new HashMap<>( );
457         EntryFilterbusiness/EntryFilter.html#EntryFilter">EntryFilter entryFilter = new EntryFilter( );
458         entryFilter.setIdSuggest( suggest.getIdSuggest( ) );
459 
460         for ( IEntry entry : EntryHome.getEntryList( entryFilter, plugin ) )
461         {
462             mapEntry.put( entry.getIdEntry( ), EntryHome.findByPrimaryKey( entry.getIdEntry( ), plugin ) );
463         }
464 
465         SubmitFilterest/business/SubmitFilter.html#SubmitFilter">SubmitFilter filter = new SubmitFilter( );
466         filter.setIdSuggest( nIdSuggest );
467 
468         List<Integer> listIdSuggestSubmit = getSuggestSubmitListId( filter, plugin );
469 
470         for ( Integer nIdSuggestSubmit : listIdSuggestSubmit )
471         {
472             updateDisplaySuggestSubmit( nIdSuggestSubmit, plugin, locale, suggest, mapEntry );
473         }
474     }
475 
476     /**
477      * {@inheritDoc}
478      */
479     @Override
480     public void updateDisplaySuggestSubmit( Integer nIdSuggestSubmit, Plugin plugin, Locale locale, Suggest suggest, Map<Integer, IEntry> mapEntry )
481     {
482         SuggestSubmit suggestSubmit = findByPrimaryKey( nIdSuggestSubmit, false, plugin );
483         suggestSubmit.setSuggest( suggest );
484 
485         SubmitFilterest/business/SubmitFilter.html#SubmitFilter">SubmitFilter filter = new SubmitFilter( );
486         filter.setIdSuggestSubmit( nIdSuggestSubmit );
487 
488         // add responses
489         List<Response> listResponses = ResponseHome.getResponseList( filter, plugin );
490 
491         for ( Response response : listResponses )
492         {
493             response.setEntry( mapEntry.get( response.getEntry( ).getIdEntry( ) ) );
494         }
495 
496         suggestSubmit.setResponses( listResponses );
497         // update Number of comment
498         suggestSubmit.setNumberComment( CommentSubmitService.getService( ).getCountCommentSubmit( filter, plugin ) );
499         // update Number of Comment Enable
500         filter.setIdCommentSubmitState( CommentSubmit.STATE_ENABLE );
501         suggestSubmit.setNumberCommentEnable( CommentSubmitService.getService( ).getCountCommentSubmit( filter, plugin ) );
502         // update SuggestSubmitValue
503         suggestSubmit.setSuggestSubmitValue( SuggestUtils.getHtmlSuggestSubmitValue( suggestSubmit, locale ) );
504         // update SuggestSubmitValue show in the list
505         suggestSubmit.setSuggestSubmitValueShowInTheList( SuggestUtils.getHtmlSuggestSubmitValueShowInTheList( suggestSubmit, locale ) );
506         // update SuggestSubmit title
507         suggestSubmit.setSuggestSubmitTitle( SuggestUtils.getSuggestSubmitTitle( suggestSubmit, locale ) );
508         // update SuggestSubmit
509         update( suggestSubmit, plugin );
510     }
511 
512     /**
513      * {@inheritDoc}
514      */
515     @Override
516     public List<SuggestSubmit> getListSuggestSubmitBySuggestId( int nIdSuggest, Plugin plugin )
517     {
518         SubmitFilterest/business/SubmitFilter.html#SubmitFilter">SubmitFilter filter = new SubmitFilter( );
519         filter.setIdSuggest( nIdSuggest );
520 
521         return getSuggestSubmitList( filter, plugin );
522     }
523 
524     /**
525      * Execute automatic workflow actions for the given SuggestSubmit element
526      * 
527      * @param suggestSubmit
528      *            The SuggestSubmit element that will be checked for automatic actions
529      * @param user
530      *            The user
531      */
532     public void executeSuggestSubmitWorkflowAction( SuggestSubmit suggestSubmit, User user )
533     {
534         Suggest suggest = suggestSubmit.getSuggest( );
535         if ( WorkflowService.getInstance( ).isAvailable( ) && suggest.getIdWorkflow( ) != SuggestUtils.CONSTANT_ID_NULL )
536         {
537             SuggestWorkflowService.processActionOnSuggestSubmitCreation( suggest, suggestSubmit, user );
538         }
539     }
540 
541     /**
542      * Remove Workflow resources for a specific SuggestSubmit element
543      * 
544      * @param nIdSuggestSubmit
545      *            The ID of the SuggestSubmit element to process
546      */
547     private void removeWorkflowResources( int nIdSuggestSubmit )
548     {
549         if ( WorkflowService.getInstance( ).isAvailable( ) )
550         {
551             try
552             {
553                 WorkflowService.getInstance( ).doRemoveWorkFlowResource( nIdSuggestSubmit, SuggestSubmit.RESOURCE_TYPE );
554             }
555             catch( Exception e )
556             {
557                 AppLogService.error( "Error when removing Workflow resources for SuggestSubmit element", e );
558             }
559         }
560     }
561 }