View Javadoc
1   /*
2    * Copyright (C) 2003-2013 eXo Platform SAS.
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU Affero General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU Affero General Public License for more details.
13   *
14   * You should have received a copy of the GNU Affero General Public License
15   * along with this program. If not, see <http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.commons.search.service.search;
18  
19  import java.text.ParseException;
20  import java.text.SimpleDateFormat;
21  import java.util.ArrayList;
22  import java.util.Collection;
23  import java.util.Date;
24  import java.util.List;
25  
26  import org.exoplatform.commons.api.search.SearchServiceConnector;
27  import org.exoplatform.commons.api.search.data.SearchContext;
28  import org.exoplatform.commons.api.search.data.SearchResult;
29  import org.exoplatform.container.xml.InitParams;
30  
31  /**
32   * Created by The eXo Platform SAS
33   * Author : Canh Pham Van
34   *          canhpv@exoplatform.com
35   * Apr 1, 2013  
36   */
37  public class EventSearchConnector extends SearchServiceConnector {
38  
39    public EventSearchConnector(InitParams initParams) {
40      super(initParams);
41      // TODO Auto-generated constructor stub
42    }
43  
44    @Override
45    public Collection<SearchResult> search(SearchContext context,
46                                           String query,
47                                           Collection<String> sites,
48                                           int offset,
49                                           int limit,
50                                           String sort,
51                                           String order) {
52      List<SearchResult> results = new ArrayList<SearchResult>();
53      
54      SimpleDateFormat sdf = new SimpleDateFormat("yyyy/mm/dd");
55      Date createDate = null;
56      try {
57        createDate = sdf.parse("2013/03/29");
58      } catch (ParseException e) {
59        // TODO Auto-generated catch block
60      }    
61      
62      SearchResult result1 = new SearchResult("calendar/details/Eventc4b1f07e7f0001010101c2cdd3cc2f8c"
63                                             , "Unitest seminar"                                           
64                                             , "Unitest seminar more detail"
65                                             , "Root Root - Monday, April 1, 2013 8:30 PM", null, createDate.getTime(), 587);
66          
67      Date createDate1 = null;
68      try {
69        createDate1 = sdf.parse("2013/04/01");
70      } catch (ParseException e) {
71        // TODO Auto-generated catch block
72      }     
73      
74      SearchResult result2 = new SearchResult("calendar/details/Eventc4b1f07e7f0001010101c2cdd3cc2f8d"
75                                             , "Unitest seminar 1"                                           
76                                             , "Unitest seminar more detail 1"
77                                             , "Root Root - Monday, April 1, 2013 8:30 PM", null, createDate1.getTime(), 587);
78      
79      results.add(result1);
80      results.add(result2);
81      
82      return results;
83    }
84  
85  }