Free cookie consent management tool by TermsFeed Policy Generator

Changeset 957


Ignore:
Timestamp:
12/10/08 17:33:27 (14 years ago)
Author:
gkronber
Message:

worked on #419 (Refactor CEDMA plugins)

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  
    3333namespace HeuristicLab.CEDMA.Core {
    3434  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;
    4038    private string serverUri;
    4139    public string ServerUri {
     
    4341    }
    4442
    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; }
    5545    }
    5646
    5747    public Console()
    5848      : base() {
    59       agentList = new AgentList();
    60       resultsList = new ResultList();
    61       operatorLibary = new DatabaseOperatorLibrary();
     49      dataSetList = new DataSetList();
    6250    }
    6351
     
    9280      binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements;
    9381      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;
    10285    }
    10386    #endregion
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ConsoleEditor.cs

    r561 r957  
    4949    }
    5050
     51    #region autogenerated code
    5152    private void InitializeComponent() {
    5253      this.uriTextBox = new System.Windows.Forms.TextBox();
     
    9697      this.openOpLibButton.Text = "&Open";
    9798      this.openOpLibButton.UseVisualStyleBackColor = true;
    98       this.openOpLibButton.Click += new System.EventHandler(this.opLibButton_Click);
    9999      //
    100100      // label1
     
    125125      this.openResultsButton.Text = "&Open";
    126126      this.openResultsButton.UseVisualStyleBackColor = true;
    127       this.openResultsButton.Click += new System.EventHandler(this.openChartButton_Click);
    128127      //
    129128      // openAgentsButton
     
    136135      this.openAgentsButton.Text = "&Open";
    137136      this.openAgentsButton.UseVisualStyleBackColor = true;
    138       this.openAgentsButton.Click += new System.EventHandler(this.openAgentsButton_Click);
    139137      //
    140138      // agentsLabel
     
    166164    }
    167165
     166    #endregion
     167
    168168    private void connectButton_Click(object sender, EventArgs e) {
    169169      try {
     
    177177      }
    178178    }
    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     }
    196179  }
    197180}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSet.cs

    r928 r957  
    3030
    3131namespace HeuristicLab.CEDMA.Core {
    32   public class Agent : IAgent {
    33     public IDatabase Database { get; set; }
     32  public class DataSet {
     33    public IStore Store { get; set; }
    3434    public long Id { get; set; }
    3535    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;
    3937
    40     public IOperatorGraph OperatorGraph {
    41       get { return operatorGraph; }
     38    public Problem Problem {
     39      get { return problem; }
    4240    }
    4341
    44     public Agent()
     42    public DataSet()
    4543      : base() {
    46       operatorGraph = new OperatorGraph();
     44      problem = new Problem();
    4745    }
    4846
    49     public Agent(IDatabase database, long id)
     47    public DataSet(IStore store, long id)
    5048      : this() {
    51       Database = database;
     49      Store = store;
    5250      Id = id;
    5351    }
    5452
    5553    public void Save() {
    56       Database.UpdateAgent(Id, Name);
    57       Database.UpdateAgent(Id, Status);
    58       Database.UpdateAgent(Id, PersistenceManager.SaveToGZip(OperatorGraph));
     54      throw new NotImplementedException();
    5955    }
    6056
    61     public void Start() {
    62       Status = ProcessStatus.Waiting;
    63       Save();
     57    public void Activate() {
     58      throw new NotImplementedException();
    6459    }
    6560
    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();
    9063    }
    9164
    9265    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);
    10167    }
    10268  }
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetList.cs

    r928 r957  
    3333
    3434namespace HeuristicLab.CEDMA.Core {
    35   public class AgentList : ItemBase, IAgentList {
    36     private List<IAgent> agentList;
    37     private IDatabase database;
    38     public IDatabase 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; }
    4040      set {
    41         database = value;
     41        store = value;
    4242        Action reload = ReloadList;
    43         lock(agentList) {
    44           agentList.Clear();
     43        lock(dataSetList) {
     44          dataSetList.Clear();
    4545        }
    4646        reload.BeginInvoke(null, null);
     
    4848    }
    4949
    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>();
    6053    }
    6154
    62     public AgentList()
    63       : base() {
    64       agentList = new List<IAgent>();
     55    public override IView CreateView() {
     56      return new DataSetListView(this);
    6557    }
    6658
    67     public 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      //}
    7870    }
    7971
    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);
    8480      }
    85       return agents.GetEnumerator();
     81      return dataSets.GetEnumerator();
    8682    }
    8783
     
    8985      return GetEnumerator();
    9086    }
    91 
    92     public override IView CreateView() {
    93       return new AgentListView(this);
    94     }
    9587  }
    9688}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetListView.Designer.cs

    r928 r957  
    2424
    2525namespace HeuristicLab.CEDMA.Core {
    26   partial class AgentListView {
     26  partial class DataSetListView {
    2727    /// <summary>
    2828    /// Required designer variable.
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetListView.cs

    r928 r957  
    3030
    3131namespace 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; }
    3535      set { base.Item = value; }
    3636    }
    3737
    38     public AgentListView() {
     38    public DataSetListView() {
    3939      InitializeComponent();
    40       Caption = "Agent View";
     40      Caption = "DataSet View";
    4141    }
    42     public AgentListView(IAgentList agentList)
     42    public DataSetListView(DataSetList dataSetList)
    4343      : this() {
    44       AgentList = agentList;
    45       agentList.Changed += new EventHandler(agentList_Changed);
     44      DataSetList = dataSetList;
     45      dataSetList.Changed += new EventHandler(dataSetList_Changed);
    4646    }
    4747
    48     void agentList_Changed(object sender, EventArgs e) {
     48    void dataSetList_Changed(object sender, EventArgs e) {
    4949      UpdateControls();
    5050    }
     
    5454      detailsGroupBox.Controls.Clear();
    5555      detailsGroupBox.Enabled = false;
    56       if(AgentList == null) {
    57         Caption = "Agents View";
     56      if(DataSetList == null) {
     57        Caption = "Data Sets View";
    5858        agentTreeView.Enabled = false;
    5959      } else {
    6060        agentTreeView.Enabled = true;
    6161        agentTreeView.Nodes.Clear();
    62         foreach(IAgent agent in AgentList) {
     62        foreach(DataSet dataSet in DataSetList) {
    6363          TreeNode node = new TreeNode();
    64           node.Text = agent.Name;
    65           node.Tag = agent;
     64          node.Text = dataSet.Name;
     65          node.Tag = dataSet;
    6666          node.Nodes.Add("dummy");
    6767          node.ContextMenuStrip = entryContextMenuStrip;
     
    7373    #region Button Events
    7474    private void addButton_Click(object sender, EventArgs e) {
    75       AgentList.CreateAgent();
     75      DataSetList.CreateDataSet();
    7676    }
    7777    #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     }
    10978
    11079    private void agentTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
     
    12594      UpdateControls();
    12695    }
    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     }
    13996  }
    14097}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetView.Designer.cs

    r928 r957  
    2121
    2222namespace HeuristicLab.CEDMA.Core {
    23   partial class AgentView {
     23  partial class DataSetView {
    2424    /// <summary>
    2525    /// Required designer variable.
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetView.cs

    r928 r957  
    3131
    3232namespace 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; }
    3838    }
    3939
    40     public AgentView() {
     40    public DataSetView() {
    4141      InitializeComponent();
    42       Caption = "Agent";
     42      Caption = "Data Set";
    4343    }
    44     public AgentView(Agent agent)
     44    public DataSetView(DataSet dataSet)
    4545      : this() {
    46       Agent = agent;
     46      DataSet = dataSet;
    4747      UpdateControls();
    4848    }
     
    5252      editorGroupBox.Controls.Clear();
    5353      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       }
    6554    }
    6655
    6756    private void saveButton_Click(object sender, EventArgs e) {
    68       Agent.Save();
     57      DataSet.Save();
    6958    }
    7059
    7160    private void activateButton_Click(object sender, EventArgs e) {
    72       Agent.Start();
     61      DataSet.Activate();
    7362      activateButton.Enabled = false;
    7463    }
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/HeuristicLab.CEDMA.Core.csproj

    r852 r957  
    7272  </ItemGroup>
    7373  <ItemGroup>
    74     <Compile Include="Agent.cs" />
    75     <Compile Include="AgentList.cs" />
    7674    <Compile Include="Console.cs" />
    7775    <Compile Include="ConsoleEditor.cs">
    7876      <SubType>UserControl</SubType>
    7977    </Compile>
    80     <Compile Include="ResultTable.cs" />
    81     <Compile Include="ResultExporter.cs" />
    82     <Compile Include="DatabaseOperatorLibrary.cs" />
    83     <Compile Include="DatabaseOperatorLibraryView.cs">
     78    <Compile Include="Problem.cs" />
     79    <Compile Include="DataSet.cs" />
     80    <Compile Include="DataSetList.cs" />
     81    <Compile Include="DataSetListView.cs">
    8482      <SubType>UserControl</SubType>
    8583    </Compile>
    86     <Compile Include="DatabaseOperatorLibraryView.Designer.cs">
    87       <DependentUpon>DatabaseOperatorLibraryView.cs</DependentUpon>
     84    <Compile Include="DataSetListView.Designer.cs">
     85      <DependentUpon>DataSetListView.cs</DependentUpon>
    8886    </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">
    9988      <SubType>UserControl</SubType>
    10089    </Compile>
    101     <Compile Include="AgentListView.Designer.cs">
    102       <DependentUpon>AgentListView.cs</DependentUpon>
     90    <Compile Include="DataSetView.Designer.cs">
     91      <DependentUpon>DataSetView.cs</DependentUpon>
    10392    </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" />
    11095  </ItemGroup>
    11196  <ItemGroup>
     
    135120  </ItemGroup>
    136121  <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>
    145122    <EmbeddedResource Include="ConsoleEditor.resx">
    146123      <DependentUpon>ConsoleEditor.cs</DependentUpon>
    147124      <SubType>Designer</SubType>
    148125    </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>
    152131    </EmbeddedResource>
    153132  </ItemGroup>
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/HeuristicLab.CEDMA.DB.Interfaces.csproj

    r852 r957  
    7070  </ItemGroup>
    7171  <ItemGroup>
    72     <Compile Include="AgentEntry.cs" />
    7372    <Compile Include="SelectFilter.cs" />
    7473    <Compile Include="SerializedLiteral.cs" />
     
    7978    <Compile Include="IStore.cs" />
    8079    <Compile Include="OperatorEntry.cs" />
    81     <Compile Include="ProcessStatus.cs" />
    82     <Compile Include="ResultEntry.cs" />
    8380    <Compile Include="HeuristicLabCedmaDbInterfacesPlugin.cs" />
    84     <Compile Include="IDatabase.cs" />
    8581    <Compile Include="Properties\AssemblyInfo.cs" />
    8682  </ItemGroup>
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB/HeuristicLab.CEDMA.DB.csproj

    r920 r957  
    6060      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    6161    </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>
    6662    <Reference Include="System.ServiceModel">
    6763      <RequiredTargetFramework>3.0</RequiredTargetFramework>
     
    7874  <ItemGroup>
    7975    <Compile Include="Store.cs" />
    80     <Compile Include="Database.cs" />
    8176    <Compile Include="HeuristicLabCedmaDbPlugin.cs" />
    8277    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB/Store.cs

    r557 r957  
    2828using System.ServiceModel;
    2929using System.Data;
    30 using System.Data.SQLite;
    3130using System.Data.Common;
    3231using System.Threading;
Note: See TracChangeset for help on using the changeset viewer.