View Javadoc
1   /*
2    * Copyright (c) 2002-2017, 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.directory.business;
35  
36  import fr.paris.lutece.plugins.directory.service.DirectoryService;
37  import fr.paris.lutece.plugins.directory.service.FileImgService;
38  import fr.paris.lutece.plugins.directory.utils.DirectoryUtils;
39  import fr.paris.lutece.plugins.workflowcore.business.state.State;
40  import fr.paris.lutece.portal.service.plugin.Plugin;
41  import fr.paris.lutece.portal.service.resource.IExtendableResource;
42  import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupResource;
43  import fr.paris.lutece.util.date.DateUtil;
44  import fr.paris.lutece.util.xml.XmlUtil;
45  
46  import org.apache.commons.lang.StringEscapeUtils;
47  import org.apache.commons.lang.StringUtils;
48  
49  import java.sql.Timestamp;
50  
51  import java.util.HashMap;
52  import java.util.List;
53  import java.util.Locale;
54  import java.util.Map;
55  
56  /**
57   *
58   * class Record
59   *
60   */
61  public class Record implements AdminWorkgroupResource, IExtendableResource
62  {
63      public static final String WORKFLOW_RESOURCE_TYPE = "DIRECTORY_RECORD";
64      public static final String EXTENDABLE_RESOURCE_TYPE = WORKFLOW_RESOURCE_TYPE;
65      public static final String ATTRIBUTE_TITLE = "title";
66      public static final String TAG_LIST_RECORD_FIELD = "list-record-field";
67      public static final String TAG_RECORD_FIELD = "record-field";
68      public static final String TAG_RECORD_FIELD_VALUE = "record-field-value";
69      public static final String TAG_CREATION_DATE = "creation-date";
70      public static final String TAG_MODIFICATION_DATE = "modification-date";
71      public static final String TAG_STATUS = "status";
72      public static final String ATTRIBUTE_ICON = "icon";
73      private static final String TAG_RECORD = "record";
74      private static final String ATTRIBUTE_RECORD_ID = "id";
75      private static final String ATTRIBUTE_TYPE_ENTRY = "type-entry";
76      private static final String ATTRIBUTE_SHOW_IN_RECORD = "isShownInRecord";
77      private static final String ATTRIBUTE_SHOW_IN_LIST = "isShownInList";
78      private int _nIdRecord;
79      private Timestamp _tDateCreation;
80      private Timestamp _tDateModification;
81      private Directory _directory;
82      private List<RecordField> _listRecordField;
83      private List<DirectoryAction> _listAction;
84      private boolean _bIsEnabled;
85      private String _strRoleKey;
86      private String _strWorkgroupKey;
87  
88      /**
89       *
90       * @return the directory associate to the record
91       */
92      public Directory getDirectory( )
93      {
94          return _directory;
95      }
96  
97      /**
98       *
99       * set the directory associate to the record
100      * 
101      * @param directory
102      *            the directory associate to the record
103      */
104     public void setDirectory( Directory directory )
105     {
106         this._directory = directory;
107     }
108 
109     /**
110      * return the id of the record
111      * 
112      * @return the id of the record
113      */
114     public int getIdRecord( )
115     {
116         return _nIdRecord;
117     }
118 
119     /**
120      * set the id of the record
121      * 
122      * @param idRecord
123      *            the id of the record
124      */
125     public void setIdRecord( int idRecord )
126     {
127         _nIdRecord = idRecord;
128     }
129 
130     /**
131      * return the date creation
132      * 
133      * @return the date creation
134      */
135     public Timestamp getDateCreation( )
136     {
137         return _tDateCreation;
138     }
139 
140     /**
141      * set the date creation
142      * 
143      * @param dateCreation
144      *            date creation
145      */
146     public void setDateCreation( Timestamp dateCreation )
147     {
148         _tDateCreation = dateCreation;
149     }
150 
151     /**
152      * return the date Modification
153      * 
154      * @return the date Modification
155      */
156     public Timestamp getDateModification( )
157     {
158         return _tDateModification;
159     }
160 
161     /**
162      * set the date Modification
163      * 
164      * @param dateModification
165      *            date Modification
166      */
167     public void setDateModification( Timestamp dateModification )
168     {
169         _tDateModification = dateModification;
170     }
171 
172     /**
173      *
174      * @return the list of field associate to the record
175      */
176     public List<RecordField> getListRecordField( )
177     {
178         return _listRecordField;
179     }
180 
181     /**
182      * set the list of record field associate to the record
183      * 
184      * @param listAction
185      *            the list of response associate to the form submit
186      */
187     public void setActions( List<DirectoryAction> listAction )
188     {
189         _listAction = listAction;
190     }
191 
192     /**
193      *
194      * @return the list of field associate to the record
195      */
196     public List<DirectoryAction> getActions( )
197     {
198         return _listAction;
199     }
200 
201     /**
202      * set the list of record field associate to the record
203      * 
204      * @param listRecordField
205      *            the list of response associate to the form submit
206      */
207     public void setListRecordField( List<RecordField> listRecordField )
208     {
209         _listRecordField = listRecordField;
210     }
211 
212     /**
213      *
214      * @return true if the record is enabled
215      */
216     public boolean isEnabled( )
217     {
218         return _bIsEnabled;
219     }
220 
221     /**
222      * set true if the record is enabled
223      * 
224      * @param enable
225      *            true if the record is enabled
226      */
227     public void setEnabled( boolean enable )
228     {
229         _bIsEnabled = enable;
230     }
231 
232     /**
233      * Gets the record role
234      * 
235      * @return recors's role as a String
236      *
237      */
238     public String getRoleKey( )
239     {
240         return _strRoleKey;
241     }
242 
243     /**
244      * Sets the directory's role
245      * 
246      * @param strRole
247      *            The role
248      *
249      */
250     public void setRoleKey( String strRole )
251     {
252         _strRoleKey = strRole;
253     }
254 
255     /**
256      * {@inheritDoc}
257      */
258     @Override
259     public String getWorkgroup( )
260     {
261         return _strWorkgroupKey;
262     }
263 
264     /**
265      * set the work group associate to the record
266      * 
267      * @param workGroup
268      *            the work group associate to the record
269      */
270     public void setWorkgroup( String workGroup )
271     {
272         _strWorkgroupKey = workGroup;
273     }
274 
275     /**
276      * The Xml of the record
277      * 
278      * @param plugin
279      *            the plugin
280      * @param locale
281      *            the locale
282      * @param bWithHtmlCode
283      *            true if the xml must contain html code 
284      * @param state
285      *            the state of the record
286      * @param listEntryResultSearch
287      *            the list of entry to display
288      * @param bDisplayTitleEntryTypeSelect
289      *            true if template front or false if template back
290      * @param bDisplayFront
291      *            true if template front or false if template back
292      * @param bDisplayExport
293      *            true if it must be displayed in export
294      * @param bDisplayDateCreation
295      *            true if the date creation must be displayed
296      * @param mapFieldEntry
297      *            a map containing all fields associated to the list of entry
298      * @return xml
299      */
300     public StringBuffer getXml( Plugin plugin, Locale locale, boolean bWithHtmlCode, State state, List<IEntry> listEntryResultSearch,
301             boolean bDisplayTitleEntryTypeSelect, boolean bDisplayFront, boolean bDisplayExport, boolean bDisplayDateCreation, Map<Integer, Field> mapFieldEntry )
302     {
303         return getXml( plugin, locale, bWithHtmlCode, state, listEntryResultSearch, bDisplayTitleEntryTypeSelect, bDisplayFront, bDisplayExport,
304                 bDisplayDateCreation, false, mapFieldEntry );
305     }
306 
307     /**
308      * The Xml of the record
309      * 
310      * @param plugin
311      *            the plugin
312      * @param locale
313      *            the locale
314      * @param bWithHtmlCode
315      *            true if the xml must contain html code 
316      * @param state
317      *            the state of the record
318      * @param listEntryResultSearch
319      *            the list of entry to display
320      * @param bDisplayTitleEntryTypeSelect
321      *            true if template front or false if template back
322      * @param bDisplayFront
323      *            true if template front or false if template back
324      * @param bDisplayExport
325      *            true if it must be displayed in export
326      * @param bDisplayDateCreation
327      *            true if the date creation must be displayed
328      * @param bDisplayDateModification
329      *            true if the modification date must be displayed, false otherwise
330      * @param mapFieldEntry
331      *            a map containing all fields associated to the list of entry
332      * @return xml
333      */
334     public StringBuffer getXml( Plugin plugin, Locale locale, boolean bWithHtmlCode, State state, List<IEntry> listEntryResultSearch,
335             boolean bDisplayTitleEntryTypeSelect, boolean bDisplayFront, boolean bDisplayExport, boolean bDisplayDateCreation,
336             boolean bDisplayDateModification, Map<Integer, Field> mapFieldEntry )
337     {
338         StringBuffer strXml = new StringBuffer( );
339         Map<String, String> model = new HashMap<String, String>( );
340         model.put( ATTRIBUTE_RECORD_ID, String.valueOf( this.getIdRecord( ) ) );
341         XmlUtil.beginElement( strXml, TAG_RECORD, model );
342 
343         if ( bDisplayDateCreation )
344         {
345             XmlUtil.addElement( strXml, TAG_CREATION_DATE, DateUtil.getDateString( this.getDateCreation( ), locale ) );
346         }
347 
348         if ( bDisplayDateModification )
349         {
350             XmlUtil.addElement( strXml, TAG_MODIFICATION_DATE, DateUtil.getDateString( this.getDateModification( ), locale ) );
351         }
352 
353         if ( state != null )
354         {
355             Map<String, String> stateAttributes = new HashMap<String, String>( );
356             stateAttributes.put( ATTRIBUTE_ICON, Integer.toString( state.getIcon( ).getId( ) ) );
357             XmlUtil.addElement( strXml, TAG_STATUS, state.getName( ), stateAttributes );
358         }
359 
360         XmlUtil.beginElement( strXml, Entry.TAG_LIST_ENTRY );
361 
362         Map<String, List<RecordField>> mapEntryRecordFields = DirectoryUtils.getSpecificMapIdEntryListRecordField( listEntryResultSearch, this.getIdRecord( ),
363                 plugin, mapFieldEntry );
364 
365         for ( IEntry entry : listEntryResultSearch )
366         {
367             if ( entry.getEntryType( ).getGroup( ) && ( entry.getChildren( ) != null ) )
368             {
369                 for ( IEntry entryChildren : entry.getChildren( ) )
370                 {
371                     if ( !entryChildren.getEntryType( ).getComment( ) )
372                     {
373                         getXmlListRecordField( entryChildren, strXml, plugin, locale, bWithHtmlCode,
374                                 mapEntryRecordFields.get( Integer.toString( entryChildren.getIdEntry( ) ) ), bDisplayTitleEntryTypeSelect, bDisplayFront,
375                                 bDisplayExport );
376                     }
377                 }
378             }
379             else
380                 if ( !entry.getEntryType( ).getComment( ) )
381                 {
382                     getXmlListRecordField( entry, strXml, plugin, locale, bWithHtmlCode, mapEntryRecordFields.get( Integer.toString( entry.getIdEntry( ) ) ),
383                             bDisplayTitleEntryTypeSelect, bDisplayFront, bDisplayExport );
384                 }
385         }
386 
387         XmlUtil.endElement( strXml, Entry.TAG_LIST_ENTRY );
388         XmlUtil.endElement( strXml, TAG_RECORD );
389 
390         return strXml;
391     }
392 
393     /**
394      * The Xml of the record field list
395      * 
396      * @param entry
397      *            the entry
398      * @param strXml
399      *            the xml buffer
400      * @param plugin
401      *            the plugin
402      * @param locale
403      *            the locale
404      * @param bWithHtmlCode
405      *            true if the xml must contain html code 
406      * @param listRecordField
407      *            the list of recordField to display
408      * @param bDisplayFront
409      *            true if template front or false if template back
410      * @param bDisplayExport
411      */
412     private void getXmlListRecordField( IEntry entry, StringBuffer strXml, Plugin plugin, Locale locale, boolean bWithHtmlCode,
413             List<RecordField> listRecordField, boolean bDisplayTitleEntryTypeSelect, boolean bDisplayFront, boolean bDisplayExport )
414     {
415         Map<String, String> model = DirectoryService.getInstance( ).getModelForEntryForXml( entry );
416         XmlUtil.beginElement( strXml, Entry.TAG_ENTRY, model );
417 
418         Map<String, String> modelListRecordField = new HashMap<String, String>( );
419         boolean bIsEntryTypeGeolocation = ( entry instanceof EntryTypeGeolocation ) ? true : false;
420         boolean bIsEntryTypeNumbering = ( entry instanceof EntryTypeNumbering ) ? true : false;
421         modelListRecordField.put( RecordField.ATTRIBUTE_GEOLOCATION, Boolean.toString( bIsEntryTypeGeolocation ) );
422         XmlUtil.beginElement( strXml, TAG_LIST_RECORD_FIELD, modelListRecordField );
423 
424         if ( listRecordField != null )
425         {
426             for ( RecordField recordField : listRecordField )
427             {
428                 Map<String, String> modelRecordField = new HashMap<String, String>( );
429                 Field field = recordField.getField( );
430 
431                 if ( ( field != null ) && StringUtils.isNotBlank( field.getTitle( ) ) )
432                 {
433                     modelRecordField.put( Record.ATTRIBUTE_TITLE, StringEscapeUtils.escapeXml( field.getTitle( ) ) );
434                 }
435 
436                 if ( entry.getEntryType( ) != null )
437                 {
438                     modelRecordField.put( ATTRIBUTE_TYPE_ENTRY, String.valueOf( entry.getEntryType( ).getIdType( ) ) );
439                 }
440 
441                 if ( field != null )
442                 {
443                     modelRecordField.put( ATTRIBUTE_SHOW_IN_RECORD, String.valueOf( field.isShownInResultRecord( ) ) );
444                     modelRecordField.put( ATTRIBUTE_SHOW_IN_LIST, String.valueOf( field.isShownInResultList( ) ) );
445                 }
446 
447                 XmlUtil.beginElement( strXml, TAG_RECORD_FIELD, modelRecordField );
448 
449                 if ( bWithHtmlCode )
450                 {
451                     Map<String, String> modelRecordFieldValue = new HashMap<String, String>( );
452 
453                     if ( field != null )
454                     {
455                         modelRecordFieldValue.put( Field.ATTRIBUTE_FIELD_ID, Integer.toString( field.getIdField( ) ) );
456 
457                         if ( StringUtils.isNotBlank( field.getTitle( ) ) )
458                         {
459                             modelRecordFieldValue.put( Field.ATTRIBUTE_FIELD_TITLE, StringEscapeUtils.escapeXml( recordField.getField( ).getTitle( ) ) );
460                         }
461                     }
462 
463                     XmlUtil.addElementHtml( strXml, TAG_RECORD_FIELD_VALUE, recordField.getEntry( )
464                             .getHtmlRecordFieldValue( locale, recordField, bDisplayFront ), modelRecordFieldValue );
465                 }
466                 else
467                 {
468                     if ( recordField.getFile( ) != null )
469                     {
470                         IEntry entryFile = EntryHome.findByPrimaryKey( recordField.getEntry( ).getIdEntry( ), plugin );
471 
472                         XmlUtil.addElementHtml( strXml, TAG_RECORD_FIELD_VALUE,
473                                 entry.convertRecordFieldValueToString( recordField, locale, bDisplayFront, bDisplayExport ) );
474                         strXml.append( recordField.getFile( ).getXml( plugin, locale, entry.getEntryType( ).getIdType( ), entryFile.getDisplayWidth( ),
475                                 entryFile.getDisplayHeight( ) ) );
476                     }
477                     else
478                     {
479                         if ( bDisplayTitleEntryTypeSelect && !bIsEntryTypeNumbering )
480                         {
481                             XmlUtil.addElementHtml(
482                                     strXml,
483                                     TAG_RECORD_FIELD_VALUE,
484                                     DirectoryUtils.substituteSpecialCaractersForExport( recordField.getEntry( ).convertRecordFieldTitleToString( recordField,
485                                             locale, bDisplayFront ) ) );
486                         }
487                         else
488                         {
489                             Map<String, String> modelRecordFieldValue = new HashMap<String, String>( );
490 
491                             if ( recordField.getField( ) != null )
492                             {
493                                 modelRecordFieldValue.put( Field.ATTRIBUTE_FIELD_ID, Integer.toString( recordField.getField( ).getIdField( ) ) );
494 
495                                 if ( StringUtils.isNotBlank( recordField.getField( ).getTitle( ) ) )
496                                 {
497                                     modelRecordFieldValue.put( Field.ATTRIBUTE_FIELD_TITLE, StringEscapeUtils.escapeXml( recordField.getField( ).getTitle( ) ) );
498                                 }
499                             }
500 
501                             XmlUtil.addElementHtml(
502                                     strXml,
503                                     TAG_RECORD_FIELD_VALUE,
504                                     DirectoryUtils.substituteSpecialCaractersForExport( recordField.getEntry( ).convertRecordFieldValueToString( recordField,
505                                             locale, bDisplayFront, bDisplayExport ) ), modelRecordFieldValue );
506                         }
507 
508                         XmlUtil.addEmptyElement( strXml, File.TAG_FILE, null );
509                     }
510                 }
511 
512                 XmlUtil.endElement( strXml, TAG_RECORD_FIELD );
513             }
514         }
515 
516         XmlUtil.endElement( strXml, TAG_LIST_RECORD_FIELD );
517         XmlUtil.endElement( strXml, Entry.TAG_ENTRY );
518     }
519 
520     /**
521      * The Xml of the record
522      * 
523      * @param plugin
524      *            the plugin
525      * @param locale
526      *            the locale
527      * @param bWithHtmlCode
528      *            true if the xml must contain html code
529      * @param state
530      *            the state of the record
531      * @param listEntryResultSearch
532      *            the list of entry to display
533      * @param bDisplayTitleEntryTypeSelect
534      *            true if the title must be display for entry type select
535      * @param bDisplayFront
536      *            true if template front or false if template back
537      * @param bDisplayExport
538      *            true if it must be displayed in export
539      * @param bDisplayDateCreation
540      *            true if the date creation must be displayed
541      * @param mapFieldEntry
542      *            a map containing all fields associated to the list of entry
543      * @return xml
544      */
545     public StringBuffer getXmlForCsvExport( Plugin plugin, Locale locale, boolean bWithHtmlCode, State state, List<IEntry> listEntryResultSearch,
546             boolean bDisplayTitleEntryTypeSelect, boolean bDisplayFront, boolean bDisplayExport, boolean bDisplayDateCreation, Map<Integer, Field> mapFieldEntry )
547     {
548         return getXmlForCsvExport( plugin, locale, bWithHtmlCode, state, listEntryResultSearch, bDisplayTitleEntryTypeSelect, bDisplayFront, bDisplayExport,
549                 bDisplayDateCreation, false, mapFieldEntry );
550     }
551 
552     /**
553      * The Xml of the record
554      * 
555      * @param plugin
556      *            the plugin
557      * @param locale
558      *            the locale
559      * @param bWithHtmlCode
560      *            true if the xml must contain html code 
561      * @param state
562      *            the state of the record
563      * @param listEntryResultSearch
564      *            the list of entry to display
565      * @param bDisplayTitleEntryTypeSelect
566      *            true if the title must be display for entry type select
567      * @param bDisplayFront
568      *            true if template front or false if template back
569      * @param bDisplayExport
570      *            true if it must be displayed in export
571      * @param bDisplayDateCreation
572      *            true if the date creation must be displayed
573      * @param bDisplayDateModification
574      *            true if the modification date must be displayed, false otherwise
575      * @param mapFieldEntry
576      *            a map containing all fields associated to the list of entry
577      * @return xml
578      */
579     public StringBuffer getXmlForCsvExport( Plugin plugin, Locale locale, boolean bWithHtmlCode, State state, List<IEntry> listEntryResultSearch,
580             boolean bDisplayTitleEntryTypeSelect, boolean bDisplayFront, boolean bDisplayExport, boolean bDisplayDateCreation,
581             boolean bDisplayDateModification, Map<Integer, Field> mapFieldEntry )
582     {
583         StringBuffer strXml = new StringBuffer( );
584         Map<String, String> model = new HashMap<String, String>( );
585         model.put( ATTRIBUTE_RECORD_ID, String.valueOf( this.getIdRecord( ) ) );
586         XmlUtil.beginElement( strXml, TAG_RECORD, model );
587 
588         if ( state != null )
589         {
590             Map<String, String> stateAttributes = new HashMap<String, String>( );
591             stateAttributes.put( ATTRIBUTE_ICON, Integer.toString( state.getIcon( ).getId( ) ) );
592             XmlUtil.addElement( strXml, TAG_STATUS, state.getName( ), stateAttributes );
593         }
594 
595         XmlUtil.beginElement( strXml, Entry.TAG_LIST_ENTRY );
596 
597         Map<String, List<RecordField>> mapEntryRecordFields = DirectoryUtils.getSpecificMapIdEntryListRecordField( listEntryResultSearch, this.getIdRecord( ),
598                 plugin, mapFieldEntry );
599 
600         if ( bDisplayDateCreation )
601         {
602             HashMap<String, String> modelCreationDate = new HashMap<String, String>( );
603             modelCreationDate.put( Entry.ATTRIBUTE_ENTRY_ID, "0" );
604             XmlUtil.beginElement( strXml, Entry.TAG_ENTRY, modelCreationDate );
605             XmlUtil.beginElement( strXml, TAG_LIST_RECORD_FIELD );
606             XmlUtil.beginElement( strXml, TAG_RECORD_FIELD );
607             XmlUtil.addElementHtml( strXml, TAG_RECORD_FIELD_VALUE, DateUtil.getDateString( this.getDateCreation( ), locale ) );
608             XmlUtil.endElement( strXml, TAG_RECORD_FIELD );
609             XmlUtil.endElement( strXml, TAG_LIST_RECORD_FIELD );
610             XmlUtil.endElement( strXml, Entry.TAG_ENTRY );
611         }
612 
613         if ( bDisplayDateModification )
614         {
615             HashMap<String, String> modelModificationDate = new HashMap<String, String>( );
616             modelModificationDate.put( Entry.ATTRIBUTE_ENTRY_ID, "0" );
617             XmlUtil.beginElement( strXml, Entry.TAG_ENTRY, modelModificationDate );
618             XmlUtil.beginElement( strXml, TAG_LIST_RECORD_FIELD );
619             XmlUtil.beginElement( strXml, TAG_RECORD_FIELD );
620             XmlUtil.addElementHtml( strXml, TAG_RECORD_FIELD_VALUE, DateUtil.getDateString( this.getDateModification( ), locale ) );
621             XmlUtil.endElement( strXml, TAG_RECORD_FIELD );
622             XmlUtil.endElement( strXml, TAG_LIST_RECORD_FIELD );
623             XmlUtil.endElement( strXml, Entry.TAG_ENTRY );
624         }
625 
626         for ( IEntry entry : listEntryResultSearch )
627         {
628             if ( entry.getEntryType( ).getGroup( ) && ( entry.getChildren( ) != null ) )
629             {
630                 for ( IEntry entryChildren : entry.getChildren( ) )
631                 {
632                     if ( !entryChildren.getEntryType( ).getComment( ) )
633                     {
634                         getXmlListRecordField( entryChildren, strXml, plugin, locale, bWithHtmlCode,
635                                 mapEntryRecordFields.get( Integer.toString( entryChildren.getIdEntry( ) ) ), bDisplayTitleEntryTypeSelect, bDisplayFront,
636                                 bDisplayExport );
637                     }
638                 }
639             }
640             else
641                 if ( !entry.getEntryType( ).getComment( ) )
642                 {
643                     getXmlListRecordField( entry, strXml, plugin, locale, bWithHtmlCode, mapEntryRecordFields.get( Integer.toString( entry.getIdEntry( ) ) ),
644                             bDisplayTitleEntryTypeSelect, bDisplayFront, bDisplayExport );
645                 }
646         }
647 
648         XmlUtil.endElement( strXml, Entry.TAG_LIST_ENTRY );
649         XmlUtil.endElement( strXml, TAG_RECORD );
650 
651         return strXml;
652     }
653 
654     /**
655      * {@inheritDoc}
656      */
657     @Override
658     public String getIdExtendableResource( )
659     {
660         return Integer.toString( getIdRecord( ) );
661     }
662 
663     /**
664      * {@inheritDoc}
665      */
666     @Override
667     public String getExtendableResourceType( )
668     {
669         return EXTENDABLE_RESOURCE_TYPE;
670     }
671 
672     /**
673      * {@inheritDoc}
674      */
675     @Override
676     public String getExtendableResourceName( )
677     {
678         return Integer.toString( getIdRecord( ) );
679     }
680 
681     /**
682      * {@inheritDoc}
683      */
684     @Override
685     public String getExtendableResourceDescription( )
686     {
687         return Integer.toString( getIdRecord( ) );
688     }
689 
690     /**
691      * {@inheritDoc}
692      */
693     @Override
694     public String getExtendableResourceImageUrl( )
695     {
696         if ( ( _listRecordField != null ) && ( _listRecordField.size( ) > 0 ) )
697         {
698             RecordField recordFieldImage = null;
699 
700             for ( RecordField recordField : _listRecordField )
701             {
702                 if ( recordField.isBigThumbnail( ) )
703                 {
704                     // If we find a big thumbnail, we return its URL
705                     recordFieldImage = recordField;
706 
707                     break;
708                 }
709                 else
710                     if ( recordField.isLittleThumbnail( ) )
711                     {
712                         // If we find a little thumbnail, we return its URL unless we find a big thumbnail
713                         recordFieldImage = recordField;
714                     }
715             }
716 
717             if ( recordFieldImage != null )
718             {
719                 return FileImgService.getResourceImageEntryUrlWhitoutEntities( recordFieldImage.getFile( ).getIdFile( ) );
720             }
721         }
722 
723         return null;
724     }
725 }