Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/28/10 14:52:56 (13 years ago)
Author:
cneumuel
Message:
  • moved db-context into datalayer
  • businesslayer only defines the transaction-scope
  • removed contextfactory
  • implemented convert-methods
  • made naming in db and domainobjects more consistent
  • changed wcf-service to be http-only (for now)

(#1233)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/Convert.cs

    r4598 r4649  
    2424using System.Linq;
    2525using DT = HeuristicLab.Services.Hive.Common.DataTransfer;
     26using System;
    2627
    2728namespace HeuristicLab.Services.Hive.DataAccess {
    2829  public static class Convert {
    29 
    30    
    3130    #region Job
    3231    public static DT.Job ToDto(Job source) {
    3332      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      };
    3549    }
    3650    public static Job ToEntity(DT.Job source) {
    3751      if (source == null) return null;
    38       return new Job { JobId = source.Id };// todo
     52      var entity = new Job(); ToEntity(source, entity);
     53      return entity;
    3954    }
    4055    public static void ToEntity(DT.Job source, Job target) {
    4156      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;
    4371      }
    4472    }
     
    4876    public static DT.JobData ToDto(JobData source) {
    4977      if (source == null) return null;
    50       return new DT.JobData { JobId = source.JobId };// todo
     78      return new DT.JobData { JobId = source.JobId, Data = source.Data.ToArray() };
    5179    }
    5280    public static JobData ToEntity(DT.JobData source) {
    5381      if (source == null) return null;
    54       return new JobData { JobId = source.Id };// todo
     82      var entity = new JobData(); ToEntity(source, entity);
     83      return entity;
    5584    }
    5685    public static void ToEntity(DT.JobData source, JobData target) {
    5786      if ((source != null) && (target != null)) {
    58         target.JobId = source.Id;// todo
     87        target.JobId = source.JobId; target.Data = new Binary(source.Data);
    5988      }
    6089    }
    6190    #endregion
    62    
     91
    6392    #region HiveExperiment
    6493    public static DT.HiveExperiment ToDto(HiveExperiment source) {
    6594      if (source == null) return null;
    66       return new DT.HiveExperiment { Id = source.HiveExperimentId };// todo
     95      return new DT.HiveExperiment { Id = source.HiveExperimentId, Description = source.Description, Name = source.Name, RootJobId = source.RootJobId, UserId = source.UserId };
    6796    }
    6897    public static HiveExperiment ToEntity(DT.HiveExperiment source) {
    6998      if (source == null) return null;
    70       return new HiveExperiment { HiveExperimentId = source.Id };// todo
     99      var entity = new HiveExperiment(); ToEntity(source, entity);
     100      return entity;
    71101    }
    72102    public static void ToEntity(DT.HiveExperiment source, HiveExperiment target) {
    73103      if ((source != null) && (target != null)) {
    74         target.HiveExperimentId = source.Id;// todo
     104        target.HiveExperimentId = source.Id; target.Description = source.Description; target.Name = source.Name; target.RootJobId = source.RootJobId; target.UserId = source.UserId;
    75105      }
    76106    }
     
    80110    public static DT.Slave ToDto(Slave source) {
    81111      if (source == null) return null;
    82       return new DT.Slave { Id = source.ResourceId };// todo
     112      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 };
    83113    }
    84114    public static Slave ToEntity(DT.Slave source) {
    85115      if (source == null) return null;
    86       return new Slave { ResourceId = source.Id };// todo
     116      var entity = new Slave(); ToEntity(source, entity);
     117      return entity;
    87118    }
    88119    public static void ToEntity(DT.Slave source, Slave target) {
    89120      if ((source != null) && (target != null)) {
    90         target.ResourceId = source.Id;// todo
     121        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;
    91122      }
    92123    }
     
    96127    public static DT.SlaveGroup ToDto(SlaveGroup source) {
    97128      if (source == null) return null;
    98       return new DT.SlaveGroup { Id = source.ResourceId };// todo
     129      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() };
    99130    }
    100131    public static SlaveGroup ToEntity(DT.SlaveGroup source) {
    101132      if (source == null) return null;
    102       return new SlaveGroup { ResourceId = source.Id };// todo
     133      var entity = new SlaveGroup(); ToEntity(source, entity);
     134      return entity;
    103135    }
    104136    public static void ToEntity(DT.SlaveGroup source, SlaveGroup target) {
    105137      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 =
    107142      }
    108143    }
     
    112147    public static DT.Resource ToDto(Resource source) {
    113148      if (source == null) return null;
    114       return new DT.Resource { Id = source.ResourceId };// todo
     149      return new DT.Resource { Id = source.ResourceId, Name = source.Name };
    115150    }
    116151    public static Resource ToEntity(DT.Resource source) {
    117152      if (source == null) return null;
    118       return new Resource { ResourceId = source.Id };// todo
     153      var entity = new Resource(); ToEntity(source, entity);
     154      return entity;
    119155    }
    120156    public static void ToEntity(DT.Resource source, Resource target) {
    121157      if ((source != null) && (target != null)) {
    122         target.ResourceId = source.Id;// todo
     158        target.ResourceId = source.Id; target.Name = source.Name;
    123159      }
    124160    }
Note: See TracChangeset for help on using the changeset viewer.