|
From: <jbo...@li...> - 2005-09-19 11:56:40
|
Author: aron.gombas
Date: 2005-09-19 07:56:23 -0400 (Mon, 19 Sep 2005)
New Revision: 1150
Modified:
trunk/labs/kosmos/src/java/hu/midori/kosmos/model/JiraProject.java
trunk/labs/kosmos/src/java/hu/midori/kosmos/model/SvnRepository.java
trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java
trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java
trunk/labs/kosmos/src/java/hu/midori/kosmos/server/util/ChartUtils.java
Log:
KOSMOS-17 issue fixed
Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/model/JiraProject.java
===================================================================
--- trunk/labs/kosmos/src/java/hu/midori/kosmos/model/JiraProject.java 2005-09-19 10:10:48 UTC (rev 1149)
+++ trunk/labs/kosmos/src/java/hu/midori/kosmos/model/JiraProject.java 2005-09-19 11:56:23 UTC (rev 1150)
@@ -45,7 +45,7 @@
private int optionalOpenIssues = 0;
/** Open-issues-per-assignee sorted by issues in descending order. */
- private List<Map.Entry<String,Integer>> issuesPerAssignee;
+ private List<Map.Entry<String,Integer>> openIssuesPerAssignee;
/** URL of the issues-per-status chart image. */
private String issuesPerStatusChartUrl;
@@ -62,7 +62,11 @@
super(null);
}
- public JiraProject(String name, String url, String key, String projectUrl, String description, String lead, int openIssues, int codingInProgressIssues, int reopenedIssues, int resolvedIssues, int closedIssues, int blockerOpenIssues, int criticalOpenIssues, int majorOpenIssues, int minorOpenIssues, int trivialOpenIssues, int optionalOpenIssues, List<Map.Entry<String,Integer>> issuesPerAssignee, String issuesPerStatusChartUrl, String openIssuesPerPriorityChartUrl, String openIssuesPerAssigneeChartUrl) {
+ public JiraProject(String name, String url, String key, String projectUrl, String description, String lead,
+ int openIssues, int codingInProgressIssues, int reopenedIssues, int resolvedIssues, int closedIssues,
+ int blockerOpenIssues, int criticalOpenIssues, int majorOpenIssues, int minorOpenIssues, int trivialOpenIssues, int optionalOpenIssues,
+ List<Map.Entry<String,Integer>> openIssuesPerAssignee,
+ String issuesPerStatusChartUrl, String openIssuesPerPriorityChartUrl, String openIssuesPerAssigneeChartUrl) {
super(name + url + key + projectUrl);
this.name = name;
@@ -85,7 +89,7 @@
this.trivialOpenIssues = trivialOpenIssues;
this.optionalOpenIssues = optionalOpenIssues;
- this.issuesPerAssignee = issuesPerAssignee;
+ this.openIssuesPerAssignee = openIssuesPerAssignee;
this.issuesPerStatusChartUrl = issuesPerStatusChartUrl;
this.openIssuesPerPriorityChartUrl = openIssuesPerPriorityChartUrl;
@@ -160,8 +164,8 @@
return optionalOpenIssues;
}
- public List<Map.Entry<String,Integer>> getIssuesPerAssignee() {
- return issuesPerAssignee;
+ public List<Map.Entry<String,Integer>> getOpenIssuesPerAssignee() {
+ return openIssuesPerAssignee;
}
public String getIssuesPerStatusChartUrl() {
@@ -182,6 +186,6 @@
@Override
public String toString() {
- return String.format("%s [%s] (%s), %s, %s, %s, %d/%d/%d/%d/%d, %d/%d/%d/%d/%d/%d, %s, %s, %s, %s", name, url, key, projectUrl, description, lead, openIssues, codingInProgressIssues, reopenedIssues, resolvedIssues, closedIssues, blockerOpenIssues, criticalOpenIssues, majorOpenIssues, minorOpenIssues, trivialOpenIssues, optionalOpenIssues, issuesPerAssignee, issuesPerStatusChartUrl, openIssuesPerPriorityChartUrl, openIssuesPerAssigneeChartUrl);
+ return String.format("%s [%s] (%s), %s, %s, %s, %d/%d/%d/%d/%d, %d/%d/%d/%d/%d/%d, %s, %s, %s, %s", name, url, key, projectUrl, description, lead, openIssues, codingInProgressIssues, reopenedIssues, resolvedIssues, closedIssues, blockerOpenIssues, criticalOpenIssues, majorOpenIssues, minorOpenIssues, trivialOpenIssues, optionalOpenIssues, openIssuesPerAssignee, issuesPerStatusChartUrl, openIssuesPerPriorityChartUrl, openIssuesPerAssigneeChartUrl);
}
}
Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/model/SvnRepository.java
===================================================================
--- trunk/labs/kosmos/src/java/hu/midori/kosmos/model/SvnRepository.java 2005-09-19 10:10:48 UTC (rev 1149)
+++ trunk/labs/kosmos/src/java/hu/midori/kosmos/model/SvnRepository.java 2005-09-19 11:56:23 UTC (rev 1150)
@@ -74,7 +74,13 @@
super(null);
}
- public SvnRepository(String location, long revision, Date createdDate, List<ScmRepositoryChange> commits, int commitsTotal, int commitsToday, int commitsLast7Days, int commitsLast31Days, int committersTotal, int committersToday, int committersLast7Days, int committersLast31Days, String commitsPerAuthorChartUrl, String commitsPerFileChartUrl, String commitsPerWeekChartUrl, String repoEntriesPerWeekChartUrl, int dirs, int files, int totalFileSize, List<Map.Entry<String,Integer>> commitsPerAuthor, List<Map.Entry<String,Integer>> commitsPerFile) {
+ public SvnRepository(String location, long revision,
+ Date createdDate, List<ScmRepositoryChange> commits,
+ int commitsTotal, int commitsToday, int commitsLast7Days, int commitsLast31Days,
+ int committersTotal, int committersToday, int committersLast7Days, int committersLast31Days,
+ String commitsPerAuthorChartUrl, String commitsPerFileChartUrl, String commitsPerWeekChartUrl, String repoEntriesPerWeekChartUrl,
+ int dirs, int files, int totalFileSize,
+ List<Map.Entry<String,Integer>> commitsPerAuthor, List<Map.Entry<String,Integer>> commitsPerFile) {
super(location + revision + commits.get(0).getDate());
this.location = location;
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-09-19 10:10:48 UTC (rev 1149)
+++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java 2005-09-19 11:56:23 UTC (rev 1150)
@@ -208,7 +208,7 @@
}
// scrape issue assignees
- Map<String, Integer> openIssuesPerAssignee = new HashMap<String, Integer>();
+ Map<String, Integer> openIssuesPerAssigneeMap = new HashMap<String, Integer>();
for(Iterator itIssueAssignee = resultIssueAssignee.iterator(); itIssueAssignee.hasNext();) {
String valueIssueAssignee = ((NodeInfo)itIssueAssignee.next()).getStringValue();
log.debug(String.format("Scraped issue assignee: \"%s\"", valueIssueAssignee));
@@ -216,51 +216,56 @@
StringTokenizer tokenizerIssueAssignee = new StringTokenizer(valueIssueAssignee, "|");
String assignee = tokenizerIssueAssignee.nextToken();
int count = Integer.parseInt(tokenizerIssueAssignee.nextToken());
- openIssuesPerAssignee.put(assignee, count);
+ openIssuesPerAssigneeMap.put(assignee, count);
}
-
+ List<Map.Entry<String, Integer>> openIssuesPerAssignee = (List<Map.Entry<String, Integer>>)ChartUtils.intValuedMapToSortedList(openIssuesPerAssigneeMap);
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.collectionToPieDataset(openIssuesPerAssignee, ChartUtils.MAX_ITEMS)), out);// TODO fix all generics warnings
+ String openIssuesPerAssigneeChartUrl = saveCachedFile(encodeCachedFileName(url + "_open_issues_per_assignee.png"), new ByteArrayInputStream(out.toByteArray()));
+
// generate issues-per-status chart
- Map<Integer, Integer> issuesPerStatus = new HashMap<Integer, Integer>();
+ Map<Integer, Integer> issuesPerStatusMap = new HashMap<Integer, Integer>();
if(openIssues > 0)
- issuesPerStatus.put(OPEN_COLOR, openIssues);
+ issuesPerStatusMap.put(OPEN_COLOR, openIssues);
if(codingInProgressIssues > 0)
- issuesPerStatus.put(CODING_IN_PROGRESS_COLOR, codingInProgressIssues);
+ issuesPerStatusMap.put(CODING_IN_PROGRESS_COLOR, codingInProgressIssues);
if(reopenedIssues > 0)
- issuesPerStatus.put(REOPENED_COLOR, reopenedIssues);
+ issuesPerStatusMap.put(REOPENED_COLOR, reopenedIssues);
if(resolvedIssues > 0)
- issuesPerStatus.put(RESOLVED_COLOR, resolvedIssues);
+ issuesPerStatusMap.put(RESOLVED_COLOR, resolvedIssues);
if(closedIssues > 0)
- issuesPerStatus.put(CLOSED_COLOR, closedIssues);
+ issuesPerStatusMap.put(CLOSED_COLOR, closedIssues);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ChartUtils.writeChartAsPng(ChartUtils.generateColorCodedPieChart(ChartUtils.mapToPieDataset(issuesPerStatus)), out);
+ out.reset();
+ ChartUtils.writeChartAsPng(ChartUtils.generateColorCodedPieChart(ChartUtils.mapToPieDataset(issuesPerStatusMap)), out);
String issuesPerStatusChartUrl = saveCachedFile(encodeCachedFileName(url + "_issues_per_status.png"), new ByteArrayInputStream(out.toByteArray()));
// generate issues-per-priority chart
- Map<Integer, Integer> openIssuesPerPriority = new HashMap<Integer, Integer>();
+ Map<Integer, Integer> openIssuesPerPriorityMap = new HashMap<Integer, Integer>();
if(blockerOpenIssues > 0)
- openIssuesPerPriority.put(BLOCKER_COLOR, blockerOpenIssues);
+ openIssuesPerPriorityMap.put(BLOCKER_COLOR, blockerOpenIssues);
if(criticalOpenIssues > 0)
- openIssuesPerPriority.put(CRITICAL_COLOR, criticalOpenIssues);
+ openIssuesPerPriorityMap.put(CRITICAL_COLOR, criticalOpenIssues);
if(majorOpenIssues > 0)
- openIssuesPerPriority.put(MAJOR_COLOR, majorOpenIssues);
+ openIssuesPerPriorityMap.put(MAJOR_COLOR, majorOpenIssues);
if(minorOpenIssues > 0)
- openIssuesPerPriority.put(MINOR_COLOR, minorOpenIssues);
+ openIssuesPerPriorityMap.put(MINOR_COLOR, minorOpenIssues);
if(trivialOpenIssues > 0)
- openIssuesPerPriority.put(TRIVIAL_COLOR, trivialOpenIssues);
+ openIssuesPerPriorityMap.put(TRIVIAL_COLOR, trivialOpenIssues);
if(optionalOpenIssues > 0)
- openIssuesPerPriority.put(OPTIONAL_COLOR, optionalOpenIssues);
+ openIssuesPerPriorityMap.put(OPTIONAL_COLOR, optionalOpenIssues);
out.reset();
- ChartUtils.writeChartAsPng(ChartUtils.generateColorCodedPieChart(ChartUtils.mapToPieDataset(openIssuesPerPriority)), out);
+ ChartUtils.writeChartAsPng(ChartUtils.generateColorCodedPieChart(ChartUtils.mapToPieDataset(openIssuesPerPriorityMap)), out);
String openIssuesPerPriorityChartUrl = saveCachedFile(encodeCachedFileName(url + "_open_issues_per_priority.png"), new ByteArrayInputStream(out.toByteArray()));
-
- out.reset();
- ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.mapToPieDataset(openIssuesPerAssignee, ChartUtils.MAX_ITEMS)), out);
- String openIssuesPerAssigneeChartUrl = saveCachedFile(encodeCachedFileName(url + "_open_issues_per_assignee.png"), new ByteArrayInputStream(out.toByteArray()));
-
+
// save
- JiraProject project = new JiraProject(name, url, projectKey, projectUrl, description, lead, openIssues, codingInProgressIssues, reopenedIssues, resolvedIssues, closedIssues, blockerOpenIssues, criticalOpenIssues, majorOpenIssues, minorOpenIssues, trivialOpenIssues, optionalOpenIssues, ChartUtils.sortDescByIntegerValue(openIssuesPerAssignee), issuesPerStatusChartUrl, openIssuesPerPriorityChartUrl, openIssuesPerAssigneeChartUrl);
+ JiraProject project = new JiraProject(name, url, projectKey, projectUrl, description, lead,
+ openIssues, codingInProgressIssues, reopenedIssues, resolvedIssues, closedIssues,
+ blockerOpenIssues, criticalOpenIssues, majorOpenIssues, minorOpenIssues, trivialOpenIssues, optionalOpenIssues,
+ (List<Map.Entry<String, Integer>>)openIssuesPerAssignee,
+ issuesPerStatusChartUrl, openIssuesPerPriorityChartUrl, openIssuesPerAssigneeChartUrl);
log.debug(String.format("Adding %s...", project));
projects.add(project);
}
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-09-19 10:10:48 UTC (rev 1149)
+++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-09-19 11:56:23 UTC (rev 1150)
@@ -105,6 +105,7 @@
SvnRepositoryLogStats logStats = analyzeLog(repo);
SvnRepositoryContentStats contentStats = analyzeContent(repo);
+ generateCharts(repo, logStats);
// save
previousLatestRevision = repo.getLatestRevision();
@@ -114,7 +115,7 @@
logStats.committersTotal.size(), logStats.committersToday.size(), logStats.committersLast7Days.size(), logStats.committersLast31Days.size(),
logStats.commitsPerAuthorChartUrl, logStats.commitsPerFileChartUrl, logStats.commitsPerWeekChartUrl, logStats.repoEntriesPerWeekChartUrl,
contentStats.dirs, contentStats.files, contentStats.totalSize,
- ChartUtils.sortDescByIntegerValue(logStats.commitsPerAuthor), ChartUtils.sortDescByIntegerValue(logStats.commitsPerFile));
+ (List<Map.Entry<String, Integer>>)logStats.commitsPerAuthor, (List<Map.Entry<String, Integer>>)logStats.commitsPerFile);
log.debug(String.format("Adding %s...", repository));
repositories.add(repository);
} catch (Exception ex) {
@@ -143,11 +144,13 @@
public Set<String> committersLast31Days = new HashSet<String>();
/* No of commits per author. */
- public Map<String,Integer> commitsPerAuthor = new TreeMap<String,Integer>();
+ public Map<String,Integer> commitsPerAuthorMap = new TreeMap<String,Integer>();
+public List<Map.Entry<String,Integer>> commitsPerAuthor;// TODO write comment
public String commitsPerAuthorChartUrl;
/* No of commits per file. */
- public Map<String,Integer> commitsPerFile = new TreeMap<String,Integer>();
+ public Map<String,Integer> commitsPerFileMap = new TreeMap<String,Integer>();
+public List<Map.Entry<String,Integer>> commitsPerFile;// TODO write comment
public String commitsPerFileChartUrl;
/* No of commits per week. */
@@ -158,8 +161,12 @@
public TimeSeries repoEntriesPerWeek = new TimeSeries("", Week.class);
public String repoEntriesPerWeekChartUrl;
- /** Must be called after the processing was done. */
+ /** Must be called to validate its content, after the processing was done. */
public void validate() {
+ // sort maps
+ commitsPerAuthor = (List<Map.Entry<String, Integer>>)ChartUtils.intValuedMapToSortedList(commitsPerAuthorMap);
+ commitsPerFile = (List<Map.Entry<String, Integer>>)ChartUtils.intValuedMapToSortedList(commitsPerFileMap);
+
// revert history
Collections.reverse(commits);
@@ -229,8 +236,8 @@
}
// count commits-per-author
- Integer commitsPerCurrentAuthor = stats.commitsPerAuthor.get(logEntry.getAuthor());
- stats.commitsPerAuthor.put(logEntry.getAuthor(), (commitsPerCurrentAuthor == null) ? 1 : commitsPerCurrentAuthor + 1);
+ Integer commitsPerCurrentAuthor = stats.commitsPerAuthorMap.get(logEntry.getAuthor());
+ stats.commitsPerAuthorMap.put(logEntry.getAuthor(), (commitsPerCurrentAuthor == null) ? 1 : commitsPerCurrentAuthor + 1);
// count commits-per-week
Week commitWeek = new Week(logEntry.getDate());
@@ -247,8 +254,8 @@
SVNLogEntryPath logEntryPath = (SVNLogEntryPath)changedPaths.get(it.next());
// count commits-per-file
- Integer commitsPerCurrentFile = stats.commitsPerFile.get(logEntryPath.getPath());
- stats.commitsPerFile.put(logEntryPath.getPath(), (commitsPerCurrentFile == null) ? 1 : commitsPerCurrentFile + 1);
+ Integer commitsPerCurrentFile = stats.commitsPerFileMap.get(logEntryPath.getPath());
+ stats.commitsPerFileMap.put(logEntryPath.getPath(), (commitsPerCurrentFile == null) ? 1 : commitsPerCurrentFile + 1);
// count files-per-week
TimeSeriesDataItem repoEntriesPerCurrentWeek = stats.repoEntriesPerWeek.getDataItem(commitWeek);
@@ -261,9 +268,8 @@
}
}
- // validate and generate charts
+ // validate
stats.validate();
- generateCharts(repository, stats);
return stats;
}
@@ -322,11 +328,11 @@
// generate charts
ByteArrayOutputStream out = new ByteArrayOutputStream();
- ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.mapToPieDataset(stats.commitsPerAuthor, ChartUtils.MAX_ITEMS)), out);
+ ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.collectionToPieDataset(stats.commitsPerAuthor, ChartUtils.MAX_ITEMS)), out);
stats.commitsPerAuthorChartUrl = saveCachedFile(encodeCachedFileName(prefix + "_commits_per_author.png"), new ByteArrayInputStream(out.toByteArray()));
out.reset();
- ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.mapToPieDataset(stats.commitsPerFile, ChartUtils.MAX_ITEMS)), out);
+ ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.collectionToPieDataset(stats.commitsPerFile, ChartUtils.MAX_ITEMS)), out);
stats.commitsPerFileChartUrl = saveCachedFile(encodeCachedFileName(prefix + "_commits_per_file.png"), new ByteArrayInputStream(out.toByteArray()));
out.reset();
Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/util/ChartUtils.java
===================================================================
--- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/util/ChartUtils.java 2005-09-19 10:10:48 UTC (rev 1149)
+++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/util/ChartUtils.java 2005-09-19 11:56:23 UTC (rev 1150)
@@ -12,9 +12,9 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -106,54 +106,35 @@
ChartUtilities.writeChartAsPNG(out, chart, CHART_RESOLUTION_X, CHART_RESOLUTION_Y, true, 0);
}
- /**
- * Returns the passed list as pie-dataset.
- * @see #listToPieDataset(List<Map.Entry>, int)
- * */
- public static PieDataset listToPieDataset(List<Map.Entry> data) {
- return listToPieDataset(data, -1);
+ /** Returns the passed data as unclamped pie-dataset. */
+ public static PieDataset mapToPieDataset(Map data) {// TODO should be Map<? extends Comparable, Integer>
+ return collectionToPieDataset(new ArrayList<Map.Entry>(data.entrySet()), -1);
}
-
+
/**
- * Returns the passed list as pie-dataset (equivalent key-value pairs),
- * clamped to a maximum number of items to prevent unreadably busy charts.
+ * Returns the passed collection of <code>Map.Entry</code> objects as pie-dataset
+ * (equivalent key-value pairs), optionally clamped to a maximum number of items
+ * to prevent unreadably busy charts.
* @param maxItems the maximum number of items in the returned pie-dataset or -1 if clamping is not needed.
*/
- public static PieDataset listToPieDataset(List<Map.Entry> data, int maxItems) {
+ public static PieDataset collectionToPieDataset(Collection items, int maxItems) {
DefaultPieDataset dataset = new DefaultPieDataset();
// generate dataset
int counter = 0;
- for(Iterator it = data.iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry)it.next();
- if((maxItems != -1) && (++counter >= maxItems))
+ for(Map.Entry<? extends Comparable, Integer> item : (Collection<Map.Entry<? extends Comparable, Integer>>)items) {
+ if((maxItems != -1) && (++counter > maxItems))
break;
- dataset.setValue((Comparable)entry.getKey(), (Number)entry.getValue());// TODO ILYEN LEGYEN A BEMENET
+ dataset.setValue(item.getKey(), item.getValue());
}
return dataset;
}
-
- /**
- * Returns the passed list as pie-dataset.
- * @see #mapToPieDataset(Map, int)
- * */
- public static PieDataset mapToPieDataset(Map data) {
- return mapToPieDataset(data, -1);
- }
-
- /**
- * Returns the passed list as pie-dataset.
- * @see #listToPieDataset(List<Map.Entry>, int)
- */
- public static PieDataset mapToPieDataset(Map data, int maxItems) {
- return listToPieDataset(new ArrayList(data.entrySet()), maxItems);
- }
-
+
/** Returns the list of the entries in the map sorted by their value (not by their key!) in descending order. */
- public static List<Map.Entry<String, Integer>> sortDescByIntegerValue(Map<String,Integer> map) {
- List<Map.Entry<String, Integer>> sorted = new ArrayList<Map.Entry<String, Integer>>(map.entrySet());
- Collections.sort(sorted, new Comparator() {
+ public static List intValuedMapToSortedList(Map map) {// TODO should be Map<?, Integer> and List<Map.Entry<?, Integer>>
+ List<Map.Entry> sorted = new ArrayList<Map.Entry>(map.entrySet());
+ Collections.sort(sorted, new Comparator() {// TODO should be Comparator<Map.Entry<?, Integer>>
public int compare(Object o1, Object o2) {
Integer v1 = (Integer)((Map.Entry)o1).getValue();
Integer v2 = (Integer)((Map.Entry)o2).getValue();
|