[OBCQL] Implemented summarize options (sum, average, count).
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Thu, 16 Dec 2010 12:27:43 +0100
changeset 9219 d24cdfe1270f
parent 9218 a99c58dcd897
child 9220 0721c4d48648
[OBCQL] Implemented summarize options (sum, average, count).
modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_REF_LIST.xml
modules/org.openbravo.client.querylist/src-db/database/sourcedata/OBCQL_QUERY_COLUMN.xml
modules/org.openbravo.client.querylist/src-db/database/sourcedata/OBCQL_WIDGET_QUERY.xml
modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListUtils.java
modules/org.openbravo.client.querylist/web/org.openbravo.client.querylist/js/ob-querylist-widget.js
--- a/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_REF_LIST.xml	Thu Dec 16 12:24:01 2010 +0100
+++ b/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_REF_LIST.xml	Thu Dec 16 12:27:43 2010 +0100
@@ -26,8 +26,8 @@
 <!--60CEA80ACF524079958E678F19F529EB-->  <AD_REF_LIST_ID><![CDATA[60CEA80ACF524079958E678F19F529EB]]></AD_REF_LIST_ID>
 <!--60CEA80ACF524079958E678F19F529EB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--60CEA80ACF524079958E678F19F529EB-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--60CEA80ACF524079958E678F19F529EB-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
-<!--60CEA80ACF524079958E678F19F529EB-->  <VALUE><![CDATA[AVG]]></VALUE>
+<!--60CEA80ACF524079958E678F19F529EB-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--60CEA80ACF524079958E678F19F529EB-->  <VALUE><![CDATA[avg]]></VALUE>
 <!--60CEA80ACF524079958E678F19F529EB-->  <NAME><![CDATA[Average]]></NAME>
 <!--60CEA80ACF524079958E678F19F529EB-->  <AD_REFERENCE_ID><![CDATA[B5730B21173B4AA9BB44ADAE2660A853]]></AD_REFERENCE_ID>
 <!--60CEA80ACF524079958E678F19F529EB-->  <AD_MODULE_ID><![CDATA[0A060B2AF1974E8EAA8DB61388E9AECC]]></AD_MODULE_ID>
@@ -38,7 +38,7 @@
 <!--6670A5161B774186A59380680CE9E2C6-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--6670A5161B774186A59380680CE9E2C6-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--6670A5161B774186A59380680CE9E2C6-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--6670A5161B774186A59380680CE9E2C6-->  <VALUE><![CDATA[S]]></VALUE>
+<!--6670A5161B774186A59380680CE9E2C6-->  <VALUE><![CDATA[sum]]></VALUE>
 <!--6670A5161B774186A59380680CE9E2C6-->  <NAME><![CDATA[Sum]]></NAME>
 <!--6670A5161B774186A59380680CE9E2C6-->  <AD_REFERENCE_ID><![CDATA[B5730B21173B4AA9BB44ADAE2660A853]]></AD_REFERENCE_ID>
 <!--6670A5161B774186A59380680CE9E2C6-->  <AD_MODULE_ID><![CDATA[0A060B2AF1974E8EAA8DB61388E9AECC]]></AD_MODULE_ID>
@@ -48,8 +48,8 @@
 <!--C63CDC1E9D844FF7A4E5B26E5EF17E9C-->  <AD_REF_LIST_ID><![CDATA[C63CDC1E9D844FF7A4E5B26E5EF17E9C]]></AD_REF_LIST_ID>
 <!--C63CDC1E9D844FF7A4E5B26E5EF17E9C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--C63CDC1E9D844FF7A4E5B26E5EF17E9C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--C63CDC1E9D844FF7A4E5B26E5EF17E9C-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
-<!--C63CDC1E9D844FF7A4E5B26E5EF17E9C-->  <VALUE><![CDATA[C]]></VALUE>
+<!--C63CDC1E9D844FF7A4E5B26E5EF17E9C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C63CDC1E9D844FF7A4E5B26E5EF17E9C-->  <VALUE><![CDATA[count]]></VALUE>
 <!--C63CDC1E9D844FF7A4E5B26E5EF17E9C-->  <NAME><![CDATA[Count]]></NAME>
 <!--C63CDC1E9D844FF7A4E5B26E5EF17E9C-->  <AD_REFERENCE_ID><![CDATA[B5730B21173B4AA9BB44ADAE2660A853]]></AD_REFERENCE_ID>
 <!--C63CDC1E9D844FF7A4E5B26E5EF17E9C-->  <AD_MODULE_ID><![CDATA[0A060B2AF1974E8EAA8DB61388E9AECC]]></AD_MODULE_ID>
--- a/modules/org.openbravo.client.querylist/src-db/database/sourcedata/OBCQL_QUERY_COLUMN.xml	Thu Dec 16 12:24:01 2010 +0100
+++ b/modules/org.openbravo.client.querylist/src-db/database/sourcedata/OBCQL_QUERY_COLUMN.xml	Thu Dec 16 12:27:43 2010 +0100
@@ -1,5 +1,21 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <data>
+<!--12479D7FA3AC4C2E8C9011013A090376--><OBCQL_QUERY_COLUMN>
+<!--12479D7FA3AC4C2E8C9011013A090376-->  <OBCQL_QUERY_COLUMN_ID><![CDATA[12479D7FA3AC4C2E8C9011013A090376]]></OBCQL_QUERY_COLUMN_ID>
+<!--12479D7FA3AC4C2E8C9011013A090376-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--12479D7FA3AC4C2E8C9011013A090376-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--12479D7FA3AC4C2E8C9011013A090376-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--12479D7FA3AC4C2E8C9011013A090376-->  <OBCQL_WIDGET_QUERY_ID><![CDATA[C0A8491CDB43466D9F2645018473588B]]></OBCQL_WIDGET_QUERY_ID>
+<!--12479D7FA3AC4C2E8C9011013A090376-->  <DISPLAY_EXPRESSION><![CDATA[fieldCount]]></DISPLAY_EXPRESSION>
+<!--12479D7FA3AC4C2E8C9011013A090376-->  <NAME><![CDATA[Fields number]]></NAME>
+<!--12479D7FA3AC4C2E8C9011013A090376-->  <SUMMARIZE_TYPE><![CDATA[sum]]></SUMMARIZE_TYPE>
+<!--12479D7FA3AC4C2E8C9011013A090376-->  <WIDTH><![CDATA[30]]></WIDTH>
+<!--12479D7FA3AC4C2E8C9011013A090376-->  <SEQNO><![CDATA[30]]></SEQNO>
+<!--12479D7FA3AC4C2E8C9011013A090376-->  <AD_REFERENCE_ID><![CDATA[12]]></AD_REFERENCE_ID>
+<!--12479D7FA3AC4C2E8C9011013A090376-->  <INCLUDE_IN><![CDATA[W]]></INCLUDE_IN>
+<!--12479D7FA3AC4C2E8C9011013A090376-->  <HAS_LINK><![CDATA[N]]></HAS_LINK>
+<!--12479D7FA3AC4C2E8C9011013A090376--></OBCQL_QUERY_COLUMN>
+
 <!--1B0F7BAEABF54A8EAB2CAA5A04A107DB--><OBCQL_QUERY_COLUMN>
 <!--1B0F7BAEABF54A8EAB2CAA5A04A107DB-->  <OBCQL_QUERY_COLUMN_ID><![CDATA[1B0F7BAEABF54A8EAB2CAA5A04A107DB]]></OBCQL_QUERY_COLUMN_ID>
 <!--1B0F7BAEABF54A8EAB2CAA5A04A107DB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.querylist/src-db/database/sourcedata/OBCQL_WIDGET_QUERY.xml	Thu Dec 16 12:24:01 2010 +0100
+++ b/modules/org.openbravo.client.querylist/src-db/database/sourcedata/OBCQL_WIDGET_QUERY.xml	Thu Dec 16 12:27:43 2010 +0100
@@ -6,11 +6,13 @@
 <!--C0A8491CDB43466D9F2645018473588B-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--C0A8491CDB43466D9F2645018473588B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--C0A8491CDB43466D9F2645018473588B-->  <OBKMO_WIDGET_CLASS_ID><![CDATA[D1E4261099AE4095B2F2DAEE0F7E7784]]></OBKMO_WIDGET_CLASS_ID>
-<!--C0A8491CDB43466D9F2645018473588B-->  <HQL><![CDATA[select tab.window.name as windowName, tab.name as tabName, tab.id as tabId, tab.window.id as windowId
-from ADTab tab
-where window.name like :window_name
-  and window.client.id = :client
-order by tab.window.name]]></HQL>
+<!--C0A8491CDB43466D9F2645018473588B-->  <HQL><![CDATA[select myWindow.name as windowName, myTab.name as tabName, myTab.id as tabId, count(field) as fieldCount
+from ADField field inner join field.tab myTab
+                                 inner join myTab.window myWindow
+where myWindow.name like :window_name
+  and myWindow.client.id = :client
+group by myWindow.name, myTab.name, myTab.id
+order by myWindow.name]]></HQL>
 <!--C0A8491CDB43466D9F2645018473588B--></OBCQL_WIDGET_QUERY>
 
 </data>
--- a/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListUtils.java	Thu Dec 16 12:24:01 2010 +0100
+++ b/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListUtils.java	Thu Dec 16 12:27:43 2010 +0100
@@ -109,6 +109,13 @@
           } else {
             field.put("OB_HasLink", false);
           }
+
+          // Summarize option:
+          if (column.getSummarizeType() != null) {
+            field.put("showGridSummary", true);
+            field.put("summaryFunction", column.getSummarizeType());
+          }
+
           try {
             final String fieldProperties = uiDefinition.getFieldProperties(null);
             if (fieldProperties != null && fieldProperties.trim().length() > 0) {
--- a/modules/org.openbravo.client.querylist/web/org.openbravo.client.querylist/js/ob-querylist-widget.js	Thu Dec 16 12:24:01 2010 +0100
+++ b/modules/org.openbravo.client.querylist/web/org.openbravo.client.querylist/js/ob-querylist-widget.js	Thu Dec 16 12:27:43 2010 +0100
@@ -100,6 +100,7 @@
   canGroupBy: false,
   autoFetchData: true,
   canAutoFitFields: false,
+  showGridSummary: true,
   
   //autoFitFieldWidths: true,
   //autoFitWidthApproach: 'title',