d9cacb5d3f458b7de2acdc08cf6a173ee25f3748
[jabaws.git] / webservices / compbio / stat / servlet / util / Totals.java
1 package compbio.stat.servlet.util;\r
2 \r
3 import java.util.Date;\r
4 import java.util.Map;\r
5 \r
6 import compbio.stat.collector.StatProcessor;\r
7 import compbio.ws.client.Services;\r
8 \r
9 public class Totals {\r
10         int total;\r
11         int incomplete;\r
12         int abandoned;\r
13         int cancelled;\r
14         int failed;\r
15 \r
16         public int getTotal() {\r
17                 return total;\r
18         }\r
19 \r
20         public int getIncomplete() {\r
21                 return incomplete;\r
22         }\r
23 \r
24         public int getAbandoned() {\r
25                 return abandoned;\r
26         }\r
27 \r
28         public int getCancelled() {\r
29                 return cancelled;\r
30         }\r
31 \r
32         public int getFailed() {\r
33                 return failed;\r
34         }\r
35 \r
36         public static Totals sumOfTotals(Map<Date, Totals> stat) {\r
37                 Totals total = new Totals();\r
38                 for (Map.Entry<Date, Totals> entry : stat.entrySet()) {\r
39                         Totals mtotal = entry.getValue();\r
40                         total.total += mtotal.getTotal();\r
41                         total.incomplete += mtotal.getIncomplete();\r
42                         total.abandoned += mtotal.getAbandoned();\r
43                         total.cancelled += mtotal.getCancelled();\r
44                         total.failed += mtotal.getFailed();\r
45                 }\r
46                 return total;\r
47         }\r
48 \r
49         public static Totals sumStats(Map<Services, StatProcessor> stat) {\r
50                 Totals total = new Totals();\r
51                 for (Map.Entry<Services, StatProcessor> serv : stat.entrySet()) {\r
52                         total.total += serv.getValue().getJobNumber();\r
53                         total.incomplete += serv.getValue().getIncompleteJobs().size();\r
54                         total.abandoned += serv.getValue().getAbandonedJobs().size();\r
55                         total.cancelled += serv.getValue().getCancelledJobs().size();\r
56                         total.failed += serv.getValue().getFailedJobs().size();\r
57                 }\r
58                 return total;\r
59         }\r
60 }