Author: sumedha
Date: Thu Jan 17 05:45:26 2008
New Revision: 12418

Log:

Row group & name validation should only happen for CSV and EXCEL types

Modified:
   
branches/wsas/java/2.2/wsas/java/modules/www/extensions/core/js/data_service.js

Modified: 
branches/wsas/java/2.2/wsas/java/modules/www/extensions/core/js/data_service.js
==============================================================================
--- 
branches/wsas/java/2.2/wsas/java/modules/www/extensions/core/js/data_service.js 
    (original)
+++ 
branches/wsas/java/2.2/wsas/java/modules/www/extensions/core/js/data_service.js 
    Thu Jan 17 05:45:26 2008
@@ -512,33 +512,41 @@
     var rowName = document.getElementById('txtDataServiceRowName').value;
     var rowNamespace = 
document.getElementById('txtDataServiceRowNamespace').value;
     
-    if (rgName == null || rgName.length == 0) {
-        wso2.wsf.Util.alertWarning("Group by element is required");
-        return;
-    }
-    if (rowName == null || rowName.length == 0) {
-        wso2.wsf.Util.alertWarning("Row name element is required");
-        return;
-    }
+    
     if (!rEle) {
-        rEle = rootDocument.createElement("result");
-        rEle.setAttribute("element", rgName);
-        rEle.setAttribute("rowName", rowName);
+        rEle = rootDocument.createElement("result");       
+        if (!(rgName == null || rgName.length == 0)) {
+           rEle.setAttribute("element", rgName);
+        }
+        if (!(rowName == null || rowName.length == 0)) {
+           rEle.setAttribute("rowName", rowName);
+        }                
         if (!(rowNamespace == null || rowNamespace.length == 0)) {
            rEle.setAttribute("defaultNamespace", rowNamespace);
         }else{
            rEle.removeAttribute("defaultNamespace");
         }
-        qEle.appendChild(rEle);
+        //if rowname & row group name is null, do not set result element
+        if(!(rEle.getAttribute("element") == null && 
rEle.getAttribute("rowName") == null)){
+          qEle.appendChild(rEle);        
+        }
     } else {
         rEle.removeAttribute("element");
         rEle.removeAttribute("rowName");
         rEle.removeAttribute("defaultNamespace");
-        rEle.setAttribute("element", rgName);
-        rEle.setAttribute("rowName", rowName);
+        if (!(rgName == null || rgName.length == 0)) {
+           rEle.setAttribute("element", rgName);
+        }
+        if (!(rowName == null || rowName.length == 0)) {
+           rEle.setAttribute("rowName", rowName);
+        }                        
         if (!(rowNamespace == null || rowNamespace.length == 0)) {
           rEle.setAttribute("defaultNamespace", rowNamespace);
         }        
+        //if rowname & row group name is null, do not set result element
+        if(rEle.getAttribute("element") == null || 
rEle.getAttribute("rowName") == null){
+          qEle.removeChild(rEle);    
+        }        
     }
     refreshDataServiceScreen();
 }
@@ -1631,27 +1639,55 @@
     }
     var rgName = document.getElementById('txtDataServiceWrapElement').value;
     var rowName = document.getElementById('txtDataServiceRowName').value;
-    if (rgName == null || rgName.length == 0) {
-        wso2.wsf.Util.alertWarning("Group by element is required");
-        return;
-    }
-    if (rowName == null || rowName.length == 0) {
-        wso2.wsf.Util.alertWarning("Row name element is required");
-        return;
-    }
+    var rowNamespace = 
document.getElementById('txtDataServiceRowNamespace').value;
+
     if (!rEle) {
-        rEle = rootDocument.createElement("result");
-        rEle.setAttribute("element", rgName);
-        rEle.setAttribute("rowName", rowName);
-        queryEle.appendChild(rEle);
+        rEle = rootDocument.createElement("result");       
+        if (!(rgName == null || rgName.length == 0)) {
+           rEle.setAttribute("element", rgName);
+        }
+        if (!(rowName == null || rowName.length == 0)) {
+           rEle.setAttribute("rowName", rowName);
+        }                
+        if (!(rowNamespace == null || rowNamespace.length == 0)) {
+           rEle.setAttribute("defaultNamespace", rowNamespace);
+        }else{
+           rEle.removeAttribute("defaultNamespace");
+        }
+        //if rowname & row group name is null, do not set result element
+        if(!(rEle.getAttribute("element") == null && 
rEle.getAttribute("rowName") == null)){
+          qEle.appendChild(rEle);        
+        }
     } else {
         rEle.removeAttribute("element");
         rEle.removeAttribute("rowName");
-        rEle.setAttribute("element", rgName);
-        rEle.setAttribute("rowName", rowName);
+        rEle.removeAttribute("defaultNamespace");
+        if (!(rgName == null || rgName.length == 0)) {
+           rEle.setAttribute("element", rgName);
+        }
+        if (!(rowName == null || rowName.length == 0)) {
+           rEle.setAttribute("rowName", rowName);
+        }                        
+        if (!(rowNamespace == null || rowNamespace.length == 0)) {
+          rEle.setAttribute("defaultNamespace", rowNamespace);
+        }        
+        //if rowname & row group name is null, do not set result element
+        if(rEle.getAttribute("element") == null || 
rEle.getAttribute("rowName") == null){
+          qEle.removeChild(rEle);    
+        }        
     }
+    
 
     if ("EXCEL" == dataServiceObj.getAttribute("dataSourceType")) {
+        if (rgName == null || rgName.length == 0) {
+          wso2.wsf.Util.alertWarning("Group by element is required");
+          return;
+        }
+        if (rowName == null || rowName.length == 0) {
+          wso2.wsf.Util.alertWarning("Row name element is required");
+          return;
+        }
+    
         
//sqlEle.appendChild(rootDocument.createTextNode("UseSheet=0:StartReadingFromRow=1"));
         //create excel elements
         var excelElement = rootDocument.createElement("excel");
@@ -1705,6 +1741,14 @@
         sqlEle.appendChild(sqlEleTextNode);
         queryEle.appendChild(sqlEle);
     } else if ("CSV" == dataServiceObj.getAttribute("dataSourceType")) {
+        if (rgName == null || rgName.length == 0) {
+          wso2.wsf.Util.alertWarning("Group by element is required");
+          return;
+        }
+        if (rowName == null || rowName.length == 0) {
+          wso2.wsf.Util.alertWarning("Row name element is required");
+          return;
+        }    
     }
 
     /*var resultEle = rootDocument.createElement("result");
@@ -1715,7 +1759,6 @@
 
     refreshDataServiceScreen();
 }
-
 var dataServiceNewQuery = false;
 
 function addDataServiceQuery() {

_______________________________________________
Wsas-java-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/wsas-java-dev

Reply via email to