Author: saminda
Date: Sun Jan  6 09:24:23 2008
New Revision: 11888

Log:

Added a missing feature for data services. This includes for call-query from a 
query 


Modified:
   trunk/wsas/java/modules/www/extensions/core/js/data_service.js
   
trunk/wsas/java/modules/www/extensions/core/xslt/data_service_add_edit_result_mapping.xsl

Modified: trunk/wsas/java/modules/www/extensions/core/js/data_service.js
==============================================================================
--- trunk/wsas/java/modules/www/extensions/core/js/data_service.js      
(original)
+++ trunk/wsas/java/modules/www/extensions/core/js/data_service.js      Sun Jan 
 6 09:24:23 2008
@@ -532,6 +532,26 @@
     refreshDataServiceScreen();
 }
 
+//TODO : note: this will show the inner query explorer
+//divInnerQueryExplorler_
+function showInnerQueryExplorer(obj,idArray) {
+    var divId;
+    var divObj;
+    for (var i = 0; i < idArray.length; i++) {
+        divId = idArray[i];
+        divObj = document.getElementById("divInnerQueryExplorler_"+divId);
+        if (divObj) {
+            divObj.style.display = "none";
+        }
+    }
+    divId = obj[obj.selectedIndex].value;
+    divObj = document.getElementById("divInnerQueryExplorler_" + divId);
+    if (divObj) {
+        divObj.style.display = "inline";
+    }
+
+}
+
 //TODO : note : this will refresh the preview. 
 function _refreshDataServiceScreenHelper(boolValue) {
     /*if (serviceSpecificName == null || serviceSpecificName == "") {
@@ -1053,6 +1073,13 @@
     } else if (mappingValue == 'Query') {
         document.getElementById('divOMElement').style.display = "none";
         document.getElementById('divOMQuery').style.display = "inline";
+        //First time showing for new services
+        var objCmb = document.getElementById('cmbDataServiceQueryId');
+        var cmbValue = objCmb[objCmb.selectedIndex].value;
+        var divObj = 
document.getElementById('divInnerQueryExplorler_'+cmbValue);
+        if (divObj) {
+            divObj.style.display = "inline";
+        }
     }
 }
 
@@ -1070,7 +1097,7 @@
 }
 
 //TODO : note: adding and editing for output params
-function addEditSpecificOutputMapping(queryId, mappingObj, oldOutputFieldName) 
{
+function addEditSpecificOutputMapping(queryId, mappingObj, oldOutputFieldName, 
cqmObj) {
     var qArray = dataServiceObj.getElementsByTagName('query');
     var queryEle = null;
     for (var i = 0; i < qArray.length; i++) {
@@ -1172,9 +1199,25 @@
             tEle.setAttribute("href", objValue);
             resultEle.appendChild(tEle);
         } else {
-            tEle.removeAttribute("href");
+            resultEle.removeChild(tEle);
+            tEle = rootDocument.createElement("call-query");
             tEle.setAttribute("href", objValue);
+            resultEle.appendChild(tEle);
         }
+        var withParamObj = cqmObj[objValue];
+        for(var o in withParamObj) {
+            var n = o;
+            var v = withParamObj[n];
+            var withParamEle = rootDocument.createElement("with-param");
+            tEle.appendChild(withParamEle);
+            if (v && v.length != 0) {
+                withParamEle.setAttribute("name", v);
+            } else {
+                withParamEle.setAttribute("name", n);
+            }
+            withParamEle.setAttribute("query-param", n);
+        }
+
     }
     var currentDiv = document.getElementById("divADDEditOutputMapping");
     currentDiv.style.display = "none";

Modified: 
trunk/wsas/java/modules/www/extensions/core/xslt/data_service_add_edit_result_mapping.xsl
==============================================================================
--- 
trunk/wsas/java/modules/www/extensions/core/xslt/data_service_add_edit_result_mapping.xsl
   (original)
+++ 
trunk/wsas/java/modules/www/extensions/core/xslt/data_service_add_edit_result_mapping.xsl
   Sun Jan  6 09:24:23 2008
@@ -89,19 +89,39 @@
                             <label>Select Query</label>
                             <select>
                                 <xsl:attribute 
name="id">cmbDataServiceQueryId</xsl:attribute>
+                                <xsl:variable name="arrayOfName">
+                                    [
+                                    <xsl:for-each select="$queries">
+                                        "<xsl:value-of select="@id"/>"
+                                        <xsl:if test="position()!=last()">
+                                            ,
+                                        </xsl:if>
+                                    </xsl:for-each>
+                                    ]
+                                </xsl:variable>
+                                <xsl:attribute 
name="onchange">showInnerQueryExplorer(this, <xsl:value-of 
select="$arrayOfName"/>);return false;</xsl:attribute>
                                 <xsl:for-each select="$queries">
                                     <xsl:if test="@id!=$queryId">
                                         <option>
                                             <xsl:attribute 
name="value"><xsl:value-of select="@id"/></xsl:attribute>
-                                            <xsl:value-of select="@id"/>
                                             <xsl:if test="@id=$queryHref">
                                                 <xsl:attribute 
name="selected">true</xsl:attribute>
                                             </xsl:if>
+                                            <xsl:value-of select="@id"/>
                                         </option>
                                     </xsl:if>
                                 </xsl:for-each>
                             </select>
                         </div>
+                        <div>
+                            <fieldset style="width: 500px;">
+                                <legend>Query Parameter Mapping</legend>
+                                <xsl:call-template name="queryExplorer">
+                                    <xsl:with-param name="queries" 
select="$queries"/>
+                                </xsl:call-template>
+
+                            </fieldset>
+                        </div>
                     </div>
                     <div id="divOMElement">
                         <xsl:if test="$mappingType='Query'">
@@ -145,7 +165,30 @@
 
                     </div>
                     <div>
-                        <input type="button" 
onclick="addEditSpecificOutputMapping('{$queryId}', 
document.getElementById('cmbDataServiceOMType'),'{$eleName}');return false;" 
value="OK"/>
+                        <input type="button">
+                            <xsl:attribute name="value">OK</xsl:attribute>
+                            <xsl:attribute name="onclick">
+                                var cqmObj = new Object();
+                                <xsl:for-each select="$queries">
+                                    <xsl:variable name="forEachQueryId" 
select="@id"/>
+                                    cqmObj["<xsl:value-of 
select="$forEachQueryId"/>"] = new Object();
+                                    <xsl:variable name="callQuery" 
select="[EMAIL PROTECTED]/result/[EMAIL PROTECTED]"/>
+                                    <xsl:choose>
+                                        <xsl:when test="$callQuery/with-param">
+                                            <xsl:for-each 
select="$callQuery/with-param">
+                                                cqmObj["<xsl:value-of 
select="$forEachQueryId"/>"]["<xsl:value-of select="@name"/>"] = 
document.getElementById('inputInnerQPCQ_<xsl:value-of 
select="generate-id($queries)"/>').value;
+                                            </xsl:for-each>
+                                        </xsl:when>
+                                        <xsl:otherwise>
+                                            <xsl:for-each select="param">
+                                                cqmObj["<xsl:value-of 
select="$forEachQueryId"/>"]["<xsl:value-of select="@name"/>"] = 
document.getElementById('inputInnerQP_<xsl:value-of 
select="generate-id($queries)"/>').value;
+                                            </xsl:for-each>
+                                        </xsl:otherwise>
+                                    </xsl:choose>
+                                </xsl:for-each>
+                                addEditSpecificOutputMapping('<xsl:value-of 
select="$queryId"/>', 
document.getElementById('cmbDataServiceOMType'),'<xsl:value-of 
select="$eleName"/>', cqmObj);return false;
+                            </xsl:attribute>
+                        </input>
                         <input type="button" 
onclick="closeContainer('divADDEditOutputMapping'); 
refreshParentQueryContainer('{$queryId}', 'data_service_add_query.xsl', 
'divDSAddQuery', 'Add New Query'); return false;" value="Cancel"/>
                     </div>
                 </fieldset>
@@ -153,4 +196,68 @@
         </div>
     </xsl:template>
 
+    <xsl:template name="queryExplorer">
+        <xsl:param name="queries"/>
+        <xsl:variable name="thisQuery" select="[EMAIL PROTECTED]"/>
+        <xsl:for-each select="$queries">
+            <div id="[EMAIL PROTECTED]">
+                <xsl:attribute name="style">
+                    <xsl:choose>
+                        <xsl:when test="$queryHref">
+                            <xsl:choose>
+                                <xsl:when test="@id=$queryHref">
+                                    display: inline;
+                                </xsl:when>
+                                <xsl:otherwise>
+                                    display: none;
+                                </xsl:otherwise>
+                            </xsl:choose>
+                        </xsl:when>
+                        <xsl:otherwise>
+                              display: none;
+                        </xsl:otherwise>
+                    </xsl:choose>
+                </xsl:attribute>
+                <xsl:choose>
+                    <xsl:when test="not(param)">
+                        <strong>Query params are not available</strong>
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:variable name="callQuery" 
select="$thisQuery/result/[EMAIL PROTECTED]"/>
+                        <xsl:choose>
+                            <xsl:when test="$callQuery/with-param">
+                                <xsl:for-each select="$callQuery/with-param">
+                                    <div>
+                                        <label>
+                                            <xsl:value-of 
select="@query-param"/>
+                                        </label>
+                                        <input type="text">
+                                            <xsl:attribute 
name="id">inputInnerQPCQ_<xsl:value-of 
select="generate-id($queries)"/></xsl:attribute>
+                                            <xsl:attribute 
name="size">30</xsl:attribute>
+                                            <xsl:attribute 
name="value"><xsl:value-of select="@name"/></xsl:attribute>
+                                            <xsl:attribute 
name="style">background-color:#E4E8F5;</xsl:attribute>
+                                        </input>
+                                    </div>
+                                </xsl:for-each>
+                            </xsl:when>
+                            <xsl:otherwise>
+                                <xsl:for-each select="param">
+                                    <div>
+                                        <label>
+                                            <xsl:value-of select="@name"/>
+                                        </label>
+                                        <input type="text">
+                                            <xsl:attribute 
name="id">inputInnerQP_<xsl:value-of 
select="generate-id($queries)"/></xsl:attribute>
+                                            <xsl:attribute 
name="size">30</xsl:attribute>
+                                        </input>
+                                    </div>
+                                </xsl:for-each>
+                            </xsl:otherwise>
+                        </xsl:choose>
+                    </xsl:otherwise>
+                </xsl:choose>
+            </div>
+        </xsl:for-each>
+    </xsl:template>
+
 </xsl:stylesheet>
\ No newline at end of file

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

Reply via email to