Skip to content

Commit

Permalink
Updated add node function. Now using the AddComponentFromDefinition f…
Browse files Browse the repository at this point in the history
…unction to add nodes. Added a function to get MetadataDefinition GetComponentByID(string ID) in ComponentLibraryViewModel.cs.
  • Loading branch information
andsprague1 committed Mar 31, 2018
1 parent 474c5c4 commit 90c79da
Show file tree
Hide file tree
Showing 58 changed files with 181 additions and 134 deletions.
Binary file modified Main/Types/TraceLabSDK.Types.dll
Binary file not shown.
Binary file modified Main/Types/TraceLabSDK.Types.jar
Binary file not shown.
Binary file modified Main/Types/TraceLabSDK.Types.pdb
Binary file not shown.
Binary file modified Main/WebService/Bin/TraceLab.Core.dll
Binary file not shown.
Binary file modified Main/WebService/Bin/TraceLab.Core.pdb
Binary file not shown.
Binary file modified Main/WebService/Bin/TraceLab.dll
Binary file not shown.
Binary file modified Main/WebService/Bin/TraceLab.pdb
Binary file not shown.
Binary file modified Main/WebService/Bin/TraceLabSDK.Types.dll
Binary file not shown.
Binary file modified Main/WebService/Bin/TraceLabSDK.Types.pdb
Binary file not shown.
Binary file modified Main/WebService/Bin/TraceLabSDK.dll
Binary file not shown.
Binary file modified Main/WebService/Bin/TraceLabSDK.pdb
Binary file not shown.
Binary file modified Main/WebService/Bin/TraceLabWeb.dll
Binary file not shown.
Binary file modified Main/WebService/Bin/TraceLabWeb.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected ChallengeMetadata()
/// <param name="compositeComponentGraph">The composite component graph.</param>
/// <param name="label">The label.</param>
/// <param name="experimentLocationRoot">The experiment location root.</param>
internal ChallengeMetadata(CompositeComponentEditableGraph compositeComponentGraph, string label, string experimentLocationRoot)
public ChallengeMetadata(CompositeComponentEditableGraph compositeComponentGraph, string label, string experimentLocationRoot)
: base(compositeComponentGraph, label, experimentLocationRoot)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected ComponentMetadata()
/// Initializes a new s_instance of the <see cref="ComponentMetadata"/> class.
/// </summary>
/// <param name="componentMetadataDefinition">The component metadata definition.</param>
internal ComponentMetadata(ComponentMetadataDefinition componentMetadataDefinition, string experimentLocationRoot)
public ComponentMetadata(ComponentMetadataDefinition componentMetadataDefinition, string experimentLocationRoot)
{
m_experimentLocationRoot = experimentLocationRoot;
ComponentMetadataDefinition = componentMetadataDefinition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected LoopScopeMetadata()
/// <param name="compositeComponentGraph">The composite component graph.</param>
/// <param name="label">The label.</param>
/// <param name="experimentLocationRoot">The experiment location root.</param>
internal LoopScopeMetadata(CompositeComponentEditableGraph compositeComponentGraph, string label, string experimentLocationRoot)
public LoopScopeMetadata(CompositeComponentEditableGraph compositeComponentGraph, string label, string experimentLocationRoot)
: base(compositeComponentGraph, label, experimentLocationRoot)
{
UniqueDecisionID = Guid.NewGuid().ToString();
Expand Down
2 changes: 1 addition & 1 deletion Main/WebService/TraceLab.Core/Components/ScopeMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected ScopeMetadata()
/// <param name="compositeComponentGraph">The composite component graph.</param>
/// <param name="label">The label.</param>
/// <param name="experimentLocationRoot">The experiment location root.</param>
internal ScopeMetadata(CompositeComponentEditableGraph compositeComponentGraph, string label, string experimentLocationRoot)
public ScopeMetadata(CompositeComponentEditableGraph compositeComponentGraph, string label, string experimentLocationRoot)
: base(compositeComponentGraph, label, experimentLocationRoot)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ public IEnumerable<MetadataDefinition> ComponentsCollection
}
}

public MetadataDefinition GetComponentByID(string ID)
{
foreach(MetadataDefinition definition in m_packageAwareComponentLibrary.Components )
{
if (definition.ID.Equals(ID))
{
return definition;
}
}
return null;
}

public IEnumerable<string> PackageTypeDirectories
{
get { return this.m_componentsLibraryInstance.PackageTypeDirectories; }
Expand Down
Binary file not shown.
Binary file modified Main/WebService/TraceLab.Core/obj/Debug/TraceLab.Core.dll
Binary file not shown.
Binary file modified Main/WebService/TraceLab.Core/obj/Debug/TraceLab.Core.pdb
Binary file not shown.
Binary file modified Main/WebService/TraceLab/bin/Debug/TraceLab.Core.dll
Binary file not shown.

Large diffs are not rendered by default.

Binary file modified Main/WebService/TraceLab/bin/Debug/TraceLab.Core.pdb
Binary file not shown.
Binary file modified Main/WebService/TraceLab/bin/Debug/TraceLab.dll
Binary file not shown.
Binary file modified Main/WebService/TraceLab/bin/Debug/TraceLab.pdb
Binary file not shown.
Binary file modified Main/WebService/TraceLab/bin/Debug/TraceLabSDK.Types.dll
Binary file not shown.
Binary file modified Main/WebService/TraceLab/bin/Debug/TraceLabSDK.Types.pdb
Binary file not shown.
Binary file modified Main/WebService/TraceLab/bin/Debug/TraceLabSDK.dll
Binary file not shown.
Binary file modified Main/WebService/TraceLab/bin/Debug/TraceLabSDK.pdb
Binary file not shown.
Binary file modified Main/WebService/TraceLab/lib/TraceLabSDK.dll
Binary file not shown.
Binary file modified Main/WebService/TraceLab/lib/TraceLabSDK.pdb
Binary file not shown.
Binary file not shown.
Binary file modified Main/WebService/TraceLab/obj/Debug/TraceLab.dll
Binary file not shown.
Binary file modified Main/WebService/TraceLab/obj/Debug/TraceLab.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ C:\Users\Owner\Documents\W&M\cs635\TraceLab\Main\WebService\TraceLabSDK\obj\Debu
C:\Users\Owner\Documents\W&M\cs635\TraceLab\Main\WebService\TraceLabSDK\obj\Debug\TraceLabSDK.csproj.CoreCompileInputs.cache
C:\Users\Owner\Documents\W&M\cs635\TraceLab\Main\WebService\TraceLabSDK\obj\Debug\TraceLabSDK.dll
C:\Users\Owner\Documents\W&M\cs635\TraceLab\Main\WebService\TraceLabSDK\obj\Debug\TraceLabSDK.pdb
C:\Users\Andrew\Documents\Git\TraceLab\Main\WebService\TraceLabSDK\obj\Debug\TraceLabSDK.csprojResolveAssemblyReference.cache
Binary file modified Main/WebService/TraceLabSDK/obj/Debug/TraceLabSDK.dll
Binary file not shown.
Binary file modified Main/WebService/TraceLabSDK/obj/Debug/TraceLabSDK.pdb
Binary file not shown.
49 changes: 11 additions & 38 deletions Main/WebService/TraceLabWeb/TraceLabApplicationWebConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using TraceLab;
using System.Diagnostics;
using System.Data;

namespace TraceLabWeb
{
Expand Down Expand Up @@ -40,6 +41,13 @@ public string GetComponents()
return WebConsoleUI.GetComponents();
}

public DataTable GetComponentListForDropDown()
{
return WebConsoleUI.GetComponentsForDropDown ();
}



public string GetNodes()
{
return WebConsoleUI.GetNodes (); // TODO WebConsoleUI.GetNodes
Expand All @@ -63,46 +71,11 @@ public void AddEdge(string edgeName,string sourceName,string targetName)
WebConsoleUI.AddEdge(edgeName,sourceName,targetName );
}

public void AddNode(string nodeName, string nodeType)
public void AddNode(string componentType,int xloc,int yloc)
{

switch(nodeType )
{
case ("ExperimentStartNode"):
WebConsoleUI.AddStartNode (nodeName);
break;
case ("ExperimentEndNode"):
WebConsoleUI.AddEndNode(nodeName);
break;
case ("ComponentNode"):
WebConsoleUI.AddComponenetNode (nodeName);
break;
case ("CompositeComponentNode"):
WebConsoleUI.AddCompositeComponenetNode (nodeName);
break;
case ("DecisionNode"):
WebConsoleUI.AddDecisionNode (nodeName);
break;
case ("ExitDecisionNode"):
WebConsoleUI.AddExitDecisionNode (nodeName);
break;
case ("ScopeNode"):
WebConsoleUI.AddScopeNode (nodeName);
break;
case ("LoopScopeNode"):
WebConsoleUI.AddLoopScopeNode (nodeName);
break;
case ("ChallengeNode"):
WebConsoleUI.AddChallengeNode (nodeName);
break;
case ("CommentNode"):
WebConsoleUI.AddCommentNode (nodeName);
break;
default:
break;


}
WebConsoleUI.AddComponenetNode (componentType ,xloc,yloc);

}

public void RunExperiment()
Expand Down
86 changes: 66 additions & 20 deletions Main/WebService/TraceLabWeb/WebConsoleUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using TraceLab.Core.Components;
using TraceLab.Core.Workspaces;
using TraceLab.Core.Experiments;
using TraceLab.Core.Utilities;
using System.Data;

namespace TraceLabWeb
{
Expand Down Expand Up @@ -65,6 +67,23 @@ internal static string GetComponents()
components += "</ul>";
return components;
}

internal static DataTable GetComponentsForDropDown()
{
DataTable dt = new DataTable ();
dt.Columns.Add("Label");
dt.Columns.Add("ID");
foreach (MetadataDefinition definition in ConsoleInstance.Application.ComponentLibraryViewModel.ComponentsCollection)
{
DataRow dr = dt.NewRow();
dr["Label"] = definition.Label;
dr["ID"] = definition.ID;
dt.Rows.Add(dr);
}

return dt;
}

public static string GetNodes()
{
string components = "<ul><li>Nodes:</li>";
Expand Down Expand Up @@ -252,18 +271,17 @@ public static void AddEdge(string value, string sourceName,string targetName)
}


public static void AddComponenetNode(string value) //TODO Implement for Node Type
public static void AddComponenetNode(string value, int xloc,int yloc) //TODO Implement for Node Type
{
try
{
var experiment = ConsoleInstance.Application.Experiment;

SerializedVertexData svd = new SerializedVertexData();
svd.Metadata = new DecisionMetadata(value);
ExperimentDecisionNode nodeToAdd = new ExperimentDecisionNode(Guid.NewGuid().ToString(), svd);
MetadataDefinition metadataDefinition =ConsoleInstance.Application.ComponentLibraryViewModel.GetComponentByID (value) ;

ExperimentNode nodeToAdd = experiment.AddComponentFromDefinition(metadataDefinition, xloc,yloc);


nodeToAdd.Data.Metadata.Label = value;
experiment.AddVertex(nodeToAdd);
}

catch
Expand Down Expand Up @@ -294,6 +312,10 @@ public static void AddEdge(string value, string sourceName,string targetName)

}

/// <summary>
/// Add Decision Node to Experiment
/// </summary>
/// <param name="value">Label of Decision Node</param>
public static void AddDecisionNode(string value)
{
try
Expand Down Expand Up @@ -337,15 +359,24 @@ public static void AddDecisionNode(string value)

}

public static void AddScopeNode(string value) //TODO Implement for Node Type
/// <summary>
/// Add a scopeNode to the Experiment
/// </summary>
/// <param name="value">Name of the scope node</param>
public static void AddScopeNode(string value)
{
try
{
var experiment = ConsoleInstance.Application.Experiment;
var componentGraph = new CompositeComponentEditableGraph(true);

SerializedVertexData svd = new SerializedVertexData();
svd.Metadata = new DecisionMetadata(value);
ExperimentDecisionNode nodeToAdd = new ExperimentDecisionNode(Guid.NewGuid().ToString(), svd);
if (componentGraph.References != null)
{
componentGraph.References = experiment.References.CopyCollection();
}
SerializedVertexDataWithSize svd = new SerializedVertexDataWithSize();
svd.Metadata = new ScopeMetadata (componentGraph,value, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));
ScopeNode nodeToAdd = new ScopeNode(Guid.NewGuid().ToString(),svd);

nodeToAdd.Data.Metadata.Label = value;
experiment.AddVertex(nodeToAdd);
Expand All @@ -358,15 +389,25 @@ public static void AddDecisionNode(string value)

}

public static void AddLoopScopeNode(string value) //TODO Implement for Node Type
/// <summary>
/// Add a Loop Scope Node to the Experiment
/// </summary>
/// <param name="value">The name of the node</param>
public static void AddLoopScopeNode(string value)
{
try
{
var experiment = ConsoleInstance.Application.Experiment;
var componentGraph = new CompositeComponentEditableGraph(true);

SerializedVertexData svd = new SerializedVertexData();
svd.Metadata = new DecisionMetadata(value);
ExperimentDecisionNode nodeToAdd = new ExperimentDecisionNode(Guid.NewGuid().ToString(), svd);
if (componentGraph.References != null)
{
componentGraph.References = experiment.References.CopyCollection();
}

SerializedVertexDataWithSize svd = new SerializedVertexDataWithSize();
svd.Metadata = new LoopScopeMetadata ( componentGraph, value, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));
LoopScopeNode nodeToAdd = new LoopScopeNode(Guid.NewGuid().ToString(), svd);

nodeToAdd.Data.Metadata.Label = value;
experiment.AddVertex(nodeToAdd);
Expand All @@ -379,18 +420,23 @@ public static void AddDecisionNode(string value)

}


public static void AddChallengeNode(string value) //TODO Implement for Node Type
/// <summary>
/// Add a challenge node to the Experiment
/// </summary>
/// <param name="value">the name of the challenge</param>
public static void AddChallengeNode(string value)
{
try
{
var experiment = ConsoleInstance.Application.Experiment;

SerializedVertexData svd = new SerializedVertexData();
svd.Metadata = new DecisionMetadata(value);
ExperimentDecisionNode nodeToAdd = new ExperimentDecisionNode(Guid.NewGuid().ToString(), svd);
SerializedVertexDataWithSize svd = new SerializedVertexDataWithSize();
CompositeComponentEditableGraph compositeComponentGraph = new CompositeComponentEditableGraph (true);

nodeToAdd.Data.Metadata.Label = value;
svd.Metadata = new ChallengeMetadata (compositeComponentGraph ,value, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));
ChallengeNode nodeToAdd = new ChallengeNode(Guid.NewGuid().ToString(), svd);

nodeToAdd.Data.Metadata.Label = value;
experiment.AddVertex(nodeToAdd);
}

Expand Down
Binary file modified Main/WebService/TraceLabWeb/bin/Debug/TraceLab.Core.dll
Binary file not shown.
Binary file modified Main/WebService/TraceLabWeb/bin/Debug/TraceLab.Core.pdb
Binary file not shown.
Binary file modified Main/WebService/TraceLabWeb/bin/Debug/TraceLab.dll
Binary file not shown.
Binary file modified Main/WebService/TraceLabWeb/bin/Debug/TraceLab.pdb
Binary file not shown.
Binary file modified Main/WebService/TraceLabWeb/bin/Debug/TraceLabSDK.Types.dll
Binary file not shown.
Binary file modified Main/WebService/TraceLabWeb/bin/Debug/TraceLabSDK.Types.pdb
Binary file not shown.
Binary file modified Main/WebService/TraceLabWeb/bin/Debug/TraceLabSDK.dll
Binary file not shown.
Binary file modified Main/WebService/TraceLabWeb/bin/Debug/TraceLabSDK.pdb
Binary file not shown.
Binary file modified Main/WebService/TraceLabWeb/bin/Debug/TraceLabWeb.dll
Binary file not shown.
Binary file modified Main/WebService/TraceLabWeb/bin/Debug/TraceLabWeb.pdb
Binary file not shown.
Binary file not shown.
Binary file modified Main/WebService/TraceLabWeb/obj/Debug/TraceLabWeb.dll
Binary file not shown.
Binary file modified Main/WebService/TraceLabWeb/obj/Debug/TraceLabWeb.pdb
Binary file not shown.
19 changes: 5 additions & 14 deletions Main/WebService/TraceLab_UI.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,11 @@
<br />
<asp:LinkButton ID="NodeButton" CssClass="btn btn-primary btn-lg" runat="server" OnClick="AddNode"><span class="glyphicon glyphicon-ok""></span></asp:LinkButton>
<asp:TextBox ID="NodeText" runat="server" Width="599px" Text =""></asp:TextBox>
<asp:TextBox ID="txt_nodeX" runat="server" Width="50px" Text =""></asp:TextBox>
<asp:TextBox ID="txt_nodeY" runat="server" Width="50px" Text =""></asp:TextBox>
<asp:DropDownList ID="NodeType" runat="server" Width ="200px">
<asp:ListItem Text ="Start Node" Value ="ExperimentStartNode"/>
<asp:ListItem Text ="End Node" Value ="ExperimentEndNode"/>
<asp:ListItem Text ="Component Node" Value ="ComponentNode"/>
<asp:ListItem Text ="Composite Component Node" Value ="CompositeComponentNode"/>
<asp:ListItem Text ="Decision Node" Value ="DecisionNode"/>
<asp:ListItem Text ="Exit Decision Node" Value ="ExitDecisionNode"/>
<asp:ListItem Text ="Scope Node" Value ="ScopeNode"/>
<asp:ListItem Text ="Loop Scope Node" Value ="LoopScopeNode"/>
<asp:ListItem Text ="Challenge Node" Value ="ChallengeNode"/>
<asp:ListItem Text ="Comment Node" Value ="CommentNode"/>
X: <asp:TextBox ID="txt_nodeX" runat="server" Width="50px" Text =""></asp:TextBox>
Y:<asp:TextBox ID="txt_nodeY" runat="server" Width="50px" Text =""></asp:TextBox>

ComponentType:<asp:DropDownList ID="ComponentDropDown" runat="server" Width ="400px">

</asp:DropDownList>
<br />
</div>
Expand Down
28 changes: 26 additions & 2 deletions Main/WebService/TraceLab_UI.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ protected void Page_Load(object sender, EventArgs e)
{
var app = TraceLabApplicationWebConsole.Instance;
Components.Text = app.GetComponents();
ComponentDropDown.DataSource = app.GetComponentListForDropDown();
ComponentDropDown.DataTextField = "Label";
ComponentDropDown.DataValueField = "ID";
ComponentDropDown.DataBind();
Workspace.Text = app.GetWorkspace();
}

Expand All @@ -23,6 +27,10 @@ protected void OpenButton_Click(object sender, EventArgs e)

Console.Text += app.GetLog();
Components.Text = app.GetComponents();
ComponentDropDown.DataSource = app.GetComponentListForDropDown();
ComponentDropDown.DataTextField = "Label";
ComponentDropDown.DataValueField = "ID";
ComponentDropDown.DataBind();
Workspace.Text = app.GetWorkspace();
}

Expand All @@ -32,6 +40,10 @@ protected void Save_Click(object sender, EventArgs e)
app.SaveExperiment (SaveText.Text);
Console.Text = app.GetLog();
Components.Text = app.GetComponents();
ComponentDropDown.DataSource = app.GetComponentListForDropDown();
ComponentDropDown.DataTextField = "Label";
ComponentDropDown.DataValueField = "ID";
ComponentDropDown.DataBind();
Workspace.Text = app.GetWorkspace();
}

Expand All @@ -42,6 +54,10 @@ protected void Log_Click(object sender, EventArgs e)
Components.Text = app.GetComponents();
Workspace.Text = app.GetWorkspace();
ComponentList.Text = app.GetNodes();
ComponentDropDown.DataSource = app.GetComponentListForDropDown();
ComponentDropDown.DataTextField = "Label";
ComponentDropDown.DataValueField = "ID";
ComponentDropDown.DataBind();
}

protected void Run_Click(object sender, EventArgs e)
Expand All @@ -51,6 +67,10 @@ protected void Run_Click(object sender, EventArgs e)
Console.Text = app.GetLog();
Components.Text = app.GetComponents();
Workspace.Text = app.GetWorkspace();
ComponentDropDown.DataSource = app.GetComponentListForDropDown();
ComponentDropDown.DataTextField = "Label";
ComponentDropDown.DataValueField = "ID";
ComponentDropDown.DataBind();
}

protected void EdgeCommand(object sender, EventArgs e)
Expand All @@ -62,7 +82,11 @@ protected void EdgeCommand(object sender, EventArgs e)
protected void AddNode(object sender, EventArgs e)
{
var app = TraceLabApplicationWebConsole.Instance;
app.AddNode(NodeText.Text,NodeType.SelectedValue );

int x = 0;
int y = 0;
Int32.TryParse(txt_nodeX.Text,out x);
Int32.TryParse(txt_nodeY.Text, out y);
app.AddNode(ComponentDropDown.SelectedValue , x, y);

}
}

0 comments on commit 90c79da

Please sign in to comment.