View Javadoc

1   /*
2    * @(#)GameActorContentStore.java Jul 8, 2004 Copyright (c) 2003, 2004 Delft
3    * 
4    * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
5    * Delft, the Netherlands. All rights reserved.
6    * 
7    * See for project information <a href="http://www.simulation.tudelft.nl/">
8    * www.simulation.tudelft.nl </a>.
9    * 
10   * The source code and binary code of this software is proprietary information
11   * of Delft University of Technology.
12   */
13  package org.gscg.game;
14  
15  import java.rmi.RemoteException;
16  import java.util.ArrayList;
17  import java.util.Collections;
18  import java.util.HashMap;
19  import java.util.List;
20  import java.util.Map;
21  
22  import nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface;
23  import nl.tudelft.simulation.event.Event;
24  import nl.tudelft.simulation.event.EventType;
25  import nl.tudelft.simulation.logger.Logger;
26  import nl.tudelft.simulation.supplychain.actor.SupplyChainActor;
27  import nl.tudelft.simulation.supplychain.content.Bill;
28  import nl.tudelft.simulation.supplychain.content.Content;
29  import nl.tudelft.simulation.supplychain.content.LeanContentStore;
30  import nl.tudelft.simulation.supplychain.content.Order;
31  import nl.tudelft.simulation.supplychain.content.OrderBasedOnQuote;
32  import nl.tudelft.simulation.supplychain.content.OrderConfirmation;
33  import nl.tudelft.simulation.supplychain.content.OrderStandAlone;
34  import nl.tudelft.simulation.supplychain.content.Payment;
35  import nl.tudelft.simulation.supplychain.content.Quote;
36  import nl.tudelft.simulation.supplychain.content.RequestForQuote;
37  import nl.tudelft.simulation.supplychain.content.Shipment;
38  
39  import org.gscg.singleuser.interactionlayer.SingleUserInteractionLayerInterface;
40  import org.gscg.singleuser.interactionlayer.dataobjects.ContentNumberData;
41  import org.gscg.singleuser.interactionlayer.dataobjects.content.BillData;
42  import org.gscg.singleuser.interactionlayer.dataobjects.content.ContentListData;
43  import org.gscg.singleuser.interactionlayer.dataobjects.content.OrderBasedOnQuoteData;
44  import org.gscg.singleuser.interactionlayer.dataobjects.content.OrderConfirmationData;
45  import org.gscg.singleuser.interactionlayer.dataobjects.content.OrderStandAloneData;
46  import org.gscg.singleuser.interactionlayer.dataobjects.content.PaymentData;
47  import org.gscg.singleuser.interactionlayer.dataobjects.content.QuoteData;
48  import org.gscg.singleuser.interactionlayer.dataobjects.content.RFQData;
49  import org.gscg.singleuser.interactionlayer.dataobjects.content.ShipmentData;
50  
51  /***
52   * The GameActorContentStore is taking care of storing content for display on
53   * the client screen. It acts as a kind of primitive database system. In this
54   * implementation, all the messages are linked to an InternalDemand, as this
55   * sets off the whole chain of messages, no matter whether it is a purchase,
56   * internal production, or stock replenishment: in all cases the InternalDemand
57   * triggers all the other messages. <br>
58   * <br>
59   * The ContentStore has a HashMap called internalDemandMap that maps the
60   * internal demand's uniqueID onto the so-called contentClassMap. This map has
61   * the Content's class as key, and maps that onto an ArrayList called
62   * 'contentList', which contains all the contents sent or received in order of
63   * arrival or sending. <br>
64   * <br>
65   * Messages that move to the following 'stage' are removed from the previous
66   * 'stage'. The class fires an event for each change that occurs. There is a
67   * standard ContentNumberData class to indicate the new number. <br>
68   * <br>
69   * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
70   * Delft, the Netherlands. All rights reserved.
71   * 
72   * See for project information <a href="http://www.simulation.tudelft.nl/">
73   * www.simulation.tudelft.nl </a>.
74   * 
75   * The source code and binary code of this software is proprietary information
76   * of Delft University of Technology.
77   * 
78   * @author <a
79   *         href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
80   *         Verbraeck </a>
81   * @version $Revision: 1.3 $ $Date: 2005/08/10 11:23:30 $
82   * @since 1.0.0 <br>
83   */
84  
85  public class GameActorContentStore extends LeanContentStore
86  {
87  	/*** the serial version uid */
88  	private static final long serialVersionUID = 11L;
89  
90  	/*** the UPDATE_ALL_NUMBER_DATA_EVENT event */
91  	public static final EventType UPDATE_ALL_NUMBER_DATA_EVENT = new EventType(
92  			"UPDATE_ALL_NUMBER_DATA_EVENT");
93  
94  	/*** the event for the order confirmation received */
95  	public static final EventType EVENT_ORDERCOMMIT_RECEIVED = new EventType(
96  			"EVENT_ORDERCOMMIT_RECEIVED");
97  
98  	/*** the event for the order confirmation sent */
99  	public static final EventType EVENT_ORDERCOMMIT_SENT = new EventType(
100 			"EVENT_ORDERCOMMIT_SENT");
101 
102 	/*** the single user interaction layer */
103 	private SingleUserInteractionLayerInterface singleUserInteractionLayer = null;
104 
105 	/*** the received content per product and class, latest state */
106 	private Map receivedProductStateMap = Collections
107 			.synchronizedMap(new HashMap());
108 
109 	/*** the sent content per product and class, latest state */
110 	private Map sentProductStateMap = Collections
111 			.synchronizedMap(new HashMap());
112 
113 	/***
114 	 * Constructs a new GameActorContentStore
115 	 * 
116 	 * @param owner the owner
117 	 * @param simulator the simulator
118 	 */
119 	public GameActorContentStore(final SupplyChainActor owner,
120 			final DEVSSimulatorInterface simulator)
121 
122 	{
123 		super(owner, simulator);
124 	}
125 
126 	/***
127 	 * @param singleUserInteractionLayer the interaction layer
128 	 */
129 	public void setSingleUserInteractionlayer(
130 			final SingleUserInteractionLayerInterface singleUserInteractionLayer)
131 	{
132 		this.singleUserInteractionLayer = singleUserInteractionLayer;
133 		this.addListener(singleUserInteractionLayer,
134 				ContentNumberData.EVENT_NUMBER_RFQ_SENT);
135 		try
136 		{
137 			singleUserInteractionLayer
138 					.addEventType(ContentNumberData.EVENT_NUMBER_RFQ_SENT);
139 
140 			this.addListener(singleUserInteractionLayer,
141 					ContentNumberData.EVENT_NUMBER_RFQ_RECEIVED);
142 			singleUserInteractionLayer
143 					.addEventType(ContentNumberData.EVENT_NUMBER_RFQ_RECEIVED);
144 
145 			this.addListener(singleUserInteractionLayer,
146 					ContentNumberData.EVENT_NUMBER_QUOTE_SENT);
147 			singleUserInteractionLayer
148 					.addEventType(ContentNumberData.EVENT_NUMBER_QUOTE_SENT);
149 
150 			this.addListener(singleUserInteractionLayer,
151 					ContentNumberData.EVENT_NUMBER_QUOTE_RECEIVED);
152 			singleUserInteractionLayer
153 					.addEventType(ContentNumberData.EVENT_NUMBER_QUOTE_RECEIVED);
154 
155 			this.addListener(singleUserInteractionLayer,
156 					ContentNumberData.EVENT_NUMBER_ORDER_SENT);
157 			singleUserInteractionLayer
158 					.addEventType(ContentNumberData.EVENT_NUMBER_ORDER_SENT);
159 
160 			this.addListener(singleUserInteractionLayer,
161 					ContentNumberData.EVENT_NUMBER_ORDER_RECEIVED);
162 			singleUserInteractionLayer
163 					.addEventType(ContentNumberData.EVENT_NUMBER_ORDER_RECEIVED);
164 
165 			this.addListener(singleUserInteractionLayer,
166 					ContentNumberData.EVENT_NUMBER_ORDERCOMMIT_SENT);
167 			singleUserInteractionLayer
168 					.addEventType(ContentNumberData.EVENT_NUMBER_ORDERCOMMIT_SENT);
169 
170 			this.addListener(singleUserInteractionLayer,
171 					ContentNumberData.EVENT_NUMBER_ORDERCOMMIT_RECEIVED);
172 			singleUserInteractionLayer
173 					.addEventType(ContentNumberData.EVENT_NUMBER_ORDERCOMMIT_RECEIVED);
174 
175 			this.addListener(singleUserInteractionLayer,
176 					ContentNumberData.EVENT_NUMBER_SHIPMENT_SENT);
177 			singleUserInteractionLayer
178 					.addEventType(ContentNumberData.EVENT_NUMBER_SHIPMENT_SENT);
179 
180 			this.addListener(singleUserInteractionLayer,
181 					ContentNumberData.EVENT_NUMBER_SHIPMENT_RECEIVED);
182 			singleUserInteractionLayer
183 					.addEventType(ContentNumberData.EVENT_NUMBER_SHIPMENT_RECEIVED);
184 
185 			this.addListener(singleUserInteractionLayer,
186 					ContentNumberData.EVENT_NUMBER_BILL_SENT);
187 			singleUserInteractionLayer
188 					.addEventType(ContentNumberData.EVENT_NUMBER_BILL_SENT);
189 
190 			this.addListener(singleUserInteractionLayer,
191 					ContentNumberData.EVENT_NUMBER_BILL_RECEIVED);
192 			singleUserInteractionLayer
193 					.addEventType(ContentNumberData.EVENT_NUMBER_BILL_RECEIVED);
194 
195 			this.addListener(singleUserInteractionLayer,
196 					ContentNumberData.EVENT_NUMBER_PAYMENT_SENT);
197 			singleUserInteractionLayer
198 					.addEventType(ContentNumberData.EVENT_NUMBER_PAYMENT_SENT);
199 
200 			this.addListener(singleUserInteractionLayer,
201 					ContentNumberData.EVENT_NUMBER_PAYMENT_RECEIVED);
202 			singleUserInteractionLayer
203 					.addEventType(ContentNumberData.EVENT_NUMBER_PAYMENT_RECEIVED);
204 
205 			// the full list events
206 
207 			this.addListener(singleUserInteractionLayer,
208 					ContentNumberData.EVENT_FULL_LIST_RFQ_SENT);
209 			singleUserInteractionLayer
210 					.addEventType(ContentNumberData.EVENT_FULL_LIST_RFQ_SENT);
211 
212 			this.addListener(singleUserInteractionLayer,
213 					ContentNumberData.EVENT_FULL_LIST_RFQ_RECEIVED);
214 			singleUserInteractionLayer
215 					.addEventType(ContentNumberData.EVENT_FULL_LIST_RFQ_RECEIVED);
216 
217 			this.addListener(singleUserInteractionLayer,
218 					ContentNumberData.EVENT_FULL_LIST_QUOTE_SENT);
219 			singleUserInteractionLayer
220 					.addEventType(ContentNumberData.EVENT_FULL_LIST_QUOTE_SENT);
221 
222 			this.addListener(singleUserInteractionLayer,
223 					ContentNumberData.EVENT_FULL_LIST_QUOTE_RECEIVED);
224 			singleUserInteractionLayer
225 					.addEventType(ContentNumberData.EVENT_FULL_LIST_QUOTE_RECEIVED);
226 
227 			this.addListener(singleUserInteractionLayer,
228 					ContentNumberData.EVENT_FULL_LIST_ORDER_SENT);
229 			singleUserInteractionLayer
230 					.addEventType(ContentNumberData.EVENT_FULL_LIST_ORDER_SENT);
231 
232 			this.addListener(singleUserInteractionLayer,
233 					ContentNumberData.EVENT_FULL_LIST_ORDER_RECEIVED);
234 			singleUserInteractionLayer
235 					.addEventType(ContentNumberData.EVENT_FULL_LIST_ORDER_RECEIVED);
236 
237 			this.addListener(singleUserInteractionLayer,
238 					ContentNumberData.EVENT_FULL_LIST_ORDERCOMMIT_SENT);
239 			singleUserInteractionLayer
240 					.addEventType(ContentNumberData.EVENT_FULL_LIST_ORDERCOMMIT_SENT);
241 
242 			this.addListener(singleUserInteractionLayer,
243 					ContentNumberData.EVENT_FULL_LIST_ORDERCOMMIT_RECEIVED);
244 			singleUserInteractionLayer
245 					.addEventType(ContentNumberData.EVENT_FULL_LIST_ORDERCOMMIT_RECEIVED);
246 
247 			this.addListener(singleUserInteractionLayer,
248 					ContentNumberData.EVENT_FULL_LIST_SHIPMENT_SENT);
249 			singleUserInteractionLayer
250 					.addEventType(ContentNumberData.EVENT_FULL_LIST_SHIPMENT_SENT);
251 
252 			this.addListener(singleUserInteractionLayer,
253 					ContentNumberData.EVENT_FULL_LIST_SHIPMENT_RECEIVED);
254 			singleUserInteractionLayer
255 					.addEventType(ContentNumberData.EVENT_FULL_LIST_SHIPMENT_RECEIVED);
256 
257 			this.addListener(singleUserInteractionLayer,
258 					ContentNumberData.EVENT_FULL_LIST_BILL_SENT);
259 			singleUserInteractionLayer
260 					.addEventType(ContentNumberData.EVENT_FULL_LIST_BILL_SENT);
261 
262 			this.addListener(singleUserInteractionLayer,
263 					ContentNumberData.EVENT_FULL_LIST_BILL_RECEIVED);
264 			singleUserInteractionLayer
265 					.addEventType(ContentNumberData.EVENT_FULL_LIST_BILL_RECEIVED);
266 
267 			this.addListener(singleUserInteractionLayer,
268 					ContentNumberData.EVENT_FULL_LIST_PAYMENT_SENT);
269 			singleUserInteractionLayer
270 					.addEventType(ContentNumberData.EVENT_FULL_LIST_PAYMENT_SENT);
271 
272 			this.addListener(singleUserInteractionLayer,
273 					ContentNumberData.EVENT_FULL_LIST_PAYMENT_RECEIVED);
274 			singleUserInteractionLayer
275 					.addEventType(ContentNumberData.EVENT_FULL_LIST_PAYMENT_RECEIVED);
276 		} catch (RemoteException remoteException)
277 		{
278 			Logger.severe(this, "setSIngleUserInteractionLayer",
279 					remoteException);
280 		}
281 	}
282 
283 	/***
284 	 * Method addContent stores a new Content object into the store.
285 	 * 
286 	 * @param content the content to add
287 	 * @param sent indicates whether the content was sent or received
288 	 */
289 	public synchronized void addContent(final Content content,
290 			final boolean sent)
291 	{
292 		super.addContent(content, sent);
293 		Class contentClass = foldExtendedContentClass(content);
294 		if (content.getProduct() == null)
295 		{
296 			Logger.warning(this, "addContent",
297 					"GameActorContentStore.addContent: null product");
298 			return;
299 		}
300 		String productName = content.getProduct().getName();
301 		String key = makeProductKey(contentClass, productName);
302 		List contentList;
303 		if (sent)
304 		{
305 			contentList = (List) this.sentProductStateMap.get(key);
306 			if (contentList == null)
307 			{
308 				contentList = new ArrayList();
309 				this.sentProductStateMap.put(key, contentList);
310 			}
311 		} else
312 		{
313 			contentList = (List) this.receivedProductStateMap.get(key);
314 			if (contentList == null)
315 			{
316 				contentList = new ArrayList();
317 				this.receivedProductStateMap.put(key, contentList);
318 			}
319 		}
320 		contentList.add(content);
321 
322 		//
323 		// Fire all the events, based on the product and content type
324 		//
325 		List allProductContent = getAllProductContent(contentClass, sent,
326 				productName);
327 		ContentNumberData contentNumberData = new ContentNumberData(
328 				productName, content, allProductContent.size(), sent);
329 		this.fireEvent(ContentNumberData.resolveEventType(contentClass, sent),
330 				contentNumberData);
331 
332 		// create an object (ContentListData) that contains the list as well as
333 		// the productname; client-side the productname is needed to prevent
334 		// unexpected closures of panels
335 		this.fireEvent(ContentNumberData.resolveFullListEventType(content
336 				.getClass(), sent), new ContentListData(productName, this
337 				.getAllContentData(contentClass, allProductContent)));
338 
339 		//
340 		// Special events for the committed / confirmed orders
341 		//
342 		if (content instanceof OrderConfirmation)
343 		{
344 			OrderConfirmationData data = new OrderConfirmationData(
345 					(OrderConfirmation) content, super.simulator);
346 			if (sent)
347 			{
348 				this.fireEvent(GameActorContentStore.EVENT_ORDERCOMMIT_SENT,
349 						data);
350 			} else
351 			{
352 				this.fireEvent(
353 						GameActorContentStore.EVENT_ORDERCOMMIT_RECEIVED, data);
354 			}
355 		}
356 	}
357 
358 	/***
359 	 * @see nl.tudelft.simulation.supplychain.content.ContentStore#removeSentReceivedContent(nl.tudelft.simulation.supplychain.content.Content,
360 	 *      boolean)
361 	 */
362 	public synchronized void removeSentReceivedContent(final Content content,
363 			final boolean sent)
364 	{
365 		super.removeSentReceivedContent(content, sent);
366 		// fold back the other types of orders to 'Order' in the map
367 		Class contentClass = foldExtendedContentClass(content);
368 		//
369 		// fire an event that the number of content messages has changed
370 		//
371 		if (content.getProduct() == null)
372 		{
373 			return;
374 		}
375 		String productName = content.getProduct().getName();
376 		String key = makeProductKey(contentClass, productName);
377 		List contentList;
378 		if (sent)
379 		{
380 			contentList = (List) this.sentProductStateMap.get(key);
381 			if (contentList != null)
382 			{
383 				contentList.remove(content);
384 			}
385 		} else
386 		{
387 			contentList = (List) this.receivedProductStateMap.get(key);
388 			if (contentList != null)
389 			{
390 				contentList.remove(content);
391 			}
392 		}
393 		List allProductContent = getAllProductContent(contentClass, sent,
394 				productName);
395 		ContentNumberData contentNumberData = new ContentNumberData(
396 				productName, content, allProductContent.size(), sent);
397 		this.fireEvent(ContentNumberData.resolveEventType(content.getClass(),
398 				sent), contentNumberData);
399 
400 		// create an object (ContentListData) that contains the list as well as
401 		// the productname; client-side the productname is needed to prevent
402 		// unexpected closures of panels
403 		this.fireEvent(ContentNumberData.resolveFullListEventType(content
404 				.getClass(), sent), new ContentListData(productName, this
405 				.getAllContentData(content.getClass(), allProductContent)));
406 	}
407 
408 	/***
409 	 * Method getAllProductContentData returns the Content object of type
410 	 * contentClass for a certain product in the form of data objects
411 	 * 
412 	 * @param contentClass the content class to look for
413 	 * @param sent indicates whether the content was sent or received
414 	 * @param productName the name of the product
415 	 * @return returns a list of all the content of type contentClass
416 	 */
417 	public List getAllProductContentData(final Class contentClass,
418 			final boolean sent, final String productName)
419 	{
420 		List contentList = getAllProductContent(contentClass, sent, productName);
421 		return getAllContentData(contentClass, contentList);
422 	}
423 
424 	/***
425 	 * Method makeProductKey generates a product key based on the content class
426 	 * and the product name
427 	 * 
428 	 * @param contentClass the content class
429 	 * @param productName the name of the product
430 	 * @return returns a string reflecting the key
431 	 */
432 	private String makeProductKey(final Class contentClass,
433 			final String productName)
434 	{
435 		return contentClass.toString() + "#" + productName;
436 	}
437 
438 	/***
439 	 * Method getAllProductContent returns the Content objects of type
440 	 * contentClass for a certain product
441 	 * 
442 	 * @param contentClass the content class to look for
443 	 * @param sent indicates whether the content was sent or received
444 	 * @param productName the name of the product
445 	 * @return returns a list of all the content of type contentClass
446 	 */
447 	public List getAllProductContent(final Class contentClass,
448 			final boolean sent, final String productName)
449 	{
450 		String key = makeProductKey(contentClass, productName);
451 		List contentList;
452 		if (sent)
453 		{
454 			contentList = (List) this.sentProductStateMap.get(key);
455 		} else
456 		{
457 			contentList = (List) this.receivedProductStateMap.get(key);
458 		}
459 		if (contentList == null)
460 		{
461 			return new ArrayList();
462 		}
463 		return contentList;
464 	}
465 
466 	/***
467 	 * Method getContent returns the Content object of type contentClass in the
468 	 * form of data objects
469 	 * 
470 	 * @param contentClass the content class to look for
471 	 * @param contentList the list with content
472 	 * @return returns a list of all the content of type contentClass
473 	 */
474 	private List getAllContentData(final Class contentClass,
475 			final List contentList)
476 	{
477 		List result = new ArrayList();
478 		if (RequestForQuote.class.isAssignableFrom(contentClass))
479 		{
480 			for (int i = 0; i < contentList.size(); i++)
481 			{
482 				if (contentList.get(i) instanceof RequestForQuote)
483 				{
484 					RequestForQuote rfq = (RequestForQuote) contentList.get(i);
485 					result.add(new RFQData(rfq, this.simulator));
486 				} else
487 				{
488 					Logger.warning(this, "getAllContentData",
489 							"Expected rfq but got "
490 									+ contentList.get(i).getClass());
491 				}
492 			}
493 			return result;
494 		}
495 		if (Quote.class.isAssignableFrom(contentClass))
496 		{
497 			for (int i = 0; i < contentList.size(); i++)
498 			{
499 				if (contentList.get(i) instanceof Quote)
500 				{
501 					Quote quote = (Quote) contentList.get(i);
502 					result.add(new QuoteData(quote, this.simulator));
503 				} else
504 				{
505 					Logger.warning(this, "getAllContentData",
506 							"Expected quote but got "
507 									+ contentList.get(i).getClass());
508 				}
509 			}
510 			return result;
511 		}
512 		if (Order.class.isAssignableFrom(contentClass))
513 		{
514 			for (int i = 0; i < contentList.size(); i++)
515 			{
516 				if (contentList.get(i) instanceof Order)
517 				{
518 					Order order = (Order) contentList.get(i);
519 					if (OrderBasedOnQuote.class.equals(order.getClass()))
520 					{
521 						result.add(new OrderBasedOnQuoteData(
522 								(OrderBasedOnQuote) order, this.simulator));
523 					} else if (OrderStandAlone.class.equals(order.getClass()))
524 					{
525 						result.add(new OrderStandAloneData(
526 								(OrderStandAlone) order, this.simulator));
527 					} else
528 					{
529 						Logger.warning(this, "getAllContentData",
530 								"Order not OrderBasedOnQuote or OrderStandAloneData but: "
531 										+ order.getClass());
532 					}
533 				} else
534 				{
535 					Logger.warning(this, "getAllContentData",
536 							"Expected order but got "
537 									+ contentList.get(i).getClass());
538 				}
539 			}
540 			return result;
541 		}
542 		if (OrderConfirmation.class.isAssignableFrom(contentClass))
543 		{
544 			for (int i = 0; i < contentList.size(); i++)
545 			{
546 				if (contentList.get(i) instanceof OrderConfirmation)
547 				{
548 					OrderConfirmation orderConfirm = (OrderConfirmation) contentList
549 							.get(i);
550 					result.add(new OrderConfirmationData(orderConfirm,
551 							this.simulator));
552 				} else
553 				{
554 					Logger.warning(this, "getAllContentData",
555 							"Expected OrderConfirmation but got "
556 									+ contentList.get(i).getClass());
557 				}
558 			}
559 			return result;
560 		}
561 		if (Shipment.class.isAssignableFrom(contentClass))
562 		{
563 			for (int i = 0; i < contentList.size(); i++)
564 			{
565 				if (contentList.get(i) instanceof Shipment)
566 				{
567 					Shipment shipment = (Shipment) contentList.get(i);
568 					result.add(new ShipmentData(shipment, this.simulator));
569 				} else
570 				{
571 					Logger.warning(this, "getAllContentData",
572 							"Expected Shipment but got "
573 									+ contentList.get(i).getClass());
574 				}
575 			}
576 			return result;
577 		}
578 		if (Bill.class.isAssignableFrom(contentClass))
579 		{
580 			for (int i = 0; i < contentList.size(); i++)
581 			{
582 				if (contentList.get(i) instanceof Bill)
583 				{
584 					Bill bill = (Bill) contentList.get(i);
585 					result.add(new BillData(bill, this.simulator));
586 				} else
587 				{
588 					Logger.warning(this, "getAllContentData",
589 							"Expected Bill but got "
590 									+ contentList.get(i).getClass());
591 				}
592 			}
593 			return result;
594 		}
595 		if (Payment.class.isAssignableFrom(contentClass))
596 		{
597 			for (int i = 0; i < contentList.size(); i++)
598 			{
599 				if (contentList.get(i) instanceof Payment)
600 				{
601 					Payment payment = (Payment) contentList.get(i);
602 					result.add(new PaymentData(payment, this.simulator));
603 				} else
604 				{
605 					Logger.warning(this, "getAllContentData",
606 							"Expected Payment but got "
607 									+ contentList.get(i).getClass());
608 				}
609 			}
610 			return result;
611 		}
612 		return new ArrayList();
613 	}
614 
615 	/***
616 	 * Method fireAllContentData.
617 	 * 
618 	 * @param contentClass the content class to look for
619 	 * @param sent indicates whether the content was sent or received
620 	 * @param productName the name of the product
621 	 */
622 	public void fireAllProductContentData(final Class contentClass,
623 			final boolean sent, final String productName)
624 	{
625 		// create an object (ContentListData) that contains the list as well as
626 		// the productname; client-side the productname is needed to prevent
627 		// unexpected closures of panels
628 		this.fireEvent(ContentNumberData.resolveFullListEventType(contentClass,
629 				sent), new ContentListData(productName, this
630 				.getAllProductContentData(contentClass, sent, productName)));
631 	}
632 
633 	/***
634 	 * Method fireAllNumberData.
635 	 * 
636 	 * @param productName the name of the product
637 	 * @param clazz the class
638 	 */
639 	private void fireAllProductNumberData(final String productName,
640 			final Class clazz)
641 	{
642 		List allProductContentSent = getAllProductContent(clazz, true,
643 				productName);
644 		ContentNumberData contentNumberDataSent = new ContentNumberData(
645 				productName, clazz, allProductContentSent.size(), true);
646 		try
647 		{
648 			if (contentNumberDataSent.getNumber() > 0)
649 			{
650 
651 				this.singleUserInteractionLayer.notifyAnnounced(new Event(
652 						ContentNumberData.resolveEventType(clazz, true), this,
653 						contentNumberDataSent));
654 			}
655 
656 			List allProductContentReceived = getAllProductContent(clazz, false,
657 					productName);
658 			ContentNumberData contentNumberDataReceived = new ContentNumberData(
659 					productName, clazz, allProductContentReceived.size(), false);
660 			if (contentNumberDataReceived.getNumber() > 0)
661 			{
662 				this.singleUserInteractionLayer.notifyAnnounced(new Event(
663 						ContentNumberData.resolveEventType(clazz, false), this,
664 						contentNumberDataReceived));
665 			}
666 		} catch (RemoteException remoteException)
667 		{
668 			Logger.severe(this, "fireAllProductNumberData", remoteException);
669 		}
670 	}
671 
672 	/***
673 	 * Method fireAllNumberData.
674 	 * 
675 	 * @param productName the name of the product
676 	 */
677 	public void fireAllProductNumberData(final String productName)
678 	{
679 		this.fireAllProductNumberData(productName, RequestForQuote.class);
680 		this.fireAllProductNumberData(productName, Quote.class);
681 		this.fireAllProductNumberData(productName, Order.class);
682 		this.fireAllProductNumberData(productName, OrderConfirmation.class);
683 		this.fireAllProductNumberData(productName, Shipment.class);
684 		this.fireAllProductNumberData(productName, Bill.class);
685 		this.fireAllProductNumberData(productName, Payment.class);
686 	}
687 }