Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/PermissionOwnerAdapter.cs @ 1346

Last change on this file since 1346 was 1175, checked in by svonolfe, 15 years ago

Refactored DAL, avoided possible race conditions (#372)

File size: 3.4 KB
RevLine 
[845]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;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26
27using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
28using HeuristicLab.Hive.Contracts.BusinessObjects;
29
30namespace HeuristicLab.Hive.Server.ADODataAccess {
[995]31  class PermissionOwnerAdapter:
32    DataAdapterBase<
33      dsHiveServerTableAdapters.PermissionOwnerTableAdapter,
34      PermissionOwner,
35      dsHiveServer.PermissionOwnerRow>,
36    IPermissionOwnerAdapter {
37    #region Overrides
[1131]38    protected override PermissionOwner ConvertRow(dsHiveServer.PermissionOwnerRow row,
[905]39      PermissionOwner permOwner) {
40      if (row != null && permOwner != null) {
[995]41        permOwner.Id = row.PermissionOwnerId;
[905]42
43        if (!row.IsNameNull())
44          permOwner.Name = row.Name;
45        else
46          permOwner.Name = String.Empty;
47
48        return permOwner;
49      } else
50        return null;
51    }
52
[1131]53    protected override dsHiveServer.PermissionOwnerRow ConvertObj(PermissionOwner permOwner,
[905]54      dsHiveServer.PermissionOwnerRow row) {
55      if (row != null && permOwner != null) {
56        row.Name = permOwner.Name;
57
58        return row;
59      } else
60        return null;
61    }
[925]62
[995]63    protected override dsHiveServer.PermissionOwnerRow
64      InsertNewRow(PermissionOwner permOwner) {
[1166]65      dsHiveServer.PermissionOwnerDataTable data =
66        new dsHiveServer.PermissionOwnerDataTable();
67
[995]68      dsHiveServer.PermissionOwnerRow row =
69        data.NewPermissionOwnerRow();
[845]70
[995]71      data.AddPermissionOwnerRow(row);
72
73      return row;
[845]74    }
75
[995]76    protected override void
77      UpdateRow(dsHiveServer.PermissionOwnerRow row) {
[1131]78      Adapter.Update(row);
[995]79    }
80
81    protected override IEnumerable<dsHiveServer.PermissionOwnerRow>
82      FindById(long id) {
[1131]83      return Adapter.GetDataById(id);
[995]84    }
85
86    protected override IEnumerable<dsHiveServer.PermissionOwnerRow>
87      FindAll() {
[1131]88      return Adapter.GetData();
[995]89    }
90    #endregion
91
92    #region IPermissionOwner Members
93
94    public bool GetById(PermissionOwner permOwner) {
[899]95      if (permOwner != null) {
[995]96        dsHiveServer.PermissionOwnerRow row =
97          base.GetRowById(permOwner.Id);
[925]98
99        if(row != null) {
[905]100          Convert(row, permOwner);
101
[899]102          return true;
[905]103        }
[899]104      }
105
106      return false;
107    }
[995]108   
109    public PermissionOwner GetByName(String name) {
110      if (name != null) {
111        return base.FindSingle(
112          delegate() {
[1131]113            return Adapter.GetDataByName(name);
[995]114          });
[925]115      }
116
[995]117      return null;
[845]118    }
119
120    #endregion
121  }
122}
Note: See TracBrowser for help on using the repository browser.