alias/relation is now encoded to prevent from-clause aliases from becoming too large
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 2 Oct 2006 21:11:31 +0000 (21:11 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 2 Oct 2006 21:11:31 +0000 (21:11 +0000)
the path is still stored on the object and used instead of alias/relation where appropriate

git-svn-id: svn://svn.open-ils.org/ILS/trunk@6358 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/reports/oils_rpt.js
Open-ILS/web/reports/oils_rpt_builder.js
Open-ILS/web/reports/oils_rpt_common.xhtml
Open-ILS/web/reports/oils_rpt_folders.js
Open-ILS/web/reports/oils_rpt_param_editor.js

index 84c3a58..7c2096e 100644 (file)
@@ -122,6 +122,7 @@ oilsReport.prototype._gatherParams = function(params, arr, type, field) {
                        op                      : op,
                        value           : this.params[key],
                        column  : obj.column,
+                       path            : obj.path,
                        type            : type, 
                        relation : obj.relation,
                        field           : field
index 0b05072..47ed45a 100644 (file)
@@ -43,7 +43,7 @@ function oilsReportBuilderSave() {
                return;
 
        debugFMObject(tmpl);
-       return; /* XXX */
+       //return; /* XXX */
 
 
        var req = new Request(OILS_RPT_CREATE_TEMPLATE, SESSION, tmpl);
@@ -73,7 +73,9 @@ function oilsAddRptDisplayItem(path, name, tform, params) {
 
        /* add this item to the select blob */
        var sel = {
-               relation: oilsRptPathRel(path), 
+               relation: hex_md5(oilsRptPathRel(path)), 
+               _relation: oilsRptPathRel(path), 
+               path : path,
                alias:    name,
                column:   { transform: tform, colname: oilsRptPathCol(path) }
        };
@@ -122,7 +124,9 @@ function oilsRptBuildFromClause(path) {
 
                /* extract relevant info */
                tobj.table = node.table;
-               tobj.alias = newpath;
+               tobj.path = newpath;
+               tobj.alias = hex_md5(newpath);
+
                _debug('field type is ' + field.type);
                if( i == (parts.length - 2) ) break;
 
@@ -156,16 +160,19 @@ function oilsDelDisplayItem(val) {
 function oilsDelSelectedDisplayItems() {
        var list = oilsDelSelectedItems(oilsRptDisplaySelector);
 
+       _debug('deleting list: ' + list);
+
        /* remove the de-selected columns from the report output */
        oilsRpt.def.select = grep( oilsRpt.def.select, 
                function(i) {
                        for( var j = 0; j < list.length; j++ ) {
-                               var d = list[j];
+                               var d = list[j]; /* path */
                                var col = i.column;
 
-                               if( oilsRptPathRel(d) == i.relation && oilsRptPathCol(d) == col.colname ) {
-                                       //var param = (i.alias) ? i.alias.match(/::PARAM\d*/) : null;
-                                       //      if( param ) delete oilsRpt.params[param];
+                               _debug('in delete, looking at list = '+d+' : col = ' + 
+                                       col.colname + ' : relation = ' + i.relation + ' : encoded = ' + hex_md5(oilsRptPathRel(d)) );
+
+                               if( hex_md5(oilsRptPathRel(d)) == i.relation && oilsRptPathCol(d) == col.colname ) {
                                        return false;
                                }
                        }
@@ -173,21 +180,22 @@ function oilsDelSelectedDisplayItems() {
                }
        );
 
-       if(!oilsRpt.def.select) {
-               oilsRpt.def.select = [];
-               //oilsReportBuilderReset();
+       if(!oilsRpt.def.select) oilsRpt.def.select = [];
 
-       } else {
-               for( var j = 0; j < list.length; j++ ) 
-                       /* if there are no items left in the "select", "where", or "having" clauses 
-                               for the given relation, trim this relation from the "from" clause */
-                       if(     !grep(oilsRpt.def.select,
-                                       function(i){ return (i.relation == oilsRptPathRel(list[j])); })
-                               && !grep(oilsRpt.def.where,
-                                       function(i){ return (i.relation == oilsRptPathRel(list[j])); })
-                               && !grep(oilsRpt.def.having,
-                                       function(i){ return (i.relation == oilsRptPathRel(list[j])); })
-                       ) oilsRptPruneFromClause(oilsRptPathRel(list[j]));
+       for( var j = 0; j < list.length; j++ ) {
+               /* if there are no items left in the "select", "where", or "having" clauses 
+                       for the given relation, trim this relation from the "from" clause */
+               debug('seeing if we can prune from clause with relation = ' + hex_md5(oilsRptPathRel(list[j])));
+               if(     !grep(oilsRpt.def.select,
+                               function(i){ return (i.relation == hex_md5(oilsRptPathRel(list[j]))); })
+                       && !grep(oilsRpt.def.where,
+                               function(i){ return (i.relation == hex_md5(oilsRptPathRel(list[j]))); })
+                       && !grep(oilsRpt.def.having,
+                               function(i){ return (i.relation == hex_md5(oilsRptPathRel(list[j]))); })
+               ) {
+                       _debug('pruning from clause');
+                       oilsRptPruneFromClause(oilsRptPathRel(list[j]));
+               }
        }
 
        oilsRptDebug();
@@ -200,8 +208,9 @@ function oilsDelSelectedDisplayItems() {
 function oilsRptPruneFromClause(relation, node) {
        _debug("removing relation from 'from' clause " + relation);
        if(!node) node = oilsRpt.def.from.join;
+
        for( var i in node ) {
-               _debug("looking at node "+node[i].alias);
+               _debug("looking at node "+node[i].path);
                // first, descend into the tree, and prune leaves first
                if( node[i].join ) {
                        oilsRptPruneFromClause(relation, node[i].join); 
@@ -209,14 +218,20 @@ function oilsRptPruneFromClause(relation, node) {
                }
        }
 
+       _debug(js2JSON(node));
+
        // if we're at an unused empty leaf, remove it
-       if(  !node[i].join ) {
+       if(  !node.join ) {
+
+               var key = oilsRptObjectKeys(node)[0];
+               _debug("pruning from clause with "+node[key].alias);
+
                if(     !grep(oilsRpt.def.select,
-                               function(i){ return (i.relation == node[i].alias)})
+                               function(n){ _debug(n.relation); return (n.relation == node[key].alias)})
                        && !grep(oilsRpt.def.where,
-                               function(i){ return (i.relation == node[i].alias)})
+                               function(n){ _debug(n.relation); return (n.relation == node[key].alias)})
                        && !grep(oilsRpt.def.having,
-                               function(i){ return (i.relation == node[i].alias)})
+                               function(n){ _debug(n.relation); return (n.relation == node[key].alias)})
                ) {
                        delete node[i];
                        return true;
@@ -249,7 +264,9 @@ function oilsAddRptFilterItem(path, tform, filter) {
                return;
 
        var where = {
-               relation: oilsRptPathRel(path), 
+               relation: hex_md5(oilsRptPathRel(path)), 
+               _relation: oilsRptPathRel(path), 
+               path : path,
                column:   { transform: tform, colname: oilsRptPathCol(path) },
                condition : {}
        };
index a2794e8..540f8e0 100644 (file)
@@ -15,6 +15,7 @@
 <script language='javascript' src='/opac/common/js/sorttable.js'> </script>
 <script language='javascript' src='/opac/common/js/fm_table.js'> </script>
 <script language='javascript' src='/opac/common/js/fm_table_conf.js'> </script>
+<script language='javascript' src='/opac/common/js/md5.js'> </script>
 <script>
        stpicopen  = '../opac/images/slimtree/folder2.gif';
        stpicclose = '../opac/images/slimtree/folderopen2.gif';
index 733c656..37ee85e 100644 (file)
@@ -139,19 +139,17 @@ oilsRptFolderManager.prototype.createTopFolder = function(type, orgsel) {
        if( folder.shared() == 't' )
                folder.share_with( orgsel.getValue() );
 
-       if(confirm(DOM.oils_rpt_folder_manager_new_confirm.innerHTML + ' "'+folder.name()+'"')) {
-               oilsRptCreateFolder(folder, type,
-                       function(success) {
-                               if(success) {
-                                       oilsRptAlertSuccess();
-                                       oilsRptCurrentFolderManager.draw();
-                                       hideMe(DOM.oils_rpt_top_folder);
-                                       hideMe(DOM.oils_rpt_folder_table_alt_td);
-                                       unHideMe(DOM.oils_rpt_editor_div);
-                               }
+       oilsRptCreateFolder(folder, type,
+               function(success) {
+                       if(success) {
+                               oilsRptAlertSuccess();
+                               oilsRptCurrentFolderManager.draw();
+                               hideMe(DOM.oils_rpt_top_folder);
+                               hideMe(DOM.oils_rpt_folder_table_alt_td);
+                               unHideMe(DOM.oils_rpt_editor_div);
                        }
-               );
-       }
+               }
+       );
 }
 
 
index e7301fd..836703e 100644 (file)
@@ -31,7 +31,7 @@ oilsRptParamEditor.prototype.draw = function() {
        for( var p = 0; p < params.length; p++ ) {
                var par = params[p];
                var row = oilsRptParamEditor.row.cloneNode(true);
-               $n(row, 'object').appendChild(text(oilsRptMakeLabel(par.relation)));
+               $n(row, 'object').appendChild(text(oilsRptMakeLabel(oilsRptPathRel(par.path))));
                $n(row, 'column').appendChild(text(par.column.colname));
                $n(row, 'transform').appendChild(text(par.column.transform));
                $n(row, 'action').appendChild(text(par.op));
@@ -43,7 +43,10 @@ oilsRptParamEditor.prototype.draw = function() {
 
 
 oilsRptParamEditor.prototype.buildWidget = function(param, node) {
-       var cls = param.relation.split(/-/).pop();
+       //var cls = param.relation.split(/-/).pop();
+       var path = param.path.split(/-/);
+       path.pop();
+       var cls = path.pop();
        _debug("building widget with param class:" + cls + ' col: '+param.column.colname + ' op: '+ param.op);
        switch(param.op) {
                case 'in':