1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System.Collections.Generic;
|
---|
23 | using System.Data.Linq;
|
---|
24 | using System.Linq;
|
---|
25 | using DT = HeuristicLab.Services.Hive.Common.DataTransfer;
|
---|
26 |
|
---|
27 | namespace HeuristicLab.Services.Hive.DataAccess {
|
---|
28 | public static class Convert {
|
---|
29 |
|
---|
30 |
|
---|
31 | #region Job
|
---|
32 | public static DT.Job ToDto(Job source) {
|
---|
33 | if (source == null) return null;
|
---|
34 | return new DT.Job { Id = source.JobId };// todo
|
---|
35 | }
|
---|
36 | public static Job ToEntity(DT.Job source) {
|
---|
37 | if (source == null) return null;
|
---|
38 | return new Job { JobId = source.Id };// todo
|
---|
39 | }
|
---|
40 | public static void ToEntity(DT.Job source, Job target) {
|
---|
41 | if ((source != null) && (target != null)) {
|
---|
42 | target.JobId = source.Id;// todo
|
---|
43 | }
|
---|
44 | }
|
---|
45 | #endregion
|
---|
46 |
|
---|
47 | #region JobData
|
---|
48 | public static DT.JobData ToDto(JobData source) {
|
---|
49 | if (source == null) return null;
|
---|
50 | return new DT.JobData { JobId = source.JobId };// todo
|
---|
51 | }
|
---|
52 | public static JobData ToEntity(DT.JobData source) {
|
---|
53 | if (source == null) return null;
|
---|
54 | return new JobData { JobId = source.Id };// todo
|
---|
55 | }
|
---|
56 | public static void ToEntity(DT.JobData source, JobData target) {
|
---|
57 | if ((source != null) && (target != null)) {
|
---|
58 | target.JobId = source.Id;// todo
|
---|
59 | }
|
---|
60 | }
|
---|
61 | #endregion
|
---|
62 |
|
---|
63 | #region HiveExperiment
|
---|
64 | public static DT.HiveExperiment ToDto(HiveExperiment source) {
|
---|
65 | if (source == null) return null;
|
---|
66 | return new DT.HiveExperiment { Id = source.HiveExperimentId };// todo
|
---|
67 | }
|
---|
68 | public static HiveExperiment ToEntity(DT.HiveExperiment source) {
|
---|
69 | if (source == null) return null;
|
---|
70 | return new HiveExperiment { HiveExperimentId = source.Id };// todo
|
---|
71 | }
|
---|
72 | public static void ToEntity(DT.HiveExperiment source, HiveExperiment target) {
|
---|
73 | if ((source != null) && (target != null)) {
|
---|
74 | target.HiveExperimentId = source.Id;// todo
|
---|
75 | }
|
---|
76 | }
|
---|
77 | #endregion
|
---|
78 |
|
---|
79 | #region Slave
|
---|
80 | public static DT.Slave ToDto(Slave source) {
|
---|
81 | if (source == null) return null;
|
---|
82 | return new DT.Slave { Id = source.ResourceId };// todo
|
---|
83 | }
|
---|
84 | public static Slave ToEntity(DT.Slave source) {
|
---|
85 | if (source == null) return null;
|
---|
86 | return new Slave { ResourceId = source.Id };// todo
|
---|
87 | }
|
---|
88 | public static void ToEntity(DT.Slave source, Slave target) {
|
---|
89 | if ((source != null) && (target != null)) {
|
---|
90 | target.ResourceId = source.Id;// todo
|
---|
91 | }
|
---|
92 | }
|
---|
93 | #endregion
|
---|
94 |
|
---|
95 | #region SlaveGroup
|
---|
96 | public static DT.SlaveGroup ToDto(SlaveGroup source) {
|
---|
97 | if (source == null) return null;
|
---|
98 | return new DT.SlaveGroup { Id = source.ResourceId };// todo
|
---|
99 | }
|
---|
100 | public static SlaveGroup ToEntity(DT.SlaveGroup source) {
|
---|
101 | if (source == null) return null;
|
---|
102 | return new SlaveGroup { ResourceId = source.Id };// todo
|
---|
103 | }
|
---|
104 | public static void ToEntity(DT.SlaveGroup source, SlaveGroup target) {
|
---|
105 | if ((source != null) && (target != null)) {
|
---|
106 | target.ResourceId = source.Id;// todo
|
---|
107 | }
|
---|
108 | }
|
---|
109 | #endregion
|
---|
110 |
|
---|
111 | #region Resource
|
---|
112 | public static DT.Resource ToDto(Resource source) {
|
---|
113 | if (source == null) return null;
|
---|
114 | return new DT.Resource { Id = source.ResourceId };// todo
|
---|
115 | }
|
---|
116 | public static Resource ToEntity(DT.Resource source) {
|
---|
117 | if (source == null) return null;
|
---|
118 | return new Resource { ResourceId = source.Id };// todo
|
---|
119 | }
|
---|
120 | public static void ToEntity(DT.Resource source, Resource target) {
|
---|
121 | if ((source != null) && (target != null)) {
|
---|
122 | target.ResourceId = source.Id;// todo
|
---|
123 | }
|
---|
124 | }
|
---|
125 | #endregion
|
---|
126 | }
|
---|
127 | }
|
---|