Changeset 1388


Ignore:
Timestamp:
06/01/11 21:59:12 (13 years ago)
Author:
gaba
Message:

save, savenew
publish existing query
workspace functionality corrections

Location:
MDService2/trunk/MDService2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • MDService2/trunk/MDService2/WebContent/scripts/mdservice_model.js

    r1384 r1388  
    3737};
    3838
    39 Workspace.setTypedElement = function(type, id,data){
     39Workspace.prototype.setTypedElement = function(type, id,data){
    4040        switch(type){
    4141        case 'queryset':
    42                 this.user_json["WorkspaceProfile"].Querysets = data;
     42                if (data == "[{}]"){
     43                        this.user_json["WorkspaceProfile"].Querysets = [{}];
     44                } else {
     45                        this.user_json["WorkspaceProfile"].Querysets = data;
     46                }
    4347                break;
    4448        case 'bookmarkset':
    45                 this.user_json["WorkspaceProfile"].Bookmarksets = data;
     49                if (data == "[{}]"){
     50                        this.user_json["WorkspaceProfile"].Bookmarksets = [{}];
     51                } else {
     52                        this.user_json["WorkspaceProfile"].Bookmarksets = data;
     53                }
    4654                break;
    4755        case 'query':
    48                 workspace.user_json["WorkspaceProfile"]["Querysets"][id]["Queries"] = data;
     56                if (data == "[{}]"){
     57                        workspace.user_json["WorkspaceProfile"]["Querysets"][id]["Queries"] = [{}];
     58                } else {
     59                        workspace.user_json["WorkspaceProfile"]["Querysets"][id]["Queries"] = data;
     60                }
    4961                break;
    5062        case 'bookmark':
    51                 workspace.user_json["WorkspaceProfile"]["Bookmarksets"][id]["Bookmarks"] = data;
     63                if (data == "[{}]"){
     64                        workspace.user_json["WorkspaceProfile"]["Bookmarksets"][id]["Bookmarks"] = [{}];
     65                } else {
     66                        workspace.user_json["WorkspaceProfile"]["Bookmarksets"][id]["Bookmarks"] = data;
     67                }
    5268                break;
    5369        }
     
    6076       
    6177        if (elems == "null"){
    62                 Workspace.setTypedElement(type,id, "[{}]");
     78                this.setTypedElement(type,id, "[{}]");
     79                elems = this.getTypedElement('user', type, id);
    6380        } else {
    6481                iq = elems.length;
     
    147164        // set null string , if 0 querysets
    148165        if (size == 1) {
    149                 Workspace.setTypedElement(type,id2,"null");
     166                this.setTypedElement(type,id2,"null");
    150167        }
    151168};
     
    193210
    194211};
    195 Workspace.prototype.savequery = function(json, qsid, bookmark){
     212Workspace.prototype.savequery = function(json, qsid, query){
    196213        var JSONText;
    197214        var type = "user";
    198215        var qdata = "/";// + querysetid;
    199216        JSONText = JSON.stringify(json);
    200         if (bookmark == 0){
     217        if (query.bookmark == 0){
    201218                qdata = qdata + this.getTypedElement(type, 'queryset')[qsid]["id"];
    202219        } else {
     
    207224                if (json.id == 0){
    208225                        json.id = $(data).text();
    209                         if (bookmark == 0){
     226                        query.id = $(data).text();
     227                        if (query.bookmark == 0){
    210228                                appendQueryUI(json,qsid, $('#userqueries'));
    211229                        } else {
     
    355373                if (this.id == 0){
    356374                        workspace.addelement("query",jsonq, qsid);//qsjson);
    357                         workspace.savequery(jsonq, qsid,this.bookmark);
    358                 } else {
    359                         workspace.savequery(jsonq, this.bookmark);
     375                        workspace.savequery(jsonq, qsid, this);
     376                } else {
     377                        workspace.savequery(jsonq, qsid, this);
    360378                }
    361379        } else {
     
    364382                if (this.id == 0){
    365383                        workspace.addelement("bookmark", jsonq, qsid);//qsjson);
    366                         workspace.savequery(jsonq, qsid,this.bookmark);
    367                 } else {
    368                         workspace.savequery(jsonq, this.bookmark);
     384                        workspace.savequery(jsonq, qsid,this);
     385                } else {
     386                        workspace.savequery(jsonq, qsid, this);
    369387                }
    370388        }
     
    481499        //$.data("query",this);
    482500        var q = this;
    483         if (q.vcrid == 0){
     501        //if (q.vcrid == 0){
    484502                $.get("/MDService2/virtualcollection/USER/" + this.id,"", function(data){
    485                         var id = parseInt($(data).children().children('virtualcollectionid').text());
    486                         q.vcrid = id;
    487                         q.save();
     503                        if (q.vcrid == 0){
     504                                var id = parseInt($(data).children().children('virtualcollectionid').text());
     505                                q.vcrid = id;
     506                                q.save();
     507                        }
    488508                });
    489         }
     509        //}
    490510};
    491511
     
    11361156        $(q_header).data('query',query);
    11371157        q_header.find('.cmd_reload').data('query',query);
    1138         q_header.find('.cmds .cmd_save').data('query',query);
     1158        q_header.find('.cmds .cmd_save').data('qid',query.listid);
     1159        q_header.find('.cmds .cmd_savenew').data('qid',query.listid);
    11391160        q_header.find('.cmd_reload').click(function() {
    11401161                /*
  • MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui.js

    r1384 r1388  
    354354       
    355355        $('#detail_query .cmds .cmd_save').live('click',  function(event) {
    356                 qid = $(this).data('query').listid;
     356                //qid = $(this).data('query').listid;
     357                qid = $(this).data('qid');
    357358                notifyUser("here I would save query: " + qid, "debug");
    358                 $(this).data('query').save();
     359                var q = queryset.getQuery(qid);
     360                q.save();
     361                //Workspace.saveQuery($(this).data('query'));
     362        });
     363        $('#detail_query .cmds .cmd_savenew').live('click',  function(event) {
     364                //qid = $(this).data('query').listid;
     365                qid = $(this).data('qid');
     366                notifyUser("here I would savenew query: " + qid, "debug");
     367                var q = queryset.getQuery(qid);
     368                q.id = 0;
     369                q.save();
    359370                //Workspace.saveQuery($(this).data('query'));
    360371        });
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/VirtualCollectionProxyAction.java

    r1310 r1388  
    3636        //private String proxy_key = "virtual_collection";
    3737       
    38         private String qid;
     38        //private String qid;
    3939        //private String date;
    4040        //private String datefrom;
    4141        //private String dateto;
    42        
     42        /*
    4343        public String getQid(){
    4444                return qid;
     
    4747                this.qid = qid;
    4848        }
    49        
     49        */
    5050        @Override
    5151        protected void  initialize(){
     
    105105       
    106106                //create connection and post request data
    107                
    108         URL url = new URL("http://clarin.ids-mannheim.de/vcr/service/virtualcollection");
     107                // find out
     108                String urlstring = "http://clarin.ids-mannheim.de/vcr/service/virtualcollection";
     109                String vcrstr = (String)getQueryVcrid();
     110                if (!vcrstr.equals("0")){
     111                        urlstring = urlstring + "/" + vcrstr;
     112                }
     113                //qlist.item(0).get
     114        URL url = new URL(urlstring);
    109115        String charset = "UTF-8";
    110116        URLConnection urlconn = url.openConnection();
  • MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/WorkspaceAction.java

    r1384 r1388  
    552552                   // apend to specific queryset
    553553                                NodeList wsnodelist = (NodeList) getQueryParent();
    554                         wsnodelist.item(0).appendChild(node2);
     554                                Node anode = wsnodelist.item(0);
     555                                if (anode.getTextContent().trim().toLowerCase().equals("null")){
     556                                        anode.setTextContent("");
     557                                }
     558                        anode.appendChild(node2);
    555559                        }
    556560                       
     
    585589                                           // apend to specific bookmarkset
    586590                                                        NodeList wsnodelist = (NodeList) getBookmarkParent();
    587                                                 wsnodelist.item(0).appendChild(node2);
     591                                                        Node anode = wsnodelist.item(0);
     592                                                        if (anode.getTextContent().trim().toLowerCase().equals("null")){
     593                                                                anode.setTextContent("");
     594                                                        }
     595                                                anode.appendChild(node2);
    588596                                                }
    589597                                               
     
    620628                                                NodeList wsnodelist = (NodeList) this.getWorkspace();
    621629                                                Element welem = (Element)wsnodelist.item(0);
    622                                                         welem.getElementsByTagName("Querysets").item(0).appendChild(node2);
     630                                                        Node anode = welem.getElementsByTagName("Querysets").item(0);
     631                                                        if (anode.getTextContent().trim().toLowerCase().equals("null")){
     632                                                                anode.setTextContent("");
     633                                                        }
     634                                                        anode.appendChild(node2);
    623635                                                }
    624636                                               
     
    655667                                                NodeList wsnodelist = (NodeList) this.getWorkspace();
    656668                                                Element welem = (Element)wsnodelist.item(0);
    657                                                         welem.getElementsByTagName("Bookmarksets").item(0).appendChild(node2);
     669                                                Node anode = welem.getElementsByTagName("Bookmarksets").item(0);
     670                                               if (anode.getTextContent().trim().toLowerCase().equals("null")){
     671                                                                anode.setTextContent("");
     672                                                        }
     673                                                anode.appendChild(node2);
    658674                                                }
    659675                                               
     
    873889            XPathExpression expr;
    874890                        expr = xpath.compile("//Profiles/WorkspaceProfiles/WorkspaceProfile/Querysets/item/Queries/item[id='" + this.qid + "']");
     891                        //expr = xpath.compile("//Profiles/WorkspaceProfiles/WorkspaceProfile/Querysets/item/Queries/item[id='" +this.qid.toString()+"']");
    875892                                //expr = xpath.compile("//item[@id='" + this.qid + "']");
    876893                        //expression is evaluated with respect to a certain context node which is doc.
     
    901918             return result;
    902919        }
     920
     921public Object getQueryVcrid() throws XPathExpressionException{
     922       
     923        XPathFactory factory = XPathFactory.newInstance();
     924    XPath xpath = factory.newXPath();
     925    XPathExpression expr;
     926//              expr = xpath.compile("//Profiles/WorkspaceProfiles/WorkspaceProfile/Querysets/item[id='" + this.qsid + "']/vcrid");
     927                expr = xpath.compile("//Profiles/WorkspaceProfiles/WorkspaceProfile/Querysets/item/Queries/item[id='" + this.qid + "']/vcrid");
     928           
     929                //expression is evaluated with respect to a certain context node which is doc.
     930                Object result = null;
     931                try{
     932                result = expr.evaluate(workspace_doc, XPathConstants.STRING);
     933                } catch(Exception e){
     934                       
     935                }
     936
     937     return result;
     938}
    903939        public Object getQueryset() throws XPathExpressionException{
    904940               
  • MDService2/trunk/MDService2/src/xsl/mdset2view.xsl

    r1252 r1388  
    159159        <!--  <div class='ui-context-dialog ui-widget-content columns-wrapper'>  -->
    160160                <div class='ui-widget-content columns-wrapper'>
    161                         <div class='cmds'><span class="cmd cmd_reload" /><span class="cmd cmd_save" /></div>
     161                        <div class='cmds'><span class="cmd cmd_reload" /><span class="cmd cmd_save" /><span class="cmd cmd_savenew" /></div>
    162162                        <div class='query-columns'>
    163163                        <label>Columns</label>
Note: See TracChangeset for help on using the changeset viewer.