Pentaho中的动态模式处理器
我有一个工作的dsp配置的代码如下。我还想检索用户角色,并在稍后的查询中使用它。有人知道如何从用户检索角色吗Pentaho中的动态模式处理器,pentaho,mondrian,Pentaho,Mondrian,我有一个工作的dsp配置的代码如下。我还想检索用户角色,并在稍后的查询中使用它。有人知道如何从用户检索角色吗 public class SubscriptionCountry extends FilterDynamicSchemaProcessorimplements DynamicSchemaProcessor { private static final String BBDD_HOST = "xxx"; private static final String BBDD_PORT = "xx
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;
}
}我已经在jsp中完成了:我想它也应该适用于您: 这些是我的jsp中的导入(也许你不需要所有的东西……): listroles包含角色列表 另见:
<%@page import="org.pentaho.platform.api.engine.IAuthorizationPolicy" %>
<%@page import="org.pentaho.platform.api.engine.IPluginManager" %>
<%@page import="org.pentaho.platform.engine.core.system.PentahoSessionHolder" %>
<%@page import="org.pentaho.platform.engine.core.system.PentahoSystem" %>
<%@page import="org.pentaho.platform.security.policy.rolebased.actions.AdministerSecurityAction" %>
<%@page import="org.pentaho.platform.security.policy.rolebased.actions.RepositoryCreateAction" %>
<%@page import="java.util.List" %>
<%@page import="java.util.Locale"%>
<%@page import="javax.servlet.http.HttpServletRequest"%>
<%@page import="org.pentaho.platform.api.engine.IPentahoSession"%>
<%@page import="org.pentaho.platform.engine.security.SecurityParameterProvider"%>
SecurityParameterProvider secpro= new SecurityParameterProvider(PentahoSessionHolder.getSession() );
String listroles = secpro.getStringParameter("principalRoles","aucun");