Changeset 4649 for branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/Convert.cs
- Timestamp:
- 10/28/10 14:52:56 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/Convert.cs
r4598 r4649 24 24 using System.Linq; 25 25 using DT = HeuristicLab.Services.Hive.Common.DataTransfer; 26 using System; 26 27 27 28 namespace HeuristicLab.Services.Hive.DataAccess { 28 29 public static class Convert { 29 30 31 30 #region Job 32 31 public static DT.Job ToDto(Job source) { 33 32 if (source == null) return null; 34 return new DT.Job { Id = source.JobId };// todo 33 return new DT.Job { 34 Id = source.JobId, 35 CoresNeeded = source.CoresNeeded, 36 DateCalculated = source.DateCalculated, 37 DateCreated = source.DateCreated, 38 DateFinished = source.DateFinished, 39 Exception = source.Exception, 40 ExecutionTime = source.ExecutionTime, 41 MemoryNeeded = source.MemoryNeeded, 42 ParentJobId = source.ParentJobId, 43 Priority = source.Priority, 44 ProjectId = source.ProjectId, 45 SlaveId = source.SlaveId, 46 JobState = source.JobState, 47 UserId = source.UserId 48 }; 35 49 } 36 50 public static Job ToEntity(DT.Job source) { 37 51 if (source == null) return null; 38 return new Job { JobId = source.Id };// todo 52 var entity = new Job(); ToEntity(source, entity); 53 return entity; 39 54 } 40 55 public static void ToEntity(DT.Job source, Job target) { 41 56 if ((source != null) && (target != null)) { 42 target.JobId = source.Id;// todo 57 target.JobId = source.Id; 58 target.CoresNeeded = source.CoresNeeded; 59 target.DateCalculated = source.DateCalculated; 60 target.DateCreated = source.DateCreated; 61 target.DateFinished = source.DateFinished; 62 target.Exception = source.Exception; 63 target.ExecutionTime = source.ExecutionTime; 64 target.MemoryNeeded = source.MemoryNeeded; 65 target.ParentJobId = source.ParentJobId; 66 target.Priority = source.Priority; 67 target.ProjectId = source.ProjectId; 68 target.SlaveId = source.SlaveId; 69 target.JobState = source.JobState; 70 target.UserId = source.UserId; 43 71 } 44 72 } … … 48 76 public static DT.JobData ToDto(JobData source) { 49 77 if (source == null) return null; 50 return new DT.JobData { JobId = source.JobId };// todo78 return new DT.JobData { JobId = source.JobId, Data = source.Data.ToArray() }; 51 79 } 52 80 public static JobData ToEntity(DT.JobData source) { 53 81 if (source == null) return null; 54 return new JobData { JobId = source.Id };// todo 82 var entity = new JobData(); ToEntity(source, entity); 83 return entity; 55 84 } 56 85 public static void ToEntity(DT.JobData source, JobData target) { 57 86 if ((source != null) && (target != null)) { 58 target.JobId = source. Id;// todo87 target.JobId = source.JobId; target.Data = new Binary(source.Data); 59 88 } 60 89 } 61 90 #endregion 62 91 63 92 #region HiveExperiment 64 93 public static DT.HiveExperiment ToDto(HiveExperiment source) { 65 94 if (source == null) return null; 66 return new DT.HiveExperiment { Id = source.HiveExperimentId };// todo95 return new DT.HiveExperiment { Id = source.HiveExperimentId, Description = source.Description, Name = source.Name, RootJobId = source.RootJobId, UserId = source.UserId }; 67 96 } 68 97 public static HiveExperiment ToEntity(DT.HiveExperiment source) { 69 98 if (source == null) return null; 70 return new HiveExperiment { HiveExperimentId = source.Id };// todo 99 var entity = new HiveExperiment(); ToEntity(source, entity); 100 return entity; 71 101 } 72 102 public static void ToEntity(DT.HiveExperiment source, HiveExperiment target) { 73 103 if ((source != null) && (target != null)) { 74 target.HiveExperimentId = source.Id; // todo104 target.HiveExperimentId = source.Id; target.Description = source.Description; target.Name = source.Name; target.RootJobId = source.RootJobId; target.UserId = source.UserId; 75 105 } 76 106 } … … 80 110 public static DT.Slave ToDto(Slave source) { 81 111 if (source == null) return null; 82 return new DT.Slave { Id = source.ResourceId };// todo112 return new DT.Slave { Id = source.ResourceId, CalendarSyncState = source.CalendarSyncState, Cores = source.Cores, CpuSpeed = source.CpuSpeed, FreeCores = source.FreeCores, FreeMemory = source.FreeMemory, IsAllowedToCalculate = source.IsAllowedToCalculate, Memory = source.Memory, Name = source.Name, SlaveConfigId = source.SlaveConfigId, SlaveState = source.SlaveState }; 83 113 } 84 114 public static Slave ToEntity(DT.Slave source) { 85 115 if (source == null) return null; 86 return new Slave { ResourceId = source.Id };// todo 116 var entity = new Slave(); ToEntity(source, entity); 117 return entity; 87 118 } 88 119 public static void ToEntity(DT.Slave source, Slave target) { 89 120 if ((source != null) && (target != null)) { 90 target.ResourceId = source.Id; // todo121 target.ResourceId = source.Id; target.CalendarSyncState = source.CalendarSyncState; target.Cores = source.Cores; target.CpuSpeed = source.CpuSpeed; target.FreeCores = source.FreeCores; target.FreeMemory = source.FreeMemory; target.IsAllowedToCalculate = source.IsAllowedToCalculate; target.Memory = source.Memory; target.Name = source.Name; target.SlaveConfigId = source.SlaveConfigId; target.SlaveState = source.SlaveState; 91 122 } 92 123 } … … 96 127 public static DT.SlaveGroup ToDto(SlaveGroup source) { 97 128 if (source == null) return null; 98 return new DT.SlaveGroup { Id = source.ResourceId };// todo129 return new DT.SlaveGroup { Id = source.ResourceId, Name = source.Name, ChildResourcesIds = source.SlaveGroup_Resources_Children.Select(x => x.ResourceId).ToList(), ParentResourcesIds = source.SlaveGroup_Resources_Parents.Select(x => x.ResourceId).ToList() }; 99 130 } 100 131 public static SlaveGroup ToEntity(DT.SlaveGroup source) { 101 132 if (source == null) return null; 102 return new SlaveGroup { ResourceId = source.Id };// todo 133 var entity = new SlaveGroup(); ToEntity(source, entity); 134 return entity; 103 135 } 104 136 public static void ToEntity(DT.SlaveGroup source, SlaveGroup target) { 105 137 if ((source != null) && (target != null)) { 106 target.ResourceId = source.Id;// todo 138 target.ResourceId = source.Id; 139 target.Name = source.Name; 140 //target.SlaveGroup_Resources_Children = // TODO: see how working with groups will work, then decide how to handle enumerations in here 141 //target.SlaveGroup_Resources_Parents = 107 142 } 108 143 } … … 112 147 public static DT.Resource ToDto(Resource source) { 113 148 if (source == null) return null; 114 return new DT.Resource { Id = source.ResourceId };// todo149 return new DT.Resource { Id = source.ResourceId, Name = source.Name }; 115 150 } 116 151 public static Resource ToEntity(DT.Resource source) { 117 152 if (source == null) return null; 118 return new Resource { ResourceId = source.Id };// todo 153 var entity = new Resource(); ToEntity(source, entity); 154 return entity; 119 155 } 120 156 public static void ToEntity(DT.Resource source, Resource target) { 121 157 if ((source != null) && (target != null)) { 122 target.ResourceId = source.Id; // todo158 target.ResourceId = source.Id; target.Name = source.Name; 123 159 } 124 160 }
Note: See TracChangeset
for help on using the changeset viewer.