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;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Linq;
|
---|
25 | using System.Runtime.Serialization;
|
---|
26 | using HeuristicLab.Common;
|
---|
27 | using HeuristicLab.DataAccess;
|
---|
28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
29 |
|
---|
30 | namespace HeuristicLab.Hive.Contracts.BusinessObjects {
|
---|
31 |
|
---|
32 | [StorableClass]
|
---|
33 | [DataContract]
|
---|
34 | [Serializable]
|
---|
35 | public class JobDto : PersistableObject {
|
---|
36 | [Storable]
|
---|
37 | [DataMember]
|
---|
38 | public JobState State { get; set; }
|
---|
39 | [Storable]
|
---|
40 | [DataMember]
|
---|
41 | public Guid UserId { get; set; }
|
---|
42 | [Storable]
|
---|
43 | [DataMember]
|
---|
44 | public SlaveDto Slave { get; set; }
|
---|
45 | [Storable]
|
---|
46 | [DataMember]
|
---|
47 | public Guid? ParentJobId { get; set; }
|
---|
48 | [Storable]
|
---|
49 | [DataMember]
|
---|
50 | public TimeSpan ExecutionTime { get; set; }
|
---|
51 | [Storable]
|
---|
52 | [DataMember]
|
---|
53 | public String Exception { get; set; }
|
---|
54 | [Storable]
|
---|
55 | [DataMember]
|
---|
56 | public DateTime? DateCreated { get; set; }
|
---|
57 | [Storable]
|
---|
58 | [DataMember]
|
---|
59 | public DateTime? DateCalculated { get; set; }
|
---|
60 | [Storable]
|
---|
61 | [DataMember]
|
---|
62 | public DateTime? DateFinished { get; set; }
|
---|
63 | [Storable]
|
---|
64 | [DataMember]
|
---|
65 | public int Priority { get; set; }
|
---|
66 | [Storable]
|
---|
67 | [DataMember]
|
---|
68 | public int CoresNeeded { get; set; }
|
---|
69 | [Storable]
|
---|
70 | [DataMember]
|
---|
71 | public int MemoryNeeded { get; set; }
|
---|
72 | [Storable]
|
---|
73 | [DataMember]
|
---|
74 | public List<HivePluginInfoDto> PluginsNeeded { get; set; }
|
---|
75 | [Storable]
|
---|
76 | [DataMember]
|
---|
77 | public List<Guid> AssignedResourceIds { get; set; }
|
---|
78 | [Storable]
|
---|
79 | [DataMember]
|
---|
80 | public ProjectDto Project { get; set; }
|
---|
81 |
|
---|
82 | public override string ToString() {
|
---|
83 | return base.ToString() + "State: " + State + ", [Ressource : " + Slave + " ] , DateCreated: " + DateCreated + ", DateCalculated: " + DateCalculated +
|
---|
84 | "Priority: " + Priority + ", CoresNeeded: " + CoresNeeded + "AssignedResources: " + AssignedResourceIds;
|
---|
85 | }
|
---|
86 |
|
---|
87 | public JobDto() {
|
---|
88 | PluginsNeeded = new List<HivePluginInfoDto>();
|
---|
89 | AssignedResourceIds = new List<Guid>();
|
---|
90 | }
|
---|
91 | [StorableConstructor]
|
---|
92 | protected JobDto(bool deserializing) : base(deserializing) { }
|
---|
93 | protected JobDto(JobDto original, Cloner cloner)
|
---|
94 | : base(original, cloner) {
|
---|
95 | this.Id = original.Id;
|
---|
96 | this.AssignedResourceIds = new List<Guid>(original.AssignedResourceIds);
|
---|
97 | this.Slave = cloner.Clone(original.Slave);
|
---|
98 | this.CoresNeeded = original.CoresNeeded;
|
---|
99 | this.DateCalculated = original.DateCalculated;
|
---|
100 | this.DateCreated = original.DateCreated;
|
---|
101 | this.DateFinished = original.DateFinished;
|
---|
102 | this.Exception = original.Exception;
|
---|
103 | this.Id = original.Id;
|
---|
104 | this.MemoryNeeded = original.MemoryNeeded;
|
---|
105 | this.ParentJobId = original.ParentJobId;
|
---|
106 | this.ExecutionTime = original.ExecutionTime;
|
---|
107 | this.PluginsNeeded = (original.PluginsNeeded.Select(x => cloner.Clone(x))).ToList();
|
---|
108 | this.Priority = original.Priority;
|
---|
109 | this.Project = cloner.Clone(original.Project);
|
---|
110 | this.State = original.State;
|
---|
111 | this.UserId = original.UserId;
|
---|
112 | }
|
---|
113 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
114 | return new JobDto(this, cloner);
|
---|
115 | }
|
---|
116 | }
|
---|
117 | }
|
---|