- Timestamp:
- 04/16/09 17:46:11 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/JobAdapter.cs
r1530 r1580 31 31 using System.Data.Common; 32 32 using System.Data.SqlClient; 33 using HeuristicLab.Hive.Server.ADODataAccess.TableAdapterWrapper; 33 34 34 35 namespace 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.JobRow44 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 74 36 class JobAdapter : 75 37 DataAdapterBase<dsHiveServerTableAdapters.JobTableAdapter, … … 78 40 IJobAdapter { 79 41 #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 80 62 private IClientAdapter clientAdapter = null; 81 63 … … 102 84 } 103 85 } 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 } 104 99 #endregion 105 100 … … 167 162 else 168 163 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 } 169 175 170 176 return job; … … 296 302 } 297 303 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 298 319 protected override bool doDelete(Job job) { 299 320 if (job != null) { … … 310 331 } 311 332 333 //delete all relationships 334 ManyToManyRelationHelper.UpdateRelationships(job.Id, 335 new List<Guid>()); 336 312 337 return base.doDelete(job); 313 338 }
Note: See TracChangeset
for help on using the changeset viewer.