[rhmessaging-commits] rhmessaging commits: r3676 - mgmt/trunk/cumin/python/cumin/messaging.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Wed Oct 21 20:17:57 EDT 2009


Author: eallen
Date: 2009-10-21 20:17:56 -0400 (Wed, 21 Oct 2009)
New Revision: 3676

Modified:
   mgmt/trunk/cumin/python/cumin/messaging/broker.py
   mgmt/trunk/cumin/python/cumin/messaging/broker.strings
   mgmt/trunk/cumin/python/cumin/messaging/brokergroup.py
   mgmt/trunk/cumin/python/cumin/messaging/brokergroup.strings
   mgmt/trunk/cumin/python/cumin/messaging/model.py
Log:
Added list of group checkboxes to 'Add to groups' form

Modified: mgmt/trunk/cumin/python/cumin/messaging/broker.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/broker.py	2009-10-21 14:22:23 UTC (rev 3675)
+++ mgmt/trunk/cumin/python/cumin/messaging/broker.py	2009-10-22 00:17:56 UTC (rev 3676)
@@ -14,6 +14,7 @@
 from connection import *
 
 from brokerlink import LinkSet
+from brokergroup import BrokerGroupInputSet
 
 strings = StringCatalog(__file__)
 
@@ -330,7 +331,30 @@
         self.object = ListParameter(app, "broker", item)
         self.add_parameter(self.object)
 
-#    def process_submit(self, session):
-#        pass
+        self.__groups = BrokerGroupInputSet(app, "group")
+        self.add_child(self.__groups)
 
-from brokergroup import BrokerGroupCheckboxField
+    def render_content(self, session):
+        obj = self.object.get(session)
+        if len(obj) == 0:
+            return "Please select one or more brokers first"
+        else:
+            return "%s?%s" % (self.task.get_description(session, obj), 
+                                self.__groups.render(session))
+
+    def do_process(self, session):
+        super(BrokerSetEngroupForm, self).do_process(session)
+        # initialize which groups are already checked
+        # for this set of brokers
+        brokers = self.object.get(session)
+        broker_ids = [x.id for x in brokers]
+        mappings = BrokerGroupMapping.select()
+        groups = [BrokerGroup.get(x.brokerGroupID) for x in mappings if x.brokerID in broker_ids]
+        self.__groups.param.set(session, groups)
+
+    def process_submit(self, session):
+        brokers = self.object.get(session)
+        groups = self.__groups.get(session)
+        if len(brokers):
+            self.task.invoke(session, brokers, groups)
+        self.task.exit_with_redirect(session, brokers)

Modified: mgmt/trunk/cumin/python/cumin/messaging/broker.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/broker.strings	2009-10-21 14:22:23 UTC (rev 3675)
+++ mgmt/trunk/cumin/python/cumin/messaging/broker.strings	2009-10-22 00:17:56 UTC (rev 3676)
@@ -106,12 +106,6 @@
   font-style: italic;
 }
 
-[BrokerGroupInputSet.item_html]
-<div class="field">
-  <input type="checkbox" id="{id}" name="{name}" value="{item_value}" tabindex="{tab_index}" {item_checked_attr}/>
-  <label for="{id}">{item_content}</label>
-</div>
-
 [BrokerAccessControlView.html]
 <table class="twocol">
   <tbody>
@@ -145,3 +139,13 @@
     </tr>
   </tbody>
 </table>
+
+[BrokerSetEngroupForm.css]
+div.content ul {
+    list-style: none;
+}
+
+[BrokerSetEngroupForm.javascript]
+window.addEvent('domready',function () {
+    $$('button')[0].focus();
+});

Modified: mgmt/trunk/cumin/python/cumin/messaging/brokergroup.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/brokergroup.py	2009-10-21 14:22:23 UTC (rev 3675)
+++ mgmt/trunk/cumin/python/cumin/messaging/brokergroup.py	2009-10-22 00:17:56 UTC (rev 3676)
@@ -65,19 +65,6 @@
         if group in self.param.get(session):
             return "checked=\"checked\""
 
-class BrokerGroupCheckboxField(FormField):
-    def __init__(self, app, name):
-        super(BrokerGroupCheckboxField, self).__init__(app, name)
-
-        self.__groups = BrokerGroupInputSet(app, "inputs")
-        self.add_child(self.__groups)
-
-    def get(self, session):
-        return self.__groups.get(session)
-
-    def render_title(self, session):
-        return "Broker Groups"
-
 class BrokerGroupFrame(CuminFrame):
     def __init__(self, app, name):
         super(BrokerGroupFrame, self).__init__(app, name)

Modified: mgmt/trunk/cumin/python/cumin/messaging/brokergroup.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/brokergroup.strings	2009-10-21 14:22:23 UTC (rev 3675)
+++ mgmt/trunk/cumin/python/cumin/messaging/brokergroup.strings	2009-10-22 00:17:56 UTC (rev 3676)
@@ -6,3 +6,10 @@
 
 [BrokerGroupSet.count_sql]
 select count(*) from broker_group
+
+[BrokerGroupInputSet.item_html]
+<div class="field">
+  <input type="checkbox" id="{id}.{item_value}" name="{name}" value="{item_value}" tabindex="{tab_index}" {item_checked_attr}/>
+  <label for="{id}.{item_value}">{item_content}</label>
+</div>
+

Modified: mgmt/trunk/cumin/python/cumin/messaging/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/model.py	2009-10-21 14:22:23 UTC (rev 3675)
+++ mgmt/trunk/cumin/python/cumin/messaging/model.py	2009-10-22 00:17:56 UTC (rev 3676)
@@ -456,8 +456,24 @@
     def get_title(self, session):
         return "Add to groups"
 
-    def do_invoke(self, session, broker):
-        print "XXX engroup", broker
+    def do_invoke(self, session, broker, selected_groups):
+        all_groups = BrokerGroup.select()
+        selected_ids = [x.id for x in selected_groups]
+        for group in all_groups:
+            sql_sel = "broker_id=%i and broker_group_id=%i" % \
+                (broker.id, group.id)
+            existing_mapping = BrokerGroupMapping.select(sql_sel)
+            if not group.id in selected_ids:
+                if existing_mapping.count() > 0:
+                    # remove mapping if group is not checked and there
+                    # is already a mapping
+                    existing_mapping[0].destroySelf()
+            else:
+                if existing_mapping.count() == 0:
+                    # add mapping if group is checked but there
+                    # is not already a mapping
+                    new_mapping = BrokerGroupMapping(brokerID=broker.id, brokerGroupID=group.id)
+                    new_mapping.syncUpdate()
 
 class BrokerSetEngroupTask(SetTask):
     def __init__(self, app, cls):
@@ -473,9 +489,6 @@
     def do_enter(self, session, brokers):
         self.form.object.set(session, brokers)
 
-    def do_invoke(self, session, brokers):
-        pass
-
 def get_vhost_name(vhost):
     broker = vhost.broker
     name = broker.system.nodeName



More information about the rhmessaging-commits mailing list