use of mondrian.olap.Util.PropertyList in project mondrian by pentaho.
the class XmlaTest method runTest.
protected void runTest() throws Exception {
if (!MondrianProperties.instance().SsasCompatibleNaming.get() && getName().equals("mdschemaLevelsCubeDimRestrictions")) {
// 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);
}
}
use of mondrian.olap.Util.PropertyList in project mondrian by pentaho.
the class Workbench method checkSchemaFile.
/**
* 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);
}
}
use of mondrian.olap.Util.PropertyList in project mondrian by pentaho.
the class QueryPanel method connectButtonActionPerformed.
private void connectButtonActionPerformed(ActionEvent evt) {
File sfile = null;
try {
String sfname = (String) schemaList.getSelectedItem();
JInternalFrame sf = lookupFrame(sfname);
if (sf == null) {
// this case may arise when a schema file is opened, mdx query
// is opened and the schema frame is closed
JOptionPane.showMessageDialog(this, getResourceConverter().getString("queryPanel.schemaNotOpen.alert", "Schema file is not open"), getResourceConverter().getString("common.errorDialog.title", "Error"), JOptionPane.ERROR_MESSAGE);
return;
}
SchemaExplorer se = (SchemaExplorer) sf.getContentPane().getComponent(0);
if (se.isNewFile()) {
JOptionPane.showMessageDialog(this, getResourceConverter().getString("queryPanel.saveSchemaFirst.alert", "You must first save the Schema to open a Mondrian connection"), getResourceConverter().getString("common.alertDialog.title", "Alert"), JOptionPane.WARNING_MESSAGE);
sf.setSelected(true);
return;
}
sfile = se.getSchemaFile();
PropertyList list = new PropertyList();
list.put("Provider", "mondrian");
list.put("Jdbc", se.getJdbcConnectionUrl());
list.put("Catalog", se.getSchemaFile().toURL().toString());
final String jdbcUsername = se.getJdbcUsername();
if (!ValidationUtils.isEmpty(jdbcUsername)) {
list.put("JdbcUser", jdbcUsername);
}
final String jdbcPassword = se.getJdbcPassword();
if (!ValidationUtils.isEmpty(jdbcPassword)) {
list.put("JdbcPassword", jdbcPassword);
}
Connection con = DriverManager.getConnection(list, null);
// clear cache before connecting
con.getCacheControl(null).flushSchemaCache();
if (con != null) {
connection = con;
queryMenuItem.setText(getResourceConverter().getFormattedString("queryPanel.successfulConnection.menuItem", "{0} MDX - {1}", Integer.toString(windowMenuIndex), se.getSchemaFile().getName()));
Component o = this;
while (o != null) {
if (o.getClass() == JInternalFrame.class) {
((JInternalFrame) o).setTitle(getResourceConverter().getFormattedString("queryPanel.successfulConnection.internalFrame.title", "MDX Query - connected to {0}", se.getSchemaFile().getName()));
break;
}
o = o.getParent();
}
JOptionPane.showMessageDialog(this, "Mondrian connection Successful.", getResourceConverter().getString("common.informationDialog.title", "Information"), JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(this, getResourceConverter().getFormattedString("queryPanel.unsuccessfulConnection.alert", "Mondrian connection could not be done for - {0}", se.getSchemaFile().getName()), getResourceConverter().getString("common.errorDialog.title", "Error"), JOptionPane.ERROR_MESSAGE);
}
} catch (Exception ex) {
LOGGER.error("Exception: " + ex.getMessage(), ex);
JOptionPane.showMessageDialog(this, getResourceConverter().getFormattedString("queryPanel.unsuccessfulConnection.exception", "Mondrian connection could not be done for - {0}", sfile == null ? getResourceConverter().getString("queryPanel.selectedSchema.alert", "selected Schema") : sfile.getName()), getResourceConverter().getString("common.errorDialog.title", "Error"), JOptionPane.ERROR_MESSAGE);
resultTextPane.setText(getResourceConverter().getFormattedString("queryPanel.exceptionMessage", "Exception: {0}\n\nSee workbench log for full stacktrace.", ex.getMessage()));
}
}
use of mondrian.olap.Util.PropertyList in project pentaho-platform by pentaho.
the class MondrianCatalogHelper method applyDSP.
protected String applyDSP(IPentahoSession ps, String catalogDsInfo, String catalogDefinition) throws Exception {
PropertyList pl = Util.parseConnectString(catalogDsInfo);
String dsp = pl.get(RolapConnectionProperties.DynamicSchemaProcessor.name());
if (dsp != null) {
if (MondrianCatalogHelper.logger.isDebugEnabled()) {
// $NON-NLS-1$
MondrianCatalogHelper.logger.debug("applyDSP: " + dsp);
}
DynamicSchemaProcessor dynProc = ClassResolver.INSTANCE.instantiateSafe(dsp);
pl.put("Locale", getLocale().toString());
return dynProc.processSchema(catalogDefinition, pl);
} else {
return docAtUrlToString(catalogDefinition, ps);
}
}
use of mondrian.olap.Util.PropertyList in project pentaho-platform by pentaho.
the class MondrianCatalogHelper method docAtUrlToString.
protected String docAtUrlToString(final String urlStr, final IPentahoSession pentahoSession) {
// String relPath = getSolutionRepositoryRelativePath(urlStr, pentahoSession);
String res = null;
InputStream in = null;
try {
LocalizingDynamicSchemaProcessor schemaProcessor = new LocalizingDynamicSchemaProcessor();
PropertyList localeInfo = new PropertyList();
// $NON-NLS-1$
localeInfo.put("Locale", getLocale().toString());
FileSystemManager fsManager = VFS.getManager();
FileObject mondrianDS = fsManager.resolveFile(urlStr);
in = mondrianDS.getContent().getInputStream();
res = schemaProcessor.filter(null, localeInfo, in);
} catch (FileNotFoundException fnfe) {
throw new MondrianCatalogServiceException(Messages.getInstance().getErrorString("MondrianCatalogHelper.ERROR_0007_FILE_NOT_FOUND"), // $NON-NLS-1$
fnfe);
} catch (Exception e) {
throw new MondrianCatalogServiceException(Messages.getInstance().getErrorString("MondrianCatalogHelper.ERROR_0006_IO_PROBLEM"), // $NON-NLS-1$
e);
} finally {
IOUtils.closeQuietly(in);
}
return res;
}
Aggregations