has_many/might_have support in the from clause
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 29 Sep 2006 04:07:25 +0000 (04:07 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 29 Sep 2006 04:07:25 +0000 (04:07 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6263 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/reports/oils_rpt_builder.js
Open-ILS/web/reports/oils_rpt_tree.js

index 9ce344e..791771c 100644 (file)
@@ -122,6 +122,7 @@ function oilsRptBuildFromClause(path) {
                        contains relevant info, plus a list of "fields",
                        or column objects */
                var node = oilsIDL[cls];
+               var pkey = oilsRptFindField(node.pkey);
 
                /* a "field" is a parsed version of a column from the IDL,
                        contains datatype, column name, etc. */
@@ -138,14 +139,19 @@ function oilsRptBuildFromClause(path) {
                if( i == (parts.length - 2) ) break;
 
                /* we still have columns left in the path, keep adding join's */
+               var path_col = col;
+               if(field.reltype != 'has_a')
+                       col = pkey.name + '-' + col;
+
                tobj.join = {};
                tobj = tobj.join;
+
                tobj[col] = {};
                tobj = tobj[col];
                if( field.type == 'link' )
                        tobj.key = field.key;
 
-               newpath = newpath + '-'+ col;
+               newpath = newpath + '-'+ path_col;
        }
 
        _debug("built 'from' clause: path="+path+"\n"+formatJSON(js2JSON(obj)));
index c053452..c67e814 100644 (file)
@@ -34,13 +34,15 @@ function oilsParseRptTree(IDL, callback) {
        for( var i = 0; i < classes.length; i++ ) {
                var node = classes[i];
                var id = node.getAttribute('id');
+               var fields = node.getElementsByTagName('fields')[0];
 
                var obj = { 
                        fields  : oilsRptParseFields(node),
                        name            : node.getAttribute('id'),
                        table           : node.getAttributeNS(oilsIDLPersistNS, 'tablename'),
                        core            : node.getAttributeNS(oilsIDLReportsNS, 'core'),
-                       label           : node.getAttributeNS(oilsIDLReportsNS, 'label')
+                       label           : node.getAttributeNS(oilsIDLReportsNS, 'label'),
+                       pkey            : fields.getAttributeNS(oilsIDLPersistNS, 'primary')
                };
 
                if( obj.core == 'true' ) obj.core = true;
@@ -91,7 +93,6 @@ function oilsRptParseFields( node ) {
                        obj.key = link.getAttribute('key');
                        obj['class'] = link.getAttribute('class');
                        obj.reltype = link.getAttribute('reltype');
-                       if( obj.reltype == 'might_have' ) continue;
                } else {
                        if( fields[i].getAttributeNS(oilsIDLPersistNS, 'virtual') == 'true' ) 
                                continue;