本文整理汇总了Java中mondrian.olap.Util.PropertyList类的典型用法代码示例。如果您正苦于以下问题:Java PropertyList类的具体用法?Java PropertyList怎么用?Java PropertyList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PropertyList类属于mondrian.olap.Util包,在下文中一共展示了PropertyList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBasicSchemaFetch
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
public void testBasicSchemaFetch() {
RolapSchemaPool schemaPool = RolapSchemaPool.instance();
schemaPool.clear();
String catalogUrl = getFoodmartCatalogUrl().toString();
Util.PropertyList connectInfo =
Util.parseConnectString(TestContext.getDefaultConnectString());
RolapSchema schema =
schemaPool.get(
catalogUrl,
"connectionKeyA",
"joeTheUser",
"aDataSource",
connectInfo);
RolapSchema schemaA =
schemaPool.get(
catalogUrl,
"connectionKeyA",
"joeTheUser",
"aDataSource",
connectInfo);
//same arguments, same object
assertTrue(schema == schemaA);
}
示例2: getDataSources
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
public List<Map<String, Object>> getDataSources(OlapConnection connection)
throws OlapException
{
MondrianOlap4jConnection olap4jConnection =
(MondrianOlap4jConnection) connection;
MondrianServer server =
MondrianServer.forConnection(
olap4jConnection.getMondrianConnection());
final List<Map<String, Object>> databases =
server.getDatabases(olap4jConnection.getMondrianConnection());
// We can't let JdbcPassword leak out of the public API, so we remove
// it here. This is only called by the XMLA servlets.
for (Map<String, Object> db : databases) {
String dsi = (String) db.get("DataSourceInfo");
if (dsi == null) {
break;
}
PropertyList pl = Util.parseConnectString(dsi);
boolean removed =
pl.remove(RolapConnectionProperties.Jdbc.name());
removed |= pl.remove(RolapConnectionProperties.JdbcUser.name());
removed |= pl.remove(RolapConnectionProperties.JdbcPassword.name());
if (removed) {
db.put("DataSourceInfo", pl.toString());
}
}
return databases;
}
示例3: checkSchemaFile
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
/**
* Check if schema file is valid by initiating a mondrian connection.
*/
private void checkSchemaFile(File file) {
try {
// this connection parses the catalog file which if invalid will
// throw exception
PropertyList list = new PropertyList();
list.put("Provider", "mondrian");
list.put("Jdbc", jdbcConnectionUrl);
list.put("Catalog", file.toURI().toURL().toString());
list.put("JdbcDrivers", jdbcDriverClassName);
if (jdbcUsername != null && jdbcUsername.length() > 0) {
list.put("JdbcUser", jdbcUsername);
}
if (jdbcPassword != null && jdbcPassword.length() > 0) {
list.put("JdbcPassword", jdbcPassword);
}
DriverManager.getConnection(list, null);
} catch (Exception ex) {
LOGGER.error(
"Exception : Schema file "
+ file.getAbsolutePath()
+ " is invalid."
+ ex.getMessage(), ex);
} catch (Error err) {
LOGGER.error(
"Error : Schema file "
+ file.getAbsolutePath()
+ " is invalid."
+ err.getMessage(), err);
}
}
示例4: filterConnectString
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
protected String filterConnectString(String original) {
PropertyList props = Util.parseConnectString(original);
if (props.get(RolapConnectionProperties.Catalog.name()) != null) {
props.remove(RolapConnectionProperties.Catalog.name());
}
return props.toString();
}
示例5: addDatasourceInfoResponseKey
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
protected void addDatasourceInfoResponseKey(Properties props) {
XmlaTestContext s = new XmlaTestContext();
String con = s.getConnectString().replaceAll("&","&");
PropertyList pl = Util.parseConnectString(con);
pl.remove(RolapConnectionProperties.Jdbc.name());
pl.remove(RolapConnectionProperties.JdbcUser.name());
pl.remove(RolapConnectionProperties.JdbcPassword.name());
props.setProperty(DATA_SOURCE_INFO_RESPONSE_PROP, pl.toString());
}
示例6: getCatalogNameUrls
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
protected Map<String, String> getCatalogNameUrls(TestContext testContext) {
if (catalogNameUrls == null) {
catalogNameUrls = new TreeMap<String, String>();
String connectString = testContext.getConnectString();
Util.PropertyList connectProperties =
Util.parseConnectString(connectString);
String catalog = connectProperties.get(
RolapConnectionProperties.Catalog.name());
catalogNameUrls.put("FoodMart", catalog);
}
return catalogNameUrls;
}
示例7: testGetDataSourceDoesntLeakPassword
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
/**
* This test makes sure that the value of
* {@link RolapConnectionProperties#JdbcPassword} isn't leaked through
* the XmlaExtra interface.
*/
public void testGetDataSourceDoesntLeakPassword() throws Exception {
final List<Map<String, Object>> expectedList =
new ArrayList<Map<String,Object>>();
final Map<String, Object> expectedMap =
new HashMap<String, Object>();
expectedMap.put(
"DataSourceInfo",
"Provider=Mondrian;Jdbc=foo;JdbcPassword=bar;JdbcUser=bacon");
expectedList.add(expectedMap);
final MondrianServer server = mock(MondrianServer.class);
final RolapConnection rConn = mock(RolapConnection.class);
final MondrianOlap4jConnection conn =
mock(MondrianOlap4jConnection.class);
final MondrianOlap4jExtra extra =
mock(MondrianOlap4jExtra.class);
doReturn(expectedList).when(server).getDatabases(rConn);
doReturn(server).when(rConn).getServer();
doReturn(rConn).when(conn).getMondrianConnection();
doCallRealMethod().when(extra).getDataSources(conn);
for (Map<String, Object> ds : extra.getDataSources(conn)) {
final PropertyList props =
Util.parseConnectString(
String.valueOf(ds.get("DataSourceInfo")));
assertNull(
props.get(RolapConnectionProperties.Jdbc.name()));
assertNull(
props.get(RolapConnectionProperties.JdbcUser.name()));
assertNull(
props.get(RolapConnectionProperties.JdbcPassword.name()));
}
}
示例8: checkSchemaFile
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
/**
* Check if schema file is valid by initiating a mondrian connection.
*/
private void checkSchemaFile(File file) {
try {
// this connection parses the catalog file which if invalid will
// throw exception
PropertyList list = new PropertyList();
list.put("Provider", "mondrian");
list.put("Jdbc", jdbcConnectionUrl);
list.put("Catalog", file.toURL().toString());
list.put("JdbcDrivers", jdbcDriverClassName);
if (jdbcUsername != null && jdbcUsername.length() > 0) {
list.put("JdbcUser", jdbcUsername);
}
if (jdbcPassword != null && jdbcPassword.length() > 0) {
list.put("JdbcPassword", jdbcPassword);
}
// clear cache before connecting
AggregationManager.instance().getCacheControl(null)
.flushSchemaCache();
DriverManager.getConnection(list, null);
} catch (Exception ex) {
LOGGER.error(
"Exception : Schema file "
+ file.getAbsolutePath()
+ " is invalid."
+ ex.getMessage(), ex);
} catch (Error err) {
LOGGER.error(
"Error : Schema file "
+ file.getAbsolutePath()
+ " is invalid."
+ err.getMessage(), err);
}
}
示例9: getConnection
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
public OlapConnection getConnection(
MondrianServer server,
String databaseName,
String catalogName,
String roleName,
Properties props)
throws SQLException
{
final ServerInfo serverInfo = getServerInfo();
DatabaseInfo datasourceInfo;
if (databaseName == null) {
if (serverInfo.datasourceMap.size() == 0) {
throw new OlapException(
"No databases configured on this server");
}
datasourceInfo =
serverInfo
.datasourceMap
.values()
.iterator()
.next();
} else {
datasourceInfo =
serverInfo.datasourceMap.get(databaseName);
// For legacy, we have to check if the DataSourceInfo matches.
// We used to mix up DS Info and DS names. The behavior above is
// the right one. The one below is not.
// Note also that the DSInfos we sent to the client had the
// JDBC properties removed for security. We have to account for
// that here as well.
if (datasourceInfo == null) {
for (DatabaseInfo infos
: serverInfo.datasourceMap.values())
{
PropertyList pl =
Util.parseConnectString(
(String) infos.properties.get("DataSourceInfo"));
pl.remove(RolapConnectionProperties.Jdbc.name());
pl.remove(RolapConnectionProperties.JdbcUser.name());
pl.remove(RolapConnectionProperties.JdbcPassword.name());
if (pl.toString().equals(databaseName)) {
datasourceInfo = infos;
}
}
}
}
if (datasourceInfo == null) {
throw Util.newError("Unknown database '" + databaseName + "'");
}
if (catalogName == null) {
if (datasourceInfo.catalogMap.size() == 0) {
throw new OlapException(
"No catalogs in the database named "
+ datasourceInfo.name);
}
for (CatalogInfo catalogInfo : datasourceInfo.catalogMap.values()) {
try {
return getConnection(catalogInfo, server, roleName, props);
} catch (Exception e) {
LOGGER.warn("Failed getting connection. Skipping", e);
}
}
} else {
CatalogInfo namedCatalogInfo =
datasourceInfo.catalogMap.get(catalogName);
if (namedCatalogInfo == null) {
throw Util.newError("Unknown catalog '" + catalogName + "'");
}
return getConnection(namedCatalogInfo, server, roleName, props);
}
throw Util.newError("No suitable connection found");
}
示例10: getCatalogNameUrls
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
protected Map<String, String> getCatalogNameUrls(TestContext testContext) {
if (catalogNameUrls == null) {
catalogNameUrls = new TreeMap<String, String>();
String connectString = testContext.getConnectString();
Util.PropertyList connectProperties =
Util.parseConnectString(connectString);
String catalog = connectProperties.get(
RolapConnectionProperties.Catalog.name());
// read the catalog and copy it to another temp file.
File outputFile1 = null;
File outputFile2 = null;
try {
// Output
outputFile1 = File.createTempFile("cat1", ".xml");
outputFile2 = File.createTempFile("cat2", ".xml");
outputFile1.deleteOnExit();
outputFile2.deleteOnExit();
BufferedWriter bw1 =
new BufferedWriter(new FileWriter(outputFile1));
BufferedWriter bw2 =
new BufferedWriter(new FileWriter(outputFile2));
// Input
DataInputStream in =
new DataInputStream(Util.readVirtualFile(catalog));
BufferedReader br =
new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
bw1.write(
strLine.replaceAll("FoodMart", "FoodMart1schema"));
bw1.newLine();
bw2.write(
strLine.replaceAll("FoodMart", "FoodMart2schema"));
bw2.newLine();
}
in.close();
bw1.close();
bw2.close();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
catalogNameUrls.put("FoodMart1", outputFile1.getAbsolutePath());
catalogNameUrls.put("FoodMart2", outputFile2.getAbsolutePath());
}
return catalogNameUrls;
}
示例11: runTest
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
protected void runTest() throws Exception {
if (!MondrianProperties.instance().SsasCompatibleNaming.get()
&& getName().equals("mdschemaLevelsCubeDimRestrictions"))
{
// Changes in unique names of hierarchies and levels mean that the
// output is a different order in the old behavior, and cannot be
// fixed by a few sed-like comparisons.
return;
}
DiffRepository diffRepos = getDiffRepos();
String request = diffRepos.expand(null, "${request}");
String expectedResponse = diffRepos.expand(null, "${response}");
Properties props = new Properties();
XmlaTestContext s = new XmlaTestContext();
String con = s.getConnectString().replaceAll("&","&");
PropertyList pl = Util.parseConnectString(con);
pl.remove(RolapConnectionProperties.Jdbc.name());
pl.remove(RolapConnectionProperties.JdbcUser.name());
pl.remove(RolapConnectionProperties.JdbcPassword.name());
props.setProperty(DATA_SOURCE_INFO_RESPONSE_PROP, pl.toString());
expectedResponse =
Util.replaceProperties(
expectedResponse, Util.toMap(props));
Element requestElem = XmlaUtil.text2Element(
XmlaTestContext.xmlFromTemplate(
request, XmlaTestContext.ENV));
Element responseElem =
ignoreLastUpdateDate(executeRequest(requestElem));
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
StringWriter bufWriter = new StringWriter();
transformer.transform(
new DOMSource(responseElem), new StreamResult(bufWriter));
bufWriter.write(Util.nl);
String actualResponse =
TestContext.instance().upgradeActual(
bufWriter.getBuffer().toString());
try {
// Start with a purely logical XML diff to avoid test noise
// from non-determinism in XML generation.
XMLAssert.assertXMLEqual(expectedResponse, actualResponse);
} catch (AssertionFailedError e) {
// In case of failure, re-diff using DiffRepository's comparison
// method. It may have noise due to physical vs logical structure,
// but it will maintain the expected/actual, and some IDEs can even
// display visual diffs.
diffRepos.assertEquals("response", "${response}", actualResponse);
}
}
示例12: testSchemaFetchCatalogUrlJdbcUuid
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
public void testSchemaFetchCatalogUrlJdbcUuid() {
RolapSchemaPool schemaPool = RolapSchemaPool.instance();
schemaPool.clear();
final String uuid = "UUID-1";
String catalogUrl = getFoodmartCatalogUrl().toString();
Util.PropertyList connectInfo =
Util.parseConnectString(TestContext.getDefaultConnectString());
connectInfo.put(
RolapConnectionProperties.JdbcConnectionUuid.name(),
uuid);
// Put in pool
RolapSchema schema =
schemaPool.get(
catalogUrl,
"connectionKeyA",
"joeTheUser",
"aDataSource",
connectInfo);
// Same catalogUrl, same JdbcUuid
Util.PropertyList connectInfoA =
Util.parseConnectString(TestContext.getDefaultConnectString());
connectInfoA.put(
RolapConnectionProperties.JdbcConnectionUuid.name(),
uuid);
RolapSchema sameSchema =
schemaPool.get(
catalogUrl,
"aDifferentConnectionKey",
"mrDoeTheOtherUser",
"someDataSource",
connectInfoA);
//must fetch the same object
assertTrue(schema == sameSchema);
connectInfo.put(
RolapConnectionProperties.JdbcConnectionUuid.name(),
"SomethingCompletelyDifferent");
RolapSchema aNewSchema =
schemaPool.get(
catalogUrl,
"connectionKeyA",
"joeTheUser",
"aDataSource",
connectInfo);
//must create a new object
assertTrue(schema != aNewSchema);
}
示例13: testSchemaFetchMd5JdbcUid
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
/**
* Test using JdbcConnectionUUID and useSchemaChecksum
* fetches the same schema in all scenarios.
*/
public void testSchemaFetchMd5JdbcUid() throws IOException {
RolapSchemaPool pool = RolapSchemaPool.instance();
pool.clear();
final String uuid = "UUID-1";
String catalogUrl = getFoodmartCatalogUrl().toString();
Util.PropertyList connectInfo =
Util.parseConnectString(TestContext.getDefaultConnectString());
connectInfo.put(
RolapConnectionProperties.JdbcConnectionUuid.name(),
uuid);
connectInfo.put(
RolapConnectionProperties.UseContentChecksum.name(),
"true");
RolapSchema schema =
pool.get(
catalogUrl,
"connectionKeyA",
"joeTheUser",
"aDataSource",
connectInfo);
Util.PropertyList connectInfoDyn = connectInfo.clone();
connectInfoDyn.put(
RolapConnectionProperties.DynamicSchemaProcessor.name(),
NotReallyDynamicSchemaProcessor.class.getName());
RolapSchema schemaDyn =
pool.get(
catalogUrl,
"connectionKeyB",
"jed",
"dsName",
connectInfo);
assertTrue(schema == schemaDyn);
String catalogContent = Util.readVirtualFileAsString(catalogUrl);
Util.PropertyList connectInfoCont = connectInfo.clone();
connectInfoCont.remove(RolapConnectionProperties.Catalog.name());
connectInfoCont.put(
RolapConnectionProperties.CatalogContent.name(),
catalogContent);
RolapSchema schemaCont = pool.get(
catalogUrl,
"connectionKeyC", "--", "--", connectInfo);
assertTrue(schema == schemaCont);
Util.PropertyList connectInfoDS = connectInfo.clone();
final StringBuilder buf = new StringBuilder();
DataSource dataSource =
RolapConnection.createDataSource(null, connectInfoDS, buf);
RolapSchema schemaDS = pool.get(catalogUrl, dataSource, connectInfoDS);
assertTrue(schema == schemaDS);
}
示例14: processSchema
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
public String processSchema(String schemaUrl, PropertyList connectInfo)
throws Exception
{
return Util.readVirtualFileAsString(schemaUrl);
}
示例15: validateSchema
import mondrian.olap.Util.PropertyList; //导入依赖的package包/类
public List<ValidationMessage> validateSchema(Map<Parameter, Object> parameterValues) {
String connectString =
(String) parameterValues.get(
MondrianSchemaLoaderParameter.connectString);
String cubeName =
(String) parameterValues.get(
MondrianSchemaLoaderParameter.cube);
PropertyList propertyList = Util.parseConnectString(connectString);
String jdbcDrivers = propertyList.get("JdbcDrivers");
if (StringUtils.isBlank(jdbcDrivers)) {
throw new RuntimeException("missing 'JdbcDrivers' in connect string");
}
String jdbc = propertyList.get("Jdbc");
if (StringUtils.isBlank(jdbcDrivers)) {
throw new RuntimeException("missing 'Jdbc' in connect string");
}
String catalog = propertyList.get("Catalog");
if (StringUtils.isBlank(jdbcDrivers)) {
throw new RuntimeException("missing 'Catalog' in connect string");
}
String jdbcUser = propertyList.get("JdbcUser");
String jdbcPassword = propertyList.get("JdbcPassword");
List<ValidationMessage> messages = new ArrayList<ValidationMessage>();
try {
List<MondrianSchemaValidator> validators = loadValidators(parameterValues);
Class.forName(jdbcDrivers); //$NON-NLS-1$
java.sql.Connection conn = java.sql.DriverManager.getConnection(jdbc, //$NON-NLS-1$
jdbcUser, jdbcPassword); //$NON-NLS-1$ //$NON-NLS-2$
messages = ValidationHelper.validateCube(catalog, cubeName, conn, validators); //$NON-NLS-1$
conn.close();
} catch (Exception e) {
if (logger.isErrorEnabled()) {
logger.error("an exception occurred", e);
}
ValidationMessage msg = new ValidationMessage(ValidationMessage.Type.ERROR, e.getClass().getName() + ": " + e.getLocalizedMessage());
messages.add(msg);
}
return messages;
}