Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive_Milestone2/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/PermissionOwnerAdapter.cs @ 4501

Last change on this file since 4501 was 1530, checked in by gkronber, 16 years ago

Moved source files of plugins Hive ... Visualization.Test into version-specific sub-folders. #576

File size: 3.4 KB
Line 
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 {
31  class PermissionOwnerAdapter:
32    DataAdapterBase<
33      dsHiveServerTableAdapters.PermissionOwnerTableAdapter,
34      PermissionOwner,
35      dsHiveServer.PermissionOwnerRow>,
36    IPermissionOwnerAdapter {
37    #region Overrides
38    protected override PermissionOwner ConvertRow(dsHiveServer.PermissionOwnerRow row,
39      PermissionOwner permOwner) {
40      if (row != null && permOwner != null) {
41        permOwner.Id = row.PermissionOwnerId;
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
53    protected override dsHiveServer.PermissionOwnerRow ConvertObj(PermissionOwner permOwner,
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    }
62
63    protected override dsHiveServer.PermissionOwnerRow
64      InsertNewRow(PermissionOwner permOwner) {
65      dsHiveServer.PermissionOwnerDataTable data =
66        new dsHiveServer.PermissionOwnerDataTable();
67
68      dsHiveServer.PermissionOwnerRow row =
69        data.NewPermissionOwnerRow();
70
71      data.AddPermissionOwnerRow(row);
72
73      return row;
74    }
75
76    protected override void
77      UpdateRow(dsHiveServer.PermissionOwnerRow row) {
78      Adapter.Update(row);
79    }
80
81    protected override IEnumerable<dsHiveServer.PermissionOwnerRow>
82      FindById(long id) {
83      return Adapter.GetDataById(id);
84    }
85
86    protected override IEnumerable<dsHiveServer.PermissionOwnerRow>
87      FindAll() {
88      return Adapter.GetData();
89    }
90    #endregion
91
92    #region IPermissionOwner Members
93
94    public bool GetById(PermissionOwner permOwner) {
95      if (permOwner != null) {
96        dsHiveServer.PermissionOwnerRow row =
97          base.GetRowById(permOwner.Id);
98
99        if(row != null) {
100          Convert(row, permOwner);
101
102          return true;
103        }
104      }
105
106      return false;
107    }
108   
109    public PermissionOwner GetByName(String name) {
110      if (name != null) {
111        return base.FindSingle(
112          delegate() {
113            return Adapter.GetDataByName(name);
114          });
115      }
116
117      return null;
118    }
119
120    #endregion
121  }
122}
Note: See TracBrowser for help on using the repository browser.