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 Fields
|
---|
39 | dsHiveServer.PermissionOwnerDataTable data =
|
---|
40 | new dsHiveServer.PermissionOwnerDataTable();
|
---|
41 | #endregion
|
---|
42 |
|
---|
43 | #region Overrides
|
---|
44 | protected override PermissionOwner Convert(dsHiveServer.PermissionOwnerRow row,
|
---|
45 | PermissionOwner permOwner) {
|
---|
46 | if (row != null && permOwner != null) {
|
---|
47 | permOwner.Id = row.PermissionOwnerId;
|
---|
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 |
|
---|
59 | protected override dsHiveServer.PermissionOwnerRow Convert(PermissionOwner permOwner,
|
---|
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 | }
|
---|
68 |
|
---|
69 | protected override dsHiveServer.PermissionOwnerRow
|
---|
70 | InsertNewRow(PermissionOwner permOwner) {
|
---|
71 | dsHiveServer.PermissionOwnerRow row =
|
---|
72 | data.NewPermissionOwnerRow();
|
---|
73 |
|
---|
74 | data.AddPermissionOwnerRow(row);
|
---|
75 |
|
---|
76 | return row;
|
---|
77 | }
|
---|
78 |
|
---|
79 | protected override void
|
---|
80 | UpdateRow(dsHiveServer.PermissionOwnerRow row) {
|
---|
81 | adapter.Update(row);
|
---|
82 | }
|
---|
83 |
|
---|
84 | protected override IEnumerable<dsHiveServer.PermissionOwnerRow>
|
---|
85 | FindById(long id) {
|
---|
86 | return adapter.GetDataById(id);
|
---|
87 | }
|
---|
88 |
|
---|
89 | protected override IEnumerable<dsHiveServer.PermissionOwnerRow>
|
---|
90 | FindAll() {
|
---|
91 | return adapter.GetData();
|
---|
92 | }
|
---|
93 | #endregion
|
---|
94 |
|
---|
95 | #region IPermissionOwner Members
|
---|
96 |
|
---|
97 | public bool GetById(PermissionOwner permOwner) {
|
---|
98 | if (permOwner != null) {
|
---|
99 | dsHiveServer.PermissionOwnerRow row =
|
---|
100 | base.GetRowById(permOwner.Id);
|
---|
101 |
|
---|
102 | if(row != null) {
|
---|
103 | Convert(row, permOwner);
|
---|
104 |
|
---|
105 | return true;
|
---|
106 | }
|
---|
107 | }
|
---|
108 |
|
---|
109 | return false;
|
---|
110 | }
|
---|
111 |
|
---|
112 | public PermissionOwner GetByName(String name) {
|
---|
113 | if (name != null) {
|
---|
114 | return base.FindSingle(
|
---|
115 | delegate() {
|
---|
116 | return adapter.GetDataByName(name);
|
---|
117 | });
|
---|
118 | }
|
---|
119 |
|
---|
120 | return null;
|
---|
121 | }
|
---|
122 |
|
---|
123 | #endregion
|
---|
124 | }
|
---|
125 | }
|
---|