Changeset 957
- Timestamp:
- 12/10/08 17:33:27 (16 years ago)
- Location:
- branches/CEDMA-Refactoring-Ticket419
- Files:
-
- 1 added
- 10 deleted
- 6 edited
- 8 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Console.cs
r560 r957 33 33 namespace HeuristicLab.CEDMA.Core { 34 34 public class Console : ItemBase, IEditable { 35 private AgentList agentList; 36 private ResultList resultsList; 37 private DatabaseOperatorLibrary operatorLibary; 38 private ChannelFactory<IDatabase> factory; 39 private IDatabase database; 35 private DataSetList dataSetList; 36 private ChannelFactory<IStore> factory; 37 private IStore store; 40 38 private string serverUri; 41 39 public string ServerUri { … … 43 41 } 44 42 45 public IAgentList AgentList { 46 get { return agentList; } 47 } 48 49 public ResultList ResultsList { 50 get { return resultsList; } 51 } 52 53 public IOperatorLibrary OperatorLibrary { 54 get { return operatorLibary; } 43 public DataSetList DataSetList { 44 get { return dataSetList; } 55 45 } 56 46 57 47 public Console() 58 48 : base() { 59 agentList = new AgentList(); 60 resultsList = new ResultList(); 61 operatorLibary = new DatabaseOperatorLibrary(); 49 dataSetList = new DataSetList(); 62 50 } 63 51 … … 92 80 binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements; 93 81 binding.Security.Mode = SecurityMode.None; 94 factory = new ChannelFactory<IDatabase>(binding); 95 database = factory.CreateChannel(new EndpointAddress(serverUri)); 96 agentList.Database = database; 97 operatorLibary.Database = database; 98 99 ChannelFactory<IStore> storeFactory = new ChannelFactory<IStore>(binding); 100 IStore store = storeFactory.CreateChannel(new EndpointAddress(serverUri + "/RdfStore")); 101 resultsList.Store = store; 82 factory = new ChannelFactory<IStore>(binding); 83 store = factory.CreateChannel(new EndpointAddress(serverUri)); 84 dataSetList.Store = store; 102 85 } 103 86 #endregion -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ConsoleEditor.cs
r561 r957 49 49 } 50 50 51 #region autogenerated code 51 52 private void InitializeComponent() { 52 53 this.uriTextBox = new System.Windows.Forms.TextBox(); … … 96 97 this.openOpLibButton.Text = "&Open"; 97 98 this.openOpLibButton.UseVisualStyleBackColor = true; 98 this.openOpLibButton.Click += new System.EventHandler(this.opLibButton_Click);99 99 // 100 100 // label1 … … 125 125 this.openResultsButton.Text = "&Open"; 126 126 this.openResultsButton.UseVisualStyleBackColor = true; 127 this.openResultsButton.Click += new System.EventHandler(this.openChartButton_Click);128 127 // 129 128 // openAgentsButton … … 136 135 this.openAgentsButton.Text = "&Open"; 137 136 this.openAgentsButton.UseVisualStyleBackColor = true; 138 this.openAgentsButton.Click += new System.EventHandler(this.openAgentsButton_Click);139 137 // 140 138 // agentsLabel … … 166 164 } 167 165 166 #endregion 167 168 168 private void connectButton_Click(object sender, EventArgs e) { 169 169 try { … … 177 177 } 178 178 } 179 180 private void opLibButton_Click(object sender, EventArgs e) {181 IOperatorLibrary opLib = console.OperatorLibrary;182 if(opLib != null) {183 IView view = opLib.CreateView();184 if(view != null)185 PluginManager.ControlManager.ShowControl(view);186 }187 }188 189 private void openChartButton_Click(object sender, EventArgs e) {190 PluginManager.ControlManager.ShowControl(console.ResultsList.CreateView());191 }192 193 private void openAgentsButton_Click(object sender, EventArgs e) {194 PluginManager.ControlManager.ShowControl(console.AgentList.CreateView());195 }196 179 } 197 180 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSet.cs
r928 r957 30 30 31 31 namespace HeuristicLab.CEDMA.Core { 32 public class Agent : IAgent {33 public I Database Database { get; set; }32 public class DataSet { 33 public IStore Store { get; set; } 34 34 public long Id { get; set; } 35 35 public string Name { get; set; } 36 public ProcessStatus Status { get; set; } 37 public bool Terminated { get; set; } 38 private OperatorGraph operatorGraph; 36 private Problem problem; 39 37 40 public IOperatorGraph OperatorGraph{41 get { return operatorGraph; }38 public Problem Problem { 39 get { return problem; } 42 40 } 43 41 44 public Agent()42 public DataSet() 45 43 : base() { 46 operatorGraph = new OperatorGraph();44 problem = new Problem(); 47 45 } 48 46 49 public Agent(IDatabase database, long id)47 public DataSet(IStore store, long id) 50 48 : this() { 51 Database = database;49 Store = store; 52 50 Id = id; 53 51 } 54 52 55 53 public void Save() { 56 Database.UpdateAgent(Id, Name); 57 Database.UpdateAgent(Id, Status); 58 Database.UpdateAgent(Id, PersistenceManager.SaveToGZip(OperatorGraph)); 54 throw new NotImplementedException(); 59 55 } 60 56 61 public void Start() { 62 Status = ProcessStatus.Waiting; 63 Save(); 57 public void Activate() { 58 throw new NotImplementedException(); 64 59 } 65 60 66 public ICollection<IAgent> SubAgents { 67 get { 68 List<IAgent> agents = new List<IAgent>(); 69 foreach(AgentEntry entry in Database.GetSubAgents(Id)) { 70 Agent newAgent = new Agent(Database, entry.Id); 71 newAgent.Name = entry.Name; 72 newAgent.Status = entry.Status; 73 agents.Add(newAgent); 74 } 75 return agents; 76 } 77 } 78 79 public ICollection<IResult> Results { 80 get { 81 List<IResult> results = new List<IResult>(); 82 foreach(ResultEntry entry in Database.GetResults(Id)) { 83 Result result = new Result(Database, entry.Id); 84 result.Summary = entry.Summary; 85 result.Description = entry.Description; 86 results.Add(result); 87 } 88 return results; 89 } 61 private void UpdateDataSet(long Id, byte[] p) { 62 throw new NotImplementedException(); 90 63 } 91 64 92 65 public IView CreateView() { 93 if(OperatorGraph.Operators.Count == 0) { 94 byte[] rawData = Database.GetAgentRawData(Id); 95 IOperatorGraph opGraph = (IOperatorGraph)PersistenceManager.RestoreFromGZip(rawData); 96 foreach(IOperator op in opGraph.Operators) OperatorGraph.AddOperator(op); 97 OperatorGraph.InitialOperator = opGraph.InitialOperator; 98 OperatorLinkPatcher.LinkDatabase(OperatorGraph, Database); 99 } 100 return new AgentView(this); 66 return new DataSetView(this); 101 67 } 102 68 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetList.cs
r928 r957 33 33 34 34 namespace HeuristicLab.CEDMA.Core { 35 public class AgentList : ItemBase, IAgentList{36 private List< IAgent> agentList;37 private I Database database;38 public I Database Database {39 get { return database; }35 public class DataSetList : ItemBase, IEnumerable<DataSet> { 36 private List<DataSet> dataSetList; 37 private IStore store; 38 public IStore Store { 39 get { return store; } 40 40 set { 41 database = value;41 store = value; 42 42 Action reload = ReloadList; 43 lock( agentList) {44 agentList.Clear();43 lock(dataSetList) { 44 dataSetList.Clear(); 45 45 } 46 46 reload.BeginInvoke(null, null); … … 48 48 } 49 49 50 private void ReloadList() { 51 foreach(AgentEntry a in database.GetAgents()) { 52 Agent newAgent = new Agent(Database, a.Id); 53 newAgent.Name = a.Name; 54 newAgent.Status = a.Status; 55 lock(agentList) { 56 agentList.Add(newAgent); 57 } 58 FireChanged(); 59 } 50 public DataSetList() 51 : base() { 52 dataSetList = new List<DataSet>(); 60 53 } 61 54 62 public AgentList() 63 : base() { 64 agentList = new List<IAgent>(); 55 public override IView CreateView() { 56 return new DataSetListView(this); 65 57 } 66 58 67 p ublic void CreateAgent() {68 Agent agent = new Agent();69 agent.Name = DateTime.Now.ToString();70 agent.Status = ProcessStatus.Unknown;71 agent.Database = database;72 long id = database.InsertAgent(null, agent.Name, PersistenceManager.SaveToGZip(agent.OperatorGraph));73 agent.Id = id;74 lock(agentList) {75 agentList.Add(agent);76 }77 FireChanged();59 private void ReloadList() { 60 throw new NotImplementedException(); 61 //foreach( a in database.GetAgents()) { 62 // Agent newAgent = new Agent(Database, a.Id); 63 // newAgent.Name = a.Name; 64 // newAgent.Status = a.Status; 65 // lock(agentList) { 66 // agentList.Add(newAgent); 67 // } 68 // FireChanged(); 69 //} 78 70 } 79 71 80 public IEnumerator<IAgent> GetEnumerator() { 81 List<IAgent> agents = new List<IAgent>(); 82 lock(agentList) { 83 agents.AddRange(agentList); 72 internal static void CreateDataSet() { 73 throw new NotImplementedException(); 74 } 75 76 public IEnumerator<DataSet> GetEnumerator() { 77 List<DataSet> dataSets = new List<DataSet>(); 78 lock(dataSets) { 79 dataSets.AddRange(dataSetList); 84 80 } 85 return agents.GetEnumerator();81 return dataSets.GetEnumerator(); 86 82 } 87 83 … … 89 85 return GetEnumerator(); 90 86 } 91 92 public override IView CreateView() {93 return new AgentListView(this);94 }95 87 } 96 88 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetListView.Designer.cs
r928 r957 24 24 25 25 namespace HeuristicLab.CEDMA.Core { 26 partial class AgentListView {26 partial class DataSetListView { 27 27 /// <summary> 28 28 /// Required designer variable. -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetListView.cs
r928 r957 30 30 31 31 namespace HeuristicLab.CEDMA.Core { 32 public partial class AgentListView : ViewBase {33 public IAgentList AgentList{34 get { return ( IAgentList)Item; }32 public partial class DataSetListView : ViewBase { 33 public DataSetList DataSetList{ 34 get { return (DataSetList)Item; } 35 35 set { base.Item = value; } 36 36 } 37 37 38 public AgentListView() {38 public DataSetListView() { 39 39 InitializeComponent(); 40 Caption = " Agent View";40 Caption = "DataSet View"; 41 41 } 42 public AgentListView(IAgentList agentList)42 public DataSetListView(DataSetList dataSetList) 43 43 : this() { 44 AgentList = agentList;45 agentList.Changed += new EventHandler(agentList_Changed);44 DataSetList = dataSetList; 45 dataSetList.Changed += new EventHandler(dataSetList_Changed); 46 46 } 47 47 48 void agentList_Changed(object sender, EventArgs e) {48 void dataSetList_Changed(object sender, EventArgs e) { 49 49 UpdateControls(); 50 50 } … … 54 54 detailsGroupBox.Controls.Clear(); 55 55 detailsGroupBox.Enabled = false; 56 if( AgentList == null) {57 Caption = " Agents View";56 if(DataSetList == null) { 57 Caption = "Data Sets View"; 58 58 agentTreeView.Enabled = false; 59 59 } else { 60 60 agentTreeView.Enabled = true; 61 61 agentTreeView.Nodes.Clear(); 62 foreach( IAgent agent in AgentList) {62 foreach(DataSet dataSet in DataSetList) { 63 63 TreeNode node = new TreeNode(); 64 node.Text = agent.Name;65 node.Tag = agent;64 node.Text = dataSet.Name; 65 node.Tag = dataSet; 66 66 node.Nodes.Add("dummy"); 67 67 node.ContextMenuStrip = entryContextMenuStrip; … … 73 73 #region Button Events 74 74 private void addButton_Click(object sender, EventArgs e) { 75 AgentList.CreateAgent();75 DataSetList.CreateDataSet(); 76 76 } 77 77 #endregion 78 79 private void agentTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e) {80 e.Node.Nodes.Clear();81 if(e.Node.Tag is IAgent) {82 IAgent agent = (IAgent)e.Node.Tag;83 foreach(IAgent subAgent in agent.SubAgents) {84 TreeNode node = new TreeNode();85 node.Text = subAgent.Name;86 node.Tag = subAgent;87 node.ContextMenuStrip = entryContextMenuStrip;88 node.Nodes.Add("dummy");89 e.Node.Nodes.Add(node);90 }91 foreach(IResult result in agent.Results) {92 TreeNode node = new TreeNode();93 node.Text = result.Summary;94 node.Tag = result;95 node.Nodes.Add("dummy");96 e.Node.Nodes.Add(node);97 }98 } else if(e.Node.Tag is IResult) {99 IResult result = (IResult)e.Node.Tag;100 foreach(IResult subResult in result.SubResults) {101 TreeNode node = new TreeNode();102 node.Text = subResult.Summary;103 node.Tag = subResult;104 node.Nodes.Add("dummy");105 e.Node.Nodes.Add(node);106 }107 }108 }109 78 110 79 private void agentTreeView_AfterSelect(object sender, TreeViewEventArgs e) { … … 125 94 UpdateControls(); 126 95 } 127 128 private void exportAllResultsToolStripMenuItem_Click(object sender, EventArgs e) {129 TreeNode node = agentTreeView.SelectedNode;130 Agent agent = (Agent)node.Tag;131 ResultExporter exporter = new ResultExporter();132 ResultTable table = new ResultTable();133 exporter.Export(agent, table);134 135 using(System.IO.FileStream s = new System.IO.FileStream("exported-results.txt", System.IO.FileMode.Create)) {136 table.Write(s);137 }138 }139 96 } 140 97 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetView.Designer.cs
r928 r957 21 21 22 22 namespace HeuristicLab.CEDMA.Core { 23 partial class AgentView {23 partial class DataSetView { 24 24 /// <summary> 25 25 /// Required designer variable. -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetView.cs
r928 r957 31 31 32 32 namespace HeuristicLab.CEDMA.Core { 33 public partial class AgentView : ViewBase {34 private Agent agent;35 public Agent Agent {36 get { return agent; }37 set { agent = value; }33 public partial class DataSetView : ViewBase { 34 private DataSet dataSet; 35 public DataSet DataSet { 36 get { return dataSet; } 37 set { dataSet = value; } 38 38 } 39 39 40 public AgentView() {40 public DataSetView() { 41 41 InitializeComponent(); 42 Caption = " Agent";42 Caption = "Data Set"; 43 43 } 44 public AgentView(Agent agent)44 public DataSetView(DataSet dataSet) 45 45 : this() { 46 Agent = agent;46 DataSet = dataSet; 47 47 UpdateControls(); 48 48 } … … 52 52 editorGroupBox.Controls.Clear(); 53 53 editorGroupBox.Enabled = false; 54 if(Agent != null && Agent.OperatorGraph != null) {55 Control editor = (Control)Agent.OperatorGraph.CreateView();56 if(editor != null) {57 editorGroupBox.Controls.Add(editor);58 editor.Dock = DockStyle.Fill;59 editorGroupBox.Enabled = true;60 }61 62 if(Agent.Status == ProcessStatus.Unknown) activateButton.Enabled = true;63 else activateButton.Enabled = false;64 }65 54 } 66 55 67 56 private void saveButton_Click(object sender, EventArgs e) { 68 Agent.Save();57 DataSet.Save(); 69 58 } 70 59 71 60 private void activateButton_Click(object sender, EventArgs e) { 72 Agent.Start();61 DataSet.Activate(); 73 62 activateButton.Enabled = false; 74 63 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/HeuristicLab.CEDMA.Core.csproj
r852 r957 72 72 </ItemGroup> 73 73 <ItemGroup> 74 <Compile Include="Agent.cs" />75 <Compile Include="AgentList.cs" />76 74 <Compile Include="Console.cs" /> 77 75 <Compile Include="ConsoleEditor.cs"> 78 76 <SubType>UserControl</SubType> 79 77 </Compile> 80 <Compile Include=" ResultTable.cs" />81 <Compile Include=" ResultExporter.cs" />82 <Compile Include="Data baseOperatorLibrary.cs" />83 <Compile Include="Data baseOperatorLibraryView.cs">78 <Compile Include="Problem.cs" /> 79 <Compile Include="DataSet.cs" /> 80 <Compile Include="DataSetList.cs" /> 81 <Compile Include="DataSetListView.cs"> 84 82 <SubType>UserControl</SubType> 85 83 </Compile> 86 <Compile Include="Data baseOperatorLibraryView.Designer.cs">87 <DependentUpon>Data baseOperatorLibraryView.cs</DependentUpon>84 <Compile Include="DataSetListView.Designer.cs"> 85 <DependentUpon>DataSetListView.cs</DependentUpon> 88 86 </Compile> 89 <Compile Include="OperatorLink.cs" /> 90 <Compile Include="OperatorLinkPatcher.cs" /> 91 <Compile Include="Result.cs" /> 92 <Compile Include="IResult.cs" /> 93 <Compile Include="HeuristicLabCedmaCorePlugin.cs" /> 94 <Compile Include="IAgent.cs" /> 95 <Compile Include="IAgentList.cs" /> 96 <Compile Include="IDatabaseItem.cs" /> 97 <Compile Include="Properties\AssemblyInfo.cs" /> 98 <Compile Include="AgentListView.cs"> 87 <Compile Include="DataSetView.cs"> 99 88 <SubType>UserControl</SubType> 100 89 </Compile> 101 <Compile Include=" AgentListView.Designer.cs">102 <DependentUpon> AgentListView.cs</DependentUpon>90 <Compile Include="DataSetView.Designer.cs"> 91 <DependentUpon>DataSetView.cs</DependentUpon> 103 92 </Compile> 104 <Compile Include="AgentView.cs"> 105 <SubType>UserControl</SubType> 106 </Compile> 107 <Compile Include="AgentView.Designer.cs"> 108 <DependentUpon>AgentView.cs</DependentUpon> 109 </Compile> 93 <Compile Include="HeuristicLabCedmaCorePlugin.cs" /> 94 <Compile Include="Properties\AssemblyInfo.cs" /> 110 95 </ItemGroup> 111 96 <ItemGroup> … … 135 120 </ItemGroup> 136 121 <ItemGroup> 137 <EmbeddedResource Include="AgentListView.resx">138 <DependentUpon>AgentListView.cs</DependentUpon>139 <SubType>Designer</SubType>140 </EmbeddedResource>141 <EmbeddedResource Include="AgentView.resx">142 <DependentUpon>AgentView.cs</DependentUpon>143 <SubType>Designer</SubType>144 </EmbeddedResource>145 122 <EmbeddedResource Include="ConsoleEditor.resx"> 146 123 <DependentUpon>ConsoleEditor.cs</DependentUpon> 147 124 <SubType>Designer</SubType> 148 125 </EmbeddedResource> 149 <EmbeddedResource Include="DatabaseOperatorLibraryView.resx"> 150 <DependentUpon>DatabaseOperatorLibraryView.cs</DependentUpon> 151 <SubType>Designer</SubType> 126 <EmbeddedResource Include="DataSetListView.resx"> 127 <DependentUpon>DataSetListView.cs</DependentUpon> 128 </EmbeddedResource> 129 <EmbeddedResource Include="DataSetView.resx"> 130 <DependentUpon>DataSetView.cs</DependentUpon> 152 131 </EmbeddedResource> 153 132 </ItemGroup> -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/HeuristicLab.CEDMA.DB.Interfaces.csproj
r852 r957 70 70 </ItemGroup> 71 71 <ItemGroup> 72 <Compile Include="AgentEntry.cs" />73 72 <Compile Include="SelectFilter.cs" /> 74 73 <Compile Include="SerializedLiteral.cs" /> … … 79 78 <Compile Include="IStore.cs" /> 80 79 <Compile Include="OperatorEntry.cs" /> 81 <Compile Include="ProcessStatus.cs" />82 <Compile Include="ResultEntry.cs" />83 80 <Compile Include="HeuristicLabCedmaDbInterfacesPlugin.cs" /> 84 <Compile Include="IDatabase.cs" />85 81 <Compile Include="Properties\AssemblyInfo.cs" /> 86 82 </ItemGroup> -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB/HeuristicLab.CEDMA.DB.csproj
r920 r957 60 60 <RequiredTargetFramework>3.5</RequiredTargetFramework> 61 61 </Reference> 62 <Reference Include="System.Data.SQLite, Version=1.0.56.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">63 <SpecificVersion>False</SpecificVersion>64 <HintPath>..\HeuristicLab.SQLite\System.Data.SQLite.DLL</HintPath>65 </Reference>66 62 <Reference Include="System.ServiceModel"> 67 63 <RequiredTargetFramework>3.0</RequiredTargetFramework> … … 78 74 <ItemGroup> 79 75 <Compile Include="Store.cs" /> 80 <Compile Include="Database.cs" />81 76 <Compile Include="HeuristicLabCedmaDbPlugin.cs" /> 82 77 <Compile Include="Properties\AssemblyInfo.cs" /> -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB/Store.cs
r557 r957 28 28 using System.ServiceModel; 29 29 using System.Data; 30 using System.Data.SQLite;31 30 using System.Data.Common; 32 31 using System.Threading;
Note: See TracChangeset
for help on using the changeset viewer.