Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 1160 was 1131, checked in by svonolfe, 15 years ago

fixed race condition issues, improved performance (#372)

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