Ignore:
Timestamp:
05/08/11 01:04:30 (13 years ago)
Author:
gaba
Message:

query indices
VCR first version

Location:
MDService2/trunk/MDService2/WebContent/scripts
Files:
4 edited

Legend:

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

    r1252 r1273  
    99var page_record_count = 10;
    1010var formatquerystring_len = 25;
    11 var workspace;
     11//var workspace;
    1212
    1313function Workspace(){
    1414
    1515};
    16 Workspace.save = function(type){
    17         var JSONText = JSON.stringify(jsonw["WorkspaceProfile"]);
     16Workspace.save = function(type, query, id, iq){
     17        var JSONText;
     18        var qdata = "/";
     19        /*
     20        if (type == "ADMIN"){
     21                JSONText = JSON.stringify(json_admin["WorkspaceProfile"]);
     22        } else {
     23                JSONText = JSON.stringify(jsonw["WorkspaceProfile"]);
     24        }
     25        */
    1826        //var JSONText = JSON.stringify({"aa.a":"r"});
    1927        //notifyUser(JSONText,'debug');
    20         $.post("/MDService2/workspaceprofilesave/" + type,{"data":JSONText});
    21 };
    22 Workspace.saveQuery = function(query){
    23         //queryset id
    24         var id = parseInt($("#qts_select option:selected").val());
    25         var iq = 0;
    26         var queries = jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"];
    27        
    28         //var iq = $('#userqueries').children().size();
    29         if (queries == "null"){
    30                 jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"] = [{}];
    31         } else {
    32                 iq = queries.length;
    33         }
    34         var jsonq = query.toJSON();
    35         jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq] = jsonq;
    36         Workspace.save("USER");
    37         appendQueryUI(jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq],iq, $('#userqueries'));
    38        
    39 };
     28       
     29        JSONText = JSON.stringify(jsonw["WorkspaceProfile"]);
     30        if (query != undefined){
     31                qdata = "/" + query.id;
     32        }
     33        $.post("/MDService2/workspaceprofilesave/" + type + qdata,{"data":JSONText},  function(data) {
     34                query.id = $(data).text();
     35                jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq]["id"] = query.id;
     36                appendQueryUI(jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq],iq, $('#userqueries'));
     37//            alert("success");
     38        });
     39        //.success(function() { alert("second success"); })
     40    //.error(function(e) { alert("error"); })
     41    //.complete(function() { alert("complete"); });
     42
     43
     44};
     45/*
     46Workspace.newQueryID = function(){
     47        var new_id;
     48       
     49        loadAdminFile();
     50        json_admin["Admin"]["maxqid"]  = parseInt(json_admin["Admin"]["maxqid"]) + 1;
     51        new_id = json_admin["Admin"]["maxqid"];
     52        Workspace.save("ADMIN");
     53        return new_id;
     54};
     55*/
    4056function Collection(index, name){
    4157        this.index = index;
     
    4965*/
    5066function Query(collection, columns, query , squery) {
     67        this.id = 0;
    5168        this.collection = collection;   // []
    5269        this.columns = columns;         // string
     
    125142};
    126143
     144Query.prototype.save = function(){
     145        //queryset id
     146        var id = parseInt($("#qts_select option:selected").val());
     147        var iq = 0;
     148        var queries = jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"];
     149       
     150        //var iq = $('#userqueries').children().size();
     151        if (queries == "null"){
     152                jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"] = [{}];
     153        } else {
     154                iq = queries.length;
     155        }
     156        // create queryID
     157        this.id = 0;//Workspace.newQueryID();//id + "_" + iq;
     158        var jsonq = this.toJSON();
     159        jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq] = jsonq;
     160        Workspace.save("USER", this, id, iq);
     161        //appendQueryUI(jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq],iq, $('#userqueries'));
     162       
     163};
     164
     165
    127166Query.prototype.getcolumnstext = function (){
    128167       
     
    195234        str = Query.queryliststring(this.squery, this.query) + coll + " @" + this.repository.toString();
    196235        return str;
     236};
     237
     238Query.prototype.publish = function() {
     239        $.post("/MDService2/virtualcollection/USER/" + this.id,"");
    197240};
    198241
     
    245288        }
    246289
    247         var jsonq = {"name":"",
     290        var jsonq = {"id":this.id,
     291                                 "name":"",
    248292                             "squerystring":this.squery,
    249293                                 "querystring":this.query,     
     
    253297                                 "startItem" : this.startItem,
    254298                                 "maximumItems" : this.maximumItems,
    255                                  "options" : json_options, "bookmark" : "0", "time" : str_time};
     299                                 "options" : json_options,
     300                                 "bookmark" : "0",
     301                                 "time" : str_time};
    256302       
    257303        jsonq.name = Query.fullformatstring(jsonq);
  • MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui.js

    r1266 r1273  
    228228        });
    229229       
     230        $('.cmd_publish').live('click', function(event){
     231                var query = $(this).parent().data('query');
     232                query.publish();
     233        });
    230234       
    231235        //////////////////////////////////////////////
     
    351355                qid = $(this).data('query').listid;
    352356                notifyUser("here I would save query: " + qid, "debug");
    353                 Workspace.saveQuery($(this).data('query'));
     357                $(this).data('query').save();
     358                //Workspace.saveQuery($(this).data('query'));
    354359        });
    355360
  • MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui_load.js

    r1266 r1273  
    3434
    3535};
     36/*
     37function loadAdminFile(){
     38        json_admin = {'Admin':{'maxqid':'0','QueryIndices':'null'}};
     39       
     40        jQuery.getJSON("/MDService2/workspaceprofile/admin",function(data){
     41                        json_admin = preprocessJSON(data);
     42        });
     43}
     44*/
    3645function loadWorkspaceProfiles(){
    3746        //empty json
     
    3948        $('#qts_input').val("");
    4049       
    41         jQuery.getJSON("/MDService2/workspaceprofile/server",function(data){
    42                 notifyUser(data['WorkspaceProfile'],'debug');
    43                                 var json = preprocessJSON(data);
    44                                 $("#serverqs").attr("data",JSON.stringify(json));
    45                                 loadQuerysets(json["WorkspaceProfile"]["Querysets"],"server");
    46                                 loadRepositories(json["WorkspaceProfile"]["Repositories"]);
    47                                 loadCollections(true);                         
    48                                 loadTerms();
    49                                 loadTermsAutocomplete();
    50                                 createTooltip(null);
    51                 });
    52 
    5350        // USER WORKSPACEPROFILE
    5451        jQuery.getJSON("/MDService2/workspaceprofile/user",function(data){
    5552                notifyUser(data['WorkspaceProfile'],'debug');
    5653                                jsonw = preprocessJSON(data);
     54                               
     55                                jQuery.getJSON("/MDService2/workspaceprofile/server",function(data){
     56                                        notifyUser(data['WorkspaceProfile'],'debug');
     57                                                        var json = preprocessJSON(data);
     58                                                        $("#serverqs").attr("data",JSON.stringify(json));
     59                                                        loadQuerysets(json["WorkspaceProfile"]["Querysets"],"server");
     60                                                        loadRepositories(json["WorkspaceProfile"]["Repositories"]);
     61                                                        loadCollections(true);                         
     62                                                        loadTerms();
     63                                                        loadTermsAutocomplete();
     64                                                        createTooltip(null);
     65                                                       
     66                                                       
     67                                        });
     68
    5769                                loadQuerysets(jsonw["WorkspaceProfile"]["Querysets"],"user");
    5870                                //loadTermsets(jsonw["WorkspaceProfile"]["CustomTermsets"]);
    5971                                createTooltip(this);
    6072        });
     73       
     74       
    6175
    6276}
     
    259273        json.name + '</a></span>' +
    260274        del +
    261         '<div class="detail" >' +
     275        '<span class="cmd cmd_publish"></span><div class="detail" >' +
    262276        name +
    263277        '<div class="cmds-elem-prop"><span class="label">squery:</span><span class="value">' + squery + '</span></div>' +
     
    276290        $(qs).append(x);
    277291       
     292        var query = new Query([],"","","");
     293        query.load(json);
     294        $(qs).find("[href='"+ id + "_" + i + "']").closest('.cmds-elem-plus').data('query',query);
    278295        $(qs).find('.detail').css({'z-index' : '1000'});
    279296       
     
    366383
    367384function  preprocessJSON(json){
     385        if (json["Admin"] != undefined) {
     386                if (json["Admin"]["QueryIndices"] != undefined){
     387                        if (String(json["Admin"]["QueryIndices"]) != "null") {
     388                                if (json["Admin"].QueryIndices[0] == undefined){
     389                                        var jj = json["Admin"]["QueryIndices"]["item"];
     390                                        delete json["Admin"]["QueryIndices"]["item"];
     391                                        json["Admin"]["QueryIndices"] = [{}];
     392                                        json["Admin"]["QueryIndices"][0] = jj;
     393                                }
     394                        }
     395                }
     396        }
     397       
     398       
    368399        if (json["WorkspaceProfile"]["CustomTermsets"] != undefined){
    369400       
  • MDService2/trunk/MDService2/WebContent/scripts/mdservice_ui_settings.js

    r1234 r1273  
    1212
    1313//VARIABLES
    14 var jsonw;
     14var jsonw, json_admin;
    1515var url_params;
    1616var local_collections = false;
Note: See TracChangeset for help on using the changeset viewer.