rhmessaging commits: r2247 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2008-08-05 16:43:48 -0400 (Tue, 05 Aug 2008)
New Revision: 2247
Modified:
mgmt/trunk/cumin/python/cumin/exchange.py
mgmt/trunk/cumin/python/cumin/exchange.strings
Log:
Added Remove to ExchangeSet
Made ExchangeBindingsSet a phased set (for Active, Idle, and Deleted)
Modified: mgmt/trunk/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/exchange.py 2008-08-05 20:38:22 UTC (rev 2246)
+++ mgmt/trunk/cumin/python/cumin/exchange.py 2008-08-05 20:43:48 UTC (rev 2247)
@@ -9,7 +9,7 @@
from parameters import *
from formats import *
from util import *
-
+import pdb
strings = StringCatalog(__file__)
class ExchangeInputSet(RadioInputSet):
@@ -27,15 +27,21 @@
return exchange.id
def render_item_content(self, session, exchange):
- return exchange.name
+ return exchange.name or "<em>Default</em>"
def render_item_checked_attr(self, session, exchange):
return exchange is self.param.get(session) and "checked=\"checked\""
-class ExchangeSet(CuminTable):
+class ExchangeSet(CuminTable, Form):
def __init__(self, app, name):
super(ExchangeSet, self).__init__(app, name)
+ # exchange names we don't want to allow to remove
+ skips = ["", "amq.direct", "amq.topic", "amq.fanout",
+ "amq.match", "amq.xml", "qpid.management"]
+ self.ids = FilteredCheckboxIdColumn(app, "id", self, "name", skips)
+ self.add_column(self.ids)
+
col = self.NameColumn(app, "name")
self.add_column(col)
@@ -65,6 +71,9 @@
self.phase = PhaseSwitch(app, "phase")
self.add_child(self.phase)
+ self.__remove = self.Remove(app, "remove", self)
+ self.add_child(self.__remove)
+
def get_args(self, session):
reg = self.frame.get_object(session)
return (reg.getDefaultVhost(),)
@@ -76,7 +85,7 @@
def render_title(self, session, vhost):
return "Exchanges %s" % fmt_count(vhost.exchanges.count())
-
+
def render_sql_where(self, session, vhost):
elems = list()
elems.append("e.vhost_id = %(id)r")
@@ -86,6 +95,20 @@
def get_sql_values(self, session, vhost):
return {"id": vhost.id}
+ class Remove(FormButton):
+ def process_submit(self, session):
+ ids = self.parent.ids.get(session)
+ self.parent.ids.clear(session)
+
+ branch = session.branch()
+ frame = self.frame.show_exchanges_remove(branch)
+ frame.ids.set(branch, ids)
+ self.page.set_redirect_url(session, branch.marshal())
+
+ def render_content(self, session):
+ return "Remove"
+
+
class NameColumn(SqlTableColumn):
def render_title(self, session, data):
return "Name"
@@ -160,6 +183,25 @@
frame = page.show_exchange(session, exchange).show_view(session)
return frame.show_bindings(session)
+class ExchangeSetRemove(CuminBulkActionForm):
+ def process_return(self, session):
+ branch = session.branch()
+ self.frame.show_view(branch)
+ self.page.set_current_frame(branch, self.frame)
+ self.page.set_redirect_url(session, branch.marshal())
+
+ def process_item(self, session, id):
+ exchange = Exchange.get(id)
+ reg = self.frame.get_object(session)
+ action = self.app.model.exchange.remove
+ action.invoke(exchange, reg)
+
+ def render_title(self, session):
+ return "Remove Exchanges"
+
+ def render_item_content(self, session, id):
+ return "Remove Exchange '%s'" % Exchange.get(id).name
+
class ExchangeFrame(CuminFrame):
def __init__(self, app, name):
super(ExchangeFrame, self).__init__(app, name)
@@ -174,28 +216,34 @@
remove = ExchangeRemove(app, "remove")
self.add_mode(remove)
self.set_remove_mode(remove)
-
+
def render_title(self, session, exchange):
if exchange.name:
return super(ExchangeFrame, self).render_title(session, exchange)
else:
return "Default Exchange"
+ def render_href(self, session, exchange):
+ if exchange:
+ return super(ExchangeFrame, self).render_href(session, exchange)
+
+
class ExchangeRemove(CuminConfirmForm):
def get_args(self, session):
return self.frame.get_args(session)
-
- def process_cancel(self, session, reg):
+
+ def process_cancel(self, session, exchange):
branch = session.branch()
self.frame.show_view(branch)
self.page.set_redirect_url(session, branch.marshal())
- def process_submit(self, session, reg):
- action = self.app.model.broker_registration.remove
- action.invoke(reg)
+ def process_submit(self, session, exchange):
+ reg = self.frame.frame.get_object(session)
+ action = self.app.model.exchange.remove
+ action.invoke(exchange, reg)
branch = session.branch()
- self.page.show_main(branch).show_view(branch)
+ self.frame.frame.show_view(branch)
self.page.set_redirect_url(session, branch.marshal())
def render_title(self, session, exchange):
@@ -204,7 +252,7 @@
def render_submit_content(self, session, exchange):
return "Yes, Remove Exchange '%s'" % exchange.name
- def render_cancel_content(self, session, reg):
+ def render_cancel_content(self, session, exchange):
return "No, Cancel"
class ExchangeStatus(CuminStatus):
@@ -250,29 +298,103 @@
data = "model.xml?class=exchange;id=%i" % exchange.id
return "wooly.setIntervalUpdate('%s', updateExchange, 3000)" % data
-class ExchangeBindingSet(BindingSet):
- def get_args(self, session):
- return self.frame.get_args(session)
+class ExchangeBindingSet(BindingSet, Form):
+ def __init__(self, app, name):
+ super(ExchangeBindingSet, self).__init__(app, name)
+ self.__remove = self.Remove(app, "remove", self)
+ self.add_child(self.__remove)
+
+ def get_name_col(self, app):
+ return self.NameColumn(app, "q_id")
+
def render_title(self, session, exchange):
return "Queue Bindings %s" % \
- fmt_count(self.get_item_count(session, exchange))
+ fmt_count(exchange.bindings.count())
- def get_item_count(self, session, exchange):
- return exchange.bindings.count()
+ def render_sql_where(self, session, exchange):
+ elems = list()
+ elems.append("b.exchange_id = %(id)r")
+ elems.append(self.phase.get_sql_constraint(session, exchange))
+ return "where %s" % " and ".join(elems)
- def do_get_items(self, session, exchange):
- start, end = self.get_bounds(session)
- return exchange.bindings[start:end]
+ class NameColumn(SqlTableColumn):
+ def render_title(self, session, data):
+ return "Queue"
- def render_item_href(self, session, binding):
+ def render_content(self, session, data):
+ queue = Identifiable(data["q_id"])
+ branch = session.branch()
+ self.frame.frame.show_queue(branch, queue).show_view(branch)
+ return fmt_olink(branch, Queue.get(data["q_id"]))
+
+ class Remove(FormButton):
+ def process_submit(self, session):
+ ids = self.parent.ids.get(session)
+ self.parent.ids.clear(session)
+
+ exchange = self.frame.get_args(session)[0]
+ branch = session.branch()
+ frame = self.frame.frame.show_exchange_bindings_remove(branch, exchange)
+ frame.ids.set(branch, ids)
+ self.page.set_redirect_url(session, branch.marshal())
+
+ def render_content(self, session):
+ return "Remove"
+
+class BindingSetRemove(CuminBulkActionForm):
+ def process_item(self, session, id):
+ binding = Binding.get(id)
+ action = self.app.model.binding.remove
+ action.invoke(binding)
+
+ def render_title(self, session):
+ return "Remove Binding"
+
+ def render_form_heading(self, session, *args):
+ return "Remove Binding between:"
+
+ def render_item_content(self, session, id):
+ binding = Binding.get(id)
+ ename = binding.exchange.name or "Default"
+ qname = binding.queue.name
+ return "Exchange: %s <i>and</i> Queue: %s" % (ename, qname)
+
+class ExchangeBindingSetRemove(BindingSetRemove):
+ def __init__(self, app, name):
+ super(ExchangeBindingSetRemove, self).__init__(app, name)
+
+ self.__exchange = None
+
+ def set_exchange(self, exchange):
+ self.__exchange = exchange
+
+ def process_return(self, session):
branch = session.branch()
- self.frame.frame.show_queue(branch, binding.queue)
- return branch.marshal()
+ if self.__exchange:
+ mode = self.frame.show_exchange(branch, self.__exchange)
+ mode.show_view(branch).show_bindings(branch)
+ else:
+ self.frame.show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
+
+class QueueBindingSetRemove(BindingSetRemove):
+ def __init__(self, app, name):
+ super(QueueBindingSetRemove, self).__init__(app, name)
- def render_item_name(self, session, binding):
- if binding.queue:
- return binding.queue.name
+ self.__queue = None
+
+ def set_queue(self, queue):
+ self.__queue = queue
+
+ def process_return(self, session):
+ branch = session.branch()
+ if self.__queue:
+ mode = self.frame.show_queue(branch, self.__queue)
+ mode.show_view(branch).show_bindings(branch)
+ else:
+ self.frame.show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
class ExchangeForm(CuminFieldForm):
def __init__(self, app, name):
@@ -338,7 +460,7 @@
exchange.type = self.type.get(session)
action = self.app.model.exchange.add
- action.invoke(reg, exchange)
+ action.invoke(exchange, reg)
self.process_cancel(session)
@@ -372,33 +494,6 @@
def render_title(self, session, exchange):
return "Edit Exchange '%s'" % exchange.name
-class ExchangeRemove(CuminConfirmForm):
- def get_args(self, session):
- return self.frame.get_args(session)
-
- def process_cancel(self, session, exchange):
- branch = session.branch()
- self.page.show_exchange(branch, exchange).show_view(branch)
- session.set_redirect(branch.marshal())
-
- def process_submit(self, session, exchange):
- vhost = exchange.get_virtual_host()
-
- exchange.remove()
-
- branch = session.branch()
- self.page.show_broker(branch, vhost.get_broker()).show_view(branch)
- self.page.set_redirect_url(session, branch.marshal())
-
- def render_title(self, session, exchange):
- return "Remove Exchange '%s'" % exchange.name
-
- def render_submit_content(self, session, exchange):
- return "Yes, Remove Exchange '%s'" % exchange.name
-
- def render_cancel_content(self, session, exchange):
- return "No, Cancel"
-
class ExchangeStats(TabbedModeSet):
def __init__(self, app, name):
super(ExchangeStats, self).__init__(app, name)
Modified: mgmt/trunk/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/exchange.strings 2008-08-05 20:38:22 UTC (rev 2246)
+++ mgmt/trunk/cumin/python/cumin/exchange.strings 2008-08-05 20:43:48 UTC (rev 2247)
@@ -32,6 +32,7 @@
{sql_orderby}
{sql_limit}
+
[ExchangeSet.count_sql]
select count(*)
from exchange as e
@@ -46,27 +47,35 @@
}
[ExchangeSet.html]
+<form id="{id}" method="post" action="?">
-<ul class="actions">
- <li><a class="nav" href="{add_exchange_url}">Add New Exchange</a></li>
- </ul>
-
-<div class="rfloat">{phase}</div>
-{unit}
+ <ul class="actions">
+ <li><a class="nav" href="{add_exchange_url}">Add New Exchange</a></li>
+ </ul>
+
+ <div class="rfloat">{phase}</div>
+ {unit}
+
+ <div class="sactions">
+ <h2>Act on Selected Exchanges:</h2>
+ {remove}
+ </div>
+
+ <table class="mobjects">
+ <thead>
+ <tr>
+ <th class="setnav" colspan="{column_count}">
+ <div class="rfloat">{page}</div>
+ {count}
+ </th>
+ </tr>
+ <tr>{headers}</tr>
+ </thead>
+ <tbody>{items}</tbody>
+ </table>
+ <div>{hidden_inputs}</div>
+</form>
-<table class="mobjects">
- <thead>
- <tr>
- <th class="setnav" colspan="{column_count}">
- <div class="rfloat">{page}</div>
- {count}
- </th>
- </tr>
- <tr>{headers}</tr>
- </thead>
- <tbody>{items}</tbody>
-</table>
-
[ExchangeSet.item_html]
<tr>{cells}</tr>
@@ -178,27 +187,51 @@
cumin.runObjectListeners(exchange);
}
+[ExchangeBindingSet.sql]
+select
+ b.id,
+ b.queue_id as q_id,
+ b.binding_key as key
+from binding as b
+left outer join binding_stats as c on c.id = b.stats_curr_id
+{sql_where}
+{sql_orderby}
+{sql_limit}
+
+[ExchangeBindingSet.count_sql]
+select count(*)
+from binding as b
+left outer join binding_stats as c on c.id = b.stats_curr_id
+{sql_where}
+
[ExchangeBindingSet.html]
-<div class="rfloat">{page}</div>
-<ul class="radiotabs"> </ul>
+<form id="{id}" method="post" action="?">
-<table class="ExchangeBindingSet mobjects">
- <tr>
- <th>Queue</th>
- <th>Key</th>
- <th class="ralign" colspan="2">Messages Matched</th>
- </tr>
+ <div class="rfloat">{phase}</div>
+ <ul class="radiotabs"><li> </li></ul>
+
+ <div class="sactions">
+ <h2>Act on Selected Bindings:</h2>
+ {remove}
+ </div>
+
+ <table class="mobjects">
+ <thead>
+ <tr>
+ <th class="setnav" colspan="{column_count}">
+ <div class="rfloat">{page}</div>
+ {count}
+ </th>
+ </tr>
+ <tr>{headers}</tr>
+ </thead>
+ <tbody>{items}</tbody>
+ </table>
+ <div>{hidden_inputs}</div>
+</form>
- {items}
-</table>
-
[ExchangeBindingSet.item_html]
-<tr>
- <td><a href="{item_href}">{item_name}</a></td>
- <td>{item_binding_key}</td>
- <td class="ralign">{item_messages_matched_rate}</td>
- <td class="ralign">{item_messages_matched}</td>
-</tr>
+<tr>{cells}</tr>
[ExchangeStats.html]
<table class="twocol">
16 years, 5 months
rhmessaging commits: r2246 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2008-08-05 16:38:22 -0400 (Tue, 05 Aug 2008)
New Revision: 2246
Modified:
mgmt/trunk/cumin/python/cumin/brokerlink.py
Log:
Changed PeerRouteSet to a PaginatedItemSet
Modified: mgmt/trunk/cumin/python/cumin/brokerlink.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/brokerlink.py 2008-08-05 20:36:39 UTC (rev 2245)
+++ mgmt/trunk/cumin/python/cumin/brokerlink.py 2008-08-05 20:38:22 UTC (rev 2246)
@@ -146,7 +146,7 @@
data = "model.xml?class=peer;id=%i" % peer.id
return "wooly.setIntervalUpdate('%s', updatePeer, 3000)" % data
-class PeerRouteSet(RouteSet):
+class PeerRouteSet(PaginatedItemSet):
def get_args(self, session):
return self.frame.get_args(session)
16 years, 5 months
rhmessaging commits: r2245 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2008-08-05 16:36:39 -0400 (Tue, 05 Aug 2008)
New Revision: 2245
Modified:
mgmt/trunk/cumin/python/cumin/broker.py
Log:
Added modes for ExchangeSetRemove, QueueBindingSetRemove, and ExchangeBindingSetRemove
Modified: mgmt/trunk/cumin/python/cumin/broker.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/broker.py 2008-08-05 20:33:37 UTC (rev 2244)
+++ mgmt/trunk/cumin/python/cumin/broker.py 2008-08-05 20:36:39 UTC (rev 2245)
@@ -156,12 +156,21 @@
self.__exchange = ExchangeFrame(app, "exchange")
self.add_mode(self.__exchange)
+ self.__exchanges_remove = ExchangeSetRemove(app, "exchangesremove")
+ self.add_mode(self.__exchanges_remove)
+
+ self.__exchange_add = ExchangeAdd(app, "exchangeadd")
+ self.add_mode(self.__exchange_add)
+
+ self.__exchange_bindings_remove = ExchangeBindingSetRemove(app, "exbindingsremove")
+ self.add_mode(self.__exchange_bindings_remove)
+
+ self.__queue_bindings_remove = QueueBindingSetRemove(app, "qubindingsremove")
+ self.add_mode(self.__queue_bindings_remove)
+
self.__peer = PeerFrame(app, "peer")
self.add_mode(self.__peer)
- self.__exchange_add = ExchangeAdd(app, "exchangeadd")
- self.add_mode(self.__exchange_add)
-
self.__conn = ConnectionFrame(app, "conn")
self.add_mode(self.__conn)
@@ -189,14 +198,28 @@
self.page.set_current_frame(session, self.__exchange)
return self.show_mode(session, self.__exchange)
+ def show_exchanges_remove(self, session):
+ self.page.set_current_frame(session, self.__exchanges_remove)
+ return self.show_mode(session, self.__exchanges_remove)
+
+ def show_exchange_bindings_remove(self, session, exchange):
+ self.__exchange_bindings_remove.set_exchange(exchange)
+ self.page.set_current_frame(session, self.__exchange_bindings_remove)
+ return self.show_mode(session, self.__exchange_bindings_remove)
+
+ def show_queue_bindings_remove(self, session, queue):
+ self.__queue_bindings_remove.set_queue(queue)
+ self.page.set_current_frame(session, self.__queue_bindings_remove)
+ return self.show_mode(session, self.__queue_bindings_remove)
+
+ def show_exchange_add(self, session):
+ return self.show_mode(session, self.__exchange_add)
+
def show_peer(self, session, peer):
self.__peer.set_object(session, peer)
self.page.set_current_frame(session, self.__peer)
return self.show_mode(session, self.__peer)
- def show_exchange_add(self, session):
- return self.show_mode(session, self.__exchange_add)
-
def show_connection(self, session, conn):
self.__conn.set_object(session, conn)
self.page.set_current_frame(session, self.__conn)
16 years, 5 months
rhmessaging commits: r2244 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2008-08-05 16:33:37 -0400 (Tue, 05 Aug 2008)
New Revision: 2244
Added:
mgmt/trunk/cumin/python/cumin/binding.py
mgmt/trunk/cumin/python/cumin/binding.strings
Log:
FormField for entering and validating binding info
Added: mgmt/trunk/cumin/python/cumin/binding.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/binding.py (rev 0)
+++ mgmt/trunk/cumin/python/cumin/binding.py 2008-08-05 20:33:37 UTC (rev 2244)
@@ -0,0 +1,365 @@
+from cumin.util import sorted_by, is_active
+from formats import fmt_shorten
+from wooly.forms import FormInput, FormField
+from wooly.resources import StringCatalog
+from wooly import Template, Writer, Attribute
+from wooly.parameters import DictParameter
+
+strings = StringCatalog(__file__)
+
+class ExchangeInput(FormInput):
+ def __init__(self, app, name, form):
+ super(ExchangeInput, self).__init__(app, name, form)
+
+ self.exchange = None
+ self.instance_data = None
+
+ self.name_tmpl = Template(self, "name_html")
+ self.key_tmpl = Template(self, "key_html")
+
+ def get_args(self, session):
+ return (self.exchange,)
+
+ def get_exchange_info(self, session, exchange):
+ binding_info = self.form.bindings.dict_param.get(session)
+ if str(exchange.id) in binding_info:
+ return binding_info[str(exchange.id)]
+
+ def get_exchange_info_for(self, session, exchange, key):
+ exchange_info = self.get_exchange_info(session, exchange)
+ if exchange_info:
+ if key in exchange_info:
+ return exchange_info[key]
+
+ def render_exchange_name(self, session, exchange):
+ return exchange.name
+
+ def render_exchange_fmt_name(self, session, exchange):
+ return fmt_shorten(exchange.name)
+
+ def render_name_path(self, session, *args):
+ return "_".join((self.instance_data, "name"))
+
+ def render_exchange_type(self, session, exchange):
+ return exchange.type
+
+ def render_exchange_type_path(self, session, exchange):
+ return "_".join((self.instance_data, "type"))
+
+ def render_exchange_id(self, session, exchange):
+ return exchange.id
+
+ def render_exchange_checked(self, session, exchange):
+ exchange_info = self.get_exchange_info(session, exchange)
+ if exchange_info:
+ if "name" in exchange_info:
+ return "checked=\"checked\""
+
+ def render_exchange_name_input(self, session, exchange):
+ writer = Writer()
+ self.name_tmpl.render(writer, session, exchange)
+ return writer.to_string()
+
+ def render_exchange_key_input(self, session, exchange):
+ writer = Writer()
+ self.key_tmpl.render(writer, session, exchange)
+ return writer.to_string()
+
+ def render_onclick(self, session, exchange):
+ pass
+
+ def render_list_error(self, session, exchange):
+ errors = self.parent.binding_errors.get(session)
+ if exchange.name in errors:
+ return "<ul class=\"errors\" style=\"margin:0; float:left;\"><li>%s</li></ul>" % \
+ "</li><li>".join(errors[exchange.name])
+
+ def render_dict_error(self, session, exchange, key):
+ errors = self.parent.binding_errors.get(session)
+ if exchange.name in errors:
+ exchange_errors = errors[exchange.name]
+ if key in exchange_errors:
+ return "<ul class=\"errors\" style=\"margin:0; float:left;\"><li>%s</li></ul>" % \
+ "</li><li>".join(exchange_errors[key])
+
+ def set_instance_data(self, exchange, dict_key):
+ self.exchange = exchange
+ self.instance_data = dict_key
+
+class DirectExchangeInput(ExchangeInput):
+ pass
+
+class FanoutExchangeInput(ExchangeInput):
+ pass
+
+class BindingKeyExchangeInput(ExchangeInput):
+ def __init__(self, app, name, form):
+ super(BindingKeyExchangeInput, self).__init__(app, name, form)
+
+ def render_key_path(self, session, exchange):
+ return "_".join((self.instance_data, "key"))
+
+ def render_key_error(self, session, exchange):
+ return self.render_list_error(session, exchange)
+
+ def render_key_value(self, session, exchange):
+ return self.get_exchange_info_for(session, exchange, "key")
+
+class TopicExchangeInput(BindingKeyExchangeInput):
+ pass
+
+class XMLExchangeInput(BindingKeyExchangeInput):
+ def __init__(self, app, name, form):
+ super(XMLExchangeInput, self).__init__(app, name, form)
+
+ def render_xquery_path(self, session, exchange):
+ return "_".join((self.instance_data, "xquery"))
+
+ def render_headers_class(self, session, exchange):
+ exchange_info = self.get_exchange_info(session, exchange)
+ if not exchange_info or not "name" in exchange_info:
+ return "initial_header_state"
+
+ def render_key_error(self, session, exchange):
+ return self.render_dict_error(session, exchange, "key")
+
+ def render_onclick(self, session, exchange):
+ return "onclick=\"toggle_row(this, 'xml_extra')\""
+
+ def render_xquery_error(self, session, exchange):
+ return self.render_dict_error(session, exchange, "xquery")
+
+ def render_xquery_value(self, session, exchange):
+ return self.get_exchange_info_for(session, exchange, "xquery")
+
+class HeadersExchangeInput(BindingKeyExchangeInput):
+ def __init__(self, app, name, form):
+ super(HeadersExchangeInput, self).__init__(app, name, form)
+
+ def render_x_match_path(self, session, exchange):
+ return "_".join((self.instance_data, "x-match"))
+
+ def render_mkey_path(self, session, exchange):
+ return "_".join((self.instance_data, "mkey"))
+
+ def render_headers_class(self, session, exchange):
+ exchange_info = self.get_exchange_info(session, exchange)
+ if not exchange_info or not "name" in exchange_info:
+ return "initial_header_state"
+
+ def render_all_checked(self, session, exchange):
+ checked = self.render_any_checked(session, exchange)
+ if not checked:
+ return "checked=\"checked\""
+
+ def render_any_checked(self, session, exchange):
+ exchange_info = self.get_exchange_info(session, exchange)
+ if exchange_info:
+ if "x-match" in exchange_info:
+ if exchange_info["x-match"] == "any":
+ return "checked=\"checked\""
+
+ def render_mkey1_value(self, session, exchange):
+ return self.get_exchange_info_for(session, exchange, "mkey.1")
+
+ def render_mkey2_value(self, session, exchange):
+ return self.get_exchange_info_for(session, exchange, "mkey.2")
+
+ def render_mkey3_value(self, session, exchange):
+ return self.get_exchange_info_for(session, exchange, "mkey.3")
+
+ def render_mnv1_value(self, session, exchange):
+ return self.get_exchange_info_for(session, exchange, "mkey.1.nv")
+
+ def render_mnv2_value(self, session, exchange):
+ return self.get_exchange_info_for(session, exchange, "mkey.2.nv")
+
+ def render_mnv3_value(self, session, exchange):
+ return self.get_exchange_info_for(session, exchange, "mkey.3.nv")
+
+ def render_key_error(self, session, exchange):
+ return self.render_dict_error(session, exchange, "key")
+
+ def render_mkey1_error(self, session, exchange):
+ return self.render_dict_error(session, exchange, "mkey.1")
+
+ def render_mkey2_error(self, session, exchange):
+ return self.render_dict_error(session, exchange, "mkey.2")
+
+ def render_mkey3_error(self, session, exchange):
+ return self.render_dict_error(session, exchange, "mkey.3")
+
+ def render_onclick(self, session, exchange):
+ return "onclick=\"toggle_row(this, 'headers_extra')\""
+
+
+
+class ExchangeKeysField(FormField):
+ def __init__(self, app, name, form, title="Initial bindings:"):
+ super(ExchangeKeysField, self).__init__(app, name, form)
+
+ self.dict_param = DictParameter(app, "exchange", form)
+ self.add_parameter(self.dict_param)
+ form.add_form_parameter(self.dict_param)
+
+ self.direct_input = DirectExchangeInput(app, "direct", form)
+ self.add_child(self.direct_input)
+
+ self.topic_input = TopicExchangeInput(app, "topic", form)
+ self.add_child(self.topic_input)
+
+ self.fanout_input = FanoutExchangeInput(app, "fanout", form)
+ self.add_child(self.fanout_input)
+
+ self.xml_input = XMLExchangeInput(app, "xml", form)
+ self.add_child(self.xml_input)
+
+ self.headers_input = HeadersExchangeInput(app, "headers", form)
+ self.add_child(self.headers_input)
+
+ self.title = title
+
+ self.binding_errors = self.Errors(self, "binding_errors")
+ self.add_attribute(self.binding_errors)
+
+ def get_args(self, session):
+ broker = self.get_parent_named("broker")
+ reg = broker.get_object(session)
+ return (reg.getDefaultVhost(),)
+
+ class Errors(Attribute):
+ def get_default(self, session):
+ return dict()
+
+ def render_title(self, session, vhost):
+ return self.title
+
+ def render_exchanges(self, session, vhost):
+ sortedExchanges = sorted_by(vhost.exchanges)
+
+ # render each exchange we support
+ writer = Writer()
+ for exchange in sortedExchanges:
+ if is_active(exchange):
+ # instance_key gives us a unique path for each exchange
+ # we will be rendering
+ instance_key = self.dict_param.get_instance_key(str(exchange.id))
+ if exchange.type == "direct":
+ if exchange.name:
+ self.direct_input.set_instance_data(exchange, instance_key)
+ writer.write(self.direct_input.render(session))
+ elif exchange.type == "topic":
+ if not exchange.name == "qpid.management":
+ self.topic_input.set_instance_data(exchange, instance_key)
+ writer.write(self.topic_input.render(session))
+ elif exchange.type == "fanout":
+ self.fanout_input.set_instance_data(exchange, instance_key)
+ writer.write(self.fanout_input.render(session))
+ elif exchange.type == "xml":
+ self.xml_input.set_instance_data(exchange, instance_key)
+ writer.write(self.xml_input.render(session))
+ elif exchange.type == "headers":
+ self.headers_input.set_instance_data(exchange, instance_key)
+ writer.write(self.headers_input.render(session))
+
+ return writer.to_string()
+
+ def get_binding_info(self, session, queue_name):
+
+ form_binding_info = self.process_binding_info(session, queue_name)
+ binding_info = self.dict_param.get(session)
+ berrs = self.binding_errors.get(session)
+
+ for exchange in form_binding_info:
+ type = form_binding_info[exchange]["type"]
+ if type == "topic":
+ if not "key" in form_binding_info[exchange]:
+ name = form_binding_info[exchange]["name"]
+ errs = berrs.setdefault(name, list())
+ errs.append("A binding key is required")
+ elif type == "headers":
+ if not "key" in form_binding_info[exchange]:
+ name = form_binding_info[exchange]["name"]
+ errs = berrs.setdefault(name, dict())
+ errs["key"] = ["A binding key is required"]
+ for key_num in ("1", "2", "3"):
+ mkey = "mkey."+key_num
+ mkeynv = mkey+".nv"
+ if mkeynv in binding_info[exchange]:
+ if not mkey in binding_info[exchange]:
+ name = binding_info[exchange]["name"]
+ if not name in berrs:
+ berrs.setdefault(name, dict())
+ berrs[name][mkey] = ["Missing key"]
+ elif type == "xml":
+ if not "key" in form_binding_info[exchange]:
+ name = form_binding_info[exchange]["name"]
+ errs = berrs.setdefault(name, dict())
+ errs["key"] = ["A binding key is required"]
+ if not "xquery" in form_binding_info[exchange]:
+ name = binding_info[exchange]["name"]
+ if not name in berrs:
+ berrs.setdefault(name, dict())
+ berrs[name]["xquery"] = ["Missing xquery"]
+
+ if len(berrs):
+ # Tell dictionary to clear out any
+ # values the next time the page is submitted
+ # before it starts adding new entries.
+ # This is needed because checkboxes don't
+ # send a blank value when they are cleared.
+ self.dict_param.set_clear_on_add()
+ else:
+ self.dict_param.clear()
+
+ return (len(berrs), form_binding_info)
+
+ def process_binding_info(self, session, queue_name):
+ binding_info = self.dict_param.get(session)
+ form_binding_info = dict()
+ for this_exchange in binding_info:
+ # if the exchange checkbox is checked
+ if "name" in binding_info[this_exchange]:
+ form_binding_info[this_exchange] = dict()
+ arguments = dict()
+ type = binding_info[this_exchange]["type"]
+ if type == "headers":
+ arguments["x-match"] = binding_info[this_exchange]["x-match"]
+
+ # Fill out the other arguments.
+ # The form has input boxes named mkey.* and mkey.*.nv
+ # We need to create an arguments dictionary entry
+ # of the form {mkey.*.value: mkey.*.nv.value}
+ for match_info in binding_info[this_exchange]:
+ if binding_info[this_exchange][match_info]:
+ if match_info.startswith("mkey") \
+ and not match_info.endswith("nv"):
+ # find the value in the matching .nv field
+ match_value = self._find_match_value(binding_info,
+ this_exchange, match_info)
+ # it is valid for the value in the .nv field
+ # to be empty
+ arguments[binding_info[this_exchange][match_info]] = \
+ match_value or None
+ elif type == "xml":
+ if "xquery" in binding_info[this_exchange]:
+ arguments["xquery"] = binding_info[this_exchange]["xquery"]
+ elif type == "direct":
+ binding_info[this_exchange]["key"] = queue_name
+ #topic and fanout exchanges don't need any processing
+
+ form_binding_info[this_exchange]["name"] = binding_info[this_exchange]["name"]
+ if "key" in binding_info[this_exchange]:
+ form_binding_info[this_exchange]["key"] = binding_info[this_exchange]["key"]
+ form_binding_info[this_exchange]["arguments"] = arguments
+ # type is used in form validation only
+ form_binding_info[this_exchange]["type"] = binding_info[this_exchange]["type"]
+
+ return form_binding_info
+
+ def _find_match_value(self, binding_info, this_exchange, match_info):
+ for m_info in binding_info[this_exchange]:
+ if m_info.startswith(match_info):
+ if m_info.endswith("nv"):
+ return binding_info[this_exchange][m_info]
+
Added: mgmt/trunk/cumin/python/cumin/binding.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/binding.strings (rev 0)
+++ mgmt/trunk/cumin/python/cumin/binding.strings 2008-08-05 20:33:37 UTC (rev 2244)
@@ -0,0 +1,155 @@
+
+[ExchangeInput.name_html]
+ <td><input type="checkbox"
+ id="{id}.{exchange_id}"
+ name="{name_path}" value="{exchange_name}" size="15"
+ tabindex="100" {exchange_checked}
+ {onclick} />
+ <input type="hidden"
+ name="{exchange_type_path}" value="{exchange_type}" /></td>
+ <td><label class="exchange_name" for="{id}.{exchange_id}">{exchange_fmt_name}</label></td>
+ <td class="exchange_type">{exchange_type}</td>
+
+[ExchangeInput.key_html]
+ <td><input type="text"
+ name="{key_path}" id="{exchange_name}"
+ value="{key_value}" size="32" maxlength="256" tabindex="100" />
+ {key_error}</td>
+
+[DirectExchangeInput.html]
+ <tr>
+ {exchange_name_input}
+ <td> </td>
+ </tr>
+
+[TopicExchangeInput.html]
+ <tr>
+ {exchange_name_input}
+ {exchange_key_input}
+ </tr>
+
+[FanoutExchangeInput.html]
+ <tr>
+ {exchange_name_input}
+ <td> </td>
+ </tr>
+
+[XMLExchangeInput.html]
+ <tr>
+ {exchange_name_input}
+ {exchange_key_input}
+ </tr>
+ <tr id="xml_extra" class="{headers_class}"><td colspan="4"><table>
+ <tr>
+ <td>XQuery:</td>
+ <td colspan="3"><textarea name="{xquery_path}" id="{exchange_name}"
+ tabindex="100" rows="4" cols="40">{xquery_value}</textarea>{xquery_error}</td>
+ </tr></table></td></tr>
+
+[HeadersExchangeInput.html]
+ <tr>
+ {exchange_name_input}
+ {exchange_key_input}
+ </tr>
+ <tr id="headers_extra" class="{headers_class}"><td colspan="4"><table>
+ <tr>
+ <td> </td>
+ <td>x-match Type:</td>
+ <td colspan="2"><input type="radio" id="headers.x-match.all"
+ name="{x_match_path}" value="all" {all_checked} />
+ <label for="headers.x-match.all">All</label>
+ <input type="radio" id="headers.x-match.any"
+ name="{x_match_path}" value="any" {any_checked}/>
+ <label for="headers.x-match.any">Any</label>
+ </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td>Match Keys:</td>
+ <td colspan="2">
+ <table class="xmlExchange">
+ <thead>
+ <tr>
+ <th>Key</th><th>type, value</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><input type="text" name="{mkey_path}.1" value="{mkey1_value}" tabindex="100" />{mkey1_error}</td>
+ <td><input type="text" name="{mkey_path}.1.nv" value="{mnv1_value}" tabindex="100" /></td>
+ </tr>
+ <tr>
+ <td><input type="text" name="{mkey_path}.2" value="{mkey2_value}" tabindex="100" />{mkey2_error}</td>
+ <td><input type="text" name="{mkey_path}.2.nv" value="{mnv2_value}" tabindex="100" /></td>
+ </tr>
+ <tr>
+ <td><input type="text" name="{mkey_path}.3" value="{mkey3_value}" tabindex="100" />{mkey3_error}</td>
+ <td><input type="text" name="{mkey_path}.3.nv" value="{mnv3_value}" tabindex="100" /></td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr></table></td></tr>
+
+[ExchangeKeysField.css]
+td.exchange_type {
+ font-style: italic;
+}
+
+table.mobjects tr#headers_extra {
+ border-top: 0px;
+}
+
+table.mobjects tr.initial_header_state {
+ display:none;
+}
+
+table.xmlExchange {
+ border-collapse: collapse;
+ border: 1px dotted #ccc;
+ margin: 0;
+}
+
+table.xmlExchange tr {
+ border-top: 0px solid #fff;
+}
+
+table.mobjects label.exchange_name {
+ font-weight: bold;
+}
+
+table.mobjects td.exchange_type, table.mobjects th.exchange_type {
+ font-style: italic;
+}
+
+[ExchangeKeysField.javascript]
+function toggle_row(chk, row_id) {
+
+ var display = "none";
+ var headers_extra = document.getElementById(row_id);
+ if (chk.checked)
+ display = "table-row";
+
+ headers_extra.style.display = display;
+}
+
+[ExchangeKeysField.html]
+<div class="field">
+ <div class="title">{title}</div>
+
+<div class="inputs">
+<table class="mobjects" id="exchange_types">
+ <thead>
+ <tr>
+ <th colspan="2"><label class="exchange_name">Exchange Name</label></th>
+ <th class="exchange_type">Exchange Type</th>
+ <th>Binding Key</th>
+ </tr>
+ </thead>
+ <tbody>
+ {exchanges}
+ </tbody>
+</table>
+</div>
+</div>
+
16 years, 5 months
rhmessaging commits: r2243 - store/branches/java/broker-queue-refactor/java/bdbstore.
by rhmessaging-commits@lists.jboss.org
Author: ritchiem
Date: 2008-08-05 07:24:32 -0400 (Tue, 05 Aug 2008)
New Revision: 2243
Modified:
store/branches/java/broker-queue-refactor/java/bdbstore/build.xml
Log:
Updated build.xml to use build throughout
Modified: store/branches/java/broker-queue-refactor/java/bdbstore/build.xml
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/build.xml 2008-07-31 20:58:27 UTC (rev 2242)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/build.xml 2008-08-05 11:24:32 UTC (rev 2243)
@@ -1,7 +1,7 @@
<!--
- Simple Build file for BDBStore
-->
-<project name="BDBStore" default="compile">
+<project name="BDBStore" default="build">
<property name="src.dir" location="src/main/java"/>
<property name="src.test.dir" location="src/test/java"/>
@@ -30,29 +30,29 @@
<delete dir="${build.dir}"/>
</target>
- <target name="compile" depends="init">
+ <target name="build" depends="init">
<javac srcdir="${src.dir}"
destdir="${build.classes}"
classpathref="class.path"/>
</target>
- <target name="compile-tests" depends="init,compile">
+ <target name="build-tests" depends="init,build">
<javac srcdir="${src.test.dir}"
destdir="${build.test.classes}"
classpathref="test.class.path"/>
</target>
- <target name="jar" depends="compile">
+ <target name="jar" depends="build">
<jar destfile="build/qpid-bdbstore.jar" basedir="build/classes"/>
</target>
- <target name="test" depends="compile, compile-tests">
+ <target name="test" depends="build, build-tests">
</target>
- <target name="teststuff" depends="build,compile-tests" if="module.test.src.exists"
+ <target name="teststuff" depends="build,build-tests" if="module.test.src.exists"
unless="${dontruntest}" description="execute unit tests">
<delete file="${module.failed}"/>
@@ -102,7 +102,7 @@
</target>
- <target name="release" depends="compile, jar"/>
+ <target name="release" depends="build, jar"/>
</project>
16 years, 5 months