adding "Enable nullability selection" switch to allow complete control over join...
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 13 Mar 2009 21:40:01 +0000 (21:40 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 13 Mar 2009 21:40:01 +0000 (21:40 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12510 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/reports/xul/source-browse.js
Open-ILS/web/reports/xul/source-setup.js
Open-ILS/web/reports/xul/template-config.js
Open-ILS/web/reports/xul/template_builder.xul
build/i18n/po/en-US/reports.js.pot

index 12d94e7..87a40f1 100644 (file)
@@ -48,11 +48,14 @@ function sourceTreeHandler (ev, dbl) {
                                findAnscestorStack( item, 'treeitem', pathList );
 
                                var fullpath = '';
+
                                for (var j in pathList.reverse()) {
                                        var n = pathList[j].getAttribute('idlclass');
                                        var f = pathList[j].getAttribute('field');
+                                       var j = pathList[j].getAttribute('join');
 
                                        if (f) fullpath += "-" + f;
+                                       if (f && j != 'undefined') fullpath += '>' + j;
 
                                        if (fullpath) fullpath += ".";
                                        fullpath += n;
@@ -63,6 +66,7 @@ function sourceTreeHandler (ev, dbl) {
 
                                subtreeList.push(
                                        { name : name,
+                      nullable : 'Default',
                                          idlclass : idlclass,
                                          map : map,
                                          key : key,
@@ -72,6 +76,68 @@ function sourceTreeHandler (ev, dbl) {
                                          fullpath : fullpath
                                        }
                                );
+
+                if ($('nullable-source-control').checked) {
+                       if (reltype == 'has_a') {
+                                       subtreeList.push(
+                                               { name : name,
+                                 nullable : 'Parent', //rpt_strings.LINK_NULLABLE_RIGHT,
+                                                 idlclass : idlclass,
+                                                 map : map,
+                                                 key : key,
+                                                     join : 'right',
+                                                 field : field.getAttribute('name'),
+                                                 reltype : reltype,
+                                                 link : link,
+                                                 fullpath : fullpath + '>right'
+                                               }
+                                       );
+       
+                                       subtreeList.push(
+                                               { name : name,
+                                 nullable : 'None',  //rpt_strings.LINK_NULLABLE_NONE
+                                                 idlclass : idlclass,
+                                                 map : map,
+                                                     key : key,
+                                                     join : 'inner',
+                                                 field : field.getAttribute('name'),
+                                                 reltype : reltype,
+                                                 link : link,
+                                                 fullpath : fullpath + '>inner'
+                                               }
+                                       );
+       
+                       } else{
+                                       subtreeList.push(
+                                               { name : name,
+                                 nullable : 'Child', //rpt_strings.LINK_NULLABLE_LEFT,
+                                                 idlclass : idlclass,
+                                                 map : map,
+                                                 key : key,
+                                                     join : 'left',
+                                                 field : field.getAttribute('name'),
+                                                 reltype : reltype,
+                                                 link : link,
+                                                 fullpath : fullpath + '>left'
+                                               }
+                                       );
+       
+                                       subtreeList.push(
+                                               { name : name,
+                                 nullable : 'None',  //rpt_strings.LINK_NULLABLE_NONE
+                                                 idlclass : idlclass,
+                                                 map : map,
+                                                     key : key,
+                                                     join : 'inner',
+                                                 field : field.getAttribute('name'),
+                                                 reltype : reltype,
+                                                 link : link,
+                                                 fullpath : fullpath + '>inner'
+                                               }
+                                       );
+       
+                       }
+                }
                        }
 
                        populateSourcesSubtree( item.lastChild, subtreeList );
index d9fe261..729b01f 100644 (file)
@@ -195,6 +195,7 @@ function populateSourcesTree (idlclass) {
                        },
                        createTreeRow(
                                { },
+                               createTreeCell( { label : '' } ),
                                createTreeCell( { label : name } )
                        ),
                        createTreeChildren( { alternatingbackground : true } )
@@ -218,11 +219,13 @@ function populateSourcesSubtree (tcNode, classList) {
                                  key : obj.key,
                                  field : obj.field,
                                  link : obj.link,
+                                 join : obj['join'],
                                  reltype : obj.reltype,
                                  fullpath : obj.fullpath
                                },
                                createTreeRow(
                                        { },
+                                       createTreeCell( { label : obj.nullable } ),
                                        createTreeCell( { label : obj.name } )
                                ),
                                createTreeChildren( { alternatingbackground : true } )
@@ -257,11 +260,27 @@ function populateDetailTree (tcNode, c, item) {
                var _label = _cname; 
 
                if (atom.length > 1 && k == steps.length - 1) {
-                       var _f = getIDLField(classNode, atom[1]);
+            var field_name = atom[1];
+            var join_type = field_name;
+
+            field_name = field_name.split(/>/)[0];
+            join_type = join_type.split(/>/)[1];
+
+                       var _f = getIDLField(classNode, field_name);
                        var _fname = _f.getAttributeNS(rptNS, 'label');
                        if (!_fname) _fname = _f.getAttribute('name');
                        if (_fname) _label += ' :: ' + _fname; 
-               }
+                       if (join_type) _label += ' (' + join_type + ')'; 
+            
+               } else if (atom[1]){
+            var field_name = atom[1];
+            var join_type = field_name;
+
+            field_name = field_name.split(/>/)[0];
+            join_type = join_type.split(/>/)[1];
+
+                       if (join_type) _label += ' (' + join_type + ')'; 
+        }
 
                path_label.push(_label); 
        }
index 86a4bd6..6d409d6 100644 (file)
@@ -77,19 +77,21 @@ function addReportAtoms () {
                var field_class = item.getAttribute('idlclass');
                var datatype = item.getAttribute('datatype');
                var colname = item.getAttribute('idlfield');
+               var jointype = item.getAttribute('join');
                var field_label = item.firstChild.firstChild.getAttribute('label');
 
                var table_name = getSourceDefinition(field_class);
 
                if ( !rpt_rel_cache[relation_alias] ) {
                        rpt_rel_cache[relation_alias] =
-                               { label : class_label,
-                                 alias : relation_alias,
-                                 path  : class_path,
-                                 reltype  : reltype,
+                               { label     : class_label,
+                                 alias     : relation_alias,
+                                 path      : class_path,
+                                 join      : jointype,
+                                 reltype   : reltype,
                                  idlclass  : field_class,
-                                 table : table_name,
-                                 fields: { dis_tab : {}, filter_tab : {}, aggfilter_tab : {} }
+                                 table     : table_name,
+                                 fields    : { dis_tab : {}, filter_tab : {}, aggfilter_tab : {} }
                                };
                }
 
@@ -101,6 +103,7 @@ function addReportAtoms () {
                                  params    : transform && transform.getAttribute('params'),
                                  transform_label: (transform && transform.getAttribute('alias')) || rpt_strings.TEMPLATE_CONF_RAW_DATA,
                                  alias     : field_label,
+                                 join      : jointype,
                                  datatype  : datatype,
                                  op        : '=',
                                  op_label  : rpt_strings.TEMPLATE_CONF_EQUALS,
@@ -121,6 +124,7 @@ function addReportAtoms () {
                                  params    : transform && transform.getAttribute('params'),
                                  transform_label: (transform && transform.getAttribute('alias')) || rpt_strings.TEMPLATE_CONF_RAW_DATA,
                                  alias     : field_label,
+                                 join      : jointype,
                                  datatype  : datatype,
                                  op        : '=',
                                  op_label  : rpt_strings.TEMPLATE_CONF_EQUALS,
@@ -824,36 +828,58 @@ function fleshFromPath ( template, rel ) {
        var current_obj = template.from;
        var link;
        while (link = table_path.shift()) {
-               if (current_path) current_path += '-';
-               current_path += link;
-
-               var leaf = table_path.length == 0 ? true : false;
-
-               current_obj.path = current_path;
-               current_obj.table = getSourceDefinition( link.split(/-/)[0] );
 
                if (prev_link != '') {
                        var prev_class = getIDLClass( prev_link.split(/-/)[0] );
                        var prev_field = prev_link.split(/-/)[1];
 
+                       var prev_join = prev_field;
+
+                       prev_field = prev_field.split(/>/)[0];
+                       prev_join = prev_join.split(/>/)[1];
+
                        var current_link = getIDLLink( prev_class, prev_field );
                        current_obj.key = current_link.getAttribute('key');
 
-                       if (
+            //console.log("prev_link in fleshFromPath is: " + prev_link);
+            //console.log("prev_join in fleshFromPath is: " + prev_join);
+
+            if (prev_join) current_obj.type = prev_join
+                       else if ( 
                                (
                                        current_link.getAttribute('reltype') != 'has_a' ||
                                        prev_type == 'left' ||
                                        rel.reltype != 'has_a'
+
+// This disallows outer joins when the item is used in a filter
 //                             ) && (
 //                                     getKeys(rel.fields.filter_tab).length == 0 &&
 //                                     getKeys(rel.fields.aggfitler_tab).length == 0
+
                                )
                        ) current_obj.type = 'left';
 
                        prev_type = current_obj.type; 
+
                }
 
+               if (current_path) current_path += '-';
+               current_path += link.split(/>/)[0];
+
+               var leaf = table_path.length == 0 ? true : false;
+
+               current_obj.path = current_path;
+               current_obj.table = getSourceDefinition( link.split(/-/)[0] );
+
+
                if (leaf) {
+
+               var join_type = link.split(/-/)[1];
+            if (join_type) {
+                       join_type = join_type.split(/>/)[1];
+                           if (join_type && join_type != 'undefined') current_obj.type = join_type;
+            }
+
                        current_obj.label = rel.label;
                        current_obj.alias = rel.alias;
                        current_obj.idlclass = rel.idlclass;
@@ -861,6 +887,13 @@ function fleshFromPath ( template, rel ) {
                } else {
                        var current_class = getIDLClass( link.split(/-/)[0] );
                        var join_field = link.split(/-/)[1];
+                       var join_type = join_field;
+
+                       join_field = join_field.split(/>/)[0];
+                       join_type = join_type.split(/>/)[1];
+
+            //console.log("join_field in fleshFromPath is: " + join_field);
+
                        var join_link = getIDLLink(current_class, join_field);
 
                        if (join_link.getAttribute('reltype') != 'has_a') {
index 0e771ee..3ffd297 100644 (file)
                                        ondblclick="sourceTreeHandlerDblClick(event)"
                                >
                                        <treecols>
+                                               <treecol label="Nullable" flex="0"/>
                                                <treecol primary="true" label="&reports.xul.template_builder.source_name.label;" flex="1"/>
                                        </treecols>
                                        <treechildren id="sources-treetop" alternatingbackground="true" />
                                </tree>
+                <checkbox id="nullable-source-control" label="Enable nullability seletion"/>
                        </vbox>
                </hbox>
 
index 20b37d6..529f705 100644 (file)
@@ -400,3 +400,19 @@ msgstr ""
 #: reports.js:TEMPLATE_CONF_NOT_IN reports.js:TEMPLATE_CONF_NO_MATCH
 msgid "Field does not match one of list (comma separated):"
 msgstr ""
+
+#: reports.js:LINK_NULLABLE_LEFT
+msgid "Child"
+msgstr ""
+
+#: reports.js:LINK_NULLABLE_RIGHT
+msgid "Parent"
+msgstr ""
+
+#: reports.js:LINK_NULLABLE_BOTH
+msgid "Both"
+msgstr ""
+
+#: reports.js:LINK_NULLABLE_NONE
+msgid "None"
+msgstr ""