View Javadoc

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