View Javadoc
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  
36  import org.apache.lucene.document.Document;
37  
38  /**
39   * Search Item
40   */
41  public class SearchItem
42  {
43      public static final String FIELD_UID = "uid";
44      public static final String FIELD_CONTENTS = "contents";
45      public static final String FIELD_TITLE = "title";
46      public static final String FIELD_SUMMARY = "summary";
47      public static final String FIELD_METADATA = "metadata";
48      public static final String FIELD_URL = "url";
49      public static final String FIELD_DATE = "date";
50      public static final String FIELD_TYPE = "type";
51      public static final String FIELD_ROLE = "role";
52      public static final String FIELD_STATE = "state";
53      public static final String FIELD_DOCUMENT_PORTLET_ID = "document_portlet_id";
54  
55      // Variables declarations
56      private String _strId;
57      private String _strTitle;
58      private String _strSummary;
59      private String _strMetadata;
60      private String _strUrl;
61      private String _strLastModifiedDate;
62      private String _strType;
63      private String _strRole;
64      private String _strState;
65      private String _strDocPortletId;
66  
67      /**
68       * Constructor
69       * 
70       * @param document
71       *            The document retrieved by the search
72       */
73      public SearchItem( Document document )
74      {
75          _strId = document.get( FIELD_UID );
76          _strTitle = document.get( FIELD_TITLE );
77          _strUrl = document.get( FIELD_URL );
78          _strSummary = document.get( FIELD_SUMMARY );
79          _strMetadata = document.get( FIELD_METADATA );
80          _strLastModifiedDate = document.get( FIELD_DATE );
81          _strType = document.get( FIELD_TYPE );
82          _strDocPortletId = document.get( FIELD_DOCUMENT_PORTLET_ID );
83          _strRole = document.get( FIELD_ROLE );
84      }
85  
86      /**
87       * Returns the Id
88       *
89       * @return The Id
90       */
91      public String getId( )
92      {
93          return _strId;
94      }
95  
96      /**
97       * Sets the Id
98       *
99       * @param strId
100      *            The Id
101      */
102     public void setId( String strId )
103     {
104         _strId = strId;
105     }
106 
107     /**
108      * Returns the DocPortletId
109      *
110      * @return The DocPortletId
111      */
112     public String getDocPortletId( )
113     {
114         return _strDocPortletId;
115     }
116 
117     /**
118      * Sets the DocPortletId
119      *
120      * @param strDocPortletId
121      *            The DocPortletId
122      */
123     public void setDocPortletId( String strDocPortletId )
124     {
125         _strDocPortletId = strDocPortletId;
126     }
127 
128     /**
129      * Returns the Title
130      *
131      * @return The Title
132      */
133     public String getTitle( )
134     {
135         return _strTitle;
136     }
137 
138     /**
139      * Sets the Title
140      *
141      * @param strTitle
142      *            The Title
143      */
144     public void setTitle( String strTitle )
145     {
146         _strTitle = strTitle;
147     }
148 
149     /**
150      * Returns the Summary
151      *
152      * @return The Summary
153      */
154     public String getSummary( )
155     {
156         return ( _strSummary != null ) ? _strSummary : "";
157     }
158 
159     /**
160      * Sets the Summary
161      *
162      * @param strSummary
163      *            The Summary
164      */
165     public void setSummary( String strSummary )
166     {
167         _strSummary = strSummary;
168     }
169 
170     /**
171      * Returns the meta data
172      *
173      * @return The meta data
174      */
175     public String getMetadata( )
176     {
177         return ( _strMetadata != null ) ? _strMetadata : "";
178     }
179 
180     /**
181      * Sets the meta data
182      *
183      * @param strMetadata
184      *            The meta data
185      */
186     public void setMetadata( String strMetadata )
187     {
188         _strSummary = strMetadata;
189     }
190 
191     /**
192      * Returns the Url
193      *
194      * @return The Url
195      */
196     public String getUrl( )
197     {
198         return _strUrl;
199     }
200 
201     /**
202      * Sets the Url
203      *
204      * @param strUrl
205      *            The Url
206      */
207     public void setUrl( String strUrl )
208     {
209         _strUrl = strUrl;
210     }
211 
212     /**
213      * Returns the LastModifiedDate
214      *
215      * @return The LastModifiedDate
216      */
217     public String getDate( )
218     {
219         return ( _strLastModifiedDate != null ) ? _strLastModifiedDate : "";
220     }
221 
222     /**
223      * Sets the LastModifiedDate
224      *
225      * @param strLastModifiedDate
226      *            The LastModifiedDate
227      */
228     public void setDate( String strLastModifiedDate )
229     {
230         _strLastModifiedDate = strLastModifiedDate;
231     }
232 
233     /**
234      * Returns the Type
235      *
236      * @return The Type
237      */
238     public String getType( )
239     {
240         return _strType;
241     }
242 
243     /**
244      * Sets the Type
245      *
246      * @param strType
247      *            The Type
248      */
249     public void setType( String strType )
250     {
251         _strType = strType;
252     }
253 
254     /**
255      * Return the role of the document
256      * 
257      * @return the role of the document
258      */
259     public String getRole( )
260     {
261         return _strRole;
262     }
263 
264     /**
265      * Sets the role of the document
266      * 
267      * @param role
268      *            the role of the document
269      */
270     public void setRole( String role )
271     {
272         _strRole = role;
273     }
274 
275     /**
276      * Return the state of the document
277      * 
278      * @return the state of the document
279      */
280     public String getState( )
281     {
282         return _strState;
283     }
284 
285     /**
286      * Sets the state of the document
287      * 
288      * @param state
289      *            of the document
290      */
291     public void setState( String state )
292     {
293         _strState = state;
294     }
295 }