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.utils.DirectoryErrorException; 37 import fr.paris.lutece.portal.service.plugin.Plugin; 38 import fr.paris.lutece.portal.web.util.LocalizedPaginator; 39 import fr.paris.lutece.util.ReferenceList; 40 import fr.paris.lutece.util.html.Paginator; 41 42 import org.apache.commons.fileupload.FileItem; 43 44 import java.util.HashMap; 45 import java.util.List; 46 import java.util.Locale; 47 48 import javax.servlet.http.HttpServletRequest; 49 50 /** 51 * 52 * IEntry Class 53 */ 54 public interface IEntry 55 { 56 /** 57 * @return the id of entry 58 */ 59 int getIdEntry( ); 60 61 /** 62 * set the id of the entry 63 * 64 * @param idEntry 65 * the id of the entry 66 */ 67 void setIdEntry( int idEntry ); 68 69 /** 70 * 71 * @return the directory associate to the entry 72 */ 73 Directory getDirectory( ); 74 75 /** 76 * set the directory associate to the entry 77 * 78 * @param directory 79 * the directory associate to the entry 80 */ 81 void setDirectory( Directory directory ); 82 83 /** 84 * @return title entry 85 */ 86 String getTitle( ); 87 88 /** 89 * set title entry 90 * 91 * @param title 92 * title 93 */ 94 void setTitle( String title ); 95 96 /** 97 * @return the entry help message 98 */ 99 String getHelpMessage( ); 100 101 /** 102 * set entry help message 103 * 104 * @param helpMessage 105 * entry helpMessage 106 */ 107 void setHelpMessage( String helpMessage ); 108 109 /** 110 * @return the entry help message for search 111 */ 112 String getHelpMessageSearch( ); 113 114 /** 115 * set the entry help message for search 116 * 117 * @param helpMessage 118 * the entry help message for search 119 */ 120 void setHelpMessageSearch( String helpMessage ); 121 122 /** 123 * @return the entry comment 124 */ 125 String getComment( ); 126 127 /** 128 * set entry comment 129 * 130 * @param comment 131 * entry comment 132 */ 133 void setComment( String comment ); 134 135 /** 136 * @return true if the question is mandatory 137 */ 138 boolean isMandatory( ); 139 140 /** 141 * set true if the question is mandatory 142 * 143 * @param mandatory 144 * true if the question is mandatory 145 */ 146 void setMandatory( boolean mandatory ); 147 148 /** 149 * @return true if the field associate must be display in line 150 */ 151 boolean isFieldInLine( ); 152 153 /** 154 * set true if the field associate must be display in line 155 * 156 * @param fieldInLine 157 * true if the field associate must be display in line 158 */ 159 void setFieldInLine( boolean fieldInLine ); 160 161 /** 162 * @return true if the field must be shown in advanced search 163 */ 164 boolean isShownInAdvancedSearch( ); 165 166 /** 167 * @return true if the field must be shown in result list 168 */ 169 boolean isShownInResultList( ); 170 171 /** 172 * set true if the field must be shown in result list page 173 * 174 * @param shown 175 * true if the entry must be shown in result list page 176 */ 177 void setShownInResultList( boolean shown ); 178 179 /** 180 * @return true if the field must be shown in result record page 181 */ 182 boolean isShownInResultRecord( ); 183 184 /** 185 * set true if the field must be shown in result record page 186 * 187 * @param shown 188 * true if the entry must be shown in result record page 189 */ 190 void setShownInResultRecord( boolean shown ); 191 192 /** 193 * @return true if the field must be shown in result record page 194 */ 195 boolean isShownInHistory( ); 196 197 /** 198 * set true if the field must be shown in history page 199 * 200 * @param shown 201 * true if the entry must be shown in history page 202 */ 203 void setShownInHistory( boolean shown ); 204 205 /** 206 * set true if the field must be shown advanced search 207 * 208 * @param shown 209 * true if the entry must be shown in advanced search 210 */ 211 void setShownInAdvancedSearch( boolean shown ); 212 213 /** 214 * @return true if the field must be shown in data export 215 */ 216 boolean isShownInExport( ); 217 218 /** 219 * set true if the field must be shown in data export 220 * 221 * @param shown 222 * true if the entry must be shown in data export 223 */ 224 void setShownInExport( boolean shown ); 225 226 /** 227 * @return true if the field must be shown in record completeness 228 */ 229 boolean isShownInCompleteness( ); 230 231 /** 232 * set true if the field must be shown record completeness 233 * 234 * @param shown 235 * true if the entry must be shown in record completeness 236 */ 237 void setShownInCompleteness( boolean shown ); 238 239 /** 240 * @return true if the field must be indexed 241 */ 242 boolean isIndexed( ); 243 244 /** 245 * set true if the field must be indexed 246 * 247 * @param indexed 248 * true if the field must be indexed 249 */ 250 void setIndexed( boolean indexed ); 251 252 /** 253 * @return true if the field is (part of) the title of the document in the global index 254 */ 255 boolean isIndexedAsTitle( ); 256 257 /** 258 * set true if the field is (part of) the title of the document in the global index 259 * 260 * @param indexedAsTitle 261 * true if the field is (part of) the title of the document in the global index 262 */ 263 void setIndexedAsTitle( boolean indexedAsTitle ); 264 265 /** 266 * @return true if the field is (part of) the summary of the document in the global index 267 */ 268 boolean isIndexedAsSummary( ); 269 270 /** 271 * set true if the field is (part of) the summary of the document in the global index 272 * 273 * @param indexedAsSummary 274 * true if the field is (part of) the summary of the document in the global index 275 */ 276 void setIndexedAsSummary( boolean indexedAsSummary ); 277 278 /** 279 * @return position entry 280 */ 281 int getPosition( ); 282 283 /** 284 * set position entry 285 * 286 * @param position 287 * position entry 288 */ 289 void setPosition( int position ); 290 291 /** 292 * @return the type of the entry 293 */ 294 EntryType getEntryType( ); 295 296 /** 297 * set the type of the entry 298 * 299 * @param entryType 300 * the type of the entry 301 */ 302 void setEntryType( EntryType entryType ); 303 304 /** 305 * @return the list of field who are associate to the entry 306 */ 307 List<Field> getFields( ); 308 309 /** 310 * set the list of field who are associate to the entry 311 * 312 * @param fields 313 * the list of field 314 */ 315 void setFields( List<Field> fields ); 316 317 /** 318 * @return parent entry if the entry is insert in a group 319 */ 320 IEntry getParent( ); 321 322 /** 323 * set parent entry if the entry is insert in a group 324 * 325 * @param parent 326 * parent entry 327 */ 328 void setParent( IEntry parent ); 329 330 /** 331 * 332 * @return the list of entry who are insert in the group 333 */ 334 List<IEntry> getChildren( ); 335 336 /** 337 * set the list of entry who are insert in the group 338 * 339 * @param children 340 * the list of entry 341 */ 342 void setChildren( List<IEntry> children ); 343 344 /** 345 * @return true if the entry is the last entry of a group or the list of entry 346 */ 347 boolean isLastInTheList( ); 348 349 /** 350 * set true if the entry is the last entry of a group or the list of entry 351 * 352 * @param lastInTheList 353 * true if the entry is the last entry of a group or the list of entry 354 */ 355 void setLastInTheList( boolean lastInTheList ); 356 357 /** 358 * @return true if the entry is the first entry of a group or the list of entry 359 */ 360 boolean isFirstInTheList( ); 361 362 /** 363 * set true if the entry is the first entry of a group or the list of entry 364 * 365 * @param firstInTheList 366 * true if the entry is the last entry of a group or the list of entry 367 */ 368 void setFirstInTheList( boolean firstInTheList ); 369 370 /** 371 * 372 * @return the width of the entry 373 */ 374 int getDisplayWidth( ); 375 376 /** 377 * set the width of the entry 378 * 379 * @param width 380 * width of the entry 381 */ 382 void setDisplayWidth( int width ); 383 384 /** 385 * 386 * @return the height of the entry 387 */ 388 int getDisplayHeight( ); 389 390 /** 391 * set the height of the entry 392 * 393 * @param height 394 * the height of the entry 395 */ 396 void setDisplayHeight( int height ); 397 398 /** 399 * 400 * @return true if a role can be associated with a item 401 */ 402 boolean isRoleAssociated( ); 403 404 /** 405 * set true if a role can be associated with a item 406 * 407 * @param bRoleAssociated 408 * true if a role can be associated with a item 409 */ 410 void setRoleAssociated( boolean bRoleAssociated ); 411 412 /** 413 * 414 * @return true if a workgroup can be associated with a item 415 */ 416 boolean isWorkgroupAssociated( ); 417 418 /** 419 * set true if a workgroup can be associated with a item 420 * 421 * @param bWorkGroupAssociated 422 * true if a workgroup can be associated with a item 423 */ 424 void setWorkgroupAssociated( boolean bWorkGroupAssociated ); 425 426 /** 427 * 428 * @return true if the entry is display with Multiple search field 429 */ 430 boolean isMultipleSearchFields( ); 431 432 /** 433 * set true if the entry is display with Multiple search field 434 * 435 * @param multipleSearchFields 436 * true if the entry is display with Multiple search field 437 */ 438 void setMultipleSearchFields( boolean multipleSearchFields ); 439 440 /** 441 * 442 * @return the id entry associed 443 */ 444 int getEntryAssociate( ); 445 446 /** 447 * set id entry is display with Multiple search field 448 * 449 * @param idEntryAssociate 450 * id entry 451 */ 452 void setEntryAssociate( int idEntryAssociate ); 453 454 /** 455 * 456 * @return the request SQL 457 */ 458 String getRequestSQL( ); 459 460 /** 461 * set request SQL 462 * 463 * @param strRequestSQL 464 * request SQL 465 */ 466 void setRequestSQL( String strRequestSQL ); 467 468 /** 469 * 470 * @return true if add value for all search 471 */ 472 boolean isAddValueAllSearch( ); 473 474 /** 475 * set the AddValueAllSearch boolean 476 * 477 * @param bAddValueAllSearch 478 * The AddValueAllSearch boolean 479 */ 480 void setAddValueAllSearch( boolean bAddValueAllSearch ); 481 482 /** 483 * @return true if entry is autocomplete 484 */ 485 boolean isAutocompleteEntry( ); 486 487 /** 488 * set autocomplete entry type 489 * 490 * @param bIsAutocompleEntry 491 */ 492 void setAutocompleteEntry( boolean bIsAutocompleEntry ); 493 494 /** 495 * 496 * @return the label of value for all search 497 */ 498 String getLabelValueAllSearch( ); 499 500 /** 501 * Set the label value all search 502 * 503 * @param strLabelValueAllSearch 504 * The label value all search 505 */ 506 void setLabelValueAllSearch( String strLabelValueAllSearch ); 507 508 /** 509 * Get the request data 510 * 511 * @param request 512 * HttpRequest 513 * @param locale 514 * the locale 515 * @return null if all data requiered are in the request else the url of jsp error 516 */ 517 String getEntryData( HttpServletRequest request, Locale locale ); 518 519 /** 520 * save in the list of record field the record field associate to the entry 521 * 522 * @param record 523 * the record associated to the record field 524 * @param request 525 * HttpRequest 526 * @param bTestDirectoryError 527 * true if the value contains in the request must be tested 528 * @param bAddNewValue 529 * true if add new value 530 * @param listRecordField 531 * the list of record field associate to the record 532 * @param locale 533 * the locale 534 * @throws DirectoryErrorException 535 * If an error occurs 536 */ 537 void getRecordFieldData( Record record, HttpServletRequest request, boolean bTestDirectoryError, boolean bAddNewValue, List<RecordField> listRecordField, 538 Locale locale ) throws DirectoryErrorException; 539 540 /** 541 * save in the list of record field the record field associate to the entry 542 * 543 * @param record 544 * the record associated to the record field 545 * @param listValue 546 * the list which contains the string value of the record field 547 * @param bTestDirectoryError 548 * true if the value contains in the request must be tested 549 * @param bAddNewValue 550 * true if add new value 551 * @param listRecordField 552 * the list of record field associate to the record 553 * @param locale 554 * the locale 555 * @throws DirectoryErrorException 556 * If an error occurs 557 */ 558 void getRecordFieldData( Record record, List<String> listValue, boolean bTestDirectoryError, boolean bAddNewValue, List<RecordField> listRecordField, 559 Locale locale ) throws DirectoryErrorException; 560 561 /** 562 * save in the list of record field the record field associate to the entry 563 * 564 * @param record 565 * the record associated to the record field 566 * @param strImportValue 567 * the import string which contains the string value of the record field 568 * @param bTestDirectoryError 569 * true if the value contains in the request must be tested 570 * @param listRecordField 571 * the list of record field associate to the record 572 * @param locale 573 * the locale 574 * @throws DirectoryErrorException 575 * If an error occurs 576 */ 577 void getImportRecordFieldData( Record record, String strImportValue, boolean bTestDirectoryError, List<RecordField> listRecordField, Locale locale ) 578 throws DirectoryErrorException; 579 580 /** 581 * Get template create url 582 * 583 * @return template create url 584 */ 585 String getTemplateCreate( ); 586 587 /** 588 * Get the template modify url 589 * 590 * @return template modify url 591 */ 592 String getTemplateModify( ); 593 594 /** 595 * The paginator who is use in the template modify of the entry 596 * 597 * @param nItemPerPage 598 * Number of items to display per page 599 * @param strBaseUrl 600 * The base Url for build links on each page link 601 * @param strPageIndexParameterName 602 * The parameter name for the page index 603 * @param strPageIndex 604 * The current page index 605 * @return the paginator who is use in the template modify of the entry 606 */ 607 Paginator getPaginator( int nItemPerPage, String strBaseUrl, String strPageIndexParameterName, String strPageIndex ); 608 609 /** 610 * Get the list of regular expression who is use in the template modify 611 * 612 * @param plugin 613 * the plugin 614 * @param entry 615 * the entry 616 * @return the regular expression list who is use in the template modify 617 */ 618 ReferenceList getReferenceListRegularExpression( IEntry entry, Plugin plugin ); 619 620 /** 621 * Get Html code used in entry form 622 * 623 * @param locale 624 * the locale 625 * @param isDisplayFront 626 * true if the template front or false if the template back 627 * @return html code 628 * 629 * */ 630 String getHtmlFormEntry( Locale locale, boolean isDisplayFront ); 631 632 /** 633 * Get Html code used in entry form 634 * 635 * @param locale 636 * the locale 637 * @param listRecordField 638 * the list of record field associate to the entry 639 * @param isDisplayFront 640 * true if the template front or false if the template back 641 * @return html code 642 * 643 * */ 644 String getHtmlFormEntry( Locale locale, List<RecordField> listRecordField, boolean isDisplayFront ); 645 646 /** 647 * Get Html code used in search form 648 * 649 * @param locale 650 * the locale 651 * @param isDisplayFront 652 * true if the template front or false if the template back 653 * @return html code 654 * 655 * */ 656 String getHtmlFormSearchEntry( Locale locale, boolean isDisplayFront ); 657 658 /** 659 * Get Html code used in search form 660 * 661 * @param locale 662 * the locale 663 * @param listRecordField 664 * the list of record field associate to the entry 665 * @param isDisplayFront 666 * true if the template front or false if the template back 667 * @return html code 668 * 669 * */ 670 String getHtmlFormSearchEntry( Locale locale, List<RecordField> listRecordField, boolean isDisplayFront ); 671 672 /** 673 * Get the Html code used in display records 674 * 675 * @param locale 676 * the locale 677 * @param recordField 678 * the record field associate to the entry 679 * @param isDisplayFront 680 * true if the template front or false if the template back 681 * @return html code 682 * 683 * */ 684 String getHtmlRecordFieldValue( Locale locale, RecordField recordField, boolean isDisplayFront ); 685 686 /** 687 * convert the value contains in the record field to string 688 * 689 * @param recordField 690 * the recordField 691 * @param locale 692 * the locale 693 * @param bDisplayFront 694 * true if display front or false if display back 695 * @param bDisplayExport 696 * true if display export 697 * @return string 698 */ 699 700 String convertRecordFieldValueToString( RecordField recordField, Locale locale, boolean bDisplayFront, boolean bDisplayExport ); 701 702 /** 703 * convert the title contains in the record field to string 704 * 705 * @param recordField 706 * the recordField 707 * @param locale 708 * the locale 709 * @param bDisplayFront 710 * true if display front or false if display back 711 * @return string 712 */ 713 String convertRecordFieldTitleToString( RecordField recordField, Locale locale, boolean bDisplayFront ); 714 715 /** 716 * add in the search map the criteria 717 * 718 * @param recordField 719 * the record field 720 * @param mapSearchItem 721 * Search map 722 * 723 */ 724 void addSearchCriteria( HashMap<String, Object> mapSearchItem, RecordField recordField ); 725 726 /** 727 * add The Xml of the entry in the string buffer 728 * 729 * @param plugin 730 * plugin 731 * @param locale 732 * loclae 733 * @param strXml 734 * the string buffer 735 * 736 */ 737 void getXml( Plugin plugin, Locale locale, StringBuffer strXml ); 738 739 /** 740 * @param record 741 * The record 742 * @param decodedBytes 743 * decoded bytes 744 * @param nomFile 745 * name of file 746 * @param b 747 * flag 748 * @param listRecordField 749 * list of record fields 750 * @param locale 751 * the locale 752 * @throws DirectoryErrorException 753 * directory error exception 754 */ 755 void getImportRecordFieldData( Record record, byte [ ] decodedBytes, String nomFile, boolean b, List<RecordField> listRecordField, Locale locale ) 756 throws DirectoryErrorException; 757 758 /** 759 * Sets the map provider 760 * 761 * @param mapProvider 762 * the map provider 763 */ 764 void setMapProvider( IMapProvider mapProvider ); 765 766 /** 767 * Gets the map provider 768 * 769 * @return the map provider 770 */ 771 IMapProvider getMapProvider( ); 772 773 /** 774 * Check if the entry is sortable 775 * 776 * @return true if it is sortable, false otherwise 777 */ 778 boolean isSortable( ); 779 780 /** 781 * The paginator who is use in the template modify of the entry 782 * 783 * @param nItemPerPage 784 * Number of items to display per page 785 * @param strBaseUrl 786 * The base Url for build links on each page link 787 * @param strPageIndexParameterName 788 * The parameter name for the page index 789 * @param strPageIndex 790 * The current page index 791 * @param locale 792 * Locale 793 * @return the paginator who is use in the template modify of the entry 794 */ 795 LocalizedPaginator getPaginator( int nItemPerPage, String strBaseUrl, String strPageIndexParameterName, String strPageIndex, Locale locale ); 796 797 // SQL PART 798 // ADDED TO SORT LIST WITH BETTER PERFORMANCES 799 /** 800 * Gets the join clause for SQL in case of query order. This function has been added to provide better performances to sort record list. 801 * 802 * @return join clause (i.e <code>" JOIN some_table ON col1=col2 "</code>) 803 * @see #isSortable 804 */ 805 String getSQLJoin( ); 806 807 /** 808 * Gets the order by clause in case of query order. Does not contain ASC or DESC clause (provided by DAO). This function has been added to provide better 809 * performances to sort record list. 810 * 811 * @return order by clause (i.e. <code>" ORDER BY some_column "</code>) 812 * @see #isSortable 813 */ 814 String getSQLOrderBy( ); 815 816 /** 817 * Use with {@link #getSQLJoin()} and {@link #getSQLOrderBy()} to add parameters values 818 * 819 * @return an empty list if no parameter needed, parameters values otherwise. 820 */ 821 List<Object> getSQLParametersValues( ); 822 823 /** 824 * Check if the file can be uploaded or not. This method will check the size of each file and the number max of files that can be uploaded. 825 * 826 * @param listUploadedFileItems 827 * the list of uploaded files 828 * @param listFileItemsToUpload 829 * the list of files to upload 830 * @param locale 831 * the locale 832 * @throws DirectoryErrorException 833 * exception if there is an error 834 */ 835 void canUploadFiles( List<FileItem> listUploadedFileItems, List<FileItem> listFileItemsToUpload, Locale locale ) throws DirectoryErrorException; 836 837 /** 838 * Check if this entry should be anonymized when a record is anonymized. 839 * 840 * @return True if this entry should be anonymized, false otherwise. 841 */ 842 boolean getAnonymize( ); 843 844 /** 845 * Set the anonymize status of an entry. 846 * 847 * @param bAnonymize 848 * True if this entry should be anonymized when a record is anonymized, false otherwise 849 */ 850 void setAnonymize( boolean bAnonymize ); 851 852 /** 853 * Check if entries of this type are anonymizable or not. 854 * 855 * @return True if the entry is anonymizable, false otherwise 856 */ 857 boolean isAnonymizable( ); 858 859 /** 860 * @return the _nNumberRow 861 */ 862 int getNumberRow( ); 863 864 /** 865 * @param nNumberRow 866 * the _nNumberRow to set 867 */ 868 void setNumberRow( int nNumberRow ); 869 870 /** 871 * @return the _nNumberColumn 872 */ 873 int getNumberColumn( ); 874 875 /** 876 * @param nNumberColumn 877 * the _nNumberColumn to set 878 */ 879 void setNumberColumn( int nNumberColumn ); 880 881 String getHtmlFormEntryPopup( Locale locale, List<RecordField> defaultValues, boolean isDisplayFront ); 882 883 String getHtmlListEntry( Locale locale, List<RecordField> defaultValues, boolean isDisplayFront ); 884 885 }