com.sqlapp.data.db.dialect.derby.metadata.DerbyColumnPrivilegeReader Maven / Gradle / Ivy
/**
* Copyright (C) 2007-2018 Tatsuo Satoh
*
* This file is part of sqlapp-core-derby.
*
* sqlapp-core-derby is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sqlapp-core-derby is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with sqlapp-core-derby. If not, see .
*/
package com.sqlapp.data.db.dialect.derby.metadata;
import static com.sqlapp.util.CommonUtils.list;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import com.sqlapp.data.db.dialect.Dialect;
import com.sqlapp.data.db.metadata.ColumnPrivilegeReader;
import com.sqlapp.data.parameter.ParametersContext;
import com.sqlapp.data.schemas.ColumnPrivilege;
import com.sqlapp.data.schemas.ProductVersionInfo;
import com.sqlapp.jdbc.ExResultSet;
import com.sqlapp.jdbc.sql.ResultSetNextHandler;
import com.sqlapp.jdbc.sql.node.SqlNode;
public class DerbyColumnPrivilegeReader extends ColumnPrivilegeReader {
protected DerbyColumnPrivilegeReader(Dialect dialect) {
super(dialect);
}
@Override
protected List doGetAll(Connection connection,
ParametersContext context,
final ProductVersionInfo productVersionInfo) {
SqlNode node = getSqlSqlNode(productVersionInfo);
final List result = list();
execute(connection, node, context, new ResultSetNextHandler() {
@Override
public void handleResultSetNext(ExResultSet rs) throws SQLException {
ColumnPrivilege obj = createColumnPrivilege(rs);
result.add(obj);
}
});
return result;
}
protected SqlNode getSqlSqlNode(ProductVersionInfo productVersionInfo) {
return getSqlNodeCache().getString("columnPrivileges.sql");
}
protected ColumnPrivilege createColumnPrivilege(ExResultSet rs)
throws SQLException {
ColumnPrivilege obj = new ColumnPrivilege();
obj.setObjectName(getString(rs, OBJECT_NAME));
obj.setPrivilege(DerbyUtils.getPrivilege(getString(rs, PRIVILEGE_TYPE)));
obj.setGrantorName(getString(rs, GRANTOR));
obj.setGranteeName(getString(rs, GRANTEE));
String columns = getString(rs, "columns");
// TODO org.apache.derby.iapi.services.io.FormatableBitSet
return obj;
}
}