SearchItem.java

  1. /*
  2.  * Copyright (c) 2002-2022, 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.portal.service.search;

  35. import org.apache.lucene.document.Document;

  36. /**
  37.  * Search Item
  38.  */
  39. public class SearchItem
  40. {
  41.     public static final String FIELD_UID = "uid";
  42.     public static final String FIELD_CONTENTS = "contents";
  43.     public static final String FIELD_TITLE = "title";
  44.     public static final String FIELD_SUMMARY = "summary";
  45.     public static final String FIELD_METADATA = "metadata";
  46.     public static final String FIELD_URL = "url";
  47.     public static final String FIELD_DATE = "date";
  48.     public static final String FIELD_TYPE = "type";
  49.     public static final String FIELD_ROLE = "role";
  50.     public static final String FIELD_STATE = "state";
  51.     public static final String FIELD_DOCUMENT_PORTLET_ID = "document_portlet_id";

  52.     // Variables declarations
  53.     private String _strId;
  54.     private String _strTitle;
  55.     private String _strSummary;
  56.     private String _strMetadata;
  57.     private String _strUrl;
  58.     private String _strLastModifiedDate;
  59.     private String _strType;
  60.     private String _strRole;
  61.     private String _strState;
  62.     private String _strDocPortletId;

  63.     /**
  64.      * Constructor
  65.      *
  66.      * @param document
  67.      *            The document retrieved by the search
  68.      */
  69.     public SearchItem( Document document )
  70.     {
  71.         _strId = document.get( FIELD_UID );
  72.         _strTitle = document.get( FIELD_TITLE );
  73.         _strUrl = document.get( FIELD_URL );
  74.         _strSummary = document.get( FIELD_SUMMARY );
  75.         _strMetadata = document.get( FIELD_METADATA );
  76.         _strLastModifiedDate = document.get( FIELD_DATE );
  77.         _strType = document.get( FIELD_TYPE );
  78.         _strDocPortletId = document.get( FIELD_DOCUMENT_PORTLET_ID );
  79.         _strRole = document.get( FIELD_ROLE );
  80.     }

  81.     /**
  82.      * Returns the Id
  83.      *
  84.      * @return The Id
  85.      */
  86.     public String getId( )
  87.     {
  88.         return _strId;
  89.     }

  90.     /**
  91.      * Sets the Id
  92.      *
  93.      * @param strId
  94.      *            The Id
  95.      */
  96.     public void setId( String strId )
  97.     {
  98.         _strId = strId;
  99.     }

  100.     /**
  101.      * Returns the DocPortletId
  102.      *
  103.      * @return The DocPortletId
  104.      */
  105.     public String getDocPortletId( )
  106.     {
  107.         return _strDocPortletId;
  108.     }

  109.     /**
  110.      * Sets the DocPortletId
  111.      *
  112.      * @param strDocPortletId
  113.      *            The DocPortletId
  114.      */
  115.     public void setDocPortletId( String strDocPortletId )
  116.     {
  117.         _strDocPortletId = strDocPortletId;
  118.     }

  119.     /**
  120.      * Returns the Title
  121.      *
  122.      * @return The Title
  123.      */
  124.     public String getTitle( )
  125.     {
  126.         return _strTitle;
  127.     }

  128.     /**
  129.      * Sets the Title
  130.      *
  131.      * @param strTitle
  132.      *            The Title
  133.      */
  134.     public void setTitle( String strTitle )
  135.     {
  136.         _strTitle = strTitle;
  137.     }

  138.     /**
  139.      * Returns the Summary
  140.      *
  141.      * @return The Summary
  142.      */
  143.     public String getSummary( )
  144.     {
  145.         return ( _strSummary != null ) ? _strSummary : "";
  146.     }

  147.     /**
  148.      * Sets the Summary
  149.      *
  150.      * @param strSummary
  151.      *            The Summary
  152.      */
  153.     public void setSummary( String strSummary )
  154.     {
  155.         _strSummary = strSummary;
  156.     }

  157.     /**
  158.      * Returns the meta data
  159.      *
  160.      * @return The meta data
  161.      */
  162.     public String getMetadata( )
  163.     {
  164.         return ( _strMetadata != null ) ? _strMetadata : "";
  165.     }

  166.     /**
  167.      * Sets the meta data
  168.      *
  169.      * @param strMetadata
  170.      *            The meta data
  171.      */
  172.     public void setMetadata( String strMetadata )
  173.     {
  174.         _strSummary = strMetadata;
  175.     }

  176.     /**
  177.      * Returns the Url
  178.      *
  179.      * @return The Url
  180.      */
  181.     public String getUrl( )
  182.     {
  183.         return _strUrl;
  184.     }

  185.     /**
  186.      * Sets the Url
  187.      *
  188.      * @param strUrl
  189.      *            The Url
  190.      */
  191.     public void setUrl( String strUrl )
  192.     {
  193.         _strUrl = strUrl;
  194.     }

  195.     /**
  196.      * Returns the LastModifiedDate
  197.      *
  198.      * @return The LastModifiedDate
  199.      */
  200.     public String getDate( )
  201.     {
  202.         return ( _strLastModifiedDate != null ) ? _strLastModifiedDate : "";
  203.     }

  204.     /**
  205.      * Sets the LastModifiedDate
  206.      *
  207.      * @param strLastModifiedDate
  208.      *            The LastModifiedDate
  209.      */
  210.     public void setDate( String strLastModifiedDate )
  211.     {
  212.         _strLastModifiedDate = strLastModifiedDate;
  213.     }

  214.     /**
  215.      * Returns the Type
  216.      *
  217.      * @return The Type
  218.      */
  219.     public String getType( )
  220.     {
  221.         return _strType;
  222.     }

  223.     /**
  224.      * Sets the Type
  225.      *
  226.      * @param strType
  227.      *            The Type
  228.      */
  229.     public void setType( String strType )
  230.     {
  231.         _strType = strType;
  232.     }

  233.     /**
  234.      * Return the role of the document
  235.      *
  236.      * @return the role of the document
  237.      */
  238.     public String getRole( )
  239.     {
  240.         return _strRole;
  241.     }

  242.     /**
  243.      * Sets the role of the document
  244.      *
  245.      * @param role
  246.      *            the role of the document
  247.      */
  248.     public void setRole( String role )
  249.     {
  250.         _strRole = role;
  251.     }

  252.     /**
  253.      * Return the state of the document
  254.      *
  255.      * @return the state of the document
  256.      */
  257.     public String getState( )
  258.     {
  259.         return _strState;
  260.     }

  261.     /**
  262.      * Sets the state of the document
  263.      *
  264.      * @param state
  265.      *            of the document
  266.      */
  267.     public void setState( String state )
  268.     {
  269.         _strState = state;
  270.     }
  271. }