Commits

Paola Morales  committed 0cfecce
  • Participants
  • Parent commits e828907

Comments (0)

Files changed (3)

File encuestame-business/src/main/java/org/encuestame/business/service/AbstractIndexService.java

 
 package org.encuestame.business.service;
 
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.queryParser.ParseException;
 import org.encuestame.business.search.AttachmentSearchItem;
+import org.encuestame.business.search.GlobalSearchItem;
+import org.encuestame.business.search.UtilConvertToSearchItems;
 import org.encuestame.core.util.ConvertDomainBean;
+import org.encuestame.persistence.domain.Attachment;
 import org.encuestame.persistence.domain.HashTag;
 import org.encuestame.persistence.domain.question.Question;
 import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
     }
 
 
-    public List<AttachmentSearchItem> getAttachmentItem(final String keyword){
-        //getSearchOperation().search(queryText, max, field)
-        return new ArrayList<AttachmentSearchItem>();
+    public List<AttachmentSearchItem> getAttachmentItem(final String keyword, final int maxResults, final String field) throws IOException, ParseException{
+        final List<Document> attachItems = getSearchOperation().search(keyword, maxResults, field);
+        return this.convertDocumentToListAttachment(attachItems);
     }
 
     /**
     public void setSearchOperation(SearchManagerOperation searchOperation) {
         this.searchOperation = searchOperation;
     }
+
+    /**
+     * Convert Document Lucene List to Attachment Search Item List.
+     * @param docAttach Attachment
+     * @return
+     */
+    public static final  List<AttachmentSearchItem> convertDocumentToListAttachment(final List<Document> docAttach) {
+        final List<AttachmentSearchItem> attachmentItems = new ArrayList<AttachmentSearchItem>();
+          for (Document item : docAttach) {
+            attachmentItems.add(convertDoctoSearchItem(item));
+          }
+         return attachmentItems;
+    }
+
+    /**
+     * Convert Lucene Document Item to Attachment Search Bean.
+     * @param docItem Lucene Document
+     * @return
+     */
+    public static final AttachmentSearchItem convertDoctoSearchItem(final Document document){
+        final AttachmentSearchItem attachItem = new AttachmentSearchItem();
+        attachItem.setAttachId(1L);
+        attachItem.setDescription(document.get("filename"));
+        return attachItem;
+    }
 }
+

File encuestame-business/src/main/java/org/encuestame/business/service/SearchService.java

  */
 package org.encuestame.business.service;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedList;
 import org.apache.commons.collections.set.ListOrderedSet;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.queryParser.ParseException;
 import org.encuestame.business.search.AttachmentSearchItem;
 import org.encuestame.business.search.GlobalSearchItem;
 import org.encuestame.business.search.UtilConvertToSearchItems;
      */
     public List<GlobalSearchItem> quickSearch(final String keyword,
             String language, final Integer start, final Integer limit)
-            throws EnMeNoResultsFoundException {
+            throws EnMeNoResultsFoundException, IOException, ParseException {
         HashSet<GlobalSearchItem> hashset = new java.util.HashSet<GlobalSearchItem>();
 
 
         .convertHashTagToSearchItem(getHashTagDao().getListHashTagsByKeyword(keyword, limit));
 
         final List<GlobalSearchItem> attachments = UtilConvertToSearchItems
-                                    .convertAttachmentSearchToSearchItem(getAttachmentItem(keyword));
+                                    .convertAttachmentSearchToSearchItem(getAttachmentItem(keyword, 10, "content"));
 
         log.debug("questionResult " + questionResult.size());
         log.debug("profiles " + profiles.size());

File encuestame-business/src/main/java/org/encuestame/business/service/imp/SearchServiceOperations.java

  */
 package org.encuestame.business.service.imp;
 
+import java.io.IOException;
 import java.util.List;
 
+import org.apache.lucene.queryParser.ParseException;
 import org.encuestame.business.search.GlobalSearchItem;
 import org.encuestame.business.search.IndexerManager;
 import org.encuestame.core.service.ServiceOperations;
      */
     List<GlobalSearchItem> quickSearch(final String keyword,
             final String language, final Integer start, final Integer limit)
-            throws EnMeNoResultsFoundException;
+            throws EnMeNoResultsFoundException, IOException, ParseException ;
 
     /**
      *