1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.gscg.singleuser.interactionlayer.dataobjects;
15
16 import java.io.Serializable;
17
18 import nl.tudelft.simulation.event.EventType;
19 import nl.tudelft.simulation.logger.Logger;
20 import nl.tudelft.simulation.supplychain.content.Bill;
21 import nl.tudelft.simulation.supplychain.content.Content;
22 import nl.tudelft.simulation.supplychain.content.InternalDemand;
23 import nl.tudelft.simulation.supplychain.content.Order;
24 import nl.tudelft.simulation.supplychain.content.OrderConfirmation;
25 import nl.tudelft.simulation.supplychain.content.Payment;
26 import nl.tudelft.simulation.supplychain.content.ProductionOrder;
27 import nl.tudelft.simulation.supplychain.content.Quote;
28 import nl.tudelft.simulation.supplychain.content.RequestForQuote;
29 import nl.tudelft.simulation.supplychain.content.Shipment;
30
31 /***
32 * This keeps track of the different numbers per message per product. As soon as
33 * some content is handled, it processes this and send the appropriate value for
34 * the class of the content to the client-side graphical user interface. The
35 * actual firing of the data towards the client is done by the
36 * GameActorContentStore.
37 * <p>
38 * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
39 * Delft, the Netherlands. All rights reserved.
40 *
41 * See for project information <a href="http://www.simulation.tudelft.nl/">
42 * www.simulation.tudelft.nl </a>.
43 *
44 * The source code and binary code of this software is proprietary information
45 * of Delft University of Technology.
46 *
47 * @see org.gscg.game.GameActorContentStore
48 * @author <a
49 * href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
50 * Verbraeck </a>
51 * @version $Revision: 1.3 $ $Date: 2005/08/09 15:43:42 $
52 * @since 1.0.0
53 */
54 public class ContentNumberData implements Serializable
55 {
56 /*** the serial version uid */
57 private static final long serialVersionUID = 11L;
58
59 /*** the INTERNALDEMAND_SENT content */
60 public static final String CONTENT_TYPE_INTERNALDEMAND_SENT = "INTERNALDEMAND_SENT";
61
62 /*** the INTERNALDEMAND_SENT event */
63 public static final EventType EVENT_NUMBER_INTERNALDEMAND_SENT = new EventType(
64 "EVENT_NUMBER_INTERNALDEMAND_SENT");
65
66 /*** the INTERNALDEMAND_RECEIVED content */
67 public static final String CONTENT_TYPE_INTERNALDEMAND_RECEIVED = "INTERNALDEMAND_RECEIVED";
68
69 /*** the INTERNALDEMAND_RECEIVED event */
70 public static final EventType EVENT_NUMBER_INTERNALDEMAND_RECEIVED = new EventType(
71 "EVENT_NUMBER_INTERNALDEMAND_RECEIVED");
72
73 /*** the RFQ_SENT content */
74 public static final String CONTENT_TYPE_RFQ_SENT = "RFQ_SENT";
75
76 /*** the RFQ_SENT event */
77 public static final EventType EVENT_NUMBER_RFQ_SENT = new EventType(
78 "EVENT_NUMBER_RFQ_SENT");
79
80 /*** the RFQ_RECEIVED content */
81 public static final String CONTENT_TYPE_RFQ_RECEIVED = "RFQ_RECEIVED";
82
83 /*** the RFQ_RECEIVED event */
84 public static final EventType EVENT_NUMBER_RFQ_RECEIVED = new EventType(
85 "EVENT_NUMBER_RFQ_RECEIVED");
86
87 /*** the QUOTE_SENT content */
88 public static final String CONTENT_TYPE_QUOTE_SENT = "QUOTE_SENT";
89
90 /*** the QUOTE_SENT event */
91 public static final EventType EVENT_NUMBER_QUOTE_SENT = new EventType(
92 "EVENT_NUMBER_QUOTE_SENT");
93
94 /*** the QUOTE_RECEIVED content */
95 public static final String CONTENT_TYPE_QUOTE_RECEIVED = "QUOTE_RECEIVED";
96
97 /*** the QUOTE_RECEIVED event */
98 public static final EventType EVENT_NUMBER_QUOTE_RECEIVED = new EventType(
99 "EVENT_NUMBER_QUOTE_RECEIVED");
100
101 /*** the ORDER_SENT content */
102 public static final String CONTENT_TYPE_ORDER_SENT = "ORDER_SENT";
103
104 /*** the ORDER_SENT event */
105 public static final EventType EVENT_NUMBER_ORDER_SENT = new EventType(
106 "EVENT_NUMBER_ORDER_SENT");
107
108 /*** the ORDER_RECEIVED content */
109 public static final String CONTENT_TYPE_ORDER_RECEIVED = "ORDER_RECEIVED";
110
111 /*** the ORDER_RECEIVED event */
112 public static final EventType EVENT_NUMBER_ORDER_RECEIVED = new EventType(
113 "EVENT_NUMBER_ORDER_RECEIVED");
114
115 /*** the ORDER_PRODUCTION_RECEIVED event */
116 public static final EventType EVENT_NUMBER_PRODUCTION_ORDER_RECEIVED = new EventType(
117 "EVENT_NUMBER_PRODUCTION_ORDER_RECEIVED");
118
119 /*** the ORDER_PRODUCTION_SENT event */
120 public static final EventType EVENT_NUMBER_PRODUCTION_ORDER_SENT = new EventType(
121 "EVENT_NUMBER_PRODUCTION_ORDER_SENT");
122
123 /*** the PRODUCTION_ORDER_SENT content */
124 public static final String CONTENT_TYPE_PRODUCTION_ORDER_SENT = "PRODUCTION_ORDER_SENT";
125
126 /*** the PRODUCTION_ORDER_RECEIVED content */
127 public static final String CONTENT_TYPE_PRODUCTION_ORDER_RECEIVED = "PRODUCTION_ORDER_RECEIVED";
128
129
130 /*** the ORDERCOMMIT_SENT content */
131 public static final String CONTENT_TYPE_ORDERCOMMIT_SENT = "ORDERCOMMIT_SENT";
132
133 /*** the ORDERCOMMIT_SENT event */
134 public static final EventType EVENT_NUMBER_ORDERCOMMIT_SENT = new EventType(
135 "EVENT_NUMBER_ORDERCOMMIT_SENT");
136
137 /*** the ORDERCOMMIT_RECEIVED content */
138 public static final String CONTENT_TYPE_ORDERCOMMIT_RECEIVED = "ORDERCOMMIT_RECEIVED";
139
140 /*** the ORDERCOMMIT_RECEIVED event */
141 public static final EventType EVENT_NUMBER_ORDERCOMMIT_RECEIVED = new EventType(
142 "EVENT_NUMBER_ORDERCOMMIT_RECEIVED");
143
144 /*** the SHIPMENT_SENT content */
145 public static final String CONTENT_TYPE_SHIPMENT_SENT = "SHIPMENT_SENT";
146
147 /*** the SHIPMENT_SENT event */
148 public static final EventType EVENT_NUMBER_SHIPMENT_SENT = new EventType(
149 "EVENT_NUMBER_SHIPMENT_SENT");
150
151 /*** the SHIPMENT_RECEIVED content */
152 public static final String CONTENT_TYPE_SHIPMENT_RECEIVED = "SHIPMENT_RECEIVED";
153
154 /*** the SHIPMENT_RECEIVED event */
155 public static final EventType EVENT_NUMBER_SHIPMENT_RECEIVED = new EventType(
156 "EVENT_NUMBER_SHIPMENT_RECEIVED");
157
158 /*** the BILL_SENT content */
159 public static final String CONTENT_TYPE_BILL_SENT = "BILL_SENT";
160
161 /*** the BILL_SENT event */
162 public static final EventType EVENT_NUMBER_BILL_SENT = new EventType(
163 "EVENT_NUMBER_BILL_SENT");
164
165 /*** the BILL_RECEIVED content */
166 public static final String CONTENT_TYPE_BILL_RECEIVED = "BILL_RECEIVED";
167
168 /*** the BILL_RECEIVED event */
169 public static final EventType EVENT_NUMBER_BILL_RECEIVED = new EventType(
170 "EVENT_NUMBER_BILL_RECEIVED");
171
172 /*** the PAYMENT_SENT content */
173 public static final String CONTENT_TYPE_PAYMENT_SENT = "PAYMENT_SENT";
174
175 /*** the PAYMENT_SENT event */
176 public static final EventType EVENT_NUMBER_PAYMENT_SENT = new EventType(
177 "EVENT_NUMBER_PAYMENT_SENT");
178
179 /*** the PAYMENT_RECEIVED content */
180 public static final String CONTENT_TYPE_PAYMENT_RECEIVED = "PAYMENT_RECEIVED";
181
182 /*** the PAYMENT_RECEIVED event */
183 public static final EventType EVENT_NUMBER_PAYMENT_RECEIVED = new EventType(
184 "EVENT_NUMBER_PAYMENT_RECEIVED");
185
186
187
188 /*** the INTERNALDEMAND_SENT event */
189 public static final EventType EVENT_FULL_LIST_INTERNALDEMAND_SENT = new EventType(
190 "EVENT_FULL_LIST_INTERNALDEMAND_SENT");
191
192 /*** the INTERNALDEMAND_RECEIVED event */
193 public static final EventType EVENT_FULL_LIST_INTERNALDEMAND_RECEIVED = new EventType(
194 "EVENT_FULL_LIST_INTERNALDEMAND_RECEIVED");
195
196 /*** the RFQ_SENT event */
197 public static final EventType EVENT_FULL_LIST_RFQ_SENT = new EventType(
198 "EVENT_FULL_LIST_RFQ_SENT");
199
200 /*** the RFQ_RECEIVED event */
201 public static final EventType EVENT_FULL_LIST_RFQ_RECEIVED = new EventType(
202 "EVENT_FULL_LIST_RFQ_RECEIVED");
203
204 /*** the QUOTE_SENT event */
205 public static final EventType EVENT_FULL_LIST_QUOTE_SENT = new EventType(
206 "EVENT_FULL_LIST_QUOTE_SENT");
207
208 /*** the QUOTE_RECEIVED event */
209 public static final EventType EVENT_FULL_LIST_QUOTE_RECEIVED = new EventType(
210 "EVENT_FULL_LIST_QUOTE_RECEIVED");
211
212 /*** the ORDER_SENT event */
213 public static final EventType EVENT_FULL_LIST_ORDER_SENT = new EventType(
214 "EVENT_FULL_LIST_ORDER_SENT");
215
216 /*** the ORDER_RECEIVED event */
217 public static final EventType EVENT_FULL_LIST_ORDER_RECEIVED = new EventType(
218 "EVENT_FULL_LIST_ORDER_RECEIVED");
219
220 /*** the PRODUCTION_ORDER_SENT event */
221 public static final EventType EVENT_FULL_LIST_PRODUCTION_ORDER_SENT = new EventType(
222 "EVENT_FULL_LIST_PRODUCTION_ORDER_SENT");
223
224 /*** the PRODUCTION_ORDER_RECEIVED event */
225 public static final EventType EVENT_FULL_LIST_PRODUCTION_ORDER_RECEIVED = new EventType(
226 "EVENT_FULL_LIST_PRODUCTION_ORDER_RECEIVED");
227
228 /*** the ORDERCOMMIT_SENT event */
229 public static final EventType EVENT_FULL_LIST_ORDERCOMMIT_SENT = new EventType(
230 "EVENT_FULL_LIST_ORDERCOMMIT_SENT");
231
232 /*** the ORDERCOMMIT_RECEIVED event */
233 public static final EventType EVENT_FULL_LIST_ORDERCOMMIT_RECEIVED = new EventType(
234 "EVENT_FULL_LIST_ORDERCOMMIT_RECEIVED");
235
236 /*** the SHIPMENT_SENT event */
237 public static final EventType EVENT_FULL_LIST_SHIPMENT_SENT = new EventType(
238 "EVENT_FULL_LIST_SHIPMENT_SENT");
239
240 /*** the SHIPMENT_RECEIVED event */
241 public static final EventType EVENT_FULL_LIST_SHIPMENT_RECEIVED = new EventType(
242 "EVENT_FULL_LIST_SHIPMENT_RECEIVED");
243
244 /*** the BILL_SENT event */
245 public static final EventType EVENT_FULL_LIST_BILL_SENT = new EventType(
246 "EVENT_FULL_LIST_BILL_SENT");
247
248 /*** the BILL_RECEIVED event */
249 public static final EventType EVENT_FULL_LIST_BILL_RECEIVED = new EventType(
250 "EVENT_FULL_LIST_BILL_RECEIVED");
251
252 /*** the PAYMENT_SENT event */
253 public static final EventType EVENT_FULL_LIST_PAYMENT_SENT = new EventType(
254 "EVENT_FULL_LIST_PAYMENT_SENT");
255
256 /*** the PAYMENT_RECEIVED event */
257 public static final EventType EVENT_FULL_LIST_PAYMENT_RECEIVED = new EventType(
258 "EVENT_FULL_LIST_PAYMENT_RECEIVED");
259
260 /*** the product name */
261 private String productName;
262
263 /*** the message type */
264 private String contentType;
265
266 /*** the number of messages */
267 private int number;
268
269 /***
270 * @param contentClass the content class
271 * @param sent indicates whether we look for sent or received content
272 * @return returns a String reflecting the resolved content type
273 */
274 public static String resolveContentType(final Class contentClass,
275 final boolean sent)
276 {
277 if (InternalDemand.class.isAssignableFrom(contentClass))
278 {
279 if (sent)
280 {
281 return CONTENT_TYPE_INTERNALDEMAND_SENT;
282 }
283 return CONTENT_TYPE_INTERNALDEMAND_RECEIVED;
284 }
285 if (RequestForQuote.class.isAssignableFrom(contentClass))
286 {
287 if (sent)
288 {
289 return CONTENT_TYPE_RFQ_SENT;
290 }
291 return CONTENT_TYPE_RFQ_RECEIVED;
292 } else if (Quote.class.isAssignableFrom(contentClass))
293 {
294 if (sent)
295 {
296 return CONTENT_TYPE_QUOTE_SENT;
297 }
298 return CONTENT_TYPE_QUOTE_RECEIVED;
299 } else if (Order.class.isAssignableFrom(contentClass))
300 {
301 if (sent)
302 {
303 return CONTENT_TYPE_ORDER_SENT;
304 }
305 return CONTENT_TYPE_ORDER_RECEIVED;
306 } else if (ProductionOrder.class.isAssignableFrom(contentClass))
307 {
308 if (sent)
309 {
310 return CONTENT_TYPE_PRODUCTION_ORDER_SENT;
311 }
312 return CONTENT_TYPE_PRODUCTION_ORDER_RECEIVED;
313 } else if (OrderConfirmation.class.isAssignableFrom(contentClass))
314 {
315 if (sent)
316 {
317 return CONTENT_TYPE_ORDERCOMMIT_SENT;
318 }
319 return CONTENT_TYPE_ORDERCOMMIT_RECEIVED;
320 } else if (Shipment.class.isAssignableFrom(contentClass))
321 {
322 if (sent)
323 {
324 return CONTENT_TYPE_SHIPMENT_SENT;
325 }
326 return CONTENT_TYPE_SHIPMENT_RECEIVED;
327 } else if (Bill.class.isAssignableFrom(contentClass))
328 {
329 if (sent)
330 {
331 return CONTENT_TYPE_BILL_SENT;
332 }
333 return CONTENT_TYPE_BILL_RECEIVED;
334 } else if (Payment.class.isAssignableFrom(contentClass))
335 {
336 if (sent)
337 {
338 return CONTENT_TYPE_PAYMENT_SENT;
339 }
340 return CONTENT_TYPE_PAYMENT_RECEIVED;
341 }
342 Logger.warning(ContentNumberData.class, "resolveContentType",
343 "could not find content class " + contentClass);
344 return null;
345 }
346
347 /***
348 * @param contentClass the content class
349 * @param sent indicates whether we look for sent or received content
350 * @return returns a String reflecting the resolved event type
351 */
352 public static EventType resolveEventType(final Class contentClass,
353 final boolean sent)
354 {
355 if (InternalDemand.class.isAssignableFrom(contentClass))
356 {
357 if (sent)
358 {
359 return EVENT_NUMBER_INTERNALDEMAND_SENT;
360 }
361 return EVENT_NUMBER_INTERNALDEMAND_RECEIVED;
362 }
363 if (RequestForQuote.class.isAssignableFrom(contentClass))
364 {
365 if (sent)
366 {
367 return EVENT_NUMBER_RFQ_SENT;
368 }
369 return EVENT_NUMBER_RFQ_RECEIVED;
370 } else if (Quote.class.isAssignableFrom(contentClass))
371 {
372 if (sent)
373 {
374 return EVENT_NUMBER_QUOTE_SENT;
375 }
376 return EVENT_NUMBER_QUOTE_RECEIVED;
377 } else if (Order.class.isAssignableFrom(contentClass))
378 {
379 if (sent)
380 {
381 return EVENT_NUMBER_ORDER_SENT;
382 }
383 return EVENT_NUMBER_ORDER_RECEIVED;
384 } else if (ProductionOrder.class.isAssignableFrom(contentClass))
385 {
386 if (sent)
387 {
388 return EVENT_NUMBER_PRODUCTION_ORDER_SENT;
389 }
390 return EVENT_NUMBER_PRODUCTION_ORDER_RECEIVED;
391 } else if (OrderConfirmation.class.isAssignableFrom(contentClass))
392 {
393 if (sent)
394 {
395 return EVENT_NUMBER_ORDERCOMMIT_SENT;
396 }
397 return EVENT_NUMBER_ORDERCOMMIT_RECEIVED;
398 } else if (Shipment.class.isAssignableFrom(contentClass))
399 {
400 if (sent)
401 {
402 return EVENT_NUMBER_SHIPMENT_SENT;
403 }
404 return EVENT_NUMBER_SHIPMENT_RECEIVED;
405 } else if (Bill.class.isAssignableFrom(contentClass))
406 {
407 if (sent)
408 {
409 return EVENT_NUMBER_BILL_SENT;
410 }
411 return EVENT_NUMBER_BILL_RECEIVED;
412 } else if (Payment.class.isAssignableFrom(contentClass))
413 {
414 if (sent)
415 {
416 return EVENT_NUMBER_PAYMENT_SENT;
417 }
418 return EVENT_NUMBER_PAYMENT_RECEIVED;
419 }
420 Logger.warning(ContentNumberData.class, "resolveEventType",
421 "could not find content class " + contentClass);
422 return null;
423 }
424
425 /***
426 * @param contentClass the content class
427 * @param sent indicates whether we look for sent or received content
428 * @return returns an EventType based on the content class
429 */
430 public static EventType resolveFullListEventType(final Class contentClass,
431 final boolean sent)
432 {
433 if (InternalDemand.class.isAssignableFrom(contentClass))
434 {
435 if (sent)
436 {
437 return EVENT_FULL_LIST_INTERNALDEMAND_SENT;
438 }
439 return EVENT_FULL_LIST_INTERNALDEMAND_RECEIVED;
440 }
441 if (RequestForQuote.class.isAssignableFrom(contentClass))
442 {
443 if (sent)
444 {
445 return EVENT_FULL_LIST_RFQ_SENT;
446 }
447 return EVENT_FULL_LIST_RFQ_RECEIVED;
448 } else if (Quote.class.isAssignableFrom(contentClass))
449 {
450 if (sent)
451 {
452 return EVENT_FULL_LIST_QUOTE_SENT;
453 }
454 return EVENT_FULL_LIST_QUOTE_RECEIVED;
455 } else if (Order.class.isAssignableFrom(contentClass))
456 {
457 if (sent)
458 {
459 return EVENT_FULL_LIST_ORDER_SENT;
460 }
461 return EVENT_FULL_LIST_ORDER_RECEIVED;
462 } else if (ProductionOrder.class.isAssignableFrom(contentClass))
463 {
464 if (sent)
465 {
466 return EVENT_FULL_LIST_PRODUCTION_ORDER_SENT;
467 }
468 return EVENT_FULL_LIST_PRODUCTION_ORDER_RECEIVED;
469 } else if (OrderConfirmation.class.isAssignableFrom(contentClass))
470 {
471 if (sent)
472 {
473 return EVENT_FULL_LIST_ORDERCOMMIT_SENT;
474 }
475 return EVENT_FULL_LIST_ORDERCOMMIT_RECEIVED;
476 } else if (Shipment.class.isAssignableFrom(contentClass))
477 {
478 if (sent)
479 {
480 return EVENT_FULL_LIST_SHIPMENT_SENT;
481 }
482 return EVENT_FULL_LIST_SHIPMENT_RECEIVED;
483 } else if (Bill.class.isAssignableFrom(contentClass))
484 {
485 if (sent)
486 {
487 return EVENT_FULL_LIST_BILL_SENT;
488 }
489 return EVENT_FULL_LIST_BILL_RECEIVED;
490 } else if (Payment.class.isAssignableFrom(contentClass))
491 {
492 if (sent)
493 {
494 return EVENT_FULL_LIST_PAYMENT_SENT;
495 }
496 return EVENT_FULL_LIST_PAYMENT_RECEIVED;
497 }
498 Logger.warning(ContentNumberData.class, "resolveFullListEventType",
499 "could not find content class " + contentClass);
500 return null;
501 }
502
503 /***
504 * @param productName the name of the product
505 * @param content the message
506 * @param number the new number of messages
507 * @param sent is true if sent, and false if received
508 *
509 */
510 public ContentNumberData(final String productName, final Content content,
511 final int number, final boolean sent)
512 {
513 super();
514 this.productName = productName;
515 this.number = number;
516 this.contentType = resolveContentType(content.getClass(), sent);
517 }
518
519 /***
520 * @param productName the name of the product
521 * @param contentClass the class of the messages
522 * @param number the new number of messages
523 * @param sent is true if sent, and false if received
524 *
525 */
526 public ContentNumberData(final String productName,
527 final Class contentClass, final int number, final boolean sent)
528 {
529 super();
530 this.productName = productName;
531 this.number = number;
532 this.contentType = resolveContentType(contentClass, sent);
533 }
534
535 /***
536 * @return Returns the contentType.
537 */
538 public String getContentType()
539 {
540 return this.contentType;
541 }
542
543 /***
544 * @return Returns the number.
545 */
546 public int getNumber()
547 {
548 return this.number;
549 }
550
551 /***
552 * @return Returns the productName.
553 */
554 public String getProductName()
555 {
556 return this.productName;
557 }
558 }