0
我有一個工作dsp配置下面的代碼。我也想要檢索用戶角色並在稍後的查詢中使用它。有誰知道如何從用戶中檢索角色?Pentaho中的動態模式處理器
public class SubscriptionCountry extends FilterDynamicSchemaProcessorimplements DynamicSchemaProcessor {
private static final String BBDD_HOST = "xxx";
private static final String BBDD_PORT = "xxx";
private static final String BBDD_NAME = "xxx";
private static final String BBDD_USER = "xxx";
private static final String BBDD_PASSWORD = "xxx";
public SubscriptionCountry() {
}
@Override
public String filter(String schemaUrl, Util.PropertyList connectInfo, InputStream stream) throws Exception {
String schema = super.filter(schemaUrl, connectInfo, stream);
Connection c = null;
String country_list = "";
try {
// Get Pentaho Session
IPentahoSession session = PentahoSessionHolder.getSession();
// Get user from session variable
String userName = session.getName().toString();
String query_countries = "";
query_countries = "SELECT something from a table where username = + userName";
Class.forName("org.postgresql.Driver");
c = DriverManager.getConnection("jdbc:postgresql://" + BBDD_HOST + ":" + BBDD_PORT + "/" + BBDD_NAME,BBDD_USER, BBDD_PASSWORD);
Statement st = c.createStatement();
ResultSet rs = st.executeQuery(query_countries);
rs.next();
country_list = rs.getString("country_list");
rs.close();
st.close();
}
try {
schema = schema.replaceAll("%COUNTRY_LIST%", country_list);
}
return schema;
}
}