package roart.service;

import roart.service.ServiceParam.Function;
import roart.util.EurekaConstants;
import roart.util.EurekaUtil;

import javax.servlet.http.*;

import java.util.Vector;
import java.util.Enumeration;
import java.util.ArrayList;
import java.util.List;
import java.io.*;

import roart.common.searchengine.SearchEngineSearchParam;
import roart.common.searchengine.SearchEngineSearchResult;
import roart.config.ConfigConstants;
import roart.config.MyConfig;
import roart.config.NodeConfig;
import roart.model.ResultItem;
import roart.model.SearchDisplay;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.vaadin.ui.UI;

public class SearchService {
    private Logger log = LoggerFactory.getLogger(this.getClass());

    public void searchme(String str, String type) {
        SearchEngineSearchParam param = new SearchEngineSearchParam();
        param.conf = getConfig();
        param.str = str;
	// TODO fix
        //param .type = type;
        SearchEngineSearchResult result = EurekaUtil.sendMe(SearchEngineSearchResult.class, param, getAppName(), EurekaConstants.SEARCH);
        return;           
    }

    // TODO fix
	public static SearchDisplay getSearchDisplay(UI ui) {
	    SearchDisplay d = new SearchDisplay();
	    d.highlightmlt = true;
	    d.classify = true;
	    d.admindisplay = true;
	    return d;
	}

	public static boolean isHighlightMLT() {
		return MyConfig.conf.getHighlightmlt();
	}
    
    public void searchsimilar(String md5) {
        SearchEngineSearchParam param = new SearchEngineSearchParam();
        param.conf = getConfig();
        param.str = md5;
        SearchEngineSearchResult result = EurekaUtil.sendMe(SearchEngineSearchResult.class, param, getAppName(), EurekaConstants.SEARCHMLT);
        return;           
    }

    private String getAppName() {
	return EurekaConstants.AETHER;
    }
    
    private NodeConfig getConfig() {
        return MyConfig.conf;
    }


}

@@ -752,28 +752,28 @@
 %0A    public 
-void
+List
  searchme(St
@@ -931,38 +931,28 @@
 tr;%0A
-%09// TODO fix%0A
+  
       
-  //
 param
- 
 .
+search
 type
@@ -1098,16 +1098,58 @@
 EARCH);%0A
+        List lists = result.list;        %0A
         
@@ -1146,32 +1146,38 @@
  %0A        return
+ lists
 ;           %0A   

Return result.