Changeset 1569 for MDService2


Ignore:
Timestamp:
09/30/11 11:01:52 (13 years ago)
Author:
gaba
Message:

simple changes, exception for CQL parse error added

Location:
MDService2/branches/MDService_simple3
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • MDService2/branches/MDService_simple3/WebContent/scripts/mdservice_model.js

    r1561 r1569  
    206206@class Represents a Query.
    207207*/
    208 function Query(collection, columns, query) {
     208function Query(collection, columns, query, squery) {
    209209        this.id = 0;
    210210        this.collection = collection;   // []
    211211        this.columns = columns;         // string
    212212        this.query = query;              //sctext
    213         //this.squery = squery;
     213        this.squery = squery;
    214214        this.listid = "";
    215215        this.container = {};
     
    313313                this.query = json["querystring"];       
    314314        }
    315         /*
     315
    316316        if (json["squerystring"] == "[NULL]"){
    317317                this.squery = null;
     
    319319                this.squery = json["squerystring"];     
    320320        }
    321         */
     321
    322322        this.columns = columns_text;
    323323       
     
    443443Query.prototype.query_uri = function () {
    444444        var params = "?";
    445         //if (this.query != null) {
    446         //      params = params + "q=" + escape(this.query) + "&";
    447         //}
    448445        if (this.query != null) {
    449                 escaped_sq =escape(this.query).replace(/%20/g,"%2520").replace(/\%2[27]/g,"%2522") ;
     446                params = params + "query=" + escape(this.query) + "&";
     447        }
     448        if (this.squery != null) {
     449                escaped_sq =escape(this.squery).replace(/%20/g,"%2520").replace(/\%2[27]/g,"%2522") ;
    450450                escaped_sq = escaped_sq.replace(/%7C/g,"%257C").replace(/\+/g,"%2B");
    451451                //params = params + "squery=" + escaped_sq + "&";
     
    487487        var str = "";
    488488        var coll = (this.getcollectiontext("name") != "" ) ? " in " + this.getcollectiontext("name") : "";
    489         str = Query.simplequerystring(this.query) + coll + " @" + this.repository.toString();
     489        str = Query.queryliststring(this.squery,this.query) + coll + " @" + this.repository.toString();
    490490        return str;
    491491};
     
    552552                json_cols[i] = cols;
    553553        }
    554 
     554/*
     555        var q = "";
     556        if (this.squery != undefined){
     557                q = q + squery;
     558        }
     559        if (this.query != undefined){
     560                q = q + query;
     561        }
     562*/
    555563        var jsonq = {"id":this.id,
    556564                                 "name":"",
    557                              //"squerystring":this.squery,
    558                                  "querystring":this.query,     
     565                             "squerystring":this.squery,
     566                                 "querystring":query,   
    559567                                 "searchclauses":"null" ,
    560568                                 "collections" : json_coll,
     
    647655Query.fullformatstring = function (json) {
    648656        var qs = json.querystring;
    649         //var sqs = json.squerystring;
     657        var sqs = json.squerystring;
    650658       
    651659        if (qs == "[NULL]") {
    652660                qs = null;
    653661        }
    654         /*
     662       
    655663        if (sqs == "[NULL]") {
    656664                sqs = null;
    657665        }
    658         */
     666       
    659667        var collection_text = Query.collectiontext(json);
    660668       
    661669        var full_str = "";
    662670        var len = formatquerystring_len;
    663         /*
     671       
    664672        if (sqs != null) {
    665673                if (sqs.length > len){
     
    670678                }
    671679        }
    672         */
     680       
    673681        if (qs != null) {
    674682                qs = Query.simplequerystring(qs);
     
    688696        return full_str;
    689697};
    690 /*
     698
    691699Query.queryliststring = function(squery, query) {
    692700        var s_squery = "";
     
    709717        return str;
    710718};
    711 */
     719
    712720Query.simplequerystring = function (querystring) {
    713721
  • MDService2/branches/MDService_simple3/WebContent/scripts/mdservice_searchclause.js

    r1561 r1569  
    569569        },
    570570       
    571         // from searchclauses to querystring
     571        // from searchclauses to simple querystring only * any <string> is converted
    572572        simplequerytext: function(){
    573573                this.buildsctext();
    574                 return sctext.replace('* any ','');
    575         },
     574                if (sctext.substring(0,6) == '* any '){
     575                        return sctext.replace('* any ','');
     576                }
     577                return "";
     578        },
     579       
    576580        buildsctext: function(){
    577581           var uncompletequery = false;
  • MDService2/branches/MDService_simple3/WebContent/scripts/mdservice_ui.js

    r1561 r1569  
    2020                var DEBUG = false;
    2121       
    22                 // check for jQuery and Sarissa
     22                // check for jQuery
    2323                try{
    2424                        jQuery;
     
    2828               
    2929                /////// INIT VARIABLE SETTINGS
    30                 // get url parameters
    3130                url_params = getUrlVars();
    3231                workspace = new Workspace();
    33                 // create searchclauses
    34                 //searchclauseset.addsearchclause(new SearchClause("","",""),"",0,0);
    35                 // load query if exists params
    36                 //loadQueryFromUriParams();     
     32               
    3733                // create widgets
    38                
    3934                columns_widget = new ListWidget($('#columns-widget'), "columns");
    4035                collections_widget = new ListWidget($('#collections-widget'), "collections");
    4136                listwidgetset.add(columns_widget);
    4237                listwidgetset.add(collections_widget);
    43                 createInfos();
    4438               
    4539                //////////// LOAD DATA
    4640                loadData();
    47                 //handleBubble();
    48        
    4941                addFunctionality();
    50                 //addVisuals();
    51                
    52                 //queryuriparams loaded after collections and workspaceprofile are loaded
    53                 //loadQueryFromUriParams();     
    5442               
    5543                ////////////// CREATE  UI-LAYOUT
    5644                createBlock('base','');
    57                 //jQuery.each(blocks_settings,function(index,block){
    58                 //      jQuery.each(block.sublayouts,function(index,name){
    59                 //              createLayouts(name);
    60                 //      });
    61                 //});
    6245                createLayouts('base');
    6346
     47                // ??autocomplete correction
    6448                initDetailFloat();
    65                 // autocomplete correction
    6649                searchclauseset.addsearchclause(new SearchClause("","",""),"",0,0);
    67                 //createInfos();
    68                
     50                createInfos();
    6951                detailcaller.calldetail(undefined, "info");
    7052       
     
    8769
    8870function getSelectedRepository(){
    89         //var id = parseInt($('#repositories_select').find("option:selected").val());
    90         return $('#repositories_select').find("option:selected").text();//val();
    91 
     71        return $('#repositories_select').find("option:selected").text();
    9272}
     73
    9374function getInputMode(){
    9475        if ($('#searchclauselist').is(":visible")){
     
    9778        return 'simple';
    9879}
     80
    9981/**
    10082 * This function is called during the initialization sequence and binds event-handlers to events of ui-elements.
     
    10284 */
    10385function addFunctionality(){
    104         //TODO query-input action not valid (solve in html_snippets.xsl ?)
    105         //$('#query-input').children("form").attr("id","searchretrieve");
    10686       
    10787        //switch the input simple query vs complex query
    108         //$('#searchclauselist').hide();
    10988        $('#switch-input').live('click',function(){
    11089                $('#searchclauselist').toggle();
     
    274253                event.preventDefault();
    275254                //hideWelcomeMessage();
    276                 var query;
     255                var query, squery;
    277256                if (getInputMode() == 'complex'){
    278257                        searchclauseset.buildsctext();
    279258                        query = searchclauseset.sctext;
    280259                } else {
    281                         query = $('#input-simplequery').attr("value");
     260                        squery = $('#input-simplequery').attr("value");
    282261                }
    283262                //searchclauseset.buildsctext();
     
    296275                        query = null;
    297276                }
    298                 var q = new Query(collections, columns, query); //actions.collections.current, query );
     277                var q = new Query(collections, columns, query, squery); //actions.collections.current, query );
    299278                q.repository = getSelectedRepository();
    300279                //if (ws) {
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/action/GenericAction.java

    r1559 r1569  
    1414import com.opensymphony.xwork2.ActionSupport;
    1515
     16import eu.clarin.cmdi.mdservice.internal.CQLParseException;
    1617import eu.clarin.cmdi.mdservice.internal.Cache;
    1718import eu.clarin.cmdi.mdservice.internal.MDTransformer;
     
    208209         */
    209210        public String getActionContentType() {
    210                 if (this.getFormat().toLowerCase().startsWith("html")) {
     211                if (this.getFormat().toLowerCase().startsWith("html")) { // && !getDiagnostics().Exists()) {
    211212                        this.actionContentType = "text/html";           
    212213                        //this.actionContentType = "application/xhtml+xml";
     
    263264         * @throws IOException
    264265         * @throws NoStylesheetException
    265          */
    266         public InputStream getSourceStream() throws IOException, NoStylesheetException {               
     266         * @throws CQLParseException
     267         */
     268        public InputStream getSourceStream() throws IOException, NoStylesheetException, CQLParseException {             
    267269                        return getTargetProxy().getSourceStream();
    268270        }
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/proxy/BasicProxy.java

    r1541 r1569  
    88import org.apache.log4j.Logger;
    99import eu.clarin.cmdi.mdservice.action.GenericAction;
     10import eu.clarin.cmdi.mdservice.internal.CQLParseException;
    1011import eu.clarin.cmdi.mdservice.internal.NoStylesheetException;
    1112import eu.clarin.cmdi.mdservice.internal.Utils;
     
    9192         * uses base_url + url_pattern (parametrized by actionkey) to form a url
    9293         * @return the full target-request URL to be sent to the target repository
     94         * @throws CQLParseException
    9395         * @throws Exception
    9496         */     
    95         public URL getTargetRequest() throws IOException {
     97        public URL getTargetRequest() throws IOException, CQLParseException {
    9698                 
    9799                URL targetURL =new URL(getBaseURI() + this.getSourceAction().getTargetRequestParams());
     
    102104        }
    103105
    104         public InputStream getSourceStream() throws IOException, NoStylesheetException {
     106        public InputStream getSourceStream() throws IOException, NoStylesheetException, CQLParseException {
    105107                URLConnection urlConnection = getTargetRequest().openConnection();
    106108                getSourceAction().setRequestProperties(urlConnection);
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/proxy/MDRepoProxy.java

    r1554 r1569  
    55import java.util.HashMap;
    66import org.apache.log4j.Logger;
     7
     8import eu.clarin.cmdi.mdservice.internal.CQLParseException;
     9import eu.clarin.cmdi.mdservice.model.Diagnostic;
    710import eu.clarin.cmdi.mdservice.model.Query;
    811import eu.clarin.cmdi.mdservice.model.WorkspaceProfile;
     
    5457         * uses base_url + url_pattern (parametrized by actionkey) to form a url
    5558         * @return the full target-request URL to be sent to the target repository
     59         * @throws CQLParseException
    5660         * @throws Exception
    5761         */
    5862         @Override
    59         public URL getTargetRequest() throws IOException {
     63        public URL getTargetRequest() throws IOException, CQLParseException {
    6064       
    6165                //TODO squery removed
     
    7074                if (query.isStatus(Query.PARSEERROR)) {
    7175                        log.debug("MDRP.query.PARSEERROR:" + query.getMsg());
     76                        throw new CQLParseException("MDRP.query.PARSEERROR:" + query.getMsg());
     77                        //getSourceAction().getDiagnostics().Add(Diagnostic.SYSTEM_ERROR, "MDRP.query.PARSEERROR:" + query.getMsg());
    7278                        //TODO exception ??
    73                         return null;
     79                        //return null;
    7480                } else {
    7581                        query.setMaxdepth(Integer.valueOf(getParam("maxdepth")));               
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/proxy/ProxyInterface.java

    r1536 r1569  
    77
    88import eu.clarin.cmdi.mdservice.action.GenericAction;
     9import eu.clarin.cmdi.mdservice.internal.CQLParseException;
    910import eu.clarin.cmdi.mdservice.internal.NoStylesheetException;
    1011
    1112public interface ProxyInterface {
    1213
    13         public URL getTargetRequest() throws IOException;
    14         public InputStream getSourceStream() throws IOException, NoStylesheetException;
     14        public URL getTargetRequest() throws IOException, CQLParseException;
     15        public InputStream getSourceStream() throws IOException, NoStylesheetException, CQLParseException;
    1516        public void setSourceAction(GenericAction action) ;
    1617        /**
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/proxy/Pz2Proxy.java

    r1511 r1569  
    3434import org.xml.sax.SAXException;
    3535
     36import eu.clarin.cmdi.mdservice.internal.CQLParseException;
    3637import eu.clarin.cmdi.mdservice.internal.NoStylesheetException;
    3738import eu.clarin.cmdi.mdservice.model.Query;
     
    136137 * The distinction is based on the command parameter: if it is given, the Class(Service) acts as a basic proxy
    137138 * transparently passing the communication between client and target repository. 
     139 * @throws CQLParseException
    138140 */
    139141        @Override
    140         public InputStream getSourceStream() throws IOException, NoStylesheetException {
     142        public InputStream getSourceStream() throws IOException, NoStylesheetException, CQLParseException {
    141143                if (getCommand() == null){
    142144                        try {
  • MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/proxy/RepoProxy.java

    r1522 r1569  
    3030import eu.clarin.cmdi.mdservice.action.GenericAction;
    3131import eu.clarin.cmdi.mdservice.action.RepoAction;
     32import eu.clarin.cmdi.mdservice.internal.CQLParseException;
    3233import eu.clarin.cmdi.mdservice.internal.NoStylesheetException;
    3334import eu.clarin.cmdi.mdservice.model.Diagnostic;
     
    128129       
    129130       
    130         public InputStream getSourceStream() throws IOException, NoStylesheetException {
     131        public InputStream getSourceStream() throws IOException, NoStylesheetException, CQLParseException {
    131132                return getTargetRequest().openStream();         
    132133        }
     
    155156         * uses base_url + url_pattern (parametrized by actionkey) to form a url
    156157         * @return the full target-request URL to be sent to the target repository
     158         * @throws CQLParseException
    157159         * @throws Exception
    158160         */     
    159         public URL getTargetRequest() throws IOException {
     161        public URL getTargetRequest() throws IOException, CQLParseException {
    160162                 
    161163               
Note: See TracChangeset for help on using the changeset viewer.