Changeset 24891

Show
Ignore:
Timestamp:
13.12.2011 10:04:04 (8 years ago)
Author:
sjm84
Message:

Added the ability to perform a raw query (a query whose arguments are not parsed in any way)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2FieldSearch.java

    r24856 r24891  
    3939abstract public class AbstractGS2FieldSearch extends AbstractGS2TextSearch 
    4040{ 
    41  
    4241    // extra services offered by mgpp collections 
    4342    protected static final String FIELD_QUERY_SERVICE = "FieldQuery"; 
    4443    protected static final String ADVANCED_FIELD_QUERY_SERVICE = "AdvancedFieldQuery"; 
     44    protected static final String RAW_QUERY_SERVICE = "RawQuery"; 
    4545 
    4646    // extra parameters used 
     
    5151    protected static final String SIMPLE_FIELD_PARAM = "simpleField"; 
    5252    protected static final String ADVANCED_FIELD_PARAM = "complexField"; 
     53 
     54    protected static final String RAW_PARAM = "rawquery"; 
    5355 
    5456    // more params for field query 
     
    6870    protected static final String SEARCH_TYPE_SIMPLE_FORM = "simpleform"; 
    6971    protected static final String SEARCH_TYPE_ADVANCED_FORM = "advancedform"; 
     72    protected static final String SEARCH_TYPE_RAW = "raw"; 
    7073 
    7174    protected static final String DEFAULT_LEVEL_ELEM = "defaultLevel"; 
     
    7780    protected static final int SIMPLE_QUERY = 1; 
    7881    protected static final int ADVANCED_QUERY = 2; 
     82    protected static final int RAW_QUERY = 3; 
    7983 
    8084    protected String AND_OPERATOR = "&"; 
     
    9094    protected boolean simple_form_search = false; 
    9195    protected boolean advanced_form_search = false; 
     96    protected boolean raw_search = true; 
    9297 
    9398    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.AbstractGS2FieldSearch.class.getName()); 
     
    166171                        this.advanced_form_search = true; 
    167172                    } 
     173                    else if (type_name.equals(SEARCH_TYPE_RAW)) 
     174                    { 
     175                        this.raw_search = true; 
     176                    } 
    168177                } 
    169178            } 
     
    242251        } 
    243252 
     253        if (this.raw_search) 
     254        { 
     255            Element rq_service = this.doc.createElement(GSXML.SERVICE_ELEM); 
     256            rq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 
     257            rq_service.setAttribute(GSXML.NAME_ATT, RAW_QUERY_SERVICE); 
     258            this.short_service_info.appendChild(rq_service); 
     259 
     260            if (format_info != null) 
     261            { 
     262                this.format_info_map.put(RAW_QUERY_SERVICE, format_info); 
     263            } 
     264        } 
     265 
    244266        return true; 
    245267    } 
     
    249271        // should we check that the service is actually on offer? presumably we wont get asked for services that we haven't advertised previously. 
    250272 
    251         if (!service_id.equals(FIELD_QUERY_SERVICE) && !service_id.equals(ADVANCED_FIELD_QUERY_SERVICE)) 
     273        if (!service_id.equals(FIELD_QUERY_SERVICE) && !service_id.equals(ADVANCED_FIELD_QUERY_SERVICE) && !service_id.equals(RAW_QUERY_SERVICE)) 
    252274        { 
    253275            return super.getServiceDescription(service_id, lang, subset); 
     
    295317 
    296318            } 
    297             else 
     319            else if (service_id.equals(ADVANCED_FIELD_QUERY_SERVICE)) 
    298320            { 
    299321                createParameter(LEVEL_PARAM, param_list, lang); 
     
    335357                createParameter(FIELD_FIELD_PARAM, multiparam, lang); 
    336358 
     359            } 
     360            else if (service_id.equals(RAW_QUERY_SERVICE)) 
     361            { 
     362                if (does_chunking) 
     363                { 
     364                    createParameter(MAXDOCS_PARAM, param_list, lang); 
     365                } 
     366                if (does_paging) 
     367                { 
     368                    createParameter(HITS_PER_PAGE_PARAM, param_list, lang); 
     369                    createParameter(START_PAGE_PARAM, param_list, lang); 
     370                } 
     371                createParameter(RAW_PARAM, param_list, lang); 
     372                service.appendChild(param_list); 
    337373            } 
    338374        } 
     
    477513    { 
    478514        return processAnyQuery(request, ADVANCED_QUERY); 
     515    } 
     516 
     517    protected Element processRawQuery(Element request) 
     518    { 
     519        return processAnyQuery(request, RAW_QUERY); 
    479520    } 
    480521 
     
    499540            empty_query_test_param = FIELD_QUERY_PARAM; 
    500541            break; 
     542        case RAW_QUERY: 
     543            service_name = RAW_QUERY_SERVICE; 
     544            empty_query_test_param = RAW_PARAM; 
     545            break; 
    501546        default: 
    502547            // should never get here