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