Skip to content

Commit

Permalink
Added a new field to the DependencyItem: Comment. On the TFSService, …
Browse files Browse the repository at this point in the history
…this will be (as for now) the Sprint/Iteration
  • Loading branch information
Roberto committed Aug 27, 2018
1 parent 874a159 commit ab7cd8a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 15 deletions.
1 change: 1 addition & 0 deletions DependenciesVisualizer/Connectors/Models/CsvDependency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class CsvDependency
{
public string Title;
public int Id;
public string Comment;

[FieldConverter(typeof(CommaSeparatedtoIntListConverter))]
public List<int> SuccessorIds;
Expand Down
1 change: 1 addition & 0 deletions DependenciesVisualizer/Connectors/Services/CsvService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void ImportDependenciesFromCsvFile(string csvFile)
tempItem = new DependencyItem(
csvDependency.Id,
csvDependency.Title,
csvDependency.Comment,
csvDependency.SuccessorIds ?? new List<int>(),
csvDependency.Tags ?? new List<string>());

Expand Down
12 changes: 7 additions & 5 deletions DependenciesVisualizer/Connectors/Services/TfsService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using DependenciesVisualizer.Contracts;
using DependenciesVisualizer.Helpers;
using DependenciesVisualizer.Model;
Expand Down Expand Up @@ -60,7 +61,7 @@ public void ImportDependenciesFromTfs(int pbiId)

var theModel = new Dictionary<int, DependencyItem>();

DependencyItem mainDependencyItem = new DependencyItem(pbiId) { Title = workItem.Title, State = workItem.State };
DependencyItem mainDependencyItem = new DependencyItem(pbiId) { Title = workItem.Title, State = workItem.State, Comment = Path.GetFileName(workItem.IterationPath) };
mainDependencyItem.Tags.AddRange(TfsHelper.GetTags(workItem));
theModel.Add(pbiId, mainDependencyItem);

Expand Down Expand Up @@ -179,6 +180,7 @@ private void PopulateDependenciesWithLinkQuery(Dictionary<int, DependencyItem> d
var workItem = this.WorkItemStore.GetWorkItem(entry.Key);
entry.Value.Title = workItem.Title;
entry.Value.State = workItem.State;
entry.Value.Comment = Path.GetFileName(workItem.IterationPath);

entry.Value.Tags.AddRange(TfsHelper.GetTags(workItem));
}
Expand All @@ -189,7 +191,7 @@ private void PopulateDependenciesWithLinkQuery(Dictionary<int, DependencyItem> d
if (!dependenciesModel.ContainsKey(successor))
{
var workItem = this.WorkItemStore.GetWorkItem(successor);
var dependencyItem = new DependencyItem(successor) { Title = workItem.Title, State = workItem.State };
var dependencyItem = new DependencyItem(successor) { Title = workItem.Title, State = workItem.State, Comment = Path.GetFileName(workItem.IterationPath) };
dependencyItem.Tags.AddRange(TfsHelper.GetTags(workItem));

successorsThatAreNotParents.Add(dependencyItem);
Expand Down Expand Up @@ -227,7 +229,7 @@ private void PopulateDependenciesWithFlatQuery(Dictionary<int, DependencyItem> d

if (!dependenciesModel.ContainsKey(workItem.Id))
{
DependencyItem mainDependencyItem = new DependencyItem(workItem.Id) { Title = workItem.Title, State = workItem.State };
DependencyItem mainDependencyItem = new DependencyItem(workItem.Id) { Title = workItem.Title, State = workItem.State, Comment = Path.GetFileName(workItem.IterationPath) };
mainDependencyItem.Tags.AddRange(TfsHelper.GetTags(workItem));
dependenciesModel.Add(workItem.Id, mainDependencyItem);

Expand Down Expand Up @@ -256,7 +258,7 @@ private void GetPredecessorsRec(Dictionary<int, DependencyItem> model, WorkItem

foreach (var predecessor in predecessors)
{
innerDependencyItem = new DependencyItem(predecessor.Id) { Title = predecessor.Title, State = predecessor.State };
innerDependencyItem = new DependencyItem(predecessor.Id) { Title = predecessor.Title, State = predecessor.State, Comment = Path.GetFileName(predecessor.IterationPath) };
innerDependencyItem.Tags.AddRange(TfsHelper.GetTags(predecessor));


Expand Down Expand Up @@ -295,7 +297,7 @@ private void GetSuccessorsRec(Dictionary<int, DependencyItem> model, WorkItem pa
var successors = this.GetSuccessorsFromTfs(parent);
foreach (var successor in successors)
{
innerDependencyItem = new DependencyItem(successor.Id) { Title = successor.Title, State = successor.State };
innerDependencyItem = new DependencyItem(successor.Id) { Title = successor.Title, State = successor.State, Comment = Path.GetFileName(successor.IterationPath) };
innerDependencyItem.Tags.AddRange(TfsHelper.GetTags(successor));

try
Expand Down
28 changes: 21 additions & 7 deletions DependenciesVisualizer/Helpers/GraphVizHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static class GraphVizHelper

private static ImmutableDictionary<Id, Id> emptyDictionary = new Dictionary<Id, Id>().ToImmutableDictionary();

public static void AddGeneralStatements(ref List<Statement> statements)
private static void AddGeneralStatements(ref List<Statement> statements)
{
// Graph orientation: left to right
var generalStyleSettings = new Dictionary<Id, Id>();
Expand All @@ -56,7 +56,7 @@ public static void AddGeneralStatements(ref List<Statement> statements)
statements.Add(generalNodeStyleAttributes);
}

public static void AddEdgeStatement(ref List<Statement> statements, int origin, int destination)
private static void AddEdgeStatement(ref List<Statement> statements, int origin, int destination)
{
var edge = new EdgeStatement(new NodeId(Convert.ToString(origin)),
new NodeId(Convert.ToString(destination)),
Expand All @@ -66,7 +66,7 @@ public static void AddEdgeStatement(ref List<Statement> statements, int origin,
}

/*
digraph finite_state_machine {
digraph finite_state_machine {
node [shape=Mrecord, style=filled, fontsize = 11];
struct1 [label="<f0> left|<f1> mid&#92; dle|<f2> right"];
struct2 [label="<f0> one|<f1> two"];
Expand All @@ -81,6 +81,11 @@ digraph finite_state_machine {
struct11 [color="black", fillcolor="papayawhip" label="{Cinco|Seis Siete|Ocho}"];
struct1:f1 -> struct2:f0;
struct1:f2 -> struct3:here;
struct12 [label="struct12 |{ [CheckPoint] OSAL 2 - Date/Time and Reboot/Shutdown and USB\n management And Network management | Sprint 89 }"];
struct13 [label="{struct13 |[CheckPoint] OSAL 2 - Date/Time and Reboot/Shutdown and USB\n management And Network management } |Sprint 89"];
struct14 [label="{struct14 |{[CheckPoint] OSAL 2 - Date/Time and Reboot/Shutdown and USB\n management And Network management| Sprint 89 } }"];
struct12 -> struct13;
struct12 -> struct14;
}
https://graphviz.gitlab.io/_pages/doc/info/colors.html
Expand Down Expand Up @@ -115,7 +120,7 @@ private static string SplitInLines(string title, ushort maxLineLength)
return null;
}

private static void DefineNode(ref List<Statement> statements, int nodeId, string title, Color nodeColor, Color textColor, bool outerBold, ushort maxLineLength)
private static void DefineNode(ref List<Statement> statements, int nodeId, string title, string comment, Color nodeColor, Color textColor, bool outerBold, ushort maxLineLength)
{
Dictionary<Id, Id> nodeStyleSettings = null;
Dictionary<Id, Id> nodeLabelSettings = null;
Expand All @@ -137,7 +142,16 @@ private static void DefineNode(ref List<Statement> statements, int nodeId, strin


title = string.Concat(title.Split(badChars, StringSplitOptions.RemoveEmptyEntries));
nodeStyleSettings.Add(new Id("label"), new Id("{ " + Convert.ToString(nodeId) + " | " + GraphVizHelper.SplitInLines(title, maxLineLength) + "}"));
if (string.IsNullOrWhiteSpace(comment)) {
nodeStyleSettings.Add(new Id("label"), new Id("{ " + Convert.ToString(nodeId) + " | " + GraphVizHelper.SplitInLines(title, maxLineLength) + "}"));
} else
{
//nodeStyleSettings.Add(new Id("label"), new Id(Convert.ToString(nodeId) + " | { " + GraphVizHelper.SplitInLines(title, maxLineLength) + " | " + comment + " } "));
nodeStyleSettings.Add(new Id("label"), new Id("{" + Convert.ToString(nodeId) + "| { " + GraphVizHelper.SplitInLines(title, maxLineLength) + " | " + comment + " } }"));

//{ struct14 |{[CheckPoint] OSAL 2 - Date/Time and Reboot/Shutdown and USB\n management And Network management| Sprint 89 }}
//struct12 |{ [CheckPoint] OSAL 2 - Date/Time and Reboot/Shutdown and USB\n management And Network management | Sprint 89 }
}
// nodeStyleSettings.Add(new Id("label"), new Id(@"two\nlines\nMore long lines\ncheck how this looks like")); FUNCIONA...
//nodeStyleSettings.Add(new Id("label"), new Id("{<<TABLE>< TR >< TD > AAAA </ TD ></ TR >< TR >< TD > caption </ TD ></ TR ></ TABLE >>}")); NO FUNCIONA

Expand All @@ -152,7 +166,7 @@ private static void DefineNode(ref List<Statement> statements, int nodeId, strin
statements.Add(node);
}

public static void SetNodeAndTextColors(string state, out Color nodeColor, out Color textColor)
private static void SetNodeAndTextColors(string state, out Color nodeColor, out Color textColor)
{
nodeColor = Color.Lightgray;
textColor = Color.Black;
Expand Down Expand Up @@ -216,7 +230,7 @@ public static Graph CreateDependencyGraph(Dictionary<int, DependencyItem> model,
}
}

DefineNode(ref statements, entry.Value.Id, entry.Value.Title, nodeColor, textColor, outerBold, maxLineLength);
DefineNode(ref statements, entry.Value.Id, entry.Value.Title, entry.Value.Comment, nodeColor, textColor, outerBold, maxLineLength);

//else
//{
Expand Down
8 changes: 5 additions & 3 deletions DependenciesVisualizer/Model/DependencyItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ public DependencyItem(int id)
this.Id = id;
this.Successors = new List<int>();
this.Tags = new List<string>();
this.Comment = string.Empty;
}

public DependencyItem(int id, string title, List<int> successors, List<string> tags)
public DependencyItem(int id, string title, string comment, List<int> successors, List<string> tags)
{
this.Id = id;
this.Title = title;
this.Comment = comment;
this.Successors = successors;
this.Tags = tags;
}

public int Id { get; }
public string Title { get; set; }

public string State { get; set; }
public string Comment { get; set; }

//public string ReducedTitle {
// get
Expand All @@ -48,7 +50,7 @@ public DependencyItem(int id, string title, List<int> successors, List<string> t

public override string ToString()
{
return string.Format(@"<{0}> State: {1} | Title: {2}", this.Id, this.State, this.Title);
return string.Format(@"<{0}> State: {1} | Title: {2} | Comment: {3}", this.Id, this.State, this.Title, this.Comment);
//var longTitle = this.Title;
//try
//{
Expand Down

0 comments on commit ab7cd8a

Please sign in to comment.