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