From: <jbo...@li...> - 2005-12-25 18:38:07
|
Author: aron.gombas Date: 2005-12-25 13:37:44 -0500 (Sun, 25 Dec 2005) New Revision: 1932 Added: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnRepositoryContentStats.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnRepositoryLogStats.java Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java Log: SVN "stat" classes factored out from inner classes Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java 2005-12-25 00:35:09 UTC (rev 1931) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java 2005-12-25 18:37:44 UTC (rev 1932) @@ -78,10 +78,11 @@ try { // download database info connect(url); + Document dom = ScrapingUtils.downloadHtmlDom(new URL(ScrapingUtils.removeUserInfoFromUrl(url))); + disconnect(url); - // TODO review these queries // TODO restructure all the services code // run XQueries Added: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnRepositoryContentStats.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnRepositoryContentStats.java 2005-12-25 00:35:09 UTC (rev 1931) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnRepositoryContentStats.java 2005-12-25 18:37:44 UTC (rev 1932) @@ -0,0 +1,24 @@ +/* + * Kosmos. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package hu.midori.kosmos.server.svn; + +import java.util.List; +import java.util.Map; + +/** Wraps the stats retrieved from the log of a SVN repository. */ +class SvnRepositoryContentStats {// TODO rewrite as bean + /** No of dirs. */ + public int dirs; + /** No of files. */ + public int files; + /** Total filesize. */ + public int totalSize; + + /* No of files per file-type. */ + public List<Map.Entry<String,Integer>> filesPerFileType; + public String filesPerFileTypeChartUrl; +} \ No newline at end of file Added: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnRepositoryLogStats.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnRepositoryLogStats.java 2005-12-25 00:35:09 UTC (rev 1931) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnRepositoryLogStats.java 2005-12-25 18:37:44 UTC (rev 1932) @@ -0,0 +1,77 @@ +/* + * Kosmos. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package hu.midori.kosmos.server.svn; + +import hu.midori.kosmos.model.ScmRepositoryChange; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.Week; + +/** Wraps the stats retrieved from the content of a SVN repository. */ +class SvnRepositoryLogStats {// TODO rewrite as bean + public Date createdDate; + /** Full history of the commits in reversed order. */ + public List<ScmRepositoryChange> commits = new ArrayList<ScmRepositoryChange>(); + + /* No of commits over a certain period. */ + public int commitsTotal; + public int commitsToday; + public int commitsLast7Days; + public int commitsLast31Days; + + /* Author of commits over a certain period. */ + public Set<String> committersTotal = new HashSet<String>(); + public Set<String> committersToday = new HashSet<String>(); + public Set<String> committersLast7Days = new HashSet<String>(); + public Set<String> committersLast31Days = new HashSet<String>(); + + /* No of repository entries per week. */ + public TimeSeries repoEntriesPerWeek = new TimeSeries("", Week.class); + public String repoEntriesPerWeekChartUrl; + + /* No of commits per author. */ + public List<Map.Entry<String,Integer>> commitsPerAuthor; + public String commitsPerAuthorChartUrl; + + /* No of commits per file. */ + public List<Map.Entry<String,Integer>> commitsPerFile; + public String commitsPerFileChartUrl; + + /* No of commits per week. */ + public TimeSeries commitsPerWeek = new TimeSeries("", Week.class); + public String commitsPerWeekChartUrl; + + /** Must be called to validate its content, after the processing was done. */ + public void validate() { + // revert history + Collections.reverse(commits); + + // cummulate files-per-week values + for(int i = 1; i < repoEntriesPerWeek.getItemCount(); i++) + repoEntriesPerWeek.update(i, repoEntriesPerWeek.getValue(i).intValue() + repoEntriesPerWeek.getValue(i - 1).intValue()); + + // add files-per-week value for the current week even if no activity + Week currentWeek = new Week(new Date()); + if(repoEntriesPerWeek.getDataItem(currentWeek) == null) + repoEntriesPerWeek.add(currentWeek, repoEntriesPerWeek.getValue(repoEntriesPerWeek.getItemCount() - 1)); + + // assert calculations + int calculatedCommitsTotal = 0; + for(int i = 0; i < commitsPerWeek.getItemCount(); i++) // FIXME these kind of counting should be rather done with a commons Bag + calculatedCommitsTotal += commitsPerWeek.getDataItem(i).getValue().intValue(); + if(calculatedCommitsTotal != commitsTotal) + throw new IllegalStateException(String.format("Calculated commits (%d) does not equal statistical commits (%d)", calculatedCommitsTotal, commitsTotal)); + } +} \ No newline at end of file Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-12-25 00:35:09 UTC (rev 1931) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-12-25 18:37:44 UTC (rev 1932) @@ -21,19 +21,15 @@ import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.Date; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesDataItem; import org.jfree.data.time.Week; import org.tmatesoft.svn.core.SVNDirEntry; @@ -166,63 +162,6 @@ // do nothing } - /** Wraps the stats retrieved from the content of a SVN repository. */ - private class SvnRepositoryLogStats {// TODO rewrite as bean - public Date createdDate; - /** Full history of the commits in reversed order. */ - public List<ScmRepositoryChange> commits = new ArrayList<ScmRepositoryChange>(); - - /* No of commits over a certain period. */ - public int commitsTotal; - public int commitsToday; - public int commitsLast7Days; - public int commitsLast31Days; - - /* Author of commits over a certain period. */ - public Set<String> committersTotal = new HashSet<String>(); - public Set<String> committersToday = new HashSet<String>(); - public Set<String> committersLast7Days = new HashSet<String>(); - public Set<String> committersLast31Days = new HashSet<String>(); - - /* No of repository entries per week. */ - public TimeSeries repoEntriesPerWeek = new TimeSeries("", Week.class); - public String repoEntriesPerWeekChartUrl; - - /* No of commits per author. */ - public List<Map.Entry<String,Integer>> commitsPerAuthor; - public String commitsPerAuthorChartUrl; - - /* No of commits per file. */ - public List<Map.Entry<String,Integer>> commitsPerFile; - public String commitsPerFileChartUrl; - - /* No of commits per week. */ - public TimeSeries commitsPerWeek = new TimeSeries("", Week.class); - public String commitsPerWeekChartUrl; - - /** Must be called to validate its content, after the processing was done. */ - public void validate() { - // revert history - Collections.reverse(commits); - - // cummulate files-per-week values - for(int i = 1; i < repoEntriesPerWeek.getItemCount(); i++) - repoEntriesPerWeek.update(i, repoEntriesPerWeek.getValue(i).intValue() + repoEntriesPerWeek.getValue(i - 1).intValue()); - - // add files-per-week value for the current week even if no activity - Week currentWeek = new Week(new Date()); - if(repoEntriesPerWeek.getDataItem(currentWeek) == null) - repoEntriesPerWeek.add(currentWeek, repoEntriesPerWeek.getValue(repoEntriesPerWeek.getItemCount() - 1)); - - // assert calculations - int calculatedCommitsTotal = 0; - for(int i = 0; i < commitsPerWeek.getItemCount(); i++) // FIXME these kind of counting should be rather done with a commons Bag - calculatedCommitsTotal += commitsPerWeek.getDataItem(i).getValue().intValue(); - if(calculatedCommitsTotal != commitsTotal) - throw new IllegalStateException(String.format("Calculated commits (%d) does not equal statistical commits (%d)", calculatedCommitsTotal, commitsTotal)); - } - } - /** Analyzes the log of the repo and returns its stats. */ @SuppressWarnings("unchecked") protected SvnRepositoryLogStats analyzeLog(SVNRepository repository) throws SVNException { @@ -325,20 +264,6 @@ return stats; } - /** Wraps the stats retrieved from the log of a SVN repository. */ - private class SvnRepositoryContentStats { - /** No of dirs. */ - public int dirs; - /** No of files. */ - public int files; - /** Total filesize. */ - public int totalSize; - - /* No of files per file-type. */ - public List<Map.Entry<String,Integer>> filesPerFileType; - public String filesPerFileTypeChartUrl; - } - /** Analyzes the repository content and returns its stats. */ @SuppressWarnings("unchecked") protected SvnRepositoryContentStats analyzeContent(SVNRepository repository) throws SVNException { |