Skip to content

Commit

Permalink
MONDRIAN: Updates to Schema Workbench to cover more DBMS's metadata a…
Browse files Browse the repository at this point in the history
…nd use of username/password in connections. Updated copyright text. Split mondrian.gui.* classes out of mondrian.jar into workbench.jar. workbench.bat shows how to start the workbench, with required JARs listed.

[git-p4: depot-paths = "//open/mondrian/": change = 8988]
  • Loading branch information
Sherman Wood committed Mar 29, 2007
1 parent 5633820 commit ad689d6
Show file tree
Hide file tree
Showing 11 changed files with 439 additions and 88 deletions.
13 changes: 8 additions & 5 deletions build.xml
Expand Up @@ -70,6 +70,7 @@ ${java.dir}/mondrian/xmla/DataSourcesConfig*.java,
${etc.dir}/mondrian/web/jsp/**/*.java"/>
<property name="generated.lib.files" value="
${lib.dir}/mondrian.jar,
${lib.dir}/workbench.jar,
${jar-jdk14.file},
${lib.dir}/mondrian.war,
${lib.dir}/mondrian.xml,
Expand Down Expand Up @@ -834,7 +835,8 @@ doc/**/*.xml"
**/*.class,
**/*.properties,
**/*.xml,
META-INF/**"/>
META-INF/**"
excludes="mondrian/gui/**/*.*"/>
<zipfileset
dir="${testclasses.dir}"
includes="
Expand Down Expand Up @@ -1119,13 +1121,14 @@ xalan.jar"/>
</target>

<target name="workbench" depends="compile">
<jar jarfile="${workbench.jar.file}" manifest="misc/workbench-manifest.mf">
<jar destfile="${lib.dir}/${workbench.jar.file}"
update="true">
<fileset
dir="${classes.dir}"
includes="**/*.class"/>
includes="mondrian/gui/**/*.class"/>
<fileset
dir="."
includes="images/*.*"/>
dir="${java.dir}"
includes="mondrian/gui/**/*.gif,mondrian/gui/**/*.properties,mondrian/gui/**/*.html"/>
</jar>
</target>

Expand Down
23 changes: 23 additions & 0 deletions demo/workbench.bat
@@ -0,0 +1,23 @@
@echo off

rem base Mondrian JARs

set CP=../lib/commons-dbcp.jar;../lib/commons-collections.jar;../lib/commons-pool.jar
set CP=%CP%;../lib/eigenbase-properties.jar;../lib/eigenbase-resgen.jar;../lib/eigenbase-xom.jar
set CP=%CP%;../lib/javacup.jar;../lib/log4j-1.2.9.jar;../lib/mondrian.jar
set CP=%CP%;../lib/jlfgr-1_0.jar;../lib/jmi.jar;lib/mof.jar;../lib/commons-math-1.0.jar
set CP=%CP%;../lib/commons-vfs.jar;../lib/commons-logging.jar

rem Workbench GUI code and resources

set CP=%CP%;../lib/workbench.jar

rem add all needed JDBC drivers to the classpath

set CP=%CP%;../testlib/mysql-connector-java-3.1.11-bin.jar
set CP=%CP%;../testlib/postgresql-driver-jdbc3-74-214.jar

rem set the log4j.properties system property "-Dlog4j.properties=<.properties or .xml file>"
rem in the java command below to adjust workbench logging

java -Xms100m -Xmx500m -cp "%CP%" mondrian.gui.Workbench
36 changes: 31 additions & 5 deletions src/main/mondrian/gui/JDBCMetaData.java
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2006-2007 Julian Hyde and others
// Copyright (C) 2006-2007 Julian Hyde, Cincom Systems, Inc., JasperSoft and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
//
Expand All @@ -21,6 +21,8 @@
public class JDBCMetaData {
String jdbcDriverClassName = null; //"org.postgresql.Driver"
String jdbcConnectionUrl = null; // "jdbc:postgresql://localhost:5432/hello?user=postgres&password=post"
String jdbcUsername = null;
String jdbcPassword = null;

Connection conn = null;
DatabaseMetaData md = null;
Expand Down Expand Up @@ -48,9 +50,11 @@ public class JDBCMetaData {
private String errMsg = null;
private Database db = new Database();

public JDBCMetaData(String jdbcDriverClassName, String jdbcConnectionUrl) {
public JDBCMetaData(String jdbcDriverClassName, String jdbcConnectionUrl, String jdbcUsername, String jdbcPassword) {
this.jdbcConnectionUrl = jdbcConnectionUrl;
this.jdbcDriverClassName = jdbcDriverClassName;
this.jdbcUsername = jdbcUsername;
this.jdbcPassword = jdbcPassword;

if (initConnection() == null) {
setAllSchemas();
Expand All @@ -60,13 +64,22 @@ public JDBCMetaData(String jdbcDriverClassName, String jdbcConnectionUrl) {

/* Creates a database connection and initializes the meta data details */
public String initConnection(){
try{
System.out.println("JDBCMetaData: initConnection");

try {
if (jdbcDriverClassName==null || jdbcConnectionUrl==null) {
throw new Exception("Driver="+jdbcDriverClassName+"\nConn Url="+jdbcConnectionUrl+"\n(Hint: Use Prefrences to set Database Connection parameters first and then open a Schema.)");
}

Class.forName(jdbcDriverClassName);
conn = DriverManager.getConnection(jdbcConnectionUrl);

if (jdbcUsername != null && jdbcUsername.length() > 0 &&
jdbcPassword != null && jdbcPassword.length() > 0) {
conn = DriverManager.getConnection(jdbcConnectionUrl, jdbcUsername, jdbcPassword);
} else {

conn = DriverManager.getConnection(jdbcConnectionUrl);
}

System.out.println("JDBC connection OPEN");
md = conn.getMetaData();
Expand All @@ -93,6 +106,7 @@ public String initConnection(){
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/demo","admin","admin");
*/
System.out.println("JDBCMetaData: initConnection - no error");
return null;
} catch (Exception e) {
errMsg = e.getMessage();
Expand All @@ -111,22 +125,33 @@ public void closeConnection() {

/* set all schemas in the currently connected database */
private void setAllSchemas(){
System.out.println("JDBCMetaData: setAllSchemas");

ResultSet rs = null;
boolean gotSchema = false;

try{
rs = md.getSchemas();
/*
if (true)
throw new Exception("Schema concept not found in database");
*/

while(rs.next()) {
DbSchema dbs = new DbSchema();
dbs.name = rs.getString("TABLE_SCHEM");
System.out.println("JDBCMetaData: setAllTables - " + dbs.name);
setAllTables(dbs);
db.addDbSchema(dbs);
gotSchema = true;
}
rs.close();
} catch (Exception e) {
System.out.println("Exception : Database does not support schemas."+e.getMessage());
}

if (!gotSchema) {
System.out.println("JDBCMetaData: setAllSchemas - tables with no schema name");
DbSchema dbs = new DbSchema();
dbs.name = null; //tables with no schema name
setAllTables(dbs);
Expand All @@ -136,8 +161,9 @@ private void setAllSchemas(){

/* set all tables in the currently connected database */
private void setAllTables(DbSchema dbs){
System.out.println("JDBCMetaData: Loading schema: '" + dbs.name + "'");
ResultSet rs = null;
try{
try {
rs = md.getTables(null, dbs.name, null, new String[]{"TABLE"});
while(rs.next()) {
String tbname = rs.getString("TABLE_NAME");
Expand Down
10 changes: 1 addition & 9 deletions src/main/mondrian/gui/JTreeUpdater.java
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2006-2007 Julian Hyde and others
// Copyright (C) 2006-2007 Julian Hyde, Cincom Systems, Inc. and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down Expand Up @@ -64,10 +64,6 @@ public synchronized void update() {
}
}

/**
* Copyright (C) 2006, 2007 CINCOM SYSTEMS, INC.
* All Rights Reserved
*/
public void treeExpanded(TreeExpansionEvent treeExpansionEvent) {
TreePath expandedPath = treeExpansionEvent.getPath();

Expand All @@ -90,10 +86,6 @@ public void treeExpanded(TreeExpansionEvent treeExpansionEvent) {
//System.out.println("added expended ="+expandedTreePaths.size());
}

/**
* Copyright (C) 2006, 2007 CINCOM SYSTEMS, INC.
* All Rights Reserved
*/
public void treeCollapsed(TreeExpansionEvent treeExpansionEvent) {
TreePath collapsedPath = treeExpansionEvent.getPath();
expandedTreePaths.remove(collapsedPath);
Expand Down
64 changes: 63 additions & 1 deletion src/main/mondrian/gui/PreferencesDialog.java
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2002-2007 Julian Hyde and others
// Copyright (C) 2002-2007 Julian Hyde, Cincom Systems, Inc. JasperSoft and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down Expand Up @@ -35,6 +35,22 @@ public String getJDBCConnectionUrl() {
return urlTextField.getText();
}

public void setJDBCUsername(String s) {
this.usernameTextField.setText(s);
}

public String getJDBCUsername() {
return usernameTextField.getText();
}

public void setJDBCPassword(String s) {
this.passwordTextField.setText(s);
}

public String getJDBCPassword() {
return passwordTextField.getText();
}

public void setJDBCDriverClassName(String s) {
this.driverClassTextField.setText(s);
}
Expand All @@ -55,7 +71,11 @@ private void initComponents() {//GEN-BEGIN:initComponents
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
urlTextField = new javax.swing.JTextField();
usernameTextField = new javax.swing.JTextField();
passwordTextField = new javax.swing.JTextField();
driverClassTextField = new javax.swing.JTextField();
acceptButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
Expand Down Expand Up @@ -88,6 +108,24 @@ public void windowClosing(java.awt.event.WindowEvent evt) {
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
jPanel1.add(jLabel2, gridBagConstraints);

jLabel3.setText("User name");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
jPanel1.add(jLabel3, gridBagConstraints);

jLabel4.setText("Password");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
jPanel1.add(jLabel4, gridBagConstraints);

urlTextField.setText("jdbc:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
Expand All @@ -99,6 +137,26 @@ public void windowClosing(java.awt.event.WindowEvent evt) {
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
jPanel1.add(urlTextField, gridBagConstraints);

usernameTextField.setText("");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
jPanel1.add(usernameTextField, gridBagConstraints);

passwordTextField.setText("");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
jPanel1.add(passwordTextField, gridBagConstraints);

driverClassTextField.setText("org.gjt.mm.mysql.Driver");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
Expand Down Expand Up @@ -178,9 +236,13 @@ public static void main(String args[]) {
private javax.swing.JTextField driverClassTextField;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField urlTextField;
private javax.swing.JTextField usernameTextField;
private javax.swing.JTextField passwordTextField;
private javax.swing.JButton acceptButton;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JButton cancelButton;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel1;
// End of variables declaration//GEN-END:variables
Expand Down
18 changes: 1 addition & 17 deletions src/main/mondrian/gui/PropertyTableModel.java
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2002-2007 Julian Hyde and others
// Copyright (C) 2002-2007 Julian Hyde, Cincom Systems, Inc., and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down Expand Up @@ -45,10 +45,6 @@ public String getColumnName(int i) {
return "?";
}

/**
* Copyright (C) 2006, 2007 CINCOM SYSTEMS, INC.
* All Rights Reserved
*/
// get property name for given row no.
public String getRowName(int i) {
String pName = propertyNames[i];
Expand Down Expand Up @@ -97,10 +93,6 @@ public int getRowCount() {
return propertyNames.length;
}

/**
* Copyright (C) 2006, 2007 CINCOM SYSTEMS, INC.
* All Rights Reserved
*/
/** Returns the value for the cell at <code>columnIndex</code> and
* <code>rowIndex</code>.
*
Expand Down Expand Up @@ -158,10 +150,6 @@ public Object getValueAt(int rowIndex, int columnIndex) {
}
}

/**
* Copyright (C) 2006, 2007 CINCOM SYSTEMS, INC.
* All Rights Reserved
*/
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
setErrorMsg(null);
try {
Expand Down Expand Up @@ -240,10 +228,6 @@ public Object getValue() {
return target;
}

/**
* Copyright (C) 2006, 2007 CINCOM SYSTEMS, INC.
* All Rights Reserved
*/
public Object getParentTarget() {
return parentTarget;
}
Expand Down

0 comments on commit ad689d6

Please sign in to comment.