source: vlo/branches/vlo-2.13-param/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/pages/HtmlFormCreator.java @ 2627

Last change on this file since 2627 was 2627, checked in by keeloo, 11 years ago

Fixed a few tests, moved the SearchResultsDao? method to the init
method of the WebApplication? class. Tested the web application.

From now on, it is possible to override an optional external
configuration file in the context segment by a context definition of
the solrUrl parameter.

Removed parameters from application properties, removed application
properties files themselves, removed unused configuration files and
context segments, and finally: removed Spring dependencies.

  • Property svn:mime-type set to text/plain
File size: 1.8 KB
Line 
1package eu.clarin.cmdi.vlo.pages;
2
3import eu.clarin.cmdi.vlo.config.VloConfig;
4import java.io.UnsupportedEncodingException;
5import java.util.Iterator;
6import java.util.List;
7import java.util.Map;
8import net.sf.json.JSONArray;
9import net.sf.json.JSONObject;
10
11/**
12 * Little helper class that creates HTML forms as String
13 *
14 * @author Thomas Eckart
15 *
16 */
17public class HtmlFormCreator {
18        /**
19         * Creates an HTML form for the content search (FCS).
20         * @param aggregationContextMap Mapping CQL endpoint -> List of resource IDs
21         * @return HTML content search form as String
22         * @throws UnsupportedEncodingException
23         */
24        public static String getContentSearchForm(Map<String, List<String>> aggregationContextMap) throws UnsupportedEncodingException {
25                JSONObject aggregationJson = new JSONObject();
26                Iterator<String> aggregationContextIter = aggregationContextMap.keySet().iterator();
27                while(aggregationContextIter.hasNext()) {
28                        String endpoint = aggregationContextIter.next();
29                        JSONArray idArray = new JSONArray();
30                        for(String id : aggregationContextMap.get(endpoint)) {
31                                idArray.add(id);
32                        }
33                        aggregationJson.put(endpoint, idArray);
34                }               
35               
36                String form = "<form method=\"post\" action=\""+VloConfig.get().getFederatedContentSearchUrl()+"\"> \n"
37                                + "<fieldset style=\"border:0px;\"> \n"
38                                + "\t  <label for=\"query\">CQL query:</label> \n"
39                                + "\t <input id=\"query\" type=\"text\" name=\"query\" size=\"30\" /> \n"
40                                + "\t <input type=\"hidden\" name=\"x-aggregation-context\" value=\'"+aggregationJson.toString(2)+"\' /> \n"
41                                + "\t <input type=\"hidden\" name=\"operation\" value=\"searchRetrieve\" /> \n"
42                                + "\t <input type=\"hidden\" name=\"version\" value=\"1.2\" /> \n"
43                                + "\t <input type=\"submit\" value=\"Send query\" /> \n"
44                                + "</fieldset> \n"
45                                + "</form> \n";
46                return form;   
47        }
48}
Note: See TracBrowser for help on using the repository browser.