001    package org.hackystat.projectbrowser.page.dailyprojectdata.issue;
002    
003    import java.io.Serializable;
004    import java.util.Map;
005    import java.util.TreeMap;
006    
007    import org.hackystat.dailyprojectdata.resource.issue.jaxb.IssueDailyProjectData;
008    import org.hackystat.dailyprojectdata.resource.issue.jaxb.IssueData;
009    import org.hackystat.sensorbase.resource.projects.jaxb.Project;
010    
011    /**
012     * Represents commit and churn data for a given project and day.
013     * @author Philip Johnson
014     *
015     */
016    public class IssueDpdData implements Serializable {
017      
018      /** Support serialization. */
019      private static final long serialVersionUID = 1L;
020      
021      /** The project whose data is kept in this instance. */
022      private Project project;
023      
024      private final int openIssues;
025      private final int closedIssues;
026      
027      private final Map<String, Integer> issueStatusCount = new TreeMap<String, Integer>();
028    
029      /**
030       * Constructs a CommitData instance with member data. 
031       * @param project The project associated with this Commit data. 
032       * @param issueDpd The individual member data. 
033       */
034      public IssueDpdData(Project project, IssueDailyProjectData issueDpd) {
035        this.project = project;
036        openIssues = issueDpd.getOpenIssues();
037        closedIssues = issueDpd.getIssueData().size() - openIssues;
038        for (IssueData issueData : issueDpd.getIssueData()) {
039          String status = issueData.getStatus();
040          if (status != null && status.length() > 0) {
041            if (issueStatusCount.containsKey(status)) {
042              issueStatusCount.put(status, issueStatusCount.get(status) + 1);
043            }
044            else {
045              issueStatusCount.put(status, 1);
046            }
047          }
048        }
049      }
050      
051      /**
052       * Constructs an empty CommitData instance.
053       * Used to initialize the session state.  
054       * @param project The project.
055       */
056      public IssueDpdData(Project project) {
057        this.project = project;
058        openIssues = 0;
059        closedIssues = 0;
060      }
061      
062      /**
063       * Returns the project associated with this instance. 
064       * @return The project. 
065       */
066      public Project getProject() {
067        return this.project;
068      }
069    
070      /**
071       * @return the openIssues
072       */
073      public int getOpenIssues() {
074        return openIssues;
075      }
076    
077      /**
078       * @return the closedIssues
079       */
080      public int getClosedIssues() {
081        return closedIssues;
082      }
083    
084      /**
085       * @return the issueStatusCount
086       */
087      public Map<String, Integer> getIssueStatusCount() {
088        return issueStatusCount;
089      }
090      
091    }