01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.http.webclient.repository.query;
07:
08: import java.util.HashMap;
09: import java.util.Map;
10: import java.util.TreeMap;
11:
12: import javax.servlet.http.HttpServletRequest;
13:
14: import org.springframework.web.servlet.mvc.SimpleFormController;
15:
16: import org.openrdf.query.QueryLanguage;
17: import org.openrdf.query.parser.QueryParserFactory;
18: import org.openrdf.query.parser.QueryParserRegistry;
19:
20: /**
21: * @author Herko ter Horst
22: * @author Arjohn Kampman
23: */
24: public class QueryFormController extends SimpleFormController {
25:
26: @Override
27: protected Map<String, Object> referenceData(
28: HttpServletRequest request) {
29: Map<String, Object> result = new HashMap<String, Object>();
30:
31: Map<String, QueryLanguage> queryLanguages = new TreeMap<String, QueryLanguage>();
32:
33: for (QueryParserFactory factory : QueryParserRegistry
34: .getInstance().getAll()) {
35: QueryLanguage ql = factory.getQueryLanguage();
36: // FIXME: webclient produces an error when the ql name is not upper
37: // cased. Why?
38: queryLanguages.put(ql.getName().toUpperCase(), ql);
39: }
40:
41: result.put("queryLanguages", queryLanguages);
42:
43: return result;
44: }
45: }
|