Coverage Summary for Class: SQLResult (com.acciente.oacc.sql.internal.persister)
Class | Class, % | Method, % | Line, % |
---|---|---|---|
SQLResult | 100% (1/ 1) | 85% (17/ 20) | 87% (20/ 23) |
1 /*
2 * Copyright 2009-2018, Acciente LLC
3 *
4 * Acciente LLC licenses this file to you under the
5 * Apache License, Version 2.0 (the "License"); you
6 * may not use this file except in compliance with the
7 * License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in
12 * writing, software distributed under the License is
13 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
14 * OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing
16 * permissions and limitations under the License.
17 */
18 package com.acciente.oacc.sql.internal.persister;
19
20 import com.acciente.oacc.DomainCreatePermissions;
21 import com.acciente.oacc.DomainPermissions;
22 import com.acciente.oacc.Resource;
23 import com.acciente.oacc.ResourceCreatePermissions;
24 import com.acciente.oacc.ResourcePermissions;
25 import com.acciente.oacc.Resources;
26 import com.acciente.oacc.sql.internal.persister.id.DomainId;
27 import com.acciente.oacc.sql.internal.persister.id.Id;
28 import com.acciente.oacc.sql.internal.persister.id.ResourceClassId;
29 import com.acciente.oacc.sql.internal.persister.id.ResourceId;
30 import com.acciente.oacc.sql.internal.persister.id.ResourcePermissionId;
31
32 import java.sql.ResultSet;
33 import java.sql.SQLException;
34
35 public class SQLResult {
36 private final ResultSet resultSet;
37
38 SQLResult(ResultSet resultSet) {
39 this.resultSet = resultSet;
40 }
41
42 public Id<ResourceId> getResourceId(String columnLabel) throws SQLException {
43 return Id.from(resultSet.getLong(columnLabel));
44 }
45
46 public Resource getResource(String columnLabel) throws SQLException {
47 return Resources.getInstance(resultSet.getLong(columnLabel));
48 }
49
50 public Resource getResource(String resourceIdColumnLabel, String externalIdColumnLabel) throws SQLException {
51 return Resources.getInstance(resultSet.getLong(resourceIdColumnLabel),
52 resultSet.getString(externalIdColumnLabel));
53 }
54
55 public Id<ResourceId> getNextResourceId(int columnIndex) throws SQLException {
56 return Id.from(resultSet.getLong(columnIndex));
57 }
58
59 public Id<ResourceClassId> getResourceClassId(String columnLabel) throws SQLException {
60 return Id.from(resultSet.getLong(columnLabel));
61 }
62
63 public Id<DomainId> getResourceDomainId(String columnLabel) throws SQLException {
64 return Id.from(resultSet.getLong(columnLabel));
65 }
66
67 public Id<ResourcePermissionId> getResourcePermissionId(String columnLabel) throws SQLException {
68 return Id.from(resultSet.getLong(columnLabel));
69 }
70
71 public String getResourceCreateSysPermissionName(String columnLabel) throws SQLException {
72 return ResourceCreatePermissions.getSysPermissionName(resultSet.getLong(columnLabel));
73 }
74
75 public String getResourceSysPermissionName(String columnLabel) throws SQLException {
76 return ResourcePermissions.getSysPermissionName(resultSet.getLong(columnLabel));
77 }
78
79 public String getDomainCreateSysPermissionName(String columnLabel) throws SQLException {
80 return DomainCreatePermissions.getSysPermissionName(resultSet.getLong(columnLabel));
81 }
82
83 public String getDomainSysPermissionName(String columnLabel) throws SQLException {
84 return DomainPermissions.getSysPermissionName(resultSet.getLong(columnLabel));
85 }
86
87 public Long getSysPermissionId(String columnLabel) throws SQLException {
88 return resultSet.getLong(columnLabel);
89 }
90
91 public boolean getBoolean(String columnLabel) throws SQLException {
92 return int2bool(resultSet.getInt(columnLabel));
93 }
94
95 public int getInteger(String columnLabel) throws SQLException {
96 return resultSet.getInt(columnLabel);
97 }
98
99 public int getInteger(int columnIndex) throws SQLException {
100 return resultSet.getInt(columnIndex);
101 }
102
103 public String getString(String columnLabel) throws SQLException {
104 return resultSet.getString(columnLabel);
105 }
106
107 public boolean next() throws SQLException {
108 return resultSet.next();
109 }
110
111 public void close() throws SQLException {
112 resultSet.close();
113 }
114
115 // helpers
116
117 private static boolean int2bool(int value) {
118 return value != 0;
119 }
120 }