[907] | 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 |
|
---|
| 22 | using System;
|
---|
[800] | 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Linq;
|
---|
| 25 | using System.Text;
|
---|
| 26 | using HeuristicLab.Hive.Contracts.Interfaces;
|
---|
| 27 | using HeuristicLab.Hive.Contracts.BusinessObjects;
|
---|
[902] | 28 | using HeuristicLab.Hive.Contracts;
|
---|
[967] | 29 | using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
|
---|
[800] | 30 |
|
---|
| 31 | namespace HeuristicLab.Hive.Server.Core {
|
---|
| 32 | class JobManager: IJobManager {
|
---|
[820] | 33 |
|
---|
[967] | 34 | IJobAdapter jobAdapter;
|
---|
[820] | 35 |
|
---|
[800] | 36 | #region IJobManager Members
|
---|
| 37 |
|
---|
[820] | 38 | public JobManager() {
|
---|
[967] | 39 | jobAdapter = ServiceLocator.GetJobAdapter();
|
---|
[820] | 40 | }
|
---|
| 41 |
|
---|
[902] | 42 | public ResponseList<Job> GetAllJobs() {
|
---|
[907] | 43 | ResponseList<Job> response = new ResponseList<Job>();
|
---|
[967] | 44 |
|
---|
| 45 | response.List = new List<Job>(jobAdapter.GetAllJobs());
|
---|
| 46 | response.Success = true;
|
---|
| 47 | response.StatusMessage = ApplicationConstants.RESPONSE_JOB_ALL_JOBS;
|
---|
| 48 |
|
---|
[907] | 49 | return response;
|
---|
[800] | 50 | }
|
---|
| 51 |
|
---|
[967] | 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 |
|
---|
| 86 | return response;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
[800] | 89 | #endregion
|
---|
| 90 | }
|
---|
| 91 | }
|
---|