- Timestamp:
- 04/12/11 13:43:05 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources
- Property svn:ignore
-
old new 4 4 PrecompiledWeb 5 5 CreateEventLogSources 6 WindowsFormsTestProject
-
- Property svn:ignore
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Convert.cs
r5786 r6006 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Data.Linq; 24 25 using System.Linq; … … 37 38 ParentJobId = source.ParentJobId, 38 39 Priority = source.Priority, 39 PluginsNeededIds = source.RequiredPlugins.Select(x => x.PluginId).ToList(),40 PluginsNeededIds = (source.RequiredPlugins == null ? new List<Guid>() : source.RequiredPlugins.Select(x => x.PluginId).ToList()), 40 41 LastHeartbeat = source.LastHeartbeat, 41 42 State = source.State, 42 StateLog = source.StateLogs.Select(x => Convert.ToDto(x)).OrderBy(x => x.DateTime).ToList(),43 StateLog = (source.StateLogs == null ? new List<DT.StateLog>() : source.StateLogs.Select(x => Convert.ToDto(x)).OrderBy(x => x.DateTime).ToList()), 43 44 IsParentJob = source.IsParentJob, 44 45 FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished, 45 46 Command = source.Command, 46 LastJobDataUpdate = source.JobData.LastUpdate 47 LastJobDataUpdate = (source.JobData == null ? DateTime.MinValue : source.JobData.LastUpdate), 48 HiveExperimentId = source.HiveExperimentId 47 49 }; 48 50 } … … 71 73 target.Command = source.Command; 72 74 // RequiredPlugins are added by Dao 75 target.HiveExperimentId = source.HiveExperimentId; 73 76 } 74 77 } … … 129 132 public static DT.HiveExperiment ToDto(HiveExperiment source) { 130 133 if (source == null) return null; 131 return new DT.HiveExperiment { Id = source.HiveExperimentId, Description = source.Description, Name = source.Name, RootJobId = source.RootJobId,OwnerUserId = source.OwnerUserId, DateCreated = source.DateCreated, ResourceNames = source.ResourceIds, LastAccessed = source.LastAccessed };134 return new DT.HiveExperiment { Id = source.HiveExperimentId, Description = source.Description, Name = source.Name, OwnerUserId = source.OwnerUserId, DateCreated = source.DateCreated, ResourceNames = source.ResourceIds, LastAccessed = source.LastAccessed }; 132 135 } 133 136 public static HiveExperiment ToEntity(DT.HiveExperiment source) { … … 138 141 public static void ToEntity(DT.HiveExperiment source, HiveExperiment target) { 139 142 if ((source != null) && (target != null)) { 140 target.HiveExperimentId = source.Id; target.Description = source.Description; target.Name = source.Name; target. RootJobId = source.RootJobId; target.OwnerUserId = source.OwnerUserId; target.DateCreated = source.DateCreated; target.ResourceIds = source.ResourceNames; target.LastAccessed = source.LastAccessed;143 target.HiveExperimentId = source.Id; target.Description = source.Description; target.Name = source.Name; target.OwnerUserId = source.OwnerUserId; target.DateCreated = source.DateCreated; target.ResourceIds = source.ResourceNames; target.LastAccessed = source.LastAccessed; 141 144 } 142 145 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs
r5955 r6006 237 237 238 238 private DT.HiveExperiment AddStatsToExperiment(HiveDataContext db, DT.HiveExperiment exp) { 239 var jobs = new List<Job>(); 240 CollectChildJobs(db, exp.RootJobId, jobs); 241 exp.JobCount = jobs.Count; 239 if (exp == null) 240 return null; 241 242 var jobs = db.Jobs.Where(j => j.HiveExperimentId == exp.Id); 243 exp.JobCount = jobs.Count(); 242 244 exp.CalculatingCount = jobs.Count(j => j.State == JobState.Calculating); 243 245 exp.FinishedCount = jobs.Count(j => j.State == JobState.Finished); … … 575 577 public Guid GetExperimentForJob(Guid jobId) { 576 578 using (var db = CreateContext()) { 577 var job = db.Jobs.SingleOrDefault(j => j.JobId == jobId); 578 if (job.ParentJobId.HasValue) { 579 return GetExperimentForJob(job.ParentJobId.Value); 580 } else { 581 return db.HiveExperiments.SingleOrDefault(he => he.RootJobId == jobId).HiveExperimentId; 582 } 579 return db.Jobs.Single(j => j.JobId == jobId).HiveExperimentId; 583 580 } 584 581 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.dbml
r5779 r6006 70 70 <Column Name="FinishWhenChildJobsFinished" Type="System.Boolean" DbType="Bit" CanBeNull="false" /> 71 71 <Column Name="Command" Type="global::HeuristicLab.Services.Hive.Common.DataTransfer.Command?" DbType="VarChar(30)" CanBeNull="true" /> 72 <Column Name="HiveExperimentId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" CanBeNull="false" /> 72 73 <Association Name="Job_AssignedResource" Member="AssignedResources" ThisKey="JobId" OtherKey="JobId" Type="AssignedResource" /> 73 74 <Association Name="Job_RequiredPlugin" Member="RequiredPlugins" ThisKey="JobId" OtherKey="JobId" Type="RequiredPlugin" /> … … 76 77 <Association Name="Job_StateLog" Member="StateLogs" ThisKey="JobId" OtherKey="JobId" Type="StateLog" /> 77 78 <Association Name="Job_Job" Member="ParentJob" Storage="_Job1" ThisKey="ParentJobId" OtherKey="JobId" Type="Job" IsForeignKey="true" /> 79 <Association Name="HiveExperiment_Job" Member="HiveExperiment" ThisKey="HiveExperimentId" OtherKey="HiveExperimentId" Type="HiveExperiment" IsForeignKey="true" /> 78 80 </Type> 79 81 </Table> … … 97 99 <Column Name="ResourceIds" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" /> 98 100 <Column Name="OwnerUserId" Storage="_UserId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="false" /> 99 <Column Name="RootJobId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="false" />100 101 <Column Name="DateCreated" Type="System.DateTime" DbType="DateTime" CanBeNull="false" /> 101 102 <Column Name="LastAccessed" Type="System.DateTime" DbType="DateTime" CanBeNull="true" /> 102 103 <Column Name="IsHiveEngine" Type="System.Boolean" DbType="Bit" CanBeNull="false" /> 103 104 <Association Name="HiveExperiment_HiveExperimentPermission" Member="HiveExperimentPermissions" ThisKey="HiveExperimentId" OtherKey="HiveExperimentId" Type="HiveExperimentPermission" /> 104 <Association Name=" Job_HiveExperiment" Member="RootJob" Storage="_Job" ThisKey="RootJobId" OtherKey="JobId" Type="Job" IsForeignKey="true" DeleteRule="CASCADE" />105 <Association Name="HiveExperiment_Job" Member="Jobs" ThisKey="HiveExperimentId" OtherKey="HiveExperimentId" Type="Job" /> 105 106 </Type> 106 107 </Table> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.dbml.layout
r5779 r6006 27 27 </nestedChildShapes> 28 28 </classShape> 29 <classShape Id="695bfc39-59f3-4e60-8644-f847964bf62c" absoluteBounds="6.5, 1, 2, 2.9247054036458331">29 <classShape Id="695bfc39-59f3-4e60-8644-f847964bf62c" absoluteBounds="6.5, 1, 2, 3.1170068359374996"> 30 30 <DataClassMoniker Name="/HiveDataContext/Job" /> 31 31 <nestedChildShapes> 32 <elementListCompartment Id="a6a30e11-03d1-4869-82e6-b733f4ef9974" absoluteBounds="6.5150000000000006, 1.46, 1.9700000000000002, 2. 364705403645833" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />32 <elementListCompartment Id="a6a30e11-03d1-4869-82e6-b733f4ef9974" absoluteBounds="6.5150000000000006, 1.46, 1.9700000000000002, 2.5570068359375" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 33 33 </nestedChildShapes> 34 34 </classShape> … … 39 39 </nestedChildShapes> 40 40 </classShape> 41 <classShape Id="e6f840cc-2968-4be1-b234-eef624ccacbb" absoluteBounds="4.125, 2.625, 2, 2. 5401025390624996">41 <classShape Id="e6f840cc-2968-4be1-b234-eef624ccacbb" absoluteBounds="4.125, 2.625, 2, 2.3478011067708326"> 42 42 <DataClassMoniker Name="/HiveDataContext/HiveExperiment" /> 43 43 <nestedChildShapes> 44 <elementListCompartment Id="0c65d4e1-256a-4a91-9a57-392f25e4de7f" absoluteBounds="4.1400000000000006, 3.0850000000000009, 1.9700000000000002, 1. 9801025390625" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />44 <elementListCompartment Id="0c65d4e1-256a-4a91-9a57-392f25e4de7f" absoluteBounds="4.1400000000000006, 3.0850000000000009, 1.9700000000000002, 1.7878011067708333" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 45 45 </nestedChildShapes> 46 46 </classShape> … … 76 76 </nodes> 77 77 </associationConnector> 78 <associationConnector edgePoints="[(7. 98437325 : 3.92470540364583); (7.98437325 : 4.59300017447917); (8.875 : 4.59300017447917)]" fixedFrom="Algorithm" fixedTo="Algorithm">78 <associationConnector edgePoints="[(7.8398428125 : 4.1170068359375); (7.8398428125 : 4.689150890625); (8.875 : 4.689150890625)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 79 79 <AssociationMoniker Name="/HiveDataContext/Job/Job_AssignedResource" /> 80 80 <nodes> … … 83 83 </nodes> 84 84 </associationConnector> 85 <associationConnector edgePoints="[(7.1 79686625 : 3.92470540364583); (7.179686625 : 5.5)]" fixedFrom="Algorithm" fixedTo="Algorithm">85 <associationConnector edgePoints="[(7.10742140625 : 4.1170068359375); (7.10742140625 : 5.5)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 86 86 <AssociationMoniker Name="/HiveDataContext/Job/Job_RequiredPlugin" /> 87 87 <nodes> … … 102 102 <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" /> 103 103 <classShapeMoniker Id="8d5712f7-7a1a-4a89-bd4d-fd60200d3306" /> 104 </nodes>105 </associationConnector>106 <associationConnector edgePoints="[(6.5 : 3.27485270182292); (6.125 : 3.27485270182292)]" fixedFrom="Algorithm" fixedTo="Algorithm">107 <AssociationMoniker Name="/HiveDataContext/Job/Job_HiveExperiment" />108 <nodes>109 <classShapeMoniker Id="695bfc39-59f3-4e60-8644-f847964bf62c" />110 <classShapeMoniker Id="e6f840cc-2968-4be1-b234-eef624ccacbb" />111 104 </nodes> 112 105 </associationConnector> … … 177 170 </nodes> 178 171 </associationConnector> 179 <associationConnector edgePoints="[(4.125 : 4. 39505126953125); (3.75 : 4.39505126953125)]" fixedFrom="NotFixed" fixedTo="NotFixed">172 <associationConnector edgePoints="[(4.125 : 4.29890055338542); (3.75 : 4.29890055338542)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 180 173 <AssociationMoniker Name="/HiveDataContext/HiveExperiment/HiveExperiment_HiveExperimentPermission" /> 181 174 <nodes> … … 190 183 </nestedChildShapes> 191 184 </classShape> 185 <associationConnector edgePoints="[(6.125 : 3.37100341796875); (6.5 : 3.37100341796875)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 186 <AssociationMoniker Name="/HiveDataContext/HiveExperiment/HiveExperiment_Job" /> 187 <nodes> 188 <classShapeMoniker Id="e6f840cc-2968-4be1-b234-eef624ccacbb" /> 189 <classShapeMoniker Id="695bfc39-59f3-4e60-8644-f847964bf62c" /> 190 </nodes> 191 </associationConnector> 192 192 </nestedChildShapes> 193 193 </ordesignerObjectsDiagram> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.designer.cs
r5779 r6006 1424 1424 private global::HeuristicLab.Services.Hive.Common.DataTransfer.Command? _Command; 1425 1425 1426 private System.Guid _HiveExperimentId; 1427 1426 1428 private EntitySet<AssignedResource> _AssignedResources; 1427 1429 … … 1435 1437 1436 1438 private EntityRef<Job> _Job1; 1439 1440 private EntityRef<HiveExperiment> _HiveExperiment; 1437 1441 1438 1442 #region Extensibility Method Definitions … … 1462 1466 partial void OnCommandChanging(global::HeuristicLab.Services.Hive.Common.DataTransfer.Command? value); 1463 1467 partial void OnCommandChanged(); 1468 partial void OnHiveExperimentIdChanging(System.Guid value); 1469 partial void OnHiveExperimentIdChanged(); 1464 1470 #endregion 1465 1471 … … 1472 1478 this._StateLogs = new EntitySet<StateLog>(new Action<StateLog>(this.attach_StateLogs), new Action<StateLog>(this.detach_StateLogs)); 1473 1479 this._Job1 = default(EntityRef<Job>); 1480 this._HiveExperiment = default(EntityRef<HiveExperiment>); 1474 1481 OnCreated(); 1475 1482 } … … 1699 1706 } 1700 1707 1708 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_HiveExperimentId", DbType="UniqueIdentifier NOT NULL")] 1709 public System.Guid HiveExperimentId 1710 { 1711 get 1712 { 1713 return this._HiveExperimentId; 1714 } 1715 set 1716 { 1717 if ((this._HiveExperimentId != value)) 1718 { 1719 if (this._HiveExperiment.HasLoadedOrAssignedValue) 1720 { 1721 throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); 1722 } 1723 this.OnHiveExperimentIdChanging(value); 1724 this.SendPropertyChanging(); 1725 this._HiveExperimentId = value; 1726 this.SendPropertyChanged("HiveExperimentId"); 1727 this.OnHiveExperimentIdChanged(); 1728 } 1729 } 1730 } 1731 1701 1732 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedResource", Storage="_AssignedResources", ThisKey="JobId", OtherKey="JobId")] 1702 1733 public EntitySet<AssignedResource> AssignedResources … … 1810 1841 } 1811 1842 this.SendPropertyChanged("ParentJob"); 1843 } 1844 } 1845 } 1846 1847 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="HiveExperiment_Job", Storage="_HiveExperiment", ThisKey="HiveExperimentId", OtherKey="HiveExperimentId", IsForeignKey=true)] 1848 public HiveExperiment HiveExperiment 1849 { 1850 get 1851 { 1852 return this._HiveExperiment.Entity; 1853 } 1854 set 1855 { 1856 HiveExperiment previousValue = this._HiveExperiment.Entity; 1857 if (((previousValue != value) 1858 || (this._HiveExperiment.HasLoadedOrAssignedValue == false))) 1859 { 1860 this.SendPropertyChanging(); 1861 if ((previousValue != null)) 1862 { 1863 this._HiveExperiment.Entity = null; 1864 previousValue.Jobs.Remove(this); 1865 } 1866 this._HiveExperiment.Entity = value; 1867 if ((value != null)) 1868 { 1869 value.Jobs.Add(this); 1870 this._HiveExperimentId = value.HiveExperimentId; 1871 } 1872 else 1873 { 1874 this._HiveExperimentId = default(System.Guid); 1875 } 1876 this.SendPropertyChanged("HiveExperiment"); 1812 1877 } 1813 1878 } … … 2146 2211 private System.Guid _UserId; 2147 2212 2148 private System.Guid _RootJobId;2149 2150 2213 private System.DateTime _DateCreated; 2151 2214 … … 2156 2219 private EntitySet<HiveExperimentPermission> _HiveExperimentPermissions; 2157 2220 2158 private Entity Ref<Job> _Job;2221 private EntitySet<Job> _Jobs; 2159 2222 2160 2223 #region Extensibility Method Definitions … … 2172 2235 partial void OnOwnerUserIdChanging(System.Guid value); 2173 2236 partial void OnOwnerUserIdChanged(); 2174 partial void OnRootJobIdChanging(System.Guid value);2175 partial void OnRootJobIdChanged();2176 2237 partial void OnDateCreatedChanging(System.DateTime value); 2177 2238 partial void OnDateCreatedChanged(); … … 2185 2246 { 2186 2247 this._HiveExperimentPermissions = new EntitySet<HiveExperimentPermission>(new Action<HiveExperimentPermission>(this.attach_HiveExperimentPermissions), new Action<HiveExperimentPermission>(this.detach_HiveExperimentPermissions)); 2187 this._Job = default(EntityRef<Job>);2248 this._Jobs = new EntitySet<Job>(new Action<Job>(this.attach_Jobs), new Action<Job>(this.detach_Jobs)); 2188 2249 OnCreated(); 2189 2250 } … … 2289 2350 } 2290 2351 2291 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_RootJobId", DbType="UniqueIdentifier")]2292 public System.Guid RootJobId2293 {2294 get2295 {2296 return this._RootJobId;2297 }2298 set2299 {2300 if ((this._RootJobId != value))2301 {2302 if (this._Job.HasLoadedOrAssignedValue)2303 {2304 throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();2305 }2306 this.OnRootJobIdChanging(value);2307 this.SendPropertyChanging();2308 this._RootJobId = value;2309 this.SendPropertyChanged("RootJobId");2310 this.OnRootJobIdChanged();2311 }2312 }2313 }2314 2315 2352 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_DateCreated", DbType="DateTime")] 2316 2353 public System.DateTime DateCreated … … 2386 2423 } 2387 2424 2388 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_HiveExperiment", Storage="_Job", ThisKey="RootJobId", OtherKey="JobId", IsForeignKey=true, DeleteRule="CASCADE")] 2389 public Job RootJob 2390 { 2391 get 2392 { 2393 return this._Job.Entity; 2394 } 2395 set 2396 { 2397 if ((this._Job.Entity != value)) 2398 { 2399 this.SendPropertyChanging(); 2400 this._Job.Entity = value; 2401 this.SendPropertyChanged("RootJob"); 2402 } 2425 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="HiveExperiment_Job", Storage="_Jobs", ThisKey="HiveExperimentId", OtherKey="HiveExperimentId")] 2426 public EntitySet<Job> Jobs 2427 { 2428 get 2429 { 2430 return this._Jobs; 2431 } 2432 set 2433 { 2434 this._Jobs.Assign(value); 2403 2435 } 2404 2436 } … … 2431 2463 2432 2464 private void detach_HiveExperimentPermissions(HiveExperimentPermission entity) 2465 { 2466 this.SendPropertyChanging(); 2467 entity.HiveExperiment = null; 2468 } 2469 2470 private void attach_Jobs(Job entity) 2471 { 2472 this.SendPropertyChanging(); 2473 entity.HiveExperiment = this; 2474 } 2475 2476 private void detach_Jobs(Job entity) 2433 2477 { 2434 2478 this.SendPropertyChanging(); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Tools/prepareHiveDatabase.sql
r5955 r6006 55 55 GO 56 56 57 --ALTER TABLE [dbo].[Job] DROP CONSTRAINT [HiveExperiment_Job] 58 --ALTER TABLE [dbo].[Job] WITH CHECK ADD CONSTRAINT [HiveExperiment_Job] FOREIGN KEY([HiveExperimentId]) 59 --REFERENCES [dbo].[HiveExperiment] ([HiveExperimentId]) 60 --ON UPDATE CASCADE 61 --ON DELETE CASCADE 62 --GO 63 57 64 ALTER TABLE dbo.Plugin ALTER COLUMN PluginId ADD ROWGUIDCOL; 58 65 ALTER TABLE dbo.Plugin WITH NOCHECK ADD CONSTRAINT [DF_Plugin_PluginId] DEFAULT (newid()) FOR PluginId; … … 107 114 -- ============================================= 108 115 -- Author: cneumuel 109 -- Create date: 11.11.2010 110 -- Description: Deletes the root-job of the experiment when experiment is deleted 116 -- Create date: 11.04.2011 117 -- Description: Deletes all associated jobs. This cannot be done with cascading delete, 118 -- because the job table defines a INSTEAD OF DELETE trigger itself, which 119 -- is not compatible with cascading deletes. 111 120 -- ============================================= 112 CREATE TRIGGER [dbo].[tr_HiveExperimentDeleteCascade] ON [dbo].[HiveExperiment] FORDELETE AS113 SET NOCOUNT ON114 DELETE Job FROM deleted, Job WHERE Job.JobId = deleted.RootJobId115 GO 121 ALTER TRIGGER [dbo].[tr_HiveExperimentDeleteCascade] ON [dbo].[HiveExperiment] INSTEAD OF DELETE AS 122 BEGIN 123 DELETE Job FROM Job WHERE Job.HiveExperimentId = HiveExperimentId 124 END 116 125 117 126 SET ANSI_NULLS ON
Note: See TracChangeset
for help on using the changeset viewer.