Author: ruwan
Date: Wed May 21 05:13:06 2008
New Revision: 17225

Log:
fixing a issue ESBJAVA-476 (aggregate mediaotr issue on clearing the attributes)

Modified:
   
branches/esb/java/1.7/esb/java/modules/distribution/src/main/www/extensions/core/js/mediators/aggregate_mediator.js

Modified: 
branches/esb/java/1.7/esb/java/modules/distribution/src/main/www/extensions/core/js/mediators/aggregate_mediator.js
==============================================================================
--- 
branches/esb/java/1.7/esb/java/modules/distribution/src/main/www/extensions/core/js/mediators/aggregate_mediator.js
 (original)
+++ 
branches/esb/java/1.7/esb/java/modules/distribution/src/main/www/extensions/core/js/mediators/aggregate_mediator.js
 Wed May 21 05:13:06 2008
@@ -44,35 +44,58 @@
     var aggregate_expr = document.getElementById("aggregate_expr");
     var on_complete = document.getElementById("on_complete");
 
-    if (correlate_expr != null && correlate_expr != undefined && 
correlate_expr.value != undefined && correlate_expr.value != "") {
-        var correlateOnElem = mediator.getElementsByTagName("correlateOn");
-        if (correlateOnElem.length != 0) {
-            correlateOnElem[0].setAttribute("expression", 
correlate_expr.value);
+    if (correlate_expr != null && correlate_expr != undefined && 
correlate_expr.value != undefined) {
+        if (correlate_expr.value == "") {
+            var correlateOnElem = mediator.getElementsByTagName("correlateOn");
+            if (correlateOnElem.length != 0) {
+                correlateOnElem[0].removeAttribute("expression");
+            } else {
+                correlateOnElem = 
mediator.getElementsByTagName("syn:correlateOn");
+                if (correlateOnElem.length != 0) {
+                    correlateOnElem[0].removeAttribute("expression");
+                }
+            }
         } else {
-            correlateOnElem = mediator.getElementsByTagName("syn:correlateOn");
+            correlateOnElem = mediator.getElementsByTagName("correlateOn");
             if (correlateOnElem.length != 0) {
                 correlateOnElem[0].setAttribute("expression", 
correlate_expr.value);
             } else {
-                mediator.appendChild(createesbelement("<syn:correlateOn 
expression='" + correlate_expr.value + "' " + syn_ns_declaration + "/>"));
+                correlateOnElem = 
mediator.getElementsByTagName("syn:correlateOn");
+                if (correlateOnElem.length != 0) {
+                    correlateOnElem[0].setAttribute("expression", 
correlate_expr.value);
+                } else {
+                    mediator.appendChild(createesbelement("<syn:correlateOn 
expression='" + correlate_expr.value + "' " + syn_ns_declaration + "/>"));
+                }
             }
         }
     }
 
-    if (complete_time != null && complete_time != undefined && 
complete_time.value != undefined && complete_time.value != "") {
+    if (complete_time != null && complete_time != undefined && 
complete_time.value != undefined) {
         var completeConditionElem = 
mediator.getElementsByTagName("completeCondition");
-        if (completeConditionElem.length != 0) {
-            completeConditionElem[0].setAttribute("timeout", 
complete_time.value);
+        if (complete_time.value == "") {
+            if (completeConditionElem.length != 0) {
+                completeConditionElem[0].removeAttribute("timeout");
+            } else {
+                completeConditionElem = 
mediator.getElementsByTagName("syn:completeCondition");
+                if (completeConditionElem.length != 0) {
+                    completeConditionElem[0].removeAttribute("timeout");
+                }
+            }
         } else {
-            completeConditionElem = 
mediator.getElementsByTagName("syn:completeCondition");
             if (completeConditionElem.length != 0) {
                 completeConditionElem[0].setAttribute("timeout", 
complete_time.value);
             } else {
-                mediator.appendChild(createesbelement("<syn:completeCondition 
timeout='" + complete_time.value + "' " + syn_ns_declaration + "/>"));
+                completeConditionElem = 
mediator.getElementsByTagName("syn:completeCondition");
+                if (completeConditionElem.length != 0) {
+                    completeConditionElem[0].setAttribute("timeout", 
complete_time.value);
+                } else {
+                    
mediator.appendChild(createesbelement("<syn:completeCondition timeout='" + 
complete_time.value + "' " + syn_ns_declaration + "/>"));
+                }
             }
         }
-    }
+        }
 
-    if (complete_max != null && complete_max != undefined && 
complete_max.value != undefined && complete_max.value != "") {
+    if (complete_max != null && complete_max != undefined && 
complete_max.value != undefined) {
         var completeConditionElem2 = 
mediator.getElementsByTagName("completeCondition");
         if (completeConditionElem2.length != 0) {
             setmessagecount(completeConditionElem2[0], "max", 
complete_max.value);
@@ -87,7 +110,7 @@
         }
     }
 
-    if (complete_min != null && complete_min != undefined && 
complete_min.value != undefined && complete_min.value != "") {
+    if (complete_min != null && complete_min != undefined && 
complete_min.value != undefined) {
         var completeConditionElem3 = 
mediator.getElementsByTagName("completeCondition");
         if (completeConditionElem3.length != 0) {
             setmessagecount(completeConditionElem3[0], "min", 
complete_min.value);
@@ -102,32 +125,56 @@
         }
     }
 
-    if (aggregate_expr != null && aggregate_expr != undefined && 
aggregate_expr.value != undefined && aggregate_expr.value != "") {
+    if (aggregate_expr != null && aggregate_expr != undefined && 
aggregate_expr.value != undefined) {
         var onCompleteElem = mediator.getElementsByTagName("onComplete");
-        if (onCompleteElem.length != 0) {
-            onCompleteElem[0].setAttribute("expression", aggregate_expr.value);
+        if (aggregate_expr.value == "") {
+            if (onCompleteElem.length != 0) {
+                onCompleteElem[0].removeAttribute("expression");
+            } else {
+                onCompleteElem = 
mediator.getElementsByTagName("syn:onComplete");
+                if (onCompleteElem.length != 0) {
+                    onCompleteElem[0].removeAttribute("expression");
+                }
+            }
         } else {
-            onCompleteElem = mediator.getElementsByTagName("syn:onComplete");
             if (onCompleteElem.length != 0) {
                 onCompleteElem[0].setAttribute("expression", 
aggregate_expr.value);
             } else {
-                mediator.appendChild(createesbelement("<syn:onComplete 
expression='" + aggregate_expr.value + "' " + syn_ns_declaration + "/>"));
+                onCompleteElem = 
mediator.getElementsByTagName("syn:onComplete");
+                if (onCompleteElem.length != 0) {
+                    onCompleteElem[0].setAttribute("expression", 
aggregate_expr.value);
+                } else {
+                    mediator.appendChild(createesbelement("<syn:onComplete 
expression='" + aggregate_expr.value + "' " + syn_ns_declaration + "/>"));
+                }
             }
         }
     }
 
-    if (on_complete != null && on_complete != undefined && on_complete.value 
!= undefined && on_complete.value != "") {
+    if (on_complete != null && on_complete != undefined && on_complete.value 
!= undefined) {
         var onCompleteElem2 = mediator.getElementsByTagName("onComplete");
-        if (onCompleteElem2.length != 0) {
-            onCompleteElem2[0].setAttribute("sequence", on_complete.value);
-            removeunwantedchilds(onCompleteElem2[0]);
+        if (on_complete.value == "") {
+            if (onCompleteElem2.length != 0) {
+                onCompleteElem2[0].removeAttribute("sequence");
+                removeunwantedchilds(onCompleteElem2[0]);
+            } else {
+                onCompleteElem2 = 
mediator.getElementsByTagName("syn:onComplete");
+                if (onCompleteElem2.length != 0) {
+                    onCompleteElem2[0].removeAttribute("sequencec");
+                    removeunwantedchilds(onCompleteElem2[0]);
+                }
+            }
         } else {
-            onCompleteElem2 = mediator.getElementsByTagName("syn:onComplete");
             if (onCompleteElem2.length != 0) {
-                onCompleteElem2[0].setAttribute("sequencec", 
on_complete.value);
+                onCompleteElem2[0].setAttribute("sequence", on_complete.value);
                 removeunwantedchilds(onCompleteElem2[0]);
             } else {
-                mediator.appendChild(createesbelement("<syn:onComplete 
sequence='" + on_complete.value + "' " + syn_ns_declaration + "/>"));
+                onCompleteElem2 = 
mediator.getElementsByTagName("syn:onComplete");
+                if (onCompleteElem2.length != 0) {
+                    onCompleteElem2[0].setAttribute("sequencec", 
on_complete.value);
+                    removeunwantedchilds(onCompleteElem2[0]);
+                } else {
+                    mediator.appendChild(createesbelement("<syn:onComplete 
sequence='" + on_complete.value + "' " + syn_ns_declaration + "/>"));
+                }
             }
         }
     }
@@ -139,11 +186,19 @@
 
     var msgcountElem = elem.getElementsByTagName("messageCount");
     if(msgcountElem.length != 0) {
-        msgcountElem[0].setAttribute(attr, attr_value);
+        if (attr_value == "") {
+            msgcountElem[0].removeAttribute(attr);
+        } else {
+            msgcountElem[0].setAttribute(attr, attr_value);
+        }
     } else {
         msgcountElem = elem.getElementsByTagName("syn:messageCount");
         if(msgcountElem.length != 0) {
-            msgcountElem[0].setAttribute(attr, attr_value);
+            if (attr_value == "") {
+                msgcountElem[0].removeAttribute(attr);
+            } else {
+                msgcountElem[0].setAttribute(attr, attr_value);
+            }
         } else {
             elem.appendChild(createesbelement("<syn:messageCount " + attr + 
"='" + attr_value + "' " + syn_ns_declaration + "/>"))
         }

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

Reply via email to