package ikube.web.admin;

import ikube.IConstants;
import ikube.model.Server;

import java.util.ArrayList;
import java.util.HashMap;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author Michael Couck
 * @since 15.05.2011
 * @version 01.00
 */
@Controller
public class GeoSearchController extends SearchBaseController {

	@RequestMapping(value = "/admin/geosearch.html", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView search(@RequestParam(required = true, value = "indexName") String indexName,
			@RequestParam(required = true, value = "searchStrings") String searchStrings,
			@RequestParam(required = true, value = "latitude") Double latitude,
			@RequestParam(required = true, value = "longitude") Double longitude,
			@RequestParam(required = true, value = "distance") Integer distance,
			@RequestParam(required = true, value = "firstResult") Integer firstResult,
			@RequestParam(required = true, value = "maxResults") Integer maxResults,
			@RequestParam(required = true, value = "targetSearchUrl") String targetSearchUrl, ModelAndView model) throws Exception {

		Server server = clusterManager.getServer();
		model.setViewName("/admin/geosearch");

		model.addObject(IConstants.LONGITUDE, longitude);
		model.addObject(IConstants.LATITUDE, latitude);
		model.addObject(IConstants.DISTANCE, distance);

		if (indexName != null) {
			ArrayList<HashMap<String, String>> results = searcherWebService.searchMultiSpacialAll(indexName,
					new String[] { searchStrings }, Boolean.TRUE, firstResult, maxResults, distance, latitude, longitude);

			HashMap<String, String> statistics = results.get(results.size() - 1);
			String total = statistics.get(IConstants.TOTAL);
			String duration = statistics.get(IConstants.DURATION);
			String corrections = statistics.get(IConstants.CORRECTIONS);

			model.addObject(IConstants.INDEX_NAME, indexName);
			model.addObject(IConstants.TOTAL, total);
			model.addObject(IConstants.DURATION, duration);
			model.addObject(IConstants.RESULTS, results);
			model.addObject(IConstants.CORRECTIONS, corrections);
		}

		model.addObject(IConstants.SEARCH_STRINGS, searchStrings);
		model.addObject(IConstants.TARGET_SEARCH_URL, targetSearchUrl);

		model.addObject(IConstants.FIRST_RESULT, firstResult);
		model.addObject(IConstants.MAX_RESULTS, maxResults);

		model.addObject(IConstants.SERVER, server);
		return model;
	}

}
@@ -736,35 +736,36 @@
 aram(required = 
-tru
+fals
 e, value = %22inde
@@ -811,35 +811,36 @@
 aram(required = 
-tru
+fals
 e, value = %22sear
@@ -894,35 +894,36 @@
 aram(required = 
-tru
+fals
 e, value = %22lati
@@ -967,35 +967,36 @@
 aram(required = 
-tru
+fals
 e, value = %22long
@@ -1042,35 +1042,36 @@
 aram(required = 
-tru
+fals
 e, value = %22dist
@@ -1116,35 +1116,36 @@
 aram(required = 
-tru
+fals
 e, value = %22firs
@@ -1196,35 +1196,36 @@
 aram(required = 
-tru
+fals
 e, value = %22maxR
@@ -1286,11 +1286,12 @@
 d = 
-tru
+fals
 e, v

Made the parameters non required.