Free cookie consent management tool by TermsFeed Policy Generator

Changeset 967 for trunk


Ignore:
Timestamp:
12/11/08 15:50:22 (16 years ago)
Author:
msteinbi
Message:

Implementation of JobManager (#431)

Location:
trunk/sources
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Contracts/ApplicationConstants.cs

    r947 r967  
    4141    public static string RESPONSE_COMMUNICATOR_NO_JOBS_LEFT = "Communicator.NoJobsLeft";
    4242
     43    public static string RESPONSE_JOB_ALL_JOBS = "Job.AllJobs";
     44    public static string RESPONSE_JOB_ID_MUST_NOT_BE_SET = "Job.IdMustNotBeSet";
     45    public static string RESPONSE_JOB_JOB_ADDED = "Job.JobAdded";
     46    public static string RESPONSE_JOB_JOB_NULL = "Job.JobNull";
     47    public static string RESPONSE_JOB_JOB_DOESNT_EXIST = "JobDoesntExist";
     48    public static string RESPONSE_JOB_JOB_REMOVED = "Job.JobRemoved";
    4349  }
    4450}
  • trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/Job.cs

    r791 r967  
    3737    public ClientInfo Client { get; set; }
    3838    [DataMember]
    39     public Job parentJob { get; set; }
     39    public Job ParentJob { get; set; }
    4040  }
    4141}
  • trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/JobResult.cs

    r824 r967  
    3838    [DataMember]
    3939    public ClientInfo Client { get; set; }
    40 
     40    [DataMember]
     41    public Exception Exception { get; set; }
    4142  }
    4243}
  • trunk/sources/HeuristicLab.Hive.Contracts/HiveServerMessages.resx

    r947 r967  
    196196    <value>In this context the id must not be set</value>
    197197  </data>
     198  <data name="Job.AllJobs" xml:space="preserve">
     199    <value>All Jobs returned</value>
     200  </data>
     201  <data name="Job.IdMustNotBeSet" xml:space="preserve">
     202    <value>Id must not be set in this context</value>
     203  </data>
     204  <data name="Job.JobAdded" xml:space="preserve">
     205    <value>Job successfully added to database</value>
     206  </data>
     207  <data name="Job.JobNull" xml:space="preserve">
     208    <value>The job you sent was null</value>
     209  </data>
     210  <data name="Job.JobRemoved" xml:space="preserve">
     211    <value>Job successfully removed</value>
     212  </data>
     213  <data name="JobDoesntExist" xml:space="preserve">
     214    <value>The specified job doesn't exist</value>
     215  </data>
    198216</root>
  • trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/IJobManager.cs

    r902 r967  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2008 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
     22using System;
    223using System.Collections.Generic;
    324using System.Linq;
     
    1435    [OperationContract]
    1536    ResponseList<Job> GetAllJobs();
     37    [OperationContract]
     38    ResponseObject<Job> AddNewJob(Job job);
     39    [OperationContract]
     40    Response RemoveJob(long jobId);
    1641  }
    1742}
  • trunk/sources/HeuristicLab.Hive.Server.Core/JobManager.cs

    r907 r967  
    2727using HeuristicLab.Hive.Contracts.BusinessObjects;
    2828using HeuristicLab.Hive.Contracts;
     29using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
    2930
    3031namespace HeuristicLab.Hive.Server.Core {
    3132  class JobManager: IJobManager {
    3233
    33     List<Job> jobs;
     34    IJobAdapter jobAdapter;
    3435
    3536    #region IJobManager Members
    3637
    3738    public JobManager() {
    38       jobs = new List<Job>();
    39 
    40       jobs.Add(new Job { JobId = 1, State = State.idle });
    41       jobs.Add(new Job { JobId = 2, State = State.idle });
    42       jobs.Add(new Job { JobId = 3, State = State.idle });
     39      jobAdapter = ServiceLocator.GetJobAdapter();
    4340    }
    4441
    4542    public ResponseList<Job> GetAllJobs() {
    4643      ResponseList<Job> response = new ResponseList<Job>();
    47       response.List = jobs;
     44
     45      response.List = new List<Job>(jobAdapter.GetAllJobs());
     46      response.Success = true;
     47      response.StatusMessage = ApplicationConstants.RESPONSE_JOB_ALL_JOBS;
     48     
     49      return response;
     50    }
     51
     52    public ResponseObject<Job> AddNewJob(Job job) {
     53      ResponseObject<Job> response = new ResponseObject<Job>();
     54
     55      if (job != null) {
     56        if (job.JobId != 0) {
     57          response.Success = false;
     58          response.StatusMessage = ApplicationConstants.RESPONSE_JOB_ID_MUST_NOT_BE_SET;
     59          return response;
     60        }
     61        jobAdapter.UpdateJob(job);
     62        response.Success = true;
     63        response.Obj = job;
     64        response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_ADDED;
     65        return response;
     66      }
     67      response.Success = false;
     68      response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_NULL;
     69
     70      return response;
     71    }
     72
     73    public Response RemoveJob(long jobId) {
     74      Response response = new Response();
     75
     76      Job job = jobAdapter.GetJobById(jobId);
     77      if (job == null) {
     78        response.Success = false;
     79        response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_DOESNT_EXIST;
     80        return response;
     81      }
     82      jobAdapter.DeleteJob(job);
     83      response.Success = false;
     84      response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_REMOVED;
     85
    4886      return response;
    4987    }
  • trunk/sources/HeuristicLab.Hive.Server.Core/ServerConsoleFacade.cs

    r952 r967  
    6767      return jobManager.GetAllJobs();
    6868    }
     69    public ResponseObject<Job> AddNewJob(Job job) {
     70      throw new NotImplementedException();
     71    }
     72
     73    public Response RemoveJob(long jobId) {
     74      throw new NotImplementedException();
     75    }
    6976
    7077    #endregion
     
    109116
    110117    #endregion
     118
    111119  }
    112120}
Note: See TracChangeset for help on using the changeset viewer.