View Javadoc

1   package org.gnomekr.potron.web.view;
2   
3   import java.util.Date;
4   import java.util.List;
5   import java.util.Map;
6   
7   import org.apache.commons.lang.NullArgumentException;
8   import org.gnomekr.potron.statistics.TranslatorStatus;
9   import org.jfree.data.general.DefaultPieDataset;
10  
11  import de.laures.cewolf.DatasetProduceException;
12  import de.laures.cewolf.DatasetProducer;
13  
14  /***
15   * TopTranslatorsDataset.java
16   * @author Xavier Cho
17   * @version $Revision 1.1 $ $Date: 2005/07/22 07:25:33 $
18   */
19  public class TopTranslatorsDataset implements DatasetProducer {
20  
21      private static final long serialVersionUID = 1399872886079057685L;
22  
23      private List<TranslatorStatus> topTranslators;
24  
25      public TopTranslatorsDataset(List<TranslatorStatus> topTranslators) {
26          if (topTranslators == null) {
27              throw new NullArgumentException("topTranslators");
28          }
29          this.topTranslators = topTranslators;
30      }
31  
32      public Object produceDataset(Map params) throws DatasetProduceException {
33          DefaultPieDataset dataset = new DefaultPieDataset();
34  
35          for (TranslatorStatus status: topTranslators) {
36              dataset.setValue(status.getTranslator().getUserName(), status
37                      .getTranslatedEntries());
38          }
39  
40          return dataset;
41      }
42  
43      /***
44       * @see de.laures.cewolf.DatasetProducer#hasExpired(java.util.Map, java.util.Date)
45       * TODO Implement some sort of caching rule.
46       */
47      public boolean hasExpired(Map params, Date since) {
48          return false;
49      }
50  
51      /***
52       * @see de.laures.cewolf.DatasetProducer#getProducerId()
53       */
54      public String getProducerId() {
55          return getClass().getName();
56      }
57  }