Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1580


Ignore:
Timestamp:
04/16/09 17:46:11 (16 years ago)
Author:
svonolfe
Message:

Added PluginInfoAdapter (#372)

Location:
trunk/sources
Files:
16 added
4 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataAccess.ADOHelper/3.2/DataAdapterBase.cs

    r1529 r1580  
    3636    private ISession session;
    3737
    38     private IDataAdapterWrapper<AdapterT, ObjT, RowT> dataAdapter;
     38    private ITableAdapterWrapper<AdapterT, ObjT, RowT> dataAdapter;
    3939
    4040    protected DataAdapterBase(
    41       IDataAdapterWrapper<AdapterT, ObjT, RowT> dataAdapter) {
     41      ITableAdapterWrapper<AdapterT, ObjT, RowT> dataAdapter) {
    4242      this.dataAdapter = dataAdapter;
    4343    }
     
    4949    }
    5050
    51     protected IDataAdapterWrapper<AdapterT, ObjT, RowT> DataAdapterWrapper {
     51    protected ITableAdapterWrapper<AdapterT, ObjT, RowT> DataAdapterWrapper {
    5252      get {
    5353        return dataAdapter;
  • trunk/sources/HeuristicLab.DataAccess.ADOHelper/3.2/HeuristicLab.DataAccess.ADOHelper-3.2.csproj

    r1534 r1580  
    8383    <Compile Include="DataAccessADOHelperPlugin.cs" />
    8484    <Compile Include="DataAdapterBase.cs" />
    85     <Compile Include="DataAdapterWrapperBase.cs" />
    86     <Compile Include="IDataAdapterWrapper.cs" />
    87     <Compile Include="BinaryRelation.cs" />
    88     <Compile Include="BinaryRelationHelper.cs" />
     85    <Compile Include="TableAdapterWrapperBase.cs" />
     86    <Compile Include="ITableAdapterWrapper.cs" />
     87    <Compile Include="ManyToManyRelation.cs" />
     88    <Compile Include="ManyToManyRelationHelper.cs" />
    8989    <Compile Include="Session.cs" />
    9090    <Compile Include="SessionFactory.cs" />
  • trunk/sources/HeuristicLab.Hive.Contracts/3.2/BusinessObjects/Job.cs

    r1478 r1580  
    5555    public int MemoryNeeded { get; set; }
    5656    [DataMember]
    57     public List<PluginInfo> PluginsNeeded { get; set; }
     57    public List<HivePluginInfo> PluginsNeeded { get; set; }
    5858  }
    5959}
  • trunk/sources/HeuristicLab.Hive.Contracts/3.2/HeuristicLab.Hive.Contracts-3.2.csproj

    r1534 r1580  
    8888    <Compile Include="ApplicationConstants.cs" />
    8989    <Compile Include="BusinessObjects\ClientGroup.cs" />
     90    <Compile Include="BusinessObjects\HivePluginInfo.cs" />
    9091    <Compile Include="BusinessObjects\HeartBeatData.cs" />
    9192    <Compile Include="BusinessObjects\Job.cs" />
  • trunk/sources/HeuristicLab.Hive.Engine/3.2/HiveEngine.cs

    r1530 r1580  
    2929using HeuristicLab.Hive.Contracts;
    3030using HeuristicLab.PluginInfrastructure;
     31using HeuristicLab.Hive.Contracts.BusinessObjects;
    3132
    3233namespace HeuristicLab.Hive.Engine {
     
    8182      jobObj.SerializedJob = PersistenceManager.SaveToGZip(job);
    8283      jobObj.State = HeuristicLab.Hive.Contracts.BusinessObjects.State.offline;
    83       jobObj.PluginsNeeded = dependentPlugins;
     84
     85      List<HivePluginInfo> pluginsNeeded =
     86        new List<HivePluginInfo>();
     87
     88      foreach (PluginInfo info in dependentPlugins) {
     89        HivePluginInfo pluginInfo =
     90          new HivePluginInfo();
     91        pluginInfo.Name = info.Name;
     92        pluginInfo.Version = info.Version.ToString();
     93        pluginInfo.BuildDate = info.BuildDate.ToString();
     94
     95        pluginsNeeded.Add(pluginInfo);
     96      }
     97
     98      jobObj.PluginsNeeded = pluginsNeeded;
    8499      ResponseObject<Contracts.BusinessObjects.Job> res = executionEngineFacade.AddJob(jobObj);
    85100      jobId = res.Obj.Id;
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/ClientAdapter.cs

    r1530 r1580  
    3232using System.Data.Common;
    3333using System.Data.SqlClient;
     34using HeuristicLab.Hive.Server.ADODataAccess.TableAdapterWrapper;
    3435
    3536namespace HeuristicLab.Hive.Server.ADODataAccess {
    36   class ClientAdapterWrapper :
    37     DataAdapterWrapperBase<
    38         dsHiveServerTableAdapters.ClientTableAdapter,
    39     ClientInfo,
    40     dsHiveServer.ClientRow> {
    41     public override void UpdateRow(dsHiveServer.ClientRow row) {
    42       TransactionalAdapter.Update(row);
    43     }
    44 
    45     public override dsHiveServer.ClientRow
    46       InsertNewRow(ClientInfo client) {
    47       dsHiveServer.ClientDataTable data =
    48         new dsHiveServer.ClientDataTable();
    49 
    50       dsHiveServer.ClientRow row = data.NewClientRow();
    51       row.ResourceId = client.Id;
    52       data.AddClientRow(row);
    53 
    54       return row;
    55     }
    56 
    57     public override IEnumerable<dsHiveServer.ClientRow>
    58       FindById(Guid id) {
    59       return TransactionalAdapter.GetDataById(id);
    60     }
    61 
    62     public override IEnumerable<dsHiveServer.ClientRow>
    63       FindAll() {
    64       return TransactionalAdapter.GetData();
    65     }
    66 
    67     protected override void SetConnection(DbConnection connection) {
    68       adapter.Connection = connection as SqlConnection;
    69     }
    70 
    71     protected override void SetTransaction(DbTransaction transaction) {
    72       adapter.Transaction = transaction as SqlTransaction;
    73     }
    74   }
    75 
    7637  class ClientAdapter:
    7738    DataAdapterBase<
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/ClientGroupAdapter.cs

    r1530 r1580  
    3232using System.Data.Common;
    3333using System.Data.SqlClient;
     34using HeuristicLab.Hive.Server.ADODataAccess.TableAdapterWrapper;
    3435
    3536namespace HeuristicLab.Hive.Server.ADODataAccess {
    36   class ClientGroupAdapterWrapper :
    37     DataAdapterWrapperBase<dsHiveServerTableAdapters.ClientGroupTableAdapter,
    38     ClientGroup,
    39     dsHiveServer.ClientGroupRow> {
    40     public override dsHiveServer.ClientGroupRow
    41      InsertNewRow(ClientGroup group) {
    42       dsHiveServer.ClientGroupDataTable data =
    43          new dsHiveServer.ClientGroupDataTable();
    44 
    45       dsHiveServer.ClientGroupRow row =
    46         data.NewClientGroupRow();
    47 
    48       row.ResourceId = group.Id;
    49 
    50       data.AddClientGroupRow(row);
    51       TransactionalAdapter.Update(row);
    52 
    53       return row;
    54     }
    55 
    56     public override void
    57       UpdateRow(dsHiveServer.ClientGroupRow row) {
    58       TransactionalAdapter.Update(row);
    59     }
    60 
    61     public override IEnumerable<dsHiveServer.ClientGroupRow>
    62       FindById(Guid id) {
    63       return TransactionalAdapter.GetDataById(id);
    64     }
    65 
    66     public override IEnumerable<dsHiveServer.ClientGroupRow>
    67       FindAll() {
    68       return TransactionalAdapter.GetData();
    69     }
    70 
    71     protected override void SetConnection(DbConnection connection) {
    72       adapter.Connection = connection as SqlConnection;
    73     }
    74 
    75     protected override void SetTransaction(DbTransaction transaction) {
    76       adapter.Transaction = transaction as SqlTransaction;
    77     }
    78   }
    79 
    80   class ClientGroup_ResourceAdapterWrapper :
    81   DataAdapterWrapperBase<dsHiveServerTableAdapters.ClientGroup_ResourceTableAdapter,
    82   BinaryRelation,
    83   dsHiveServer.ClientGroup_ResourceRow> {
    84     public override dsHiveServer.ClientGroup_ResourceRow
    85      InsertNewRow(BinaryRelation relation) {
    86       dsHiveServer.ClientGroup_ResourceDataTable data =
    87          new dsHiveServer.ClientGroup_ResourceDataTable();
    88 
    89       dsHiveServer.ClientGroup_ResourceRow row =
    90         data.NewClientGroup_ResourceRow();
    91 
    92       row.ClientGroupId = relation.Id;
    93       row.ResourceId = relation.Id2;
    94 
    95       data.AddClientGroup_ResourceRow(row);
    96       TransactionalAdapter.Update(row);
    97 
    98       return row;
    99     }
    100 
    101     public override void
    102       UpdateRow(dsHiveServer.ClientGroup_ResourceRow row) {
    103       TransactionalAdapter.Update(row);
    104     }
    105 
    106     public override IEnumerable<dsHiveServer.ClientGroup_ResourceRow>
    107       FindById(Guid id) {
    108       return TransactionalAdapter.GetDataByClientGroupId(id);
    109     }
    110 
    111     public override IEnumerable<dsHiveServer.ClientGroup_ResourceRow>
    112       FindAll() {
    113       return TransactionalAdapter.GetData();
    114     }
    115 
    116     protected override void SetConnection(DbConnection connection) {
    117       adapter.Connection = connection as SqlConnection;
    118     }
    119 
    120     protected override void SetTransaction(DbTransaction transaction) {
    121       adapter.Transaction = transaction as SqlTransaction;
    122     }
    123   }
    124  
    12537  class ClientGroupAdapter :
    12638    DataAdapterBase<dsHiveServerTableAdapters.ClientGroupTableAdapter,
     
    12941    IClientGroupAdapter {
    13042    #region Fields
    131     private BinaryRelationHelper<
     43    private ManyToManyRelationHelper<
    13244      dsHiveServerTableAdapters.ClientGroup_ResourceTableAdapter,
    133       dsHiveServer.ClientGroup_ResourceRow> binaryRelationHelper = null;
     45      dsHiveServer.ClientGroup_ResourceRow> manyToManyRelationHelper = null;
    13446
    135     private BinaryRelationHelper<dsHiveServerTableAdapters.ClientGroup_ResourceTableAdapter,
    136       dsHiveServer.ClientGroup_ResourceRow> BinaryRelationHelper {
     47    private ManyToManyRelationHelper<dsHiveServerTableAdapters.ClientGroup_ResourceTableAdapter,
     48      dsHiveServer.ClientGroup_ResourceRow> ManyToManyRelationHelper {
    13749      get {
    138         if (binaryRelationHelper == null) {
    139           binaryRelationHelper =
    140             new BinaryRelationHelper<dsHiveServerTableAdapters.ClientGroup_ResourceTableAdapter,
     50        if (manyToManyRelationHelper == null) {
     51          manyToManyRelationHelper =
     52            new ManyToManyRelationHelper<dsHiveServerTableAdapters.ClientGroup_ResourceTableAdapter,
    14153              dsHiveServer.ClientGroup_ResourceRow>(new ClientGroup_ResourceAdapterWrapper());
    14254        }
    14355
    144         binaryRelationHelper.Session = Session as Session;
     56        manyToManyRelationHelper.Session = Session as Session;
    14557
    146         return binaryRelationHelper;
     58        return manyToManyRelationHelper;
    14759      }
    14860    }
     
    18698
    18799        ICollection<Guid> resources =
    188           BinaryRelationHelper.GetRelationships(clientGroup.Id);
     100          ManyToManyRelationHelper.GetRelationships(clientGroup.Id);
    189101
    190102       clientGroup.Resources.Clear();
     
    240152        }
    241153
    242         BinaryRelationHelper.UpdateRelationships(group.Id,
     154        ManyToManyRelationHelper.UpdateRelationships(group.Id,
    243155          relationships);
    244156      }
     
    264176      if (group != null) {
    265177        //delete all relationships
    266         BinaryRelationHelper.UpdateRelationships(group.Id,
     178        ManyToManyRelationHelper.UpdateRelationships(group.Id,
    267179          new List<Guid>());
    268180
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/HeuristicLab.Hive.Server.ADODataAccess-3.2.csproj

    r1534 r1580  
    9494    <Compile Include="JobAdapter.cs" />
    9595    <Compile Include="JobResultsAdapter.cs" />
     96    <Compile Include="PluginInfoAdapter.cs" />
    9697    <Compile Include="Properties\AssemblyInfo.cs" />
    9798    <Compile Include="Properties\Settings.Designer.cs">
     
    101102    </Compile>
    102103    <Compile Include="ResourceAdapter.cs" />
     104    <Compile Include="TableAdapterWrapper\ClientAdapterWrapper.cs" />
     105    <Compile Include="TableAdapterWrapper\ClientGroupAdapterWrapper.cs" />
     106    <Compile Include="TableAdapterWrapper\ClientGroup_ResourceAdapterWrapper.cs" />
     107    <Compile Include="TableAdapterWrapper\RequiredPluginsAdapterWrapper.cs" />
     108    <Compile Include="TableAdapterWrapper\PluginInfoAdapterWrapper.cs" />
     109    <Compile Include="TableAdapterWrapper\ResourceAdapterWrapper.cs" />
     110    <Compile Include="TableAdapterWrapper\JobResultsAdapterWrapper.cs" />
     111    <Compile Include="TableAdapterWrapper\JobAdapterWrapper.cs" />
    103112  </ItemGroup>
    104113  <ItemGroup>
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/JobAdapter.cs

    r1530 r1580  
    3131using System.Data.Common;
    3232using System.Data.SqlClient;
     33using HeuristicLab.Hive.Server.ADODataAccess.TableAdapterWrapper;
    3334
    3435namespace HeuristicLab.Hive.Server.ADODataAccess {
    35   class JobAdapterWrapper :
    36     DataAdapterWrapperBase<dsHiveServerTableAdapters.JobTableAdapter,
    37                       Job,
    38                       dsHiveServer.JobRow> {   
    39     public override void UpdateRow(dsHiveServer.JobRow row) {
    40       TransactionalAdapter.Update(row);
    41     }
    42 
    43     public override dsHiveServer.JobRow
    44       InsertNewRow(Job job) {
    45       dsHiveServer.JobDataTable data =
    46         new dsHiveServer.JobDataTable();
    47 
    48       dsHiveServer.JobRow row = data.NewJobRow();
    49       row.JobId = job.Id;
    50       data.AddJobRow(row);
    51 
    52       return row;
    53     }
    54 
    55     public override IEnumerable<dsHiveServer.JobRow>
    56       FindById(Guid id) {
    57       return TransactionalAdapter.GetDataById(id);
    58     }
    59 
    60     public override IEnumerable<dsHiveServer.JobRow>
    61       FindAll() {
    62       return TransactionalAdapter.GetData();
    63     }
    64 
    65     protected override void SetConnection(DbConnection connection) {
    66       adapter.Connection = connection as SqlConnection;
    67     }
    68 
    69     protected override void SetTransaction(DbTransaction transaction) {
    70       adapter.Transaction = transaction as SqlTransaction;
    71     }
    72   }
    73  
    7436  class JobAdapter :
    7537    DataAdapterBase<dsHiveServerTableAdapters.JobTableAdapter,
     
    7840    IJobAdapter {
    7941    #region Fields
     42    private ManyToManyRelationHelper<
     43      dsHiveServerTableAdapters.RequiredPluginsTableAdapter,
     44      dsHiveServer.RequiredPluginsRow> manyToManyRelationHelper = null;
     45
     46    private ManyToManyRelationHelper<
     47      dsHiveServerTableAdapters.RequiredPluginsTableAdapter,
     48      dsHiveServer.RequiredPluginsRow> ManyToManyRelationHelper {
     49      get {
     50        if (manyToManyRelationHelper == null) {
     51          manyToManyRelationHelper =
     52            new ManyToManyRelationHelper<dsHiveServerTableAdapters.RequiredPluginsTableAdapter,
     53              dsHiveServer.RequiredPluginsRow>(new RequiredPluginsAdapterWrapper());
     54        }
     55
     56        manyToManyRelationHelper.Session = Session as Session;
     57
     58        return manyToManyRelationHelper;
     59      }
     60    }
     61
    8062    private IClientAdapter clientAdapter = null;
    8163
     
    10284      }
    10385    }
     86
     87    private IPluginInfoAdapter pluginInfoAdapter = null;
     88
     89    private IPluginInfoAdapter PluginInfoAdapter {
     90      get {
     91        if (pluginInfoAdapter == null) {
     92          pluginInfoAdapter =
     93            this.Session.GetDataAdapter<HivePluginInfo, IPluginInfoAdapter>();
     94        }
     95
     96        return pluginInfoAdapter;
     97      }
     98    }
    10499    #endregion
    105100
     
    167162        else
    168163          job.MemoryNeeded = default(int);
     164
     165        ICollection<Guid> requiredPlugins =
     166          ManyToManyRelationHelper.GetRelationships(job.Id);
     167       
     168        job.PluginsNeeded.Clear();
     169        foreach (Guid requiredPlugin in requiredPlugins) {
     170          HivePluginInfo pluginInfo =
     171            PluginInfoAdapter.GetById(requiredPlugin);
     172
     173          job.PluginsNeeded.Add(pluginInfo);
     174        }
    169175
    170176        return job;
     
    296302    }
    297303
     304    protected override void doUpdate(Job obj) {
     305      base.doUpdate(obj);
     306
     307      //update relationships
     308      List<Guid> relationships =
     309        new List<Guid>();
     310      foreach (HivePluginInfo pluginInfo in obj.PluginsNeeded) {
     311        PluginInfoAdapter.Update(pluginInfo);
     312        relationships.Add(pluginInfo.Id);
     313      }
     314
     315      ManyToManyRelationHelper.UpdateRelationships(
     316        obj.Id, relationships);
     317    }
     318
    298319    protected override bool doDelete(Job job) {
    299320      if (job != null) {
     
    310331          }
    311332
     333          //delete all relationships
     334          ManyToManyRelationHelper.UpdateRelationships(job.Id,
     335            new List<Guid>());
     336
    312337          return base.doDelete(job);
    313338        }
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/JobResultsAdapter.cs

    r1530 r1580  
    99using System.Data.Common;
    1010using System.Data.SqlClient;
     11using HeuristicLab.Hive.Server.ADODataAccess.TableAdapterWrapper;
    1112
    1213namespace HeuristicLab.Hive.Server.ADODataAccess {
    13   class JobResultsAdapterWrapper :
    14     DataAdapterWrapperBase<dsHiveServerTableAdapters.JobResultTableAdapter,
    15                     JobResult,
    16                     dsHiveServer.JobResultRow> {   
    17     public override void UpdateRow(dsHiveServer.JobResultRow row) {
    18       TransactionalAdapter.Update(row);
    19     }
    20 
    21     public override dsHiveServer.JobResultRow InsertNewRow(JobResult obj) {
    22       dsHiveServer.JobResultDataTable data =
    23         new dsHiveServer.JobResultDataTable();
    24 
    25       dsHiveServer.JobResultRow row = data.NewJobResultRow();
    26       row.JobResultId = obj.Id;
    27       data.AddJobResultRow(row);
    28 
    29       return row;
    30     }
    31 
    32     public override IEnumerable<dsHiveServer.JobResultRow> FindById(Guid id) {
    33       return TransactionalAdapter.GetDataById(id);
    34     }
    35 
    36     public override IEnumerable<dsHiveServer.JobResultRow> FindAll() {
    37       return TransactionalAdapter.GetData();
    38     }
    39 
    40     protected override void SetConnection(DbConnection connection) {
    41       adapter.Connection = connection as SqlConnection;
    42     }
    43 
    44     protected override void SetTransaction(DbTransaction transaction) {
    45       adapter.Transaction = transaction as SqlTransaction;
    46     }
    47   }
    48 
    4914  class JobResultsAdapter:
    5015    DataAdapterBase<dsHiveServerTableAdapters.JobResultTableAdapter,
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/ResourceAdapter.cs

    r1530 r1580  
    3030using System.Data.Common;
    3131using System.Data.SqlClient;
     32using HeuristicLab.Hive.Server.ADODataAccess.TableAdapterWrapper;
    3233
    3334namespace HeuristicLab.Hive.Server.ADODataAccess {
    34   class ResourceAdapterWrapper :
    35     DataAdapterWrapperBase<
    36       dsHiveServerTableAdapters.ResourceTableAdapter,
    37       Resource,
    38       dsHiveServer.ResourceRow> {   
    39     public override void UpdateRow(dsHiveServer.ResourceRow row) {
    40       TransactionalAdapter.Update(row);
    41     }
    42 
    43     public override dsHiveServer.ResourceRow
    44       InsertNewRow(Resource resource) {
    45       dsHiveServer.ResourceDataTable data =
    46         new dsHiveServer.ResourceDataTable();
    47 
    48       dsHiveServer.ResourceRow row = data.NewResourceRow();
    49       row.ResourceId = resource.Id;
    50       data.AddResourceRow(row);
    51 
    52       return row;
    53     }
    54 
    55     public override IEnumerable<dsHiveServer.ResourceRow>
    56       FindById(Guid id) {
    57       return TransactionalAdapter.GetDataById(id);
    58     }
    59 
    60     public override IEnumerable<dsHiveServer.ResourceRow>
    61       FindAll() {
    62       return TransactionalAdapter.GetData();
    63     }
    64 
    65     protected override void SetConnection(DbConnection connection) {
    66       adapter.Connection = connection as SqlConnection;
    67     }
    68 
    69     protected override void SetTransaction(DbTransaction transaction) {
    70       adapter.Transaction = transaction as SqlTransaction;
    71     }
    72   }
    73  
    7435  class ResourceAdapter:
    7536    DataAdapterBase<
  • trunk/sources/HeuristicLab.Hive.Server.DataAccess/3.2/HeuristicLab.Hive.Server.DataAccess-3.2.csproj

    r1534 r1580  
    7676  -->
    7777  <ItemGroup>
     78    <Compile Include="IPluginInfoAdapter.cs" />
    7879    <Compile Include="Properties\AssemblyInfo.cs" />
    7980    <Compile Include="HiveServerDataAccessPlugin.cs" />
Note: See TracChangeset for help on using the changeset viewer.