Commit d6491f20 authored by Guillaume Surrel's avatar Guillaume Surrel
Browse files

Adapt to new history data structures and to new UpdateCompleteHandler.

parent 4c121f43
......@@ -23,15 +23,14 @@
package com.scalagent.appli.client.presenter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import com.google.gwt.event.shared.HandlerManager;
import com.scalagent.appli.client.Application;
import com.scalagent.appli.client.RPCServiceAsync;
import com.scalagent.appli.client.RPCServiceCacheClient;
import com.scalagent.appli.client.RPCServiceCacheClient.HistoryData;
import com.scalagent.appli.client.command.message.DeleteMessageAction;
import com.scalagent.appli.client.command.message.DeleteMessageHandler;
import com.scalagent.appli.client.command.message.DeleteMessageResponse;
......@@ -41,6 +40,7 @@ import com.scalagent.appli.client.command.message.SendEditedMessageResponse;
import com.scalagent.appli.client.command.message.SendNewMessageAction;
import com.scalagent.appli.client.command.message.SendNewMessageHandler;
import com.scalagent.appli.client.command.message.SendNewMessageResponse;
import com.scalagent.appli.client.event.common.UpdateCompleteEvent;
import com.scalagent.appli.client.event.common.UpdateCompleteHandler;
import com.scalagent.appli.client.event.message.DeletedMessageHandler;
import com.scalagent.appli.client.event.message.NewMessageHandler;
......@@ -139,10 +139,10 @@ public class QueueDetailPresenter extends
* This method is called by the EventBus when the update is done.
* The refresh button is re-enabled and the chart redrawn
*/
public void onUpdateComplete(String info) {
if (queue.getId().equals(info)) {
public void onUpdateComplete(int updateType, String info) {
if (updateType == UpdateCompleteEvent.QUEUE_UPDATE) {
widget.getRefreshButton().enable();
widget.redrawChart(true);
widget.redrawChart();
}
}
......@@ -193,7 +193,7 @@ public class QueueDetailPresenter extends
*
* @result A map containing the history of the current queue
*/
public SortedMap<Date, int[]> getQueueHistory() {
public List<HistoryData> getQueueHistory() {
return cache.getSpecificHistory(queue.getId());
}
......
......@@ -22,13 +22,12 @@
*/
package com.scalagent.appli.client.presenter;
import java.util.Date;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.List;
import com.google.gwt.event.shared.HandlerManager;
import com.scalagent.appli.client.RPCServiceAsync;
import com.scalagent.appli.client.RPCServiceCacheClient;
import com.scalagent.appli.client.RPCServiceCacheClient.HistoryData;
import com.scalagent.appli.client.command.queue.ClearPendingMessageAction;
import com.scalagent.appli.client.command.queue.ClearPendingMessageHandler;
import com.scalagent.appli.client.command.queue.ClearPendingMessageResponse;
......@@ -44,6 +43,7 @@ import com.scalagent.appli.client.command.queue.SendEditedQueueResponse;
import com.scalagent.appli.client.command.queue.SendNewQueueAction;
import com.scalagent.appli.client.command.queue.SendNewQueueHandler;
import com.scalagent.appli.client.command.queue.SendNewQueueResponse;
import com.scalagent.appli.client.event.common.UpdateCompleteEvent;
import com.scalagent.appli.client.event.common.UpdateCompleteHandler;
import com.scalagent.appli.client.event.queue.DeletedQueueHandler;
import com.scalagent.appli.client.event.queue.NewQueueHandler;
......@@ -64,7 +64,6 @@ import com.smartgwt.client.util.SC;
public class QueueListPresenter extends
BasePresenter<QueueListWidget, RPCServiceAsync, RPCServiceCacheClient> implements NewQueueHandler,
DeletedQueueHandler, UpdatedQueueHandler, UpdateCompleteHandler {
SortedMap<Date, Integer> chartHistory = new TreeMap<Date, Integer>();
public QueueListPresenter(RPCServiceAsync testService, HandlerManager eventBus, RPCServiceCacheClient cache) {
......@@ -164,8 +163,8 @@ public class QueueListPresenter extends
* This method is called by the EventBus when the update is done.
* The refresh button is re-enabled and the chart redrawn
*/
public void onUpdateComplete(String info) {
if (info.equals("queue")) {
public void onUpdateComplete(int updateType, String info) {
if (updateType == UpdateCompleteEvent.QUEUE_UPDATE) {
widget.getRefreshButton().enable();
widget.redrawChart(true);
}
......@@ -176,7 +175,7 @@ public class QueueListPresenter extends
*
* @result A map containing the history of the current queue
*/
public SortedMap<Date, int[]> getQueueHistory(String name) {
public List<HistoryData> getQueueHistory(String name) {
return cache.getSpecificHistory(name);
}
......
......@@ -22,13 +22,15 @@
*/
package com.scalagent.appli.client.presenter;
import java.util.Date;
import java.util.HashMap;
import java.util.SortedMap;
import java.util.List;
import java.util.Map;
import com.google.gwt.event.shared.HandlerManager;
import com.scalagent.appli.client.RPCServiceAsync;
import com.scalagent.appli.client.RPCServiceCacheClient;
import com.scalagent.appli.client.RPCServiceCacheClient.FloatHistoryData;
import com.scalagent.appli.client.RPCServiceCacheClient.HistoryData;
import com.scalagent.appli.client.event.common.UpdateCompleteEvent;
import com.scalagent.appli.client.event.common.UpdateCompleteHandler;
import com.scalagent.appli.client.widget.ServerWidget;
import com.scalagent.appli.shared.QueueWTO;
......@@ -56,35 +58,8 @@ public class ServerPresenter extends BasePresenter<ServerWidget, RPCServiceAsync
*
* @result A map containing the history of the number of queues.
*/
public SortedMap<Date, Integer> getQueuesHistory() {
return cache.getQueuesHistory();
}
/**
* This method is called by the ServerWidget when the updating the chart.
*
* @result A map containing the history of the number of topics.
*/
public SortedMap<Date, Integer> getTopicsHistory() {
return cache.getTopicsHistory();
}
/**
* This method is called by the ServerWidget when the updating the chart.
*
* @result A map containing the history of the number of users.
*/
public SortedMap<Date, Integer> getUsersHistory() {
return cache.getUsersHistory();
}
/**
* This method is called by the ServerWidget when the updating the chart.
*
* @result A map containing the history of the number of subscriptions.
*/
public SortedMap<Date, Integer> getSubsHistory() {
return cache.getSubsHistory();
public List<HistoryData> getCountHistory() {
return cache.getCountHistory();
}
/**
......@@ -93,7 +68,7 @@ public class ServerPresenter extends BasePresenter<ServerWidget, RPCServiceAsync
* @result A map containing the history of the average load of the engine and
* the networks.
*/
public SortedMap<Date, float[]> getServerHistory() {
public List<FloatHistoryData> getServerHistory() {
return cache.getServerHistory();
}
......@@ -101,49 +76,56 @@ public class ServerPresenter extends BasePresenter<ServerWidget, RPCServiceAsync
* This method is called by the EventBus when the update is done.
* The histories are updated
*/
public void onUpdateComplete(String info) {
if (!"server".equals(info)) {
return;
}
public void onUpdateComplete(int updateType, String info) {
cache.addToHistory(RPCServiceCacheClient.QUEUE, cache.getQueues().size());
cache.addToHistory(RPCServiceCacheClient.SUB, cache.getSubscriptions().size());
cache.addToHistory(RPCServiceCacheClient.TOPIC, cache.getTopics().size());
cache.addToHistory(RPCServiceCacheClient.USER, cache.getUsers().size());
HashMap<String, QueueWTO> queues = cache.getQueues();
for (String key : queues.keySet()) {
QueueWTO queue = queues.get(key);
cache.addToSpecificHistory(queue.getId(), (int) queue.getNbMsgsReceiveSinceCreation(),
(int) queue.getNbMsgsDeliverSinceCreation(), (int) queue.getNbMsgsSentToDMQSinceCreation(),
(int) queue.getPendingMessageCount());
}
if (updateType == UpdateCompleteEvent.SERVER_INFO_UPDATE) {
HashMap<String, TopicWTO> topics = cache.getTopics();
for (String key : topics.keySet()) {
TopicWTO topic = topics.get(key);
cache.addToSpecificHistory(topic.getId(), (int) topic.getNbMsgsReceiveSinceCreation(),
(int) topic.getNbMsgsDeliverSinceCreation(), (int) topic.getNbMsgsSentToDMQSinceCreation());
}
cache.addToCountHistory(cache.getQueues().size(), cache.getTopics().size(), cache.getUsers().size(),
cache.getSubscriptions().size());
HashMap<String, UserWTO> users = cache.getUsers();
for (String key : users.keySet()) {
UserWTO user = users.get(key);
cache.addToSpecificHistory(user.getId(), (int) user.getNbMsgsSentToDMQSinceCreation(),
(int) user.getSubscriptionNames().length);
}
List<FloatHistoryData> history = cache.getServerHistory();
if (history.size() != 0) {
widget.initCharts(history.get(0).data.length);
widget.redrawChart();
}
HashMap<String, SubscriptionWTO> subs = cache.getSubscriptions();
for (String key : subs.keySet()) {
SubscriptionWTO sub = subs.get(key);
cache.addToSpecificHistory(sub.getId(), (int) sub.getPendingMessageCount(),
(int) sub.getNbMsgsDeliveredSinceCreation(), (int) sub.getNbMsgsSentToDMQSinceCreation());
}
} else if (updateType == UpdateCompleteEvent.QUEUE_UPDATE) {
Map<String, QueueWTO> queues = cache.getQueues();
for (String key : queues.keySet()) {
QueueWTO queue = queues.get(key);
cache.addToSpecificHistory(queue.getId(), (int) queue.getNbMsgsReceiveSinceCreation(),
(int) queue.getNbMsgsDeliverSinceCreation(), (int) queue.getNbMsgsSentToDMQSinceCreation(),
(int) queue.getPendingMessageCount());
}
} else if (updateType == UpdateCompleteEvent.TOPIC_UPDATE) {
Map<String, TopicWTO> topics = cache.getTopics();
for (String key : topics.keySet()) {
TopicWTO topic = topics.get(key);
cache.addToSpecificHistory(topic.getId(), (int) topic.getNbMsgsReceiveSinceCreation(),
(int) topic.getNbMsgsDeliverSinceCreation(), (int) topic.getNbMsgsSentToDMQSinceCreation());
}
} else if (updateType == UpdateCompleteEvent.USER_UPDATE) {
Map<String, UserWTO> users = cache.getUsers();
for (String key : users.keySet()) {
UserWTO user = users.get(key);
cache.addToSpecificHistory(user.getId(), (int) user.getNbMsgsSentToDMQSinceCreation(),
(int) user.getSubscriptionNames().length);
}
} else if (updateType == UpdateCompleteEvent.SUBSCRIPTION_UPDATE) {
Map<String, SubscriptionWTO> subs = cache.getSubscriptions();
for (String key : subs.keySet()) {
SubscriptionWTO sub = subs.get(key);
cache.addToSpecificHistory(sub.getId(), (int) sub.getPendingMessageCount(),
(int) sub.getNbMsgsDeliveredSinceCreation(), (int) sub.getNbMsgsSentToDMQSinceCreation());
}
SortedMap<Date, float[]> h = cache.getServerHistory();
if (h.size() != 0) {
widget.initCharts(h.get(h.firstKey()).length);
widget.redrawChart(true, true);
}
}
......
......@@ -23,15 +23,14 @@
package com.scalagent.appli.client.presenter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.shared.HandlerManager;
import com.scalagent.appli.client.RPCServiceAsync;
import com.scalagent.appli.client.RPCServiceCacheClient;
import com.scalagent.appli.client.RPCServiceCacheClient.HistoryData;
import com.scalagent.appli.client.command.message.DeleteMessageAction;
import com.scalagent.appli.client.command.message.DeleteMessageHandler;
import com.scalagent.appli.client.command.message.DeleteMessageResponse;
......@@ -41,6 +40,7 @@ import com.scalagent.appli.client.command.message.SendEditedMessageResponse;
import com.scalagent.appli.client.command.message.SendNewMessageAction;
import com.scalagent.appli.client.command.message.SendNewMessageHandler;
import com.scalagent.appli.client.command.message.SendNewMessageResponse;
import com.scalagent.appli.client.event.common.UpdateCompleteEvent;
import com.scalagent.appli.client.event.common.UpdateCompleteHandler;
import com.scalagent.appli.client.event.message.DeletedMessageHandler;
import com.scalagent.appli.client.event.message.NewMessageHandler;
......@@ -141,10 +141,10 @@ public class SubscriptionDetailPresenter extends
* This method is called by the EventBus when the update is done.
* The refresh button is re-enabled and the chart redrawn
*/
public void onUpdateComplete(String info) {
if (sub.getId().equals(info)) {
public void onUpdateComplete(int updateType, String info) {
if (updateType == UpdateCompleteEvent.SUBSCRIPTION_UPDATE) {
widget.getRefreshButton().enable();
widget.redrawChart(true);
widget.redrawChart();
}
}
......@@ -213,7 +213,7 @@ public class SubscriptionDetailPresenter extends
*
* @result A map containing the history of the number of subscriptions.
*/
public SortedMap<Date, int[]> getSubHistory() {
public List<HistoryData> getSubHistory() {
return cache.getSpecificHistory(sub.getId());
}
......
......@@ -22,12 +22,12 @@
*/
package com.scalagent.appli.client.presenter;
import java.util.Date;
import java.util.SortedMap;
import java.util.List;
import com.google.gwt.event.shared.HandlerManager;
import com.scalagent.appli.client.RPCServiceAsync;
import com.scalagent.appli.client.RPCServiceCacheClient;
import com.scalagent.appli.client.RPCServiceCacheClient.HistoryData;
import com.scalagent.appli.client.command.subscription.DeleteSubscriptionAction;
import com.scalagent.appli.client.command.subscription.DeleteSubscriptionHandler;
import com.scalagent.appli.client.command.subscription.DeleteSubscriptionResponse;
......@@ -37,6 +37,7 @@ import com.scalagent.appli.client.command.subscription.SendEditedSubscriptionRes
import com.scalagent.appli.client.command.subscription.SendNewSubscriptionAction;
import com.scalagent.appli.client.command.subscription.SendNewSubscriptionHandler;
import com.scalagent.appli.client.command.subscription.SendNewSubscriptionResponse;
import com.scalagent.appli.client.event.common.UpdateCompleteEvent;
import com.scalagent.appli.client.event.common.UpdateCompleteHandler;
import com.scalagent.appli.client.event.subscription.DeletedSubscriptionHandler;
import com.scalagent.appli.client.event.subscription.NewSubscriptionHandler;
......@@ -80,8 +81,8 @@ public class SubscriptionListPresenter extends
* The refresh button is re-enabled and the chart redrawn
*/
@Override
public void onUpdateComplete(String info) {
if (info.equals("sub")) {
public void onUpdateComplete(int updateType, String info) {
if (updateType == UpdateCompleteEvent.SUBSCRIPTION_UPDATE) {
widget.getRefreshButton().enable();
widget.redrawChart(true);
}
......@@ -120,7 +121,7 @@ public class SubscriptionListPresenter extends
*
* @result A map containing the history of the current subscription
*/
public SortedMap<Date, int[]> getSubHistory(String name) {
public List<HistoryData> getSubHistory(String name) {
return cache.getSpecificHistory(name);
}
......
......@@ -22,12 +22,12 @@
*/
package com.scalagent.appli.client.presenter;
import java.util.Date;
import java.util.SortedMap;
import java.util.List;
import com.google.gwt.event.shared.HandlerManager;
import com.scalagent.appli.client.RPCServiceAsync;
import com.scalagent.appli.client.RPCServiceCacheClient;
import com.scalagent.appli.client.RPCServiceCacheClient.HistoryData;
import com.scalagent.appli.client.command.topic.DeleteTopicAction;
import com.scalagent.appli.client.command.topic.DeleteTopicHandler;
import com.scalagent.appli.client.command.topic.DeleteTopicResponse;
......@@ -37,6 +37,7 @@ import com.scalagent.appli.client.command.topic.SendEditedTopicResponse;
import com.scalagent.appli.client.command.topic.SendNewTopicAction;
import com.scalagent.appli.client.command.topic.SendNewTopicHandler;
import com.scalagent.appli.client.command.topic.SendNewTopicResponse;
import com.scalagent.appli.client.event.common.UpdateCompleteEvent;
import com.scalagent.appli.client.event.common.UpdateCompleteHandler;
import com.scalagent.appli.client.event.topic.DeletedTopicHandler;
import com.scalagent.appli.client.event.topic.NewTopicHandler;
......@@ -105,8 +106,8 @@ public class TopicListPresenter extends
* This method is called by the EventBus when the update is done.
* The refresh button is re-enabled and the chart redrawn
*/
public void onUpdateComplete(String info) {
if (info.equals("topic")) {
public void onUpdateComplete(int updateType, String info) {
if (updateType == UpdateCompleteEvent.TOPIC_UPDATE) {
widget.getRefreshButton().enable();
widget.redrawChart(true);
}
......@@ -117,7 +118,7 @@ public class TopicListPresenter extends
*
* @result A map containing the history of the current topic
*/
public SortedMap<Date, int[]> getTopicHistory(String name) {
public List<HistoryData> getTopicHistory(String name) {
return cache.getSpecificHistory(name);
}
......
......@@ -23,13 +23,13 @@
package com.scalagent.appli.client.presenter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.SortedMap;
import java.util.List;
import java.util.Map;
import com.google.gwt.event.shared.HandlerManager;
import com.scalagent.appli.client.RPCServiceAsync;
import com.scalagent.appli.client.RPCServiceCacheClient;
import com.scalagent.appli.client.RPCServiceCacheClient.HistoryData;
import com.scalagent.appli.client.command.subscription.DeleteSubscriptionAction;
import com.scalagent.appli.client.command.subscription.DeleteSubscriptionHandler;
import com.scalagent.appli.client.command.subscription.DeleteSubscriptionResponse;
......@@ -39,6 +39,7 @@ import com.scalagent.appli.client.command.subscription.SendEditedSubscriptionRes
import com.scalagent.appli.client.command.subscription.SendNewSubscriptionAction;
import com.scalagent.appli.client.command.subscription.SendNewSubscriptionHandler;
import com.scalagent.appli.client.command.subscription.SendNewSubscriptionResponse;
import com.scalagent.appli.client.event.common.UpdateCompleteEvent;
import com.scalagent.appli.client.event.common.UpdateCompleteHandler;
import com.scalagent.appli.client.event.subscription.DeletedSubscriptionHandler;
import com.scalagent.appli.client.event.subscription.NewSubscriptionHandler;
......@@ -103,7 +104,7 @@ public class UserDetailPresenter extends
cache.retrieveSubscription(true);
String[] subSUser = user.getSubscriptionNames();
HashMap<String, SubscriptionWTO> lstSubsCache = cache.getSubscriptions();
Map<String, SubscriptionWTO> lstSubsCache = cache.getSubscriptions();
for (int i = 0; i < subSUser.length; i++) {
getWidget().updateSubscription(lstSubsCache.get(subSUser[i]));
......@@ -150,10 +151,10 @@ public class UserDetailPresenter extends
* This method is called by the EventBus when the update is done.
* The refresh button is re-enabled and the chart redrawn
*/
public void onUpdateComplete(String info) {
if (info.equals("user") || info.equals("sub")) {
public void onUpdateComplete(int updateType, String info) {
if (updateType == UpdateCompleteEvent.USER_UPDATE) {
widget.enableRefreshButton();
widget.redrawChart(true);
widget.redrawChart();
}
}
......@@ -213,7 +214,7 @@ public class UserDetailPresenter extends
*
* @result A map containing the history of the current user
*/
public SortedMap<Date, int[]> getUserHistory() {
public List<HistoryData> getUserHistory() {
return cache.getSpecificHistory(user.getId());
}
......@@ -222,7 +223,7 @@ public class UserDetailPresenter extends
*
* @result A map containing the history of the specified subscription
*/
public SortedMap<Date, int[]> getSubHistory(String sub) {
public List<HistoryData> getSubHistory(String sub) {
return cache.getSpecificHistory(sub);
}
......
......@@ -22,12 +22,12 @@
*/
package com.scalagent.appli.client.presenter;
import java.util.Date;
import java.util.SortedMap;
import java.util.List;
import com.google.gwt.event.shared.HandlerManager;
import com.scalagent.appli.client.RPCServiceAsync;
import com.scalagent.appli.client.RPCServiceCacheClient;
import com.scalagent.appli.client.RPCServiceCacheClient.HistoryData;
import com.scalagent.appli.client.command.user.DeleteUserAction;
import com.scalagent.appli.client.command.user.DeleteUserHandler;
import com.scalagent.appli.client.command.user.DeleteUserResponse;
......@@ -37,6 +37,7 @@ import com.scalagent.appli.client.command.user.SendEditedUserResponse;
import com.scalagent.appli.client.command.user.SendNewUserAction;
import com.scalagent.appli.client.command.user.SendNewUserHandler;
import com.scalagent.appli.client.command.user.SendNewUserResponse;
import com.scalagent.appli.client.event.common.UpdateCompleteEvent;
import com.scalagent.appli.client.event.common.UpdateCompleteHandler;
import com.scalagent.appli.client.event.user.DeletedUserHandler;
import com.scalagent.appli.client.event.user.NewUserHandler;
......@@ -79,8 +80,8 @@ public class UserListPresenter extends BasePresenter<UserListWidget, RPCServiceA
* This method is called by the EventBus when the update is done.
* The refresh button is re-enabled and the chart redrawn
*/
public void onUpdateComplete(String info) {
if (info.equals("user")) {
public void onUpdateComplete(int updateType, String info) {
if (updateType == UpdateCompleteEvent.USER_UPDATE) {
widget.getRefreshButton().enable();
widget.redrawChart(true);
}
......@@ -127,7 +128,7 @@ public class UserListPresenter extends BasePresenter<UserListWidget, RPCServiceA
*
* @result A map containing the history of the current user.
*/
public SortedMap<Date, int[]> getUserHistory(String name) {
public List<HistoryData> getUserHistory(String name) {
return cache.getSpecificHistory(name);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment