teiid SVN: r932 - trunk/connector-api/src/main/java/org/teiid/connector/visitor/util.
by teiid-commits@lists.jboss.org
Author: li.liang
Date: 2009-05-13 15:38:15 -0400 (Wed, 13 May 2009)
New Revision: 932
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
Log:
TEIID-591 Remove optional parenthesis for joins for all but MySql connector.
Modified: trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2009-05-13 19:28:55 UTC (rev 931)
+++ trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2009-05-13 19:38:15 UTC (rev 932)
@@ -597,7 +597,7 @@
*/
public void visit(IJoin obj) {
IFromItem leftItem = obj.getLeftItem();
- if(leftItem instanceof IJoin) {
+ if(useParensForJoins() && leftItem instanceof IJoin) {
buffer.append(LPAREN);
append(leftItem);
buffer.append(RPAREN);
@@ -635,7 +635,7 @@
.append(SPACE);
IFromItem rightItem = obj.getRightItem();
- if(rightItem instanceof IJoin) {
+ if(rightItem instanceof IJoin && (useParensForJoins() || obj.getJoinType() == IJoin.JoinType.CROSS_JOIN)) {
buffer.append(LPAREN);
append(rightItem);
buffer.append(RPAREN);
@@ -1030,5 +1030,8 @@
visitor.append(obj);
return visitor.toString();
}
-
+
+ protected boolean useParensForJoins() {
+ return false;
+ }
}
15 years, 7 months
teiid SVN: r931 - branches/6.0.x/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-05-13 15:28:55 -0400 (Wed, 13 May 2009)
New Revision: 931
Modified:
branches/6.0.x/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
Log:
TEIID-379 fix for changing the mode to ansi
Modified: branches/6.0.x/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
===================================================================
--- branches/6.0.x/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java 2009-05-13 18:07:37 UTC (rev 930)
+++ branches/6.0.x/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java 2009-05-13 19:28:55 UTC (rev 931)
@@ -81,7 +81,7 @@
Statement stmt = null;
try {
stmt = connection.createStatement();
- stmt.execute("set SESSION sql-mode = 'ANSI'"); //$NON-NLS-1$
+ stmt.execute("set SESSION sql_mode = 'ANSI'"); //$NON-NLS-1$
} catch (SQLException e) {
getEnvironment().getLogger().logError("Error setting ANSI mode", e); //$NON-NLS-1$
} finally {
15 years, 7 months
teiid SVN: r930 - in trunk: console/src/main/java/com/metamatrix/console/ui/views/vdb and 10 other directories.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2009-05-13 14:07:37 -0400 (Wed, 13 May 2009)
New Revision: 930
Added:
trunk/common-core/src/main/java/com/metamatrix/common/util/WSDLServletUtil.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/WSDLWizardRunner.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/WebServicesPanel.java
Removed:
trunk/soap/src/main/java/com/metamatrix/soap/util/WSDLServletUtil.java
Modified:
trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/UDDIConfigurationsDialog.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/VdbMainPanel.java
trunk/console/src/main/java/com/metamatrix/console/util/SavedUDDIRegistryInfo.java
trunk/console/src/main/java/com/metamatrix/console/util/StaticProperties.java
trunk/console/src/main/resources/com/metamatrix/console/i18n.properties
trunk/soap/src/main/java/com/metamatrix/soap/handler/ActionUpdateHandler.java
trunk/soap/src/main/java/com/metamatrix/soap/service/DataServiceWebServiceImpl.java
trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMDiscoverWSDLServlet.java
trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetVDBResourceServlet.java
trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetWSDLServlet.java
trunk/soap/src/main/java/com/metamatrix/soap/servlet/WSDLURLGenerator.java
trunk/soap/src/main/java/com/metamatrix/soap/util/EndpointUriTranslatorStrategyImpl.java
trunk/soap/src/test/java/com/metamatrix/soap/handler/TestActionUpdateHandler.java
trunk/soap/src/test/java/com/metamatrix/soap/service/TestDataServiceWebServiceImpl.java
trunk/soap/src/test/java/com/metamatrix/soap/servlet/TestMMGetVDBResourceServlet.java
trunk/soap/src/test/java/com/metamatrix/soap/util/TestWSDLServletUtil.java
Log:
TEIID-482 Added UDDI Publishing and re-factored WSDLServletUtil to common-core so that teiid-console and teiid-soap could access it.
Copied: trunk/common-core/src/main/java/com/metamatrix/common/util/WSDLServletUtil.java (from rev 905, trunk/soap/src/main/java/com/metamatrix/soap/util/WSDLServletUtil.java)
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/util/WSDLServletUtil.java (rev 0)
+++ trunk/common-core/src/main/java/com/metamatrix/common/util/WSDLServletUtil.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -0,0 +1,225 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.util;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.text.MessageFormat;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Constants pertaining to WSDL servlet execution.
+ *
+ * @since 4.2
+ */
+
+public class WSDLServletUtil {
+
+ /**
+ * General keys
+ */
+ public static final String SERVER_URL_KEY = "ServerURL"; //$NON-NLS-1$
+
+ public static final String SECURE_PROTOCOL = "Secure"; //$NON-NLS-1$
+
+ public static final String VDB_NAME_KEY = "VDBName"; //$NON-NLS-1$
+
+ public static final String VDB_VERSION_KEY = "VDBVersion"; //$NON-NLS-1$
+
+ public static final String ADD_PROPS = "AdditionalProperties"; //$NON-NLS-1$
+
+ public static final String TXN_AUTO_WRAP = "txnAutoWrap"; //$NON-NLS-1$
+
+ public static final String ADD_EXEC_PROPS = "AddExecProperties"; //$NON-NLS-1$
+
+ public static final String MM_WEBSERVICE_QUERY_TIMEOUT = "com.metamatrix.webservice.querytimeout"; //$NON-NLS-1$
+
+ public static final String DISCOVERED_WSDL = "discovered_wsdl"; //$NON-NLS-1$
+
+ /*
+ * This is the parameter that will tell this servlet when the web service endpoint as defined in WSDL served up by this
+ * servlet will use the HTTP vs HTTPS protocol.
+ */
+ public static final String HTTP_TYPE_PARAMETER_KEY = "httptype"; //$NON-NLS-1$
+
+ /*
+ * This is the value of the httptype URL request param that will indicate that the returned WSDL should have an http endpoint
+ * instead of an https endpoint.
+ */
+ public static final String HTTP_PARAMETER_VALUE = "http"; //$NON-NLS-1$
+
+ /*
+ * Static contant representing the standard http protocol.
+ */
+ public static final String HTTP = "http"; //$NON-NLS-1$
+
+ /**
+ * Static contant representing the secure http protocol.
+ */
+ public static final String HTTPS = "https"; //$NON-NLS-1$
+
+ /**
+ * Default content type for the VDBResourceServlet
+ */
+ public static final String DEFAULT_CONTENT_TYPE = "text/html"; //$NON-NLS-1$
+
+ /**
+ * XML content type for the VDBResourceServlet
+ */
+ public static final String XML_CONTENT_TYPE = "text/xml"; //$NON-NLS-1$
+
+ /**
+ * WSDL URL Generator keys
+ */
+ public static final String MMSERVER_HOST_PORT_KEY = "MMServerHostAndPort"; //$NON-NLS-1$
+
+ public static final String TARGET_HOST_KEY = "TargetHost"; //$NON-NLS-1$
+
+ public static final String TARGET_PORT_KEY = "TargetPort"; //$NON-NLS-1$
+
+ public static final String SERVLET_PATH = "/servlet/ArtifactDocumentService"; //$NON-NLS-1$
+
+ public static final String SQLQUERYWEBSERVICE_WSDL_PATH = "/services/SqlQueryWebService?wsdl"; //$NON-NLS-1$
+
+ public static final String GENERATED_WSDL_NAME = "MetaMatrixDataServices"; //$NON-NLS-1$
+
+ public static final String GENERATED_WSDL_FILENAME = GENERATED_WSDL_NAME + ".wsdl"; //$NON-NLS-1$
+
+ public static final String COLON = ":"; //$NON-NLS-1$
+
+ public static final String SLASH = "/"; //$NON-NLS-1$
+
+ public static final String DOUBLE_SLASH = "//"; //$NON-NLS-1$
+
+ public static final String AMP = "&"; //$NON-NLS-1$
+
+ public static final String QUESTION_MARK = "?"; //$NON-NLS-1$
+
+ public static final String EQUALS = "="; //$NON-NLS-1$
+
+ public static final String COMMA = ","; //$NON-NLS-1$
+
+ private static final String SQLQUERYWEBSERVICE_URL_FORMAT = "{0}://{1}:{2}/{3}"; //$NON-NLS-1$
+
+ /*
+ * this default value is based on Tomcat's default value in its server.xml file. This value can be overridden by setting the
+ * com.metamatrix.webservice.dataservice.httpsport System property for the VM that this servlet is running in.
+ */
+ private static final String DEFAULT_HTTPS_PORT = "8443"; //$NON-NLS-1$
+
+ private static final String DEFAULT_HTTP_PORT = "8080"; //$NON-NLS-1$
+
+ private static final String HTTPS_PORT_PROPERTY_KEY = "com.metamatrix.webservice.dataservice.httpsport"; //$NON-NLS-1$
+
+ private static final String HTTP_PORT_PROPERTY_KEY = "com.metamatrix.webservice.dataservice.httpport"; //$NON-NLS-1$
+
+ /**
+ * Returns the formatted url from the supplied info
+ *
+ * @param scheme the server scheme
+ * @param host the server host name
+ * @param port the server port
+ * @param appContext the context of this application to use in the WSDL url
+ * @param serverURLs the list of server url info, first url is full url including protocol. Subsequent items are just the
+ * host:port strings.
+ * @param vdbName the vdb name
+ * @param vdbVersion the vdb version number
+ */
+ public static String formatURL( String scheme,
+ String host,
+ String port,
+ String appContext,
+ List serverURLs,
+ String vdbName,
+ String vdbVersion ) {
+
+ StringBuffer result = new StringBuffer();
+ try {
+ boolean hasPort = true;
+ boolean hasVDBVersion = true;
+
+ if (port == null || port.length() == 0) {
+ hasPort = false;
+ }
+
+ if (vdbVersion == null || vdbVersion.trim().length() == 0) {
+ hasVDBVersion = false;
+ }
+
+ result.append(scheme).append(COLON).append(DOUBLE_SLASH).append(host);
+
+ if (hasPort) {
+ result.append(COLON).append(port);
+ }
+
+ result.append(appContext).append(SERVLET_PATH).append(SLASH).append(GENERATED_WSDL_FILENAME);
+ result.append(QUESTION_MARK).append(SERVER_URL_KEY).append(EQUALS);
+ // Append comma-delimited server urls
+ Iterator iter = serverURLs.iterator();
+ while (iter.hasNext()) {
+ String serverURL = (String)iter.next();
+ result.append(serverURL);
+ // If there is another url coming, add an encoded comma
+ if (iter.hasNext()) {
+ result.append(URLEncoder.encode(COMMA, "UTF-8")); //$NON-NLS-1$
+ }
+ }
+ result.append(AMP).append(VDB_NAME_KEY).append(EQUALS).append(vdbName);
+ if (hasVDBVersion) {
+ result.append(AMP).append(VDB_VERSION_KEY).append(EQUALS).append(vdbVersion);
+ }
+
+ } catch (UnsupportedEncodingException err) {
+ // ignore
+ }
+
+ return result.toString();
+ }
+
+ /**
+ * Returns the formatted wsdl url for the SqlQueryWebService
+ *
+ * @param server - server name
+ * @param appContext the context of this application to use in the WSDL url
+ * @param secure - secure ssl (true) or non-secure (false)
+ * @return wsdlUrl - String
+ * @since 4.3
+ */
+ public static String getSqlQueryWebServiceUrl( final String server,
+ String appContext,
+ final boolean secure ) {
+
+ appContext=appContext.replace("/",""); //$NON-NLS-1$ //$NON-NLS-2$
+ return MessageFormat.format(SQLQUERYWEBSERVICE_URL_FORMAT, new Object[] {secure ? HTTPS : HTTP, server,
+ secure ? getHttpsPort() : getHttpPort(), appContext+SQLQUERYWEBSERVICE_WSDL_PATH});
+ }
+
+ public static final String getHttpsPort() {
+ return System.getProperty(HTTPS_PORT_PROPERTY_KEY, DEFAULT_HTTPS_PORT);
+ }
+
+ public static final String getHttpPort() {
+ return System.getProperty(HTTP_PORT_PROPERTY_KEY, DEFAULT_HTTP_PORT);
+ }
+}
Property changes on: trunk/common-core/src/main/java/com/metamatrix/common/util/WSDLServletUtil.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/UDDIConfigurationsDialog.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/UDDIConfigurationsDialog.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/UDDIConfigurationsDialog.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -74,10 +74,10 @@
"General.Remove"); //$NON-NLS-1$
private final static String CONFIG_NAME = ConsolePlugin.Util.getString(
"UDDIConfigurationsDialog.configName") + ':'; //$NON-NLS-1$
- private final static String HOST = ConsolePlugin.Util.getString(
- "UDDIConfigurationsDialog.host") + ':'; //$NON-NLS-1$
- private final static String PORT = ConsolePlugin.Util.getString(
- "UDDIConfigurationsDialog.port") + ':'; //$NON-NLS-1$
+ private final static String INQUIRY_URL = ConsolePlugin.Util.getString(
+ "UDDIConfigurationsDialog.uddiInquiryUrl") + ':'; //$NON-NLS-1$
+ private final static String PUBLISH_URL = ConsolePlugin.Util.getString(
+ "UDDIConfigurationsDialog.uddiPublishUrl") + ':'; //$NON-NLS-1$
private final static String USER_NAME = ConsolePlugin.Util.getString(
"UDDIConfigurationsDialog.userName") + ':'; //$NON-NLS-1$
private final static String NOTE_LINE_1 = ConsolePlugin.Util.getString(
@@ -103,8 +103,8 @@
private JButton okButton;
private JButton cancelButton;
private JTextField nameField;
- private JTextField hostField;
- private JTextField portField;
+ private JTextField inquiryUrlField;
+ private JTextField publishUrlField;
private JTextField userField;
private SavedUDDIRegistryInfo removedItem = null;
private int curState = NO_STATE;
@@ -184,13 +184,13 @@
textFieldsPanel.add(nameLabel);
textFieldsLayout.setConstraints(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
- JLabel hostLabel = new LabelWidget(HOST);
- textFieldsPanel.add(hostLabel);
- textFieldsLayout.setConstraints(hostLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
+ JLabel inquiryUrlLabel = new LabelWidget(INQUIRY_URL);
+ textFieldsPanel.add(inquiryUrlLabel);
+ textFieldsLayout.setConstraints(inquiryUrlLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
- JLabel portLabel = new LabelWidget(PORT);
- textFieldsPanel.add(portLabel);
- textFieldsLayout.setConstraints(portLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
+ JLabel publishUrlLabel = new LabelWidget(PUBLISH_URL);
+ textFieldsPanel.add(publishUrlLabel);
+ textFieldsLayout.setConstraints(publishUrlLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
JLabel userLabel = new LabelWidget(USER_NAME);
textFieldsPanel.add(userLabel);
@@ -213,17 +213,17 @@
textFieldsPanel.add(nameField);
textFieldsLayout.setConstraints(nameField, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 2, 0, 0), 0, 0));
- hostField = new TextFieldWidget();
- hostField.getDocument().addDocumentListener(docListener);
- hostField.setEnabled(false);
- textFieldsPanel.add(hostField);
- textFieldsLayout.setConstraints(hostField, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
+ inquiryUrlField = new TextFieldWidget();
+ inquiryUrlField.getDocument().addDocumentListener(docListener);
+ inquiryUrlField.setEnabled(false);
+ textFieldsPanel.add(inquiryUrlField);
+ textFieldsLayout.setConstraints(inquiryUrlField, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 2, 0, 0), 0, 0));
- portField = new TextFieldWidget();
- portField.getDocument().addDocumentListener(docListener);
- portField.setEnabled(false);
- textFieldsPanel.add(portField);
- textFieldsLayout.setConstraints(portField, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
+ publishUrlField = new TextFieldWidget();
+ publishUrlField.getDocument().addDocumentListener(docListener);
+ publishUrlField.setEnabled(false);
+ textFieldsPanel.add(publishUrlField);
+ textFieldsLayout.setConstraints(publishUrlField, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 2, 0, 0), 0, 0));
userField = new TextFieldWidget();
userField.getDocument().addDocumentListener(docListener);
@@ -301,10 +301,10 @@
private void textFieldChanged() {
boolean newConfig = (curState == ADDING);
String configName = nameField.getText().trim();
- String host = hostField.getText().trim();
- String port = portField.getText().trim();
+ String inquiryUrl = inquiryUrlField.getText().trim();
+ String publishUrl = publishUrlField.getText().trim();
String user = userField.getText().trim();
- boolean entriesValid = isValidConfig(configName, host, port, user, newConfig);
+ boolean entriesValid = isValidConfig(configName, inquiryUrl, publishUrl, user, newConfig);
okButton.setEnabled(entriesValid);
}
@@ -339,10 +339,10 @@
case EDITING:
SavedUDDIRegistryInfo item = getSelectedItem();
String configName = item.getName();
- String host = hostField.getText().trim();
- String port = portField.getText().trim();
+ String inquiryUrl = inquiryUrlField.getText().trim();
+ String publishUrl = publishUrlField.getText().trim();
String user = userField.getText().trim();
- SavedUDDIRegistryInfo editedItem = new SavedUDDIRegistryInfo(configName, user, host, port);
+ SavedUDDIRegistryInfo editedItem = new SavedUDDIRegistryInfo(configName, user, inquiryUrl, publishUrl);
if (item.equals(editedItem)) {
handler.unchangedConfiguration(item);
} else {
@@ -351,10 +351,10 @@
break;
case ADDING:
configName = nameField.getText().trim();
- host = hostField.getText().trim();
- port = portField.getText().trim();
+ inquiryUrl = inquiryUrlField.getText().trim();
+ publishUrl = publishUrlField.getText().trim();
user = userField.getText().trim();
- SavedUDDIRegistryInfo newItem = new SavedUDDIRegistryInfo(configName, user, host, port);
+ SavedUDDIRegistryInfo newItem = new SavedUDDIRegistryInfo(configName, user, inquiryUrl, publishUrl);
handler.addedConfiguration(newItem);
break;
case REMOVING:
@@ -377,10 +377,10 @@
return found;
}
- private boolean isValidConfig(String configName, String host, String port, String userName,
+ private boolean isValidConfig(String configName, String inquiryUrl, String publishUrl, String userName,
boolean newConfig) {
boolean valid = false;
- if ((configName.length() > 0) && (host.length() > 0) && (port.length() > 0) && (userName.length() >
+ if ((configName.length() > 0) && (inquiryUrl.length() > 0) && (publishUrl.length() > 0) && (userName.length() >
0)) {
if (newConfig) {
if (!isExistingConfigName(configName)) {
@@ -396,14 +396,14 @@
private void clearText() {
String empty = StringUtil.Constants.EMPTY_STRING;
nameField.setText(empty);
- hostField.setText(empty);
- portField.setText(empty);
+ inquiryUrlField.setText(empty);
+ publishUrlField.setText(empty);
userField.setText(empty);
}
private void enableText(boolean includingName) {
- hostField.setEnabled(true);
- portField.setEnabled(true);
+ inquiryUrlField.setEnabled(true);
+ publishUrlField.setEnabled(true);
userField.setEnabled(true);
if (includingName) {
nameField.setEnabled(true);
@@ -412,8 +412,8 @@
private void disableText() {
nameField.setEnabled(false);
- hostField.setEnabled(false);
- portField.setEnabled(false);
+ inquiryUrlField.setEnabled(false);
+ publishUrlField.setEnabled(false);
userField.setEnabled(false);
}
@@ -431,8 +431,8 @@
clearText();
} else {
nameField.setText(item.getName());
- hostField.setText(item.getHost());
- portField.setText(item.getPort());
+ inquiryUrlField.setText(item.getInquiryUrl());
+ publishUrlField.setText(item.getPublishUrl());
userField.setText(item.getUserName());
}
}
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/VdbMainPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/VdbMainPanel.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/VdbMainPanel.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -118,6 +118,7 @@
private static final String TREE_TAB_TITLE = "Metadata Tree"; //$NON-NLS-1$
private static final String CONNBIND_TAB_TITLE = "Connector Bindings"; //$NON-NLS-1$
private static final String ENTITLEMENTS_TAB_TITLE = "Roles"; //$NON-NLS-1$
+ private static final String WEB_SERVICES_TAB_TITLE = "Web Services"; //$NON-NLS-1$
private static final String MATERIALIZATION_TAB_TITLE = "Materialization"; //$NON-NLS-1$
private static final String ACTIVE_DEFAULT_DISPLAY_LABEL = "Active (Default)"; //$NON-NLS-1$
@@ -248,6 +249,7 @@
pnlBindings = new VdbConnBindPanel(connection);
pnlEntitlements = new VdbEntitlementsPanel(connection);
javax.swing.JPanel pnlMaterialization = new MaterializationPanel(connection);
+ javax.swing.JPanel pnlWebServices = new WebServicesPanel(connection);
javax.swing.JPanel pnlOps = new javax.swing.JPanel();
btnImportVDB = new ButtonWidget();
setup(MenuEntry.ACTION_MENUITEM, btnImportVDB, actionImportVDB);
@@ -292,6 +294,7 @@
tpnDetails.addTab(TREE_TAB_TITLE, pnlTree);
tpnDetails.addTab(CONNBIND_TAB_TITLE, pnlBindings);
tpnDetails.addTab(ENTITLEMENTS_TAB_TITLE, pnlEntitlements);
+ tpnDetails.addTab(WEB_SERVICES_TAB_TITLE, pnlWebServices);
tpnDetails.addTab(MATERIALIZATION_TAB_TITLE, pnlMaterialization);
tpnDetails.setSelectedIndex(0);
pnlBottom.add(tpnDetails);
Added: trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/WSDLWizardRunner.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/WSDLWizardRunner.java (rev 0)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/WSDLWizardRunner.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -0,0 +1,1139 @@
+/*
+ * Copyright � 2000-2005 MetaMatrix, Inc. All rights reserved.
+ */
+package com.metamatrix.console.ui.views.vdb;
+
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.GridLayout;
+import java.awt.Insets;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JPasswordField;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import org.uddi4j.response.BusinessInfo;
+import org.uddi4j.response.BusinessList;
+
+import com.metamatrix.common.config.ResourceNames;
+import com.metamatrix.common.config.api.Configuration;
+import com.metamatrix.common.config.api.ConfigurationID;
+import com.metamatrix.common.config.api.SharedResource;
+import com.metamatrix.common.util.WSDLServletUtil;
+import com.metamatrix.console.ConsolePlugin;
+import com.metamatrix.console.models.ConfigurationManager;
+import com.metamatrix.console.ui.layout.ConsoleMainFrame;
+import com.metamatrix.console.ui.util.BasicWizardSubpanelContainer;
+import com.metamatrix.console.ui.util.IconComponent;
+import com.metamatrix.console.ui.util.WizardInterface;
+import com.metamatrix.console.ui.util.WizardInterfaceImpl;
+import com.metamatrix.console.ui.util.property.Icons;
+import com.metamatrix.console.util.ExceptionUtility;
+import com.metamatrix.console.util.SavedUDDIRegistryInfo;
+import com.metamatrix.console.util.StaticProperties;
+import com.metamatrix.console.util.StaticUtilities;
+import com.metamatrix.core.util.StringUtil;
+import com.metamatrix.toolbox.ui.widget.ButtonWidget;
+import com.metamatrix.toolbox.ui.widget.LabelWidget;
+import com.metamatrix.toolbox.ui.widget.TableWidget;
+import com.metamatrix.toolbox.ui.widget.TextFieldWidget;
+import com.metamatrix.toolbox.ui.widget.table.DefaultTableModel;
+import com.metamatrix.uddi.exception.MMUddiException;
+import com.metamatrix.uddi.util.MMUddiHelper;
+import com.metamatrix.uddi.util.UddiHelper;
+
+/**
+ * @since 5.5.3
+ */
+public class WSDLWizardRunner {
+ private final static int CONFIG_PANEL_STEP_NUM = 1;
+ private final static int BUSINESS_PANEL_STEP_NUM = 2;
+ private final static int WSDL_URL_PANEL_STEP_NUM = 3;
+ private final static int RESULTS_PANEL_STEP_NUM = 4;
+
+ private final static String NO_BUSINESSES = ConsolePlugin.Util.getString("WSDLWizardRunner.noBusinesses"); //$NON-NLS-1$
+ private final static String NO_BUSINESSES_MSG = ConsolePlugin.Util.getString("WSDLWizardRunner.noBusinessesMsg"); //$NON-NLS-1$
+ // private final static String HTTP = "http"; //$NON-NLS-1$
+
+ private Configuration currentConfig;
+ private ConfigurationManager configMgr;
+ private boolean publishing;
+ private String vdbName;
+ private String vdbVersion;
+ private SelectUDDIConfigurationPanel configPanel;
+ private SelectBusinessPanel businessPanel;
+ private CreateWSDLURLElementsPanel wsdlURLPanel;
+ private ResultsPanel resultsPanel;
+ private JPanel currentPanel;
+ private boolean cancelled = false;
+ private boolean finished = false;
+ private WSDLWizardPanel wizardPanel = null;
+ private WSDLWizardPanelDialog dialog;
+ private UddiHelper uddiAPI = null;
+ private String password = StringUtil.Constants.EMPTY_STRING;
+ private BusinessList /* <BusinessEntity> */businesses = null;
+ private boolean haveShownWSDLURLPanel = false;
+ private static String DEFAULT_WEBSERVICE_CONTEXT = "/metamatrix-soap";
+
+
+ public WSDLWizardRunner( String vdbName,
+ String vdbVersion,
+ Configuration currConfig,
+ ConfigurationManager configMgr,
+ boolean publishing ) {
+ super();
+ this.vdbName = vdbName;
+ this.vdbVersion = vdbVersion;
+ this.currentConfig = currConfig;
+ this.configMgr = configMgr;
+ this.publishing = publishing;
+ }
+
+ public void go() {
+ wizardPanel = new WSDLWizardPanel(this);
+ configPanel = new SelectUDDIConfigurationPanel(wizardPanel, CONFIG_PANEL_STEP_NUM);
+ businessPanel = new SelectBusinessPanel(wizardPanel, BUSINESS_PANEL_STEP_NUM);
+ wsdlURLPanel = new CreateWSDLURLElementsPanel(wizardPanel, WSDL_URL_PANEL_STEP_NUM);
+ resultsPanel = new ResultsPanel(wizardPanel, publishing, RESULTS_PANEL_STEP_NUM);
+ wizardPanel.addPage(configPanel);
+ wizardPanel.addPage(businessPanel);
+ wizardPanel.addPage(wsdlURLPanel);
+ wizardPanel.addPage(resultsPanel);
+ wizardPanel.getNextButton().setEnabled(false);
+ currentPanel = configPanel;
+ wizardPanel.getCancelButton().addActionListener(new ActionListener() {
+ public void actionPerformed( ActionEvent ev ) {
+ cancelPressed();
+ }
+ });
+ wizardPanel.getFinishButton().addActionListener(new ActionListener() {
+ public void actionPerformed( ActionEvent ev ) {
+ finishPressed();
+ }
+ });
+ dialog = new WSDLWizardPanelDialog(this, wizardPanel, publishing);
+ dialog.setVisible(true);
+ if (finished && (!cancelled)) {
+ // Insert any post-processing code here
+ }
+ }
+
+ public void dialogWindowClosing() {
+ cancelled = true;
+ }
+
+ public void cancelPressed() {
+ dialog.cancelPressed();
+ cancelled = true;
+ }
+
+ public void finishPressed() {
+ dialog.finishPressed();
+ finished = true;
+ }
+
+ public boolean showNextPage() {
+ boolean goingToNextPage = true;
+ if (currentPanel == configPanel) {
+ if (uddiAPI == null) {
+ uddiAPI = new MMUddiHelper();
+ }
+ SavedUDDIRegistryInfo config = configPanel.getSelectedConfig();
+ UDDIPasswordDialog passwordDialog = new UDDIPasswordDialog(config.getName());
+ passwordDialog.setVisible(true);
+ password = passwordDialog.getPassword();
+ if (password == null) {
+ goingToNextPage = false;
+ } else {
+ String inquiryUrl = config.getInquiryUrl();
+ String publishUrl = config.getPublishUrl();
+ businesses = null;
+ try {
+ StaticUtilities.startWait(dialog.getContentPane());
+ businesses = uddiAPI.getAllBusinesses(inquiryUrl, publishUrl, 100);
+ } catch (MMUddiException ex) {
+ StaticUtilities.endWait(dialog.getContentPane());
+ displayInitialUDDIAccessError(ex);
+ goingToNextPage = false;
+ }
+ if (goingToNextPage) {
+ StaticUtilities.endWait(dialog.getContentPane());
+ if (businesses.getBusinessInfos().size() == 0) {
+ StaticUtilities.displayModalDialogWithOK(NO_BUSINESSES, NO_BUSINESSES_MSG, JOptionPane.WARNING_MESSAGE);
+ goingToNextPage = false;
+ }
+ }
+ if (goingToNextPage) {
+ businessPanel.setBusinesses(businesses);
+ currentPanel = businessPanel;
+ businessPanel.setForwardButtonEnabling();
+ }
+ }
+ } else if (currentPanel == businessPanel) {
+ // Insert here any checks which might prevent proceeding to next page
+ if (goingToNextPage) {
+ if (!haveShownWSDLURLPanel) {
+ ConfigurationID configID = (ConfigurationID)currentConfig.getID();
+ wsdlURLPanel.setdefaultWebServerHost("localhost");
+ wsdlURLPanel.setDefaultWebServerPort("8080");
+ wizardPanel.getNextButton().setEnabled(true);
+ haveShownWSDLURLPanel = true;
+ }
+ currentPanel = wsdlURLPanel;
+ wsdlURLPanel.setForwardButtonEnabling();
+ }
+ } else if (currentPanel == wsdlURLPanel) {
+ String webServerScheme = wsdlURLPanel.getWebServerScheme();
+ String webServerHost = wsdlURLPanel.getWebServerHost();
+ String webServerPort = wsdlURLPanel.getWebServerPort();
+ String wsdlURL = makeURL(webServerScheme, webServerHost, webServerPort);
+ SavedUDDIRegistryInfo config = configPanel.getSelectedConfig();
+ String userName = config.getUserName();
+ String inquiryUrl = config.getInquiryUrl();
+ String publishUrl = config.getPublishUrl();
+ String businessKey = businessPanel.getSelectedBusinessKey();
+ if (publishing) {
+ MMUddiException publishingException = null;
+ boolean isPublished = false;
+ try {
+ isPublished = uddiAPI.isPublished(userName, password, businessKey, wsdlURL, inquiryUrl, publishUrl);
+ } catch (MMUddiException ex) {
+ publishingException = ex;
+ }
+ if (publishingException == null) {
+ if (isPublished) {
+ resultsPanel.addIncorrectPublishingStateText();
+ } else {
+ try {
+ uddiAPI.publish(userName, password, businessKey, wsdlURL, inquiryUrl, publishUrl);
+ } catch (MMUddiException ex) {
+ publishingException = ex;
+ }
+ }
+ }
+ if ((!isPublished) && (publishingException == null)) {
+ resultsPanel.addSuccessText();
+ wizardPanel.getBackButton().setVisible(false);
+ } else {
+ if (publishingException != null) {
+ resultsPanel.addErrorHandlingSubcomponents(publishingException);
+ }
+ }
+ } else {
+ MMUddiException unpublishingException = null;
+ boolean isPublished = false;
+ try {
+ isPublished = uddiAPI.isPublished(userName, password, businessKey, wsdlURL, inquiryUrl, publishUrl);
+ } catch (MMUddiException ex) {
+ unpublishingException = ex;
+ }
+ if (unpublishingException == null) {
+ if (!isPublished) {
+ resultsPanel.addIncorrectPublishingStateText();
+ } else {
+ try {
+ uddiAPI.unPublish(userName, password, businessKey, wsdlURL, inquiryUrl, publishUrl);
+ } catch (MMUddiException ex) {
+ unpublishingException = ex;
+ }
+ }
+ }
+ if (isPublished && (unpublishingException == null)) {
+ resultsPanel.addSuccessText();
+ wizardPanel.getBackButton().setVisible(false);
+ } else {
+ if (unpublishingException != null) {
+ resultsPanel.addErrorHandlingSubcomponents(unpublishingException);
+ }
+ }
+ }
+ // Insert any checks which might prevent proceeding to next page here
+ if (goingToNextPage) {
+ currentPanel = resultsPanel;
+ }
+ }
+ boolean cancelVisible = (currentPanel != resultsPanel);
+ wizardPanel.getCancelButton().setVisible(cancelVisible);
+ return goingToNextPage;
+ }
+
+ public void showPreviousPage() {
+ // Everything on the new current page will be as we left it which was a state that allowed
+ // enabling of the Next button. So it is safe to go ahead and enable the 'Next' button.
+ if (currentPanel == businessPanel) {
+ currentPanel = configPanel;
+ configPanel.enableForwardButton(true);
+ } else if (currentPanel == wsdlURLPanel) {
+ currentPanel = businessPanel;
+ businessPanel.enableForwardButton(true);
+ } else if (currentPanel == resultsPanel) {
+ currentPanel = wsdlURLPanel;
+ wsdlURLPanel.enableForwardButton(true);
+ }
+ boolean cancelVisible = (currentPanel != resultsPanel);
+ wizardPanel.getCancelButton().setVisible(cancelVisible);
+ }
+
+ private String makeURL( String scheme,
+ String host,
+ String port ) {
+ List list = new ArrayList();
+ list.add(configMgr.getConnection().getURL());
+ return WSDLServletUtil.formatURL(scheme, host, port, DEFAULT_WEBSERVICE_CONTEXT, list, vdbName, vdbVersion); //$NON-NLS-1$
+ }
+
+ private void displayInitialUDDIAccessError( MMUddiException ex ) {
+ // TODO-- what to display may depend on contents of exception. If can discern that
+ // unable to connect to UDDI, then so state and do not show option to show error dialog.
+ // Else possibly put up modal dialog with "View Error Dialog" button, but then dispose of
+ // pop-up before going to error dialog.
+ UDDIInitialAccessErrorDialog dlg = new UDDIInitialAccessErrorDialog(ConsoleMainFrame.getInstance(), ex);
+ dlg.setVisible(true);
+ }
+}// end WSDLWizardRunner
+
+class WSDLWizardPanel extends WizardInterfaceImpl {
+ private WSDLWizardRunner controller;
+
+ public WSDLWizardPanel( WSDLWizardRunner cntrlr ) {
+ super();
+ this.controller = cntrlr;
+ }
+
+ public void showNextPage() {
+ boolean continuing = controller.showNextPage();
+ if (continuing) {
+ super.showNextPage();
+ }
+ }
+
+ public void showPreviousPage() {
+ controller.showPreviousPage();
+ super.showPreviousPage();
+ }
+}// end WSDLWizardPanel
+
+class SelectUDDIConfigurationPanel extends BasicWizardSubpanelContainer implements UDDIConfigurationsHandler {
+ private final static String SELECT_CONFIG = ConsolePlugin.Util.getString("WSDLWizardRunner.selectAConfig"); //$NON-NLS-1$
+ private final static String CONFIGURATIONS = ConsolePlugin.Util.getString("WSDLWizardRunner.configurations"); //$NON-NLS-1$
+ private final static String UDDI_CONFIG = ConsolePlugin.Util.getString("UDDIConfigurationsDialog.configName") + ':'; //$NON-NLS-1$
+ private final static String INQUIRY_URL = ConsolePlugin.Util.getString("UDDIConfigurationsDialog.uddiInquiryUrl") + ':'; //$NON-NLS-1$
+ private final static String PUBLISH_URL = ConsolePlugin.Util.getString("UDDIConfigurationsDialog.uddiPublishUrl") + ':'; //$NON-NLS-1$
+ private final static String USER = ConsolePlugin.Util.getString("UDDIConfigurationsDialog.userName") + ':'; //$NON-NLS-1$
+ private final static int TOP_INSET = 10;
+ private final static int LEFT_INSET = 10;
+ private final static int CONFIG_ROW_BOTTOM_INSET = 5;
+ private final static int SECOND_COL_LEFT_INSET = 4;
+ private final static int FIELDS_PANEL_BETWEEN_ROWS_INSET = 4;
+
+ private JPanel thePanel;
+ private JComboBox configsCombo;
+ private JButton configsButton;
+ private JTextField inquiryUrlField;
+ private JTextField publishUrlField;
+ private JTextField userField;
+ private java.util.List /* <SavedUDDIRegistryInfo> */items;
+
+ public SelectUDDIConfigurationPanel( WizardInterface wizardInterface,
+ int stepNum ) {
+ super(wizardInterface);
+ super.setStepText(stepNum, SELECT_CONFIG);
+ SavedUDDIRegistryInfo[] savedItems = StaticProperties.getUDDIRegistryInfo();
+ items = new ArrayList(savedItems.length);
+ for (int i = 0; i < savedItems.length; i++) {
+ items.add(savedItems[i]);
+ }
+ thePanel = createPanel();
+ super.setMainContent(thePanel);
+ }
+
+ private JPanel createPanel() {
+ JPanel panel = new JPanel();
+ GridBagLayout layout = new GridBagLayout();
+ panel.setLayout(layout);
+ JLabel configsLabel = new LabelWidget(UDDI_CONFIG);
+ panel.add(configsLabel);
+ layout.setConstraints(configsLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,
+ GridBagConstraints.NONE,
+ new Insets(TOP_INSET, LEFT_INSET, CONFIG_ROW_BOTTOM_INSET, 0),
+ 0, 1));
+ String[] configNamesArray = createConfigNamesArray();
+ configsCombo = new JComboBox(configNamesArray);
+ configsCombo.addActionListener(new ActionListener() {
+ public void actionPerformed( ActionEvent ev ) {
+ configSelectionChanged();
+ }
+ });
+ configsCombo.setEditable(false);
+ panel.add(configsCombo);
+ layout.setConstraints(configsCombo, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH,
+ GridBagConstraints.HORIZONTAL,
+ new Insets(TOP_INSET, SECOND_COL_LEFT_INSET,
+ CONFIG_ROW_BOTTOM_INSET, 0), 0, 0));
+ configsButton = new ButtonWidget(CONFIGURATIONS);
+ configsButton.addActionListener(new ActionListener() {
+ public void actionPerformed( ActionEvent ev ) {
+ configsButtonPressed();
+ }
+ });
+ panel.add(configsButton);
+ layout.setConstraints(configsButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,
+ GridBagConstraints.NONE, new Insets(TOP_INSET, 4,
+ CONFIG_ROW_BOTTOM_INSET,
+ 10), 0, 0));
+ JPanel fieldsPanel = new JPanel();
+ panel.add(fieldsPanel);
+ layout.setConstraints(fieldsPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 4.0, GridBagConstraints.NORTH,
+ GridBagConstraints.HORIZONTAL, new Insets(20, LEFT_INSET, 20,
+ LEFT_INSET), 0, 0));
+ GridBagLayout fieldsLayout = new GridBagLayout();
+ fieldsPanel.setLayout(fieldsLayout);
+ JLabel hostLabel = new LabelWidget(INQUIRY_URL);
+ fieldsPanel.add(hostLabel);
+ fieldsLayout.setConstraints(hostLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE,
+ new Insets(0, 0, FIELDS_PANEL_BETWEEN_ROWS_INSET, 0), 0, 0));
+ inquiryUrlField = new TextFieldWidget(100);
+ inquiryUrlField.setEditable(false);
+ fieldsPanel.add(inquiryUrlField);
+ fieldsLayout.setConstraints(inquiryUrlField, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.HORIZONTAL,
+ new Insets(0, SECOND_COL_LEFT_INSET,
+ FIELDS_PANEL_BETWEEN_ROWS_INSET, 0), 0, 0));
+ JLabel portLabel = new LabelWidget(PUBLISH_URL);
+ fieldsPanel.add(portLabel);
+ fieldsLayout.setConstraints(portLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE,
+ new Insets(FIELDS_PANEL_BETWEEN_ROWS_INSET, 0,
+ FIELDS_PANEL_BETWEEN_ROWS_INSET, 0), 0, 0));
+ publishUrlField = new TextFieldWidget(100);
+ publishUrlField.setEditable(false);
+ fieldsPanel.add(publishUrlField);
+ fieldsLayout.setConstraints(publishUrlField, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.HORIZONTAL,
+ new Insets(FIELDS_PANEL_BETWEEN_ROWS_INSET,
+ SECOND_COL_LEFT_INSET,
+ FIELDS_PANEL_BETWEEN_ROWS_INSET, 0), 0, 0));
+ JLabel userLabel = new LabelWidget(USER);
+ fieldsPanel.add(userLabel);
+ fieldsLayout.setConstraints(userLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE,
+ new Insets(FIELDS_PANEL_BETWEEN_ROWS_INSET, 0, 0, 0), 0, 0));
+ userField = new TextFieldWidget();
+ userField.setEditable(false);
+ fieldsPanel.add(userField);
+ fieldsLayout.setConstraints(userField, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.HORIZONTAL,
+ new Insets(FIELDS_PANEL_BETWEEN_ROWS_INSET,
+ SECOND_COL_LEFT_INSET, 0, 0), 0, 0));
+ return panel;
+ }
+
+ private String[] createConfigNamesArray() {
+ String[] array = new String[items.size() + 1];
+ array[0] = StringUtil.Constants.EMPTY_STRING;
+ Iterator it = items.iterator();
+ for (int i = 1; it.hasNext(); i++) {
+ SavedUDDIRegistryInfo curItem = (SavedUDDIRegistryInfo)it.next();
+ array[i] = curItem.getName();
+ }
+ return array;
+ }
+
+ private void configSelectionChanged() {
+ setForwardButtonEnabling();
+ }
+
+ private void setForwardButtonEnabling() {
+ int index = configsCombo.getSelectedIndex();
+ if (index >= 1) {
+ SavedUDDIRegistryInfo selectedItem = (SavedUDDIRegistryInfo)items.get(index - 1);
+ inquiryUrlField.setText(selectedItem.getInquiryUrl());
+ publishUrlField.setText(selectedItem.getPublishUrl());
+ userField.setText(selectedItem.getUserName());
+ enableForwardButton(true);
+ } else {
+ inquiryUrlField.setText(StringUtil.Constants.EMPTY_STRING);
+ publishUrlField.setText(StringUtil.Constants.EMPTY_STRING);
+ userField.setText(StringUtil.Constants.EMPTY_STRING);
+ enableForwardButton(false);
+ }
+ }
+
+ private void configsButtonPressed() {
+ runConfigsDialog();
+ }
+
+ private void runConfigsDialog() {
+ SavedUDDIRegistryInfo[] array = new SavedUDDIRegistryInfo[items.size()];
+ Iterator it = items.iterator();
+ for (int i = 0; it.hasNext(); i++) {
+ array[i] = (SavedUDDIRegistryInfo)it.next();
+ }
+ UDDIConfigurationsDialog dialog = new UDDIConfigurationsDialog(ConsoleMainFrame.getInstance(), this, array);
+ dialog.setVisible(true);
+ }
+
+ public void addedConfiguration( SavedUDDIRegistryInfo config ) {
+ DefaultComboBoxModel model = (DefaultComboBoxModel)configsCombo.getModel();
+ items.add(config);
+ updateConfigs();
+ model.addElement(config.getName());
+ selectItem(config);
+ }
+
+ public void removedConfiguration( SavedUDDIRegistryInfo config ) {
+ DefaultComboBoxModel model = (DefaultComboBoxModel)configsCombo.getModel();
+ items.remove(config);
+ updateConfigs();
+ model.removeElement(config.getName());
+ }
+
+ public void editedConfiguration( SavedUDDIRegistryInfo config ) {
+ // Cannot change the name when editing the item, so we do not have to change the combo box model
+ int matchIndex = matchIndexOfConfigName(config);
+ if (matchIndex >= 0) {
+ items.set(matchIndex, config);
+ updateConfigs();
+ selectItem(config);
+ }
+ }
+
+ public void unchangedConfiguration( SavedUDDIRegistryInfo config ) {
+ selectItem(config);
+ }
+
+ private void selectItem( SavedUDDIRegistryInfo config ) {
+ int matchIndex = matchIndexOfConfigName(config);
+ if (matchIndex >= 0) {
+ // Offset by 1 to account for blank entry at start of combo
+ configsCombo.setSelectedIndex(matchIndex + 1);
+ }
+ }
+
+ private int matchIndexOfConfigName( SavedUDDIRegistryInfo config ) {
+ String configName = config.getName();
+ int matchIndex = -1;
+ int index = 0;
+ int numItems = items.size();
+ while ((matchIndex < 0) && (index < numItems)) {
+ SavedUDDIRegistryInfo curConfig = (SavedUDDIRegistryInfo)items.get(index);
+ String curConfigName = curConfig.getName();
+ if (configName.equals(curConfigName)) {
+ matchIndex = index;
+ } else {
+ index++;
+ }
+ }
+ return matchIndex;
+ }
+
+ private void updateConfigs() {
+ SavedUDDIRegistryInfo[] array = new SavedUDDIRegistryInfo[items.size()];
+ Iterator it = items.iterator();
+ for (int i = 0; it.hasNext(); i++) {
+ array[i] = (SavedUDDIRegistryInfo)it.next();
+ }
+ StaticProperties.setUDDIRegistryInfo(array);
+ }
+
+ public SavedUDDIRegistryInfo getSelectedConfig() {
+ SavedUDDIRegistryInfo selection = null;
+ int selectedIndex = configsCombo.getSelectedIndex();
+ // Offset by 1 to account for blank entry at top of combo box
+ if (selectedIndex >= 1) {
+ selection = (SavedUDDIRegistryInfo)items.get(selectedIndex - 1);
+ }
+ return selection;
+ }
+
+ /**
+ * Overridden to enable the forward button only if the file selection is valid.
+ *
+ * @see com.metamatrix.console.ui.util.BasicWizardSubpanelContainer#resolveForwardButton()
+ * @since 5.5.3
+ */
+ public void resolveForwardButton() {
+ setForwardButtonEnabling();
+ }
+
+ public Dimension getPreferredSize() {
+ Dimension size = super.getPreferredSize();
+ // System.err.println("in SelectUDDIConfigurationPanel getPreferredSize(), returning " + size);
+ return size;
+ }
+}// end SelectUDDIConfigurationPanel
+
+class SelectBusinessPanel extends BasicWizardSubpanelContainer {
+ private final static String SELECT_A_BUSINESS = ConsolePlugin.Util.getString("WSDLWizardRunner.selectABusiness"); //$NON-NLS-1$
+ private final static String SELECT_A_BUSINESS_LABEL = SELECT_A_BUSINESS + ':';
+ private final static String BUSINESS_NAME = ConsolePlugin.Util.getString("WSDLWizardRunner.businessName"); //$NON-NLS-1$
+ private final static String BUSINESS_KEY = ConsolePlugin.Util.getString("WSDLWizardRunner.businessKey"); //$NON-NLS-1$
+ private final static String DESCRIPTION_LABEL = ConsolePlugin.Util.getString("WSDLWizardRunner.description"); //$NON-NLS-1$
+
+ private final static int BUSINESS_NAME_COL_INDEX = 0;
+ private final static int BUSINESS_KEY_COL_INDEX = 1;
+ // Order must correspond to column index constants
+ private final static String[] COL_HEADERS = new String[] {BUSINESS_NAME, BUSINESS_KEY};
+
+ private final static int LEFT_INSET = 10;
+ private final static int RIGHT_INSET = 10;
+
+ private JPanel thePanel;
+ private BusinessList /* <BusinessEntity> */businesses;
+ private JTable table;
+ private JTextArea descriptionArea;
+
+ public SelectBusinessPanel( WizardInterface wizardInterface,
+ int stepNum ) {
+ super(wizardInterface);
+ super.setStepText(stepNum, SELECT_A_BUSINESS);
+ thePanel = createPanel();
+ super.setMainContent(thePanel);
+ }
+
+ private JPanel createPanel() {
+ table = new SelectBusinessPanelTable(Arrays.asList(COL_HEADERS));
+ table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+ public void valueChanged( ListSelectionEvent ev ) {
+ if (!ev.getValueIsAdjusting()) {
+ tableRowSelectionChanged();
+ }
+ }
+ });
+ ((TableWidget)table).setEditable(false);
+
+ JPanel panel = new JPanel();
+ GridBagLayout layout = new GridBagLayout();
+ panel.setLayout(layout);
+ JLabel selectBusinessLabel = new LabelWidget(SELECT_A_BUSINESS_LABEL);
+ panel.add(selectBusinessLabel);
+ layout.setConstraints(selectBusinessLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE, new Insets(10, LEFT_INSET, 10,
+ RIGHT_INSET), 0, 0));
+ JScrollPane tableScrollPane = new JScrollPane(table);
+ panel.add(tableScrollPane);
+ layout.setConstraints(tableScrollPane, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
+ GridBagConstraints.BOTH, new Insets(0, LEFT_INSET, 10,
+ RIGHT_INSET), 0, 0));
+ JLabel descriptionLabel = new LabelWidget(DESCRIPTION_LABEL);
+ panel.add(descriptionLabel);
+ layout.setConstraints(descriptionLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE, new Insets(0, LEFT_INSET, 0,
+ RIGHT_INSET), 0, 0));
+ descriptionArea = new JTextArea();
+ descriptionArea.setEditable(false);
+ descriptionArea.setLineWrap(true);
+ descriptionArea.setWrapStyleWord(true);
+ panel.add(descriptionArea);
+ layout.setConstraints(descriptionArea, new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
+ GridBagConstraints.BOTH, new Insets(0, LEFT_INSET, 0,
+ RIGHT_INSET), 0, 0));
+ return panel;
+ }
+
+ private void tableRowSelectionChanged() {
+ int selectedRow = table.getSelectedRow();
+ if (selectedRow < 0) {
+ descriptionArea.setText(StringUtil.Constants.EMPTY_STRING);
+ } else {
+ BusinessInfo selectedBusiness = businesses.getBusinessInfos().get(selectedRow);
+ String desc = selectedBusiness.getDefaultDescriptionString();
+ descriptionArea.setText(desc);
+ }
+ setForwardButtonEnabling();
+ }
+
+ public void setBusinesses( BusinessList busList ) {
+ this.businesses = busList;
+ DefaultTableModel model = (DefaultTableModel)table.getModel();
+ model.setRowCount(0);
+ Iterator it = this.businesses.getBusinessInfos().getBusinessInfoVector().iterator();
+ while (it.hasNext()) {
+ BusinessInfo business = (BusinessInfo)it.next();
+ String businessKey = business.getBusinessKey();
+ String businessName = business.getDefaultNameString();
+ String[] rowData = new String[2];
+ rowData[BUSINESS_NAME_COL_INDEX] = businessName;
+ rowData[BUSINESS_KEY_COL_INDEX] = businessKey;
+ model.addRow(rowData);
+ }
+ }
+
+ public String getSelectedBusinessKey() {
+ String key = null;
+ int selectedIndex = table.getSelectedRow();
+ if (selectedIndex >= 0) {
+ key = (String)table.getModel().getValueAt(selectedIndex, BUSINESS_KEY_COL_INDEX);
+ }
+ return key;
+ }
+
+ public void setForwardButtonEnabling() {
+ int selectedRow = table.getSelectedRow();
+ enableForwardButton((selectedRow >= 0));
+ }
+
+ /**
+ * Overridden to enable the forward button only if the file selection is valid.
+ *
+ * @see com.metamatrix.console.ui.util.BasicWizardSubpanelContainer#resolveForwardButton()
+ * @since 5.5.3
+ */
+ public void resolveForwardButton() {
+ setForwardButtonEnabling();
+ }
+
+ public Dimension getPreferredSize() {
+ Dimension size = super.getPreferredSize();
+ // System.err.println("in SelectBusinessPanel getPreferredSize(), returning " + size);
+ return size;
+ }
+}// end SelectBusinessPanel
+
+class SelectBusinessPanelTable extends TableWidget {
+ public SelectBusinessPanelTable( java.util.List columns ) {
+ super(columns);
+ }
+
+ public Dimension getPreferredSize() {
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension preferredSize = super.getPreferredSize();
+ int preferredWidth = Math.max(preferredSize.width, (screenSize.width / 2));
+ return new Dimension(preferredWidth, preferredSize.height);
+ }
+}// end SelectBusinessPanelTable
+
+/**
+ * Panel to set and display SOAP URL connection properties
+ * @since 5.5.3
+ */
+class CreateWSDLURLElementsPanel extends BasicWizardSubpanelContainer {
+ private final static String TITLE = ConsolePlugin.Util.getString("WSDLWizardRunner.setSOAPProperties"); //$NON-NLS-1$
+ private final static String DESC = ConsolePlugin.Util.getString("WSDLWizardRunner.setSOAPPropertiesDesc"); //$NON-NLS-1$
+ private final static String HOST = ConsolePlugin.Util.getString("WSDLWizardRunner.webServerHost"); //$NON-NLS-1$
+ private final static String PORT = ConsolePlugin.Util.getString("WSDLWizardRunner.webServerPort"); //$NON-NLS-1$
+ private final static String DEFAULTS = ConsolePlugin.Util.getString("WSDLWizardRunner.resetToDefaults"); //$NON-NLS-1$
+
+ private final static int BETWEEN_LABELS_VERT_GAP = 2;
+
+ private JPanel thePanel;
+ private String defaultWebServerPort;
+ private String defaultWebServerHost;
+ private JTextField inquiryUrlField;
+ private JTextField publishUrlField;
+
+ /**
+ * Constructor
+ * @param wizardInterface
+ * @param stepNum
+ */
+ public CreateWSDLURLElementsPanel( WizardInterface wizardInterface,
+ int stepNum ) {
+ super(wizardInterface);
+ super.setStepText(stepNum, TITLE);
+ thePanel = createPanel();
+ super.setMainContent(thePanel);
+ }
+
+ private JPanel createPanel() {
+ JPanel panel = new JPanel();
+ GridBagLayout layout = new GridBagLayout();
+ panel.setLayout(layout);
+ JLabel desc = new LabelWidget(DESC);
+ panel.add(desc);
+ layout.setConstraints(desc, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ JPanel textPanel = new JPanel();
+ panel.add(textPanel);
+ layout.setConstraints(textPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
+ GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ GridBagLayout textPanelLayout = new GridBagLayout();
+ textPanel.setLayout(textPanelLayout);
+ JLabel hostLabel = new LabelWidget(HOST);
+ textPanel.add(hostLabel);
+ textPanelLayout.setConstraints(hostLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE, new Insets(0, 0, 0, 4), 0, 0));
+ DocumentListener docListener = new DocumentListener() {
+ public void changedUpdate( DocumentEvent ev ) {
+ fieldsChanged();
+ }
+
+ public void removeUpdate( DocumentEvent ev ) {
+ fieldsChanged();
+ }
+
+ public void insertUpdate( DocumentEvent ev ) {
+ fieldsChanged();
+ }
+ };
+ inquiryUrlField = new TextFieldWidget(50);
+ inquiryUrlField.getDocument().addDocumentListener(docListener);
+ textPanel.add(inquiryUrlField);
+ textPanelLayout.setConstraints(inquiryUrlField,
+ new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE, new Insets(0, 0, BETWEEN_LABELS_VERT_GAP,
+ 0), 0, 0));
+ JLabel portLabel = new LabelWidget(PORT);
+ textPanel.add(portLabel);
+ textPanelLayout.setConstraints(portLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE, new Insets(0, 0, 0, 4), 0, 0));
+ publishUrlField = new TextFieldWidget(20);
+ publishUrlField.getDocument().addDocumentListener(docListener);
+ textPanel.add(publishUrlField);
+ textPanelLayout.setConstraints(publishUrlField,
+ new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE, new Insets(BETWEEN_LABELS_VERT_GAP, 0, 0,
+ 0), 0, 0));
+ JButton defaultsButton = new ButtonWidget(DEFAULTS);
+ defaultsButton.addActionListener(new ActionListener() {
+ public void actionPerformed( ActionEvent ev ) {
+ defaultsPressed();
+ }
+ });
+ panel.add(defaultsButton);
+ layout.setConstraints(defaultsButton, new GridBagConstraints(0, 2, 1, 1, 0.0, 1.0, GridBagConstraints.NORTH,
+ GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ return panel;
+ }
+
+ private void fieldsChanged() {
+ setForwardButtonEnabling();
+ }
+
+ public void setForwardButtonEnabling() {
+ String inquiryUrlText = inquiryUrlField.getText().trim();
+ String publishUrlText = publishUrlField.getText().trim();
+ boolean enabling = ((inquiryUrlText.length() > 0) && (publishUrlText.length() > 0));
+ enableForwardButton(enabling);
+ }
+
+ /**
+ * Overridden to enable the forward button only if the file selection is valid.
+ *
+ * @see com.metamatrix.console.ui.util.BasicWizardSubpanelContainer#resolveForwardButton()
+ * @since 5.5.3
+ */
+ public void resolveForwardButton() {
+ setForwardButtonEnabling();
+ }
+
+ private void defaultsPressed() {
+ inquiryUrlField.setText(defaultWebServerHost);
+ publishUrlField.setText(defaultWebServerPort);
+ }
+
+ public void setDefaultWebServerPort( String port ) {
+ defaultWebServerPort = port;
+ publishUrlField.setText(defaultWebServerPort);
+ }
+
+ public void setdefaultWebServerHost( String host ) {
+ defaultWebServerHost = host;
+ inquiryUrlField.setText(defaultWebServerHost);
+ }
+
+ public String getWebServerScheme() {
+ return inquiryUrlField.getText().trim();
+ }
+
+ public String getWebServerHost() {
+ return inquiryUrlField.getText().trim();
+ }
+
+ public String getWebServerPort() {
+ return publishUrlField.getText().trim();
+ }
+
+ public Dimension getPreferredSize() {
+ Dimension size = super.getPreferredSize();
+ // System.err.println("in CreateWSDLURLElementsPanel getPreferredSize(), returning " + size);
+ return size;
+ }
+}// end CreateWSDLURLElementsPanel
+
+class ResultsPanel extends BasicWizardSubpanelContainer {
+ private final static String SUCCESSFULLY_PUBLISHED = ConsolePlugin.Util.getString("WSDLWizardRunner.publishingSuccessfulMsg"); //$NON-NLS-1$
+ private final static String SUCCESSFULLY_UNPUBLISHED = ConsolePlugin.Util.getString("WSDLWizardRunner.unpublishingSuccessfulMsg"); //$NON-NLS-1$
+ private final static String ALREADY_PUBLISHED = ConsolePlugin.Util.getString("WSDLWizardRunner.wsdlAlreadyPublishedMsg"); //$NON-NLS-1$
+ private final static String NOT_PUBLISHED = ConsolePlugin.Util.getString("WSDLWizardRunner.noWSDLPublishedMsg"); //$NON-NLS-1$
+ private final static String ERROR_1 = ConsolePlugin.Util.getString("WSDLWizardRunner.errorMsg1"); //$NON-NLS-1$
+ private final static String ERROR_2 = ConsolePlugin.Util.getString("WSDLWizardRunner.errorMsg2"); //$NON-NLS-1$
+ private final static String PUBLISH = ConsolePlugin.Util.getString("WSDLWizardRunner.publish"); //$NON-NLS-1$
+ private final static String UNPUBLISH = ConsolePlugin.Util.getString("WSDLWizardRunner.unpublish"); //$NON-NLS-1$
+ private final static String VIEW_ERROR_DIALOG = ConsolePlugin.Util.getString("WSDLWizardRunner.viewErrorDialog"); //$NON-NLS-1$
+ private final static String ERROR_DLG_HEADER = ConsolePlugin.Util.getString("WSDLWizardRunner.errorDlgHeader"); //$NON-NLS-1$
+
+ private JPanel thePanel;
+ private boolean publishing;
+ private Throwable throwable;
+
+ public ResultsPanel( WizardInterface wizardInterface,
+ boolean publishing,
+ int stepNum ) {
+ super(wizardInterface);
+ super.setStepText(stepNum, "Results"); //$NON-NLS-1$
+ thePanel = new JPanel();
+ this.publishing = publishing;
+ super.setMainContent(thePanel);
+ }
+
+ public void addSuccessText() {
+ thePanel.removeAll();
+ GridBagLayout layout = new GridBagLayout();
+ thePanel.setLayout(layout);
+ String text;
+ if (publishing) {
+ text = SUCCESSFULLY_PUBLISHED;
+ } else {
+ text = SUCCESSFULLY_UNPUBLISHED;
+ }
+ JLabel label = new LabelWidget(text);
+ thePanel.add(label);
+ layout.setConstraints(label, new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0, GridBagConstraints.NORTH,
+ GridBagConstraints.NONE, new Insets(20, 10, 10, 10), 0, 0));
+ }
+
+ public void addIncorrectPublishingStateText() {
+ thePanel.removeAll();
+ GridBagLayout layout = new GridBagLayout();
+ thePanel.setLayout(layout);
+ String text;
+ IconComponent icon = new IconComponent(Icons.WARNING_ICON);
+ thePanel.add(icon);
+ layout.setConstraints(icon, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH,
+ GridBagConstraints.NONE, new Insets(10, 20, 10, 10), 0, 0));
+ if (publishing) {
+ text = ALREADY_PUBLISHED;
+ } else {
+ text = NOT_PUBLISHED;
+ }
+ JLabel label = new LabelWidget(text);
+ thePanel.add(label);
+ layout.setConstraints(label, new GridBagConstraints(1, 0, 1, 1, 0.0, 1.0, GridBagConstraints.NORTH,
+ GridBagConstraints.NONE, new Insets(10, 0, 10, 0), 0, 0));
+ }
+
+ public void addErrorHandlingSubcomponents( Throwable t ) {
+ this.throwable = t;
+ thePanel.removeAll();
+ GridBagLayout layout = new GridBagLayout();
+ thePanel.setLayout(layout);
+ String errorText;
+ if (publishing) {
+ errorText = ERROR_1 + ' ' + PUBLISH + ' ' + ERROR_2;
+ } else {
+ errorText = ERROR_1 + ' ' + UNPUBLISH + ' ' + ERROR_2;
+ }
+ JLabel errorLabel = new LabelWidget(errorText);
+ thePanel.add(errorLabel);
+ layout.setConstraints(errorLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST,
+ GridBagConstraints.NONE, new Insets(20, 4, 10, 4), 0, 0));
+ JButton errorDialogButton = new ButtonWidget(VIEW_ERROR_DIALOG);
+ thePanel.add(errorDialogButton);
+ layout.setConstraints(errorDialogButton,
+ new GridBagConstraints(0, 1, 1, 1, 0.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.NONE,
+ new Insets(20, 10, 10, 10), 0, 0));
+ errorDialogButton.addActionListener(new ActionListener() {
+ public void actionPerformed( ActionEvent ev ) {
+ viewErrorDialogPressed();
+ }
+ });
+ }
+
+ private void viewErrorDialogPressed() {
+ ExceptionUtility.showMessage(ERROR_DLG_HEADER, throwable);
+ }
+
+ public Dimension getPreferredSize() {
+ Dimension size = super.getPreferredSize();
+ // System.err.println("in ResultsPanel getPreferredSize(), returning " + size);
+ return size;
+ }
+}// end ResultsPanel
+
+class WSDLWizardPanelDialog extends JDialog {
+ private WSDLWizardRunner caller;
+ private WSDLWizardPanel wizardPanel;
+
+ public WSDLWizardPanelDialog( WSDLWizardRunner cllr,
+ WSDLWizardPanel wizPnl,
+ boolean publishing ) {
+ super(ConsoleMainFrame.getInstance(), publishing ? "Web Services Publishing Wizard" : //$NON-NLS-1$
+ "Web Services Unpublishing Wizard"); //$NON-NLS-1$
+ this.caller = cllr;
+ this.wizardPanel = wizPnl;
+ this.setModal(true);
+ this.addWindowListener(new WindowAdapter() {
+ public void windowClosing( WindowEvent ev ) {
+ caller.dialogWindowClosing();
+ }
+ });
+ init();
+ //this.pack();
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ // System.err.println("screenSize is " + screenSize);
+ Dimension size = this.getSize();
+ // System.err.println("in WSDLWizardPanelDialog constructor, size is " + size);
+ Dimension newSize = new Dimension(Math.min(Math.max(size.width, (int)(screenSize.width * 0.5)),
+ (int)(screenSize.width * 0.75)), Math.max(size.height,
+ (int)(screenSize.height * 0.75)));
+ this.setSize(newSize);
+ this.setLocation(StaticUtilities.centerFrame(this.getSize()));
+ }
+
+ private void init() {
+ GridBagLayout layout = new GridBagLayout();
+ this.getContentPane().setLayout(layout);
+ this.getContentPane().add(wizardPanel);
+ layout.setConstraints(wizardPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
+ GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
+ }
+
+ public void cancelPressed() {
+ this.dispose();
+ }
+
+ public void finishPressed() {
+ this.dispose();
+ }
+}// end WSDLWizardPanelDialog
+
+class UDDIPasswordDialog extends JDialog {
+ private final static String TITLE = ConsolePlugin.Util.getString("WSDLWizardRunner.passwordDialogTitle"); //$NON-NLS-1$
+ private final static String TEXT_LINE = ConsolePlugin.Util.getString("WSDLWizardRunner.passwordText"); //$NON-NLS-1$
+ private final static String PASSWORD_LABEL = ConsolePlugin.Util.getString("WSDLWizardRunner.passwordLabel"); //$NON-NLS-1$
+ private final static String OK = ConsolePlugin.Util.getString("General.OK"); //$NON-NLS-1$
+ private final static String CANCEL = ConsolePlugin.Util.getString("General.Cancel"); //$NON-NLS-1$
+ private final static int HORIZONTAL_INSETS = 4;
+
+ private JButton okButton;
+ private JButton cancelButton;
+ private JPasswordField passwordField;
+ private String password = null;
+
+ public UDDIPasswordDialog( String configName ) {
+ super(ConsoleMainFrame.getInstance(), TITLE, true);
+ createComponent(configName);
+ }
+
+ private void createComponent( String configName ) {
+ addWindowListener(new WindowAdapter() {
+ public void windowClosing( WindowEvent ev ) {
+ cancelPressed();
+ }
+ });
+ GridBagLayout layout = new GridBagLayout();
+ getContentPane().setLayout(layout);
+ String headerText = TEXT_LINE + ' ' + configName;
+ JLabel headerLabel = new LabelWidget(headerText);
+ getContentPane().add(headerLabel);
+ layout.setConstraints(headerLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE, new Insets(10, HORIZONTAL_INSETS, 10,
+ HORIZONTAL_INSETS), 0, 0));
+ JPanel passwordPanel = new JPanel();
+ GridBagLayout passwordLayout = new GridBagLayout();
+ passwordPanel.setLayout(passwordLayout);
+ getContentPane().add(passwordPanel);
+ layout.setConstraints(passwordPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
+ GridBagConstraints.NONE, new Insets(0, HORIZONTAL_INSETS, 0,
+ HORIZONTAL_INSETS), 0, 0));
+ JLabel passwordLabel = new LabelWidget(PASSWORD_LABEL);
+ passwordPanel.add(passwordLabel);
+ passwordLayout.setConstraints(passwordLabel,
+ new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
+ GridBagConstraints.NONE, new Insets(0, 0, 0, 4), 0, 0));
+ passwordField = new JPasswordField(20);
+ passwordField.setPreferredSize(new Dimension(224, 20));
+ passwordField.setMinimumSize(new Dimension(224, 20));
+
+ passwordPanel.add(passwordField);
+ passwordLayout.setConstraints(passwordField,
+ new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
+ passwordField.getDocument().addDocumentListener(new DocumentListener() {
+ public void changedUpdate( DocumentEvent ev ) {
+ passwordChanged();
+ }
+
+ public void removeUpdate( DocumentEvent ev ) {
+ passwordChanged();
+ }
+
+ public void insertUpdate( DocumentEvent ev ) {
+ passwordChanged();
+ }
+ });
+ JPanel buttonsPanel = new JPanel(new GridLayout(1, 2, 10, 0));
+ getContentPane().add(buttonsPanel);
+ layout.setConstraints(buttonsPanel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
+ GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
+ okButton = new ButtonWidget(OK);
+ buttonsPanel.add(okButton);
+ okButton.addActionListener(new ActionListener() {
+ public void actionPerformed( ActionEvent ev ) {
+ okPressed();
+ }
+ });
+ okButton.setEnabled(false);
+ cancelButton = new ButtonWidget(CANCEL);
+ buttonsPanel.add(cancelButton);
+ cancelButton.addActionListener(new ActionListener() {
+ public void actionPerformed( ActionEvent ev ) {
+ cancelPressed();
+ }
+ });
+ this.pack();
+ this.setLocation(StaticUtilities.centerFrame(this.getSize()));
+ }
+
+ private void passwordChanged() {
+ char[] passwordArray = passwordField.getPassword();
+ if (passwordArray.length == 0) {
+ password = null;
+ } else {
+ password = new String(passwordArray);
+ password = password.trim();
+ if (password.length() == 0) {
+ password = null;
+ }
+ }
+ okButton.setEnabled((password != null));
+ }
+
+ private void cancelPressed() {
+ password = null;
+ this.dispose();
+ }
+
+ private void okPressed() {
+ this.dispose();
+ }
+
+ public String getPassword() {
+ return password;
+ }
+}// end UDDIPasswordDialog
Property changes on: trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/WSDLWizardRunner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/WebServicesPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/WebServicesPanel.java (rev 0)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/WebServicesPanel.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -0,0 +1,187 @@
+/*
+ * Copyright � 2000-2008 MetaMatrix, Inc. All rights reserved.
+ */
+package com.metamatrix.console.ui.views.vdb;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.GridLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+
+import com.metamatrix.common.config.api.Configuration;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.console.ConsolePlugin;
+import com.metamatrix.console.connections.ConnectionInfo;
+import com.metamatrix.console.models.ConfigurationManager;
+import com.metamatrix.console.models.ModelManager;
+import com.metamatrix.console.models.VdbManager;
+import com.metamatrix.console.util.ExceptionUtility;
+import com.metamatrix.console.util.LogContexts;
+import com.metamatrix.console.util.StaticUtilities;
+import com.metamatrix.metadata.runtime.api.VirtualDatabase;
+import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
+import com.metamatrix.platform.admin.api.ConfigurationAdminAPI;
+import com.metamatrix.toolbox.ui.widget.ButtonWidget;
+
+/**
+ * @since 5.5.3
+ */
+public class WebServicesPanel extends JPanel implements
+ VdbDisplayer {
+
+ private final static String PUBLISH_BTN_LABEL = ConsolePlugin.Util.getString("WebServicesPanel.publish"); //$NON-NLS-1$
+ private final static String UNPUBLISH_BTN_LABEL = ConsolePlugin.Util.getString("WebServicesPanel.unpublish"); //$NON-NLS-1$
+ private final static String NO_WSDL_TEXT = ConsolePlugin.Util.getString("WebServicesPanel.noModelsMsg"); //$NON-NLS-1$
+ private final static String ERROR_RETRIEVING_DATABASES = ConsolePlugin.Util
+ .getString("WebServicesPanel.errorRetrievingVirtualDatabases"); //$NON-NLS-1$
+ private final static String ERROR_RETRIEVING_CURRENT_CONFIGURATION = ConsolePlugin.Util
+ .getString("WebServicesPanel.errorRetrievingCurrentConfiguration"); //$NON-NLS-1$
+ private final static String NOT_ACTIVE_HDR = ConsolePlugin.Util.getString("WebServicesPanel.notActiveHdr"); //$NON-NLS-1$
+ private final static String NOT_ACTIVE_MSG = ConsolePlugin.Util.getString("WebServicesPanel.notActiveMsg"); //$NON-NLS-1$
+
+ private VirtualDatabase vdb;
+ private JButton publishButton;
+ private JButton unpublishButton;
+ private JPanel buttonsPanel;
+ private ConnectionInfo connection;
+
+ /**
+ * Constructor
+ * @param connection
+ */
+ public WebServicesPanel(ConnectionInfo connection) {
+ super();
+ this.connection = connection;
+ createButtons();
+ }
+
+ private VdbManager getVdbManager() {
+ return ModelManager.getVdbManager(connection);
+ }
+
+ private void createButtons() {
+ publishButton = new ButtonWidget(PUBLISH_BTN_LABEL);
+ unpublishButton = new ButtonWidget(UNPUBLISH_BTN_LABEL);
+ publishButton.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent ev) {
+ publishPressed();
+ }
+ });
+ unpublishButton.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent ev) {
+ unpublishPressed();
+ }
+ });
+ buttonsPanel = new JPanel(new GridLayout(1, 2, 5, 0));
+ buttonsPanel.add(publishButton);
+ buttonsPanel.add(unpublishButton);
+ }
+
+ private void publishPressed() {
+ if (checkIfActive()) {
+ launchWizard(true);
+ } else {
+ displayNotActiveDialog();
+ }
+ }
+
+ private void unpublishPressed() {
+ if (checkIfActive()) {
+ launchWizard(false);
+ } else {
+ displayNotActiveDialog();
+ }
+ }
+
+ private boolean checkIfActive() {
+ boolean continuing = true;
+ Boolean active = null;
+ boolean isActive = false;
+ try {
+ String vdbName = vdb.getName();
+ VirtualDatabaseID id = (VirtualDatabaseID)vdb.getID();
+ int version = (new Integer(id.getVersion())).intValue();
+ active = getVdbManager().isVDBActive(vdbName, version);
+ } catch (Exception ex) {
+ LogManager.logError(LogContexts.VIRTUAL_DATABASE, ex, ERROR_RETRIEVING_DATABASES);
+ ExceptionUtility.showMessage(ERROR_RETRIEVING_DATABASES, ex);
+ isActive = false;
+ continuing = false;
+ }
+ if (continuing) {
+ isActive = active.booleanValue();
+ }
+ return isActive;
+ }
+
+ private void displayNotActiveDialog() {
+ StaticUtilities.displayModalDialogWithOK(NOT_ACTIVE_HDR, NOT_ACTIVE_MSG, JOptionPane.WARNING_MESSAGE);
+ }
+
+ private void launchWizard(boolean publishing) {
+ ConfigurationManager configManager = ModelManager.getConfigurationManager(connection);
+ ConfigurationAdminAPI configAPI = ModelManager.getConfigurationAPI(connection);
+ Configuration currentConfig = null;
+ try {
+ currentConfig = configAPI.getCurrentConfiguration();
+ } catch (Exception ex) {
+ LogManager.logError(LogContexts.VIRTUAL_DATABASE, ex, ERROR_RETRIEVING_CURRENT_CONFIGURATION);
+ ExceptionUtility.showMessage(ERROR_RETRIEVING_CURRENT_CONFIGURATION, ex);
+ }
+ if (currentConfig != null) {
+ VirtualDatabaseID id = (VirtualDatabaseID)vdb.getID();
+ String version = id.getVersion();
+ WSDLWizardRunner runner = new WSDLWizardRunner(vdb.getName(), version, currentConfig, configManager, publishing);
+ runner.go();
+ }
+ }
+
+ public void setVirtualDatabase(VirtualDatabase vdb) {
+ if (this.vdb != vdb) {
+ this.vdb = vdb;
+
+ this.removeAll();
+ if (vdb != null) {
+ GridBagLayout layout = new GridBagLayout();
+ setLayout(layout);
+ WSDLOperationsDescription desc = getVdbManager().getWSDLOperationsDescription(vdb);
+ if (desc == null) {
+ JTextArea noWSDLTextArea = new JTextArea(NO_WSDL_TEXT);
+ noWSDLTextArea.setEditable(false);
+ noWSDLTextArea.setLineWrap(true);
+ noWSDLTextArea.setWrapStyleWord(true);
+ noWSDLTextArea.setBackground(this.getBackground());
+ this.add(noWSDLTextArea);
+ layout.setConstraints(noWSDLTextArea, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
+ GridBagConstraints.BOTH, new Insets(10, 10, 10,
+ 10), 0, 0));
+ } else {
+ JPanel opsPanel = addOperationsDescription(desc);
+ add(opsPanel);
+ layout
+ .setConstraints(opsPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
+ GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
+ add(buttonsPanel);
+ layout.setConstraints(buttonsPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
+ GridBagConstraints.NONE, new Insets(4, 4, 4, 4),
+ 0, 0));
+ }
+ }
+
+ }
+ }
+
+ private JPanel addOperationsDescription(WSDLOperationsDescription desc) {
+ // TODO
+ return new JPanel();
+ }
+}
Property changes on: trunk/console/src/main/java/com/metamatrix/console/ui/views/vdb/WebServicesPanel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/console/src/main/java/com/metamatrix/console/util/SavedUDDIRegistryInfo.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/util/SavedUDDIRegistryInfo.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/console/src/main/java/com/metamatrix/console/util/SavedUDDIRegistryInfo.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -1,123 +1,106 @@
/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
+ * Copyright 2000-2008 MetaMatrix, Inc. All rights reserved.
*/
-
package com.metamatrix.console.util;
-
-/**
+/**
* Data class to represent the info on UDDI registy that is saved to the properties file.
*
- * @since 4.2
+ * @since 5.5.3
*/
public class SavedUDDIRegistryInfo {
- private String name;
- private String userName;
- private String host;
- private String port;
-
- public SavedUDDIRegistryInfo(String name, String userName, String host, String port) {
- super();
- this.name = name;
- this.userName = userName;
- this.host = host;
- this.port = port;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public String getPort() {
- return port;
- }
-
- public void setPort(String port) {
- this.port = port;
- }
-
- public boolean equals(Object obj) {
- boolean same;
- if (obj == this) {
- same = true;
- } else if (!(obj instanceof SavedUDDIRegistryInfo)) {
- same = false;
- } else {
- SavedUDDIRegistryInfo that = (SavedUDDIRegistryInfo)obj;
- boolean nameMatches;
- boolean userNameMatches = false;
- boolean hostMatches = false;
- boolean portMatches = false;
- String thatName = that.getName();
- if (name == null) {
- nameMatches = (thatName == null);
- } else {
- nameMatches = name.equals(thatName);
- }
- if (nameMatches) {
- String thatUserName = that.getUserName();
- if (userName == null) {
- userNameMatches = (thatUserName == null);
- } else {
- userNameMatches = userName.equals(thatUserName);
- }
- if (userNameMatches) {
- String thatHost = that.getHost();
- if (host == null) {
- hostMatches = (thatHost == null);
- } else {
- hostMatches = host.equals(thatHost);
- }
- if (hostMatches) {
- String thatPort = that.getPort();
- if (port == null) {
- portMatches = (thatPort == null);
- } else {
- portMatches = port.equals(thatPort);
- }
- }
- }
- }
- same = (nameMatches && userNameMatches && hostMatches && portMatches);
- }
- return same;
- }
+ private String name;
+ private String userName;
+ private String inquiryUrl;
+ private String publishUrl;
+
+ public SavedUDDIRegistryInfo( String name,
+ String userName,
+ String inquiryUrl,
+ String publishUrl ) {
+ super();
+ this.name = name;
+ this.userName = userName;
+ this.inquiryUrl = inquiryUrl;
+ this.publishUrl = publishUrl;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName( String userName ) {
+ this.userName = userName;
+ }
+
+ public String getInquiryUrl() {
+ return inquiryUrl;
+ }
+
+ public void setInquiryUrl( String inquiryUrl ) {
+ this.inquiryUrl = inquiryUrl;
+ }
+
+ public String getPublishUrl() {
+ return publishUrl;
+ }
+
+ public void setPublishUrl( String publishUrl ) {
+ this.publishUrl = publishUrl;
+ }
+
+ public boolean equals( Object obj ) {
+ boolean same;
+ if (obj == this) {
+ same = true;
+ } else if (!(obj instanceof SavedUDDIRegistryInfo)) {
+ same = false;
+ } else {
+ SavedUDDIRegistryInfo that = (SavedUDDIRegistryInfo)obj;
+ boolean nameMatches;
+ boolean userNameMatches = false;
+ boolean inquiryUrlMatches = false;
+ boolean publishUrlMatches = false;
+ String thatName = that.getName();
+ if (name == null) {
+ nameMatches = (thatName == null);
+ } else {
+ nameMatches = name.equals(thatName);
+ }
+ if (nameMatches) {
+ String thatUserName = that.getUserName();
+ if (userName == null) {
+ userNameMatches = (thatUserName == null);
+ } else {
+ userNameMatches = userName.equals(thatUserName);
+ }
+ if (userNameMatches) {
+ String thatInquiryUrl = that.getInquiryUrl();
+ if (inquiryUrl == null) {
+ inquiryUrlMatches = (thatInquiryUrl == null);
+ } else {
+ inquiryUrlMatches = inquiryUrl.equals(thatInquiryUrl);
+ }
+ if (inquiryUrlMatches) {
+ String thatPublishUrl = that.getPublishUrl();
+ if (publishUrl == null) {
+ publishUrlMatches = (thatPublishUrl == null);
+ } else {
+ publishUrlMatches = publishUrl.equals(thatPublishUrl);
+ }
+ }
+ }
+ }
+ same = (nameMatches && userNameMatches && inquiryUrlMatches && publishUrlMatches);
+ }
+ return same;
+ }
}
Modified: trunk/console/src/main/java/com/metamatrix/console/util/StaticProperties.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/util/StaticProperties.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/console/src/main/java/com/metamatrix/console/util/StaticProperties.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -215,155 +215,155 @@
}
public static SavedUDDIRegistryInfo[] getUDDIRegistryInfo() {
- Map /*<Integer (index stored with property) to SavedUDDIRegistryInfo>*/ infoMap = new HashMap();
- Properties properties = getProperties();
- Iterator it = properties.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry me = (Map.Entry)it.next();
- String key = (String)me.getKey();
- if (key.startsWith(UDDI_REGISTRY_NAME)) {
- String remainder = key.substring(UDDI_REGISTRY_NAME_STR_LEN);
- Integer index = null;
- try {
- index = new Integer(remainder);
- } catch (Exception ex) {
- }
- if (index != null) {
- String name = (String)me.getValue();
- SavedUDDIRegistryInfo info = (SavedUDDIRegistryInfo)infoMap.get(index);
- if (info == null) {
- info = new SavedUDDIRegistryInfo(name, null, null, null);
- infoMap.put(index, info);
- } else {
- info.setName(name);
- }
- }
- } else if (key.startsWith(UDDI_REGISTRY_USER)) {
- String remainder = key.substring(UDDI_REGISTRY_USER_STR_LEN);
- Integer index = null;
- try {
- index = new Integer(remainder);
- } catch (Exception ex) {
- }
- if (index != null) {
- String user = (String)me.getValue();
- SavedUDDIRegistryInfo info = (SavedUDDIRegistryInfo)infoMap.get(index);
- if (info == null) {
- info = new SavedUDDIRegistryInfo(null, user, null, null);
- infoMap.put(index, info);
- } else {
- info.setUserName(user);
- }
- }
- } else if (key.startsWith(UDDI_REGISTRY_HOST)) {
- String remainder = key.substring(UDDI_REGISTRY_HOST_STR_LEN);
- Integer index = null;
- try {
- index = new Integer(remainder);
- } catch (Exception ex) {
- }
- if (index != null) {
- String host = (String)me.getValue();
- SavedUDDIRegistryInfo info = (SavedUDDIRegistryInfo)infoMap.get(index);
- if (info == null) {
- info = new SavedUDDIRegistryInfo(null, null, host, null);
- infoMap.put(index, info);
- } else {
- info.setHost(host);
- }
- }
- } else if (key.startsWith(UDDI_REGISTRY_PORT)) {
- String remainder = key.substring(UDDI_REGISTRY_PORT_STR_LEN);
- Integer index = null;
- try {
- index = new Integer(remainder);
- } catch (Exception ex) {
- }
- if (index != null) {
- String port = (String)me.getValue();
- SavedUDDIRegistryInfo info = (SavedUDDIRegistryInfo)infoMap.get(index);
- if (info == null) {
- info = new SavedUDDIRegistryInfo(null, null, null, port);
- infoMap.put(index, info);
- } else {
- info.setPort(port);
- }
- }
- }
- }
- Map revisedInfoMap = new HashMap();
- it = infoMap.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry me = (Map.Entry)it.next();
- SavedUDDIRegistryInfo info = (SavedUDDIRegistryInfo)me.getValue();
- if ((info.getUserName() != null) && (info.getHost() != null) && (info.getPort() != null)) {
- revisedInfoMap.put(me.getKey(), info);
- }
- }
- SavedUDDIRegistryInfo[] result = new SavedUDDIRegistryInfo[revisedInfoMap.size()];
- int[] indices = new int[result.length];
- it = revisedInfoMap.entrySet().iterator();
- for (int i = 0; it.hasNext(); i++) {
- Map.Entry me = (Map.Entry)it.next();
- Integer intKey = (Integer)me.getKey();
- indices[i] = intKey.intValue();
- result[i] = (SavedUDDIRegistryInfo)me.getValue();
- }
- //Do bubble sort to put items in ascending order by index value
- boolean done = false;
- while (!done) {
- done = true;
- for (int i = 0; i < indices.length - 1; i++) {
- if (indices[i] > indices[i + 1]) {
- done = false;
- int tempInt = indices[i];
- indices[i] = indices[i + 1];
- indices[i + 1] = tempInt;
- SavedUDDIRegistryInfo tempInfo = result[i];
- result[i] = result[i + 1];
- result[i + 1] = tempInfo;
- }
- }
- }
- if (StaticProperties.numUDDIRegistries < 0) {
- StaticProperties.numUDDIRegistries = result.length;
- }
- return result;
- }
+ Map /* <Integer (index stored with property) to SavedUDDIRegistryInfo> */infoMap = new HashMap();
+ Properties properties = getProperties();
+ Iterator it = properties.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry me = (Map.Entry)it.next();
+ String key = (String)me.getKey();
+ if (key.startsWith(UDDI_REGISTRY_NAME)) {
+ String remainder = key.substring(UDDI_REGISTRY_NAME_STR_LEN);
+ Integer index = null;
+ try {
+ index = new Integer(remainder);
+ } catch (Exception ex) {
+ }
+ if (index != null) {
+ String name = (String)me.getValue();
+ SavedUDDIRegistryInfo info = (SavedUDDIRegistryInfo)infoMap.get(index);
+ if (info == null) {
+ info = new SavedUDDIRegistryInfo(name, null, null, null);
+ infoMap.put(index, info);
+ } else {
+ info.setName(name);
+ }
+ }
+ } else if (key.startsWith(UDDI_REGISTRY_USER)) {
+ String remainder = key.substring(UDDI_REGISTRY_USER_STR_LEN);
+ Integer index = null;
+ try {
+ index = new Integer(remainder);
+ } catch (Exception ex) {
+ }
+ if (index != null) {
+ String user = (String)me.getValue();
+ SavedUDDIRegistryInfo info = (SavedUDDIRegistryInfo)infoMap.get(index);
+ if (info == null) {
+ info = new SavedUDDIRegistryInfo(null, user, null, null);
+ infoMap.put(index, info);
+ } else {
+ info.setUserName(user);
+ }
+ }
+ } else if (key.startsWith(UDDI_REGISTRY_HOST)) {
+ String remainder = key.substring(UDDI_REGISTRY_HOST_STR_LEN);
+ Integer index = null;
+ try {
+ index = new Integer(remainder);
+ } catch (Exception ex) {
+ }
+ if (index != null) {
+ String inquiryUrl = (String)me.getValue();
+ SavedUDDIRegistryInfo info = (SavedUDDIRegistryInfo)infoMap.get(index);
+ if (info == null) {
+ info = new SavedUDDIRegistryInfo(null, null, inquiryUrl, null);
+ infoMap.put(index, info);
+ } else {
+ info.setInquiryUrl(inquiryUrl);
+ }
+ }
+ } else if (key.startsWith(UDDI_REGISTRY_PORT)) {
+ String remainder = key.substring(UDDI_REGISTRY_PORT_STR_LEN);
+ Integer index = null;
+ try {
+ index = new Integer(remainder);
+ } catch (Exception ex) {
+ }
+ if (index != null) {
+ String publishUrl = (String)me.getValue();
+ SavedUDDIRegistryInfo info = (SavedUDDIRegistryInfo)infoMap.get(index);
+ if (info == null) {
+ info = new SavedUDDIRegistryInfo(null, null, null, publishUrl);
+ infoMap.put(index, info);
+ } else {
+ info.setPublishUrl(publishUrl);
+ }
+ }
+ }
+ }
+ Map revisedInfoMap = new HashMap();
+ it = infoMap.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry me = (Map.Entry)it.next();
+ SavedUDDIRegistryInfo info = (SavedUDDIRegistryInfo)me.getValue();
+ if ((info.getUserName() != null) && (info.getInquiryUrl() != null) && (info.getPublishUrl() != null)) {
+ revisedInfoMap.put(me.getKey(), info);
+ }
+ }
+ SavedUDDIRegistryInfo[] result = new SavedUDDIRegistryInfo[revisedInfoMap.size()];
+ int[] indices = new int[result.length];
+ it = revisedInfoMap.entrySet().iterator();
+ for (int i = 0; it.hasNext(); i++) {
+ Map.Entry me = (Map.Entry)it.next();
+ Integer intKey = (Integer)me.getKey();
+ indices[i] = intKey.intValue();
+ result[i] = (SavedUDDIRegistryInfo)me.getValue();
+ }
+ // Do bubble sort to put items in ascending order by index value
+ boolean done = false;
+ while (!done) {
+ done = true;
+ for (int i = 0; i < indices.length - 1; i++) {
+ if (indices[i] > indices[i + 1]) {
+ done = false;
+ int tempInt = indices[i];
+ indices[i] = indices[i + 1];
+ indices[i + 1] = tempInt;
+ SavedUDDIRegistryInfo tempInfo = result[i];
+ result[i] = result[i + 1];
+ result[i + 1] = tempInfo;
+ }
+ }
+ }
+ if (StaticProperties.numUDDIRegistries < 0) {
+ StaticProperties.numUDDIRegistries = result.length;
+ }
+ return result;
+ }
+
+ public static void setUDDIRegistryInfo( SavedUDDIRegistryInfo[] info ) {
+ // First clean out the old
+ Properties properties = getProperties();
+ // To avoid ConcurrentModificationException, copy the keys to a separate list and
+ // iterate through that list.
+ java.util.List tempList = new ArrayList(properties.size());
+ Iterator it = properties.keySet().iterator();
+ while (it.hasNext()) {
+ String key = (String)it.next();
+ tempList.add(key);
+ }
+ it = tempList.iterator();
+ while (it.hasNext()) {
+ String key = (String)it.next();
+ if (key.startsWith(UDDI_REGISTRY_NAME) || key.startsWith(UDDI_REGISTRY_USER) || key.startsWith(UDDI_REGISTRY_HOST)
+ || key.startsWith(UDDI_REGISTRY_PORT)) {
+ UserPreferences.getInstance().removeValue(key);
+ }
+ }
+ // Then add the new
+ for (int i = 0; i < info.length; i++) {
+ int index = i + 1;
+ String key = UDDI_REGISTRY_NAME + index;
+ setProperty(key, info[i].getName());
+ key = UDDI_REGISTRY_USER + index;
+ setProperty(key, info[i].getUserName());
+ key = UDDI_REGISTRY_HOST + index;
+ setProperty(key, info[i].getInquiryUrl());
+ key = UDDI_REGISTRY_PORT + index;
+ setProperty(key, info[i].getPublishUrl());
+ }
+ }
- public static void setUDDIRegistryInfo(SavedUDDIRegistryInfo[] info) {
- //First clean out the old
- Properties properties = getProperties();
- //To avoid ConcurrentModificationException, copy the keys to a separate list and
- //iterate through that list.
- java.util.List tempList = new ArrayList(properties.size());
- Iterator it = properties.keySet().iterator();
- while (it.hasNext()) {
- String key = (String)it.next();
- tempList.add(key);
- }
- it = tempList.iterator();
- while (it.hasNext()) {
- String key = (String)it.next();
- if (key.startsWith(UDDI_REGISTRY_NAME) || key.startsWith(UDDI_REGISTRY_USER)
- || key.startsWith(UDDI_REGISTRY_HOST) || key.startsWith(UDDI_REGISTRY_PORT)) {
- UserPreferences.getInstance().removeValue(key);
- }
- }
- //Then add the new
- for (int i = 0; i < info.length; i++) {
- int index = i + 1;
- String key = UDDI_REGISTRY_NAME + index;
- setProperty(key, info[i].getName());
- key = UDDI_REGISTRY_USER + index;
- setProperty(key, info[i].getUserName());
- key = UDDI_REGISTRY_HOST + index;
- setProperty(key, info[i].getHost());
- key = UDDI_REGISTRY_PORT + index;
- setProperty(key, info[i].getPort());
- }
- }
-
public static Properties getProperties() {
return UserPreferences.getInstance().getProperties();
}
Modified: trunk/console/src/main/resources/com/metamatrix/console/i18n.properties
===================================================================
--- trunk/console/src/main/resources/com/metamatrix/console/i18n.properties 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/console/src/main/resources/com/metamatrix/console/i18n.properties 2009-05-13 18:07:37 UTC (rev 930)
@@ -190,11 +190,12 @@
UDDIConfigurationsDialog.selectAConfiguration=Select a Configuration:
UDDIConfigurationsDialog.configurationsColHdr=UDDI Configurations
UDDIConfigurationsDialog.configName=UDDI Configuration Name
-UDDIConfigurationsDialog.host=UDDI Host
-UDDIConfigurationsDialog.port=UDDI Port
+UDDIConfigurationsDialog.uddiInquiryUrl=UDDI Inquiry Url
+UDDIConfigurationsDialog.uddiPublishUrl=UDDI Publish Url
UDDIConfigurationsDialog.userName=UDDI User Name
UDDIConfigurationsDialog.noteLine1=Note: You will be prompted to enter a password whenever using
-UDDIConfigurationsDialog.noteLine2=a UDDI Configuration.
+UDDIConfigurationsDialog.noteLine2=a UDDI Configuration.
+
WebServicesPanel.publish=Publish Web Services
WebServicesPanel.unpublish=Unpublish Web Services
@@ -202,8 +203,39 @@
WebServicesPanel.errorRetrievingVirtualDatabases=Error Retrieving Virtual Databases
WebServicesPanel.errorRetrievingCurrentConfiguration=Error Retrieving Current Configuration
WebServicesPanel.notActiveMsg=This virtual database is not Active. Cannot publish or unpublish unless the virtual database is Active.
-WebServicesPanel.notActiveHdr=Not Active
+WebServicesPanel.notActiveHdr=Not Active
+
+MMUddiHelper.InvalidParameterException_in_Add_Business=InvalidParameterException while adding business: {0}
+MMUddiHelper.TransportException_in_WSDL_publish=TransportException while publishing WSDL: {0}
+MMUddiHelper.MalformedURLException_in_WSDL_publish=MalformedURLExceptrion while publishing WSDL: {0}
+MMUddiHelper.UDDIException_in_WSDL_publish=UDDIExceptrion while publishing WSDL: {0}
+MMUddiHelper.InvalidParameterException_in_WSDL_publish=InvalidParameterExceptrion while publishing WSDL: {0}
+MMUddiHelper.SOAPException_in_WSDL_publish=SOAPExceptrion while publishing WSDL: {0}
+
+MMUddiHelper.TransportException_in_WSDL_unpublish=TransportException while un-publishing WSDL: {0}
+MMUddiHelper.MalformedURLException_in_WSDL_unpublish=MalformedURLExceptrion while un-publishing WSDL: {0}
+MMUddiHelper.UDDIException_in_WSDL_unpublish=UDDIExceptrion while un-publishing WSDL: {0}
+MMUddiHelper.InvalidParameterException_in_WSDL_unpublish=InvalidParameterExceptrion while un-publishing WSDL: {0}
+MMUddiHelper.SOAPException_in_WSDL_unpublish=SOAPExceptrion while un-publishing WSDL: {0}
+
+MMUddiHelper.TransportException_isPublished=MMUddiHelper.TransportException in isPublished()" {0}
+MMUddiHelper.MalformedURLException_isPublished=MMUddiHelper. in isPublished()" {0}
+MMUddiHelper.UDDIException_isPublished=UDDIException in isPublished(): {0}
+
+MMUddiHelper.TransportException_finding_businesses_by_name=TransportException while finding business by name: {0}
+MMUddiHelper.MalformedURLException_finding_businesses_by_name=MalformedURLException while finding business by name: {0}
+MMUddiHelper.UDDIException_finding_businesses_by_name=UDDIException while finding business by name: {0}
+MMUddiHelper.InvalidParameterException_finding_businesses_by_name=InvalidParameterExceptrion while finding business by name: {0}
+MMUddiHelper.SOAPException_finding_businesses_by_name=SOAPException while finding business by name: {0}
+
+MMUddiHelper.TransportException_finding_all_businesses=TransportException while finding all businesses: {0}
+MMUddiHelper.MalformedURLException_finding_all_businesses=MalformedURLException while finding all businesses: {0}
+MMUddiHelper.UDDIException_finding_all_businesses=UDDIException while finding finding all businesses: {0}
+MMUddiHelper.InvalidParameterException_finding_all_businesses=InvalidParameterExceptrion while finding all businesses: {0}
+MMUddiHelper.SOAPException_finding_all_businesses=SOAPException while finding all businesses: {0}
+UnPublishWSDL.UnpublishWsdl.ErrorDeletingService=Error during deletion of Service operator: {0} generic: {1}
+
#----------------------------------------
# Materialization
#----------------------------------------
Modified: trunk/soap/src/main/java/com/metamatrix/soap/handler/ActionUpdateHandler.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/handler/ActionUpdateHandler.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/soap/src/main/java/com/metamatrix/soap/handler/ActionUpdateHandler.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -42,8 +42,8 @@
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.axis2.transport.http.HTTPConstants;
+import com.metamatrix.common.util.WSDLServletUtil;
import com.metamatrix.soap.exceptions.SOAPProcessingException;
-import com.metamatrix.soap.util.WSDLServletUtil;
import com.metamatrix.soap.util.WebServiceUtil;
/**
Modified: trunk/soap/src/main/java/com/metamatrix/soap/service/DataServiceWebServiceImpl.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/service/DataServiceWebServiceImpl.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/soap/src/main/java/com/metamatrix/soap/service/DataServiceWebServiceImpl.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -43,6 +43,7 @@
import com.metamatrix.admin.api.objects.LogConfiguration;
import com.metamatrix.common.util.ByteArrayHelper;
+import com.metamatrix.common.util.WSDLServletUtil;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.jdbc.api.SQLStates;
import com.metamatrix.soap.SOAPPlugin;
@@ -50,7 +51,6 @@
import com.metamatrix.soap.security.Credential;
import com.metamatrix.soap.sqlquerywebservice.log.LogUtil;
import com.metamatrix.soap.util.EndpointUriTranslatorStrategyImpl;
-import com.metamatrix.soap.util.WSDLServletUtil;
import com.metamatrix.soap.util.WebServiceUtil;
/**
Modified: trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMDiscoverWSDLServlet.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMDiscoverWSDLServlet.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMDiscoverWSDLServlet.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -35,12 +35,12 @@
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.api.exception.security.LogonException;
+import com.metamatrix.common.util.WSDLServletUtil;
import com.metamatrix.core.log.FileLogWriter;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.soap.SOAPPlugin;
import com.metamatrix.soap.object.MMServerInfo;
-import com.metamatrix.soap.util.WSDLServletUtil;
import com.metamatrix.soap.util.WebServiceUtil;
/**
Modified: trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetVDBResourceServlet.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetVDBResourceServlet.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetVDBResourceServlet.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -48,6 +48,7 @@
import org.apache.log4j.Logger;
import com.metamatrix.common.api.MMURL;
+import com.metamatrix.common.util.WSDLServletUtil;
import com.metamatrix.core.CoreConstants;
import com.metamatrix.core.log.FileLogWriter;
import com.metamatrix.core.log.LogListener;
@@ -56,7 +57,6 @@
import com.metamatrix.soap.SOAPPlugin;
import com.metamatrix.soap.util.ErrorMessageKeys;
import com.metamatrix.soap.util.SOAPConstants;
-import com.metamatrix.soap.util.WSDLServletUtil;
import com.metamatrix.soap.util.WebServiceUtil;
Modified: trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetWSDLServlet.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetWSDLServlet.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetWSDLServlet.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -34,13 +34,13 @@
import org.apache.log4j.Logger;
+import com.metamatrix.common.util.WSDLServletUtil;
import com.metamatrix.core.log.FileLogWriter;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.soap.SOAPPlugin;
import com.metamatrix.soap.util.ErrorMessageKeys;
import com.metamatrix.soap.util.SOAPConstants;
-import com.metamatrix.soap.util.WSDLServletUtil;
import com.metamatrix.soap.util.WebServiceUtil;
/**
Modified: trunk/soap/src/main/java/com/metamatrix/soap/servlet/WSDLURLGenerator.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/servlet/WSDLURLGenerator.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/soap/src/main/java/com/metamatrix/soap/servlet/WSDLURLGenerator.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -43,13 +43,13 @@
import org.apache.log4j.Logger;
+import com.metamatrix.common.util.WSDLServletUtil;
import com.metamatrix.core.log.FileLogWriter;
import com.metamatrix.core.log.LogListener;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.soap.SOAPPlugin;
import com.metamatrix.soap.util.ErrorMessageKeys;
import com.metamatrix.soap.util.SOAPConstants;
-import com.metamatrix.soap.util.WSDLServletUtil;
/**
* Servlet to build the WSDL URL for the specified VDB
Modified: trunk/soap/src/main/java/com/metamatrix/soap/util/EndpointUriTranslatorStrategyImpl.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/util/EndpointUriTranslatorStrategyImpl.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/soap/src/main/java/com/metamatrix/soap/util/EndpointUriTranslatorStrategyImpl.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -30,6 +30,7 @@
import org.apache.axis2.context.MessageContext;
+import com.metamatrix.common.util.WSDLServletUtil;
import com.metamatrix.soap.exceptions.SOAPProcessingException;
import com.metamatrix.soap.handler.ActionUpdateHandler;
import com.metamatrix.soap.service.DataServiceInfo;
Deleted: trunk/soap/src/main/java/com/metamatrix/soap/util/WSDLServletUtil.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/util/WSDLServletUtil.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/soap/src/main/java/com/metamatrix/soap/util/WSDLServletUtil.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -1,225 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.soap.util;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.text.MessageFormat;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Constants pertaining to WSDL servlet execution.
- *
- * @since 4.2
- */
-
-public class WSDLServletUtil {
-
- /**
- * General keys
- */
- public static final String SERVER_URL_KEY = "ServerURL"; //$NON-NLS-1$
-
- public static final String SECURE_PROTOCOL = "Secure"; //$NON-NLS-1$
-
- public static final String VDB_NAME_KEY = "VDBName"; //$NON-NLS-1$
-
- public static final String VDB_VERSION_KEY = "VDBVersion"; //$NON-NLS-1$
-
- public static final String ADD_PROPS = "AdditionalProperties"; //$NON-NLS-1$
-
- public static final String TXN_AUTO_WRAP = "txnAutoWrap"; //$NON-NLS-1$
-
- public static final String ADD_EXEC_PROPS = "AddExecProperties"; //$NON-NLS-1$
-
- public static final String MM_WEBSERVICE_QUERY_TIMEOUT = "com.metamatrix.webservice.querytimeout"; //$NON-NLS-1$
-
- public static final String DISCOVERED_WSDL = "discovered_wsdl"; //$NON-NLS-1$
-
- /*
- * This is the parameter that will tell this servlet when the web service endpoint as defined in WSDL served up by this
- * servlet will use the HTTP vs HTTPS protocol.
- */
- public static final String HTTP_TYPE_PARAMETER_KEY = "httptype"; //$NON-NLS-1$
-
- /*
- * This is the value of the httptype URL request param that will indicate that the returned WSDL should have an http endpoint
- * instead of an https endpoint.
- */
- public static final String HTTP_PARAMETER_VALUE = "http"; //$NON-NLS-1$
-
- /*
- * Static contant representing the standard http protocol.
- */
- public static final String HTTP = "http"; //$NON-NLS-1$
-
- /**
- * Static contant representing the secure http protocol.
- */
- public static final String HTTPS = "https"; //$NON-NLS-1$
-
- /**
- * Default content type for the VDBResourceServlet
- */
- public static final String DEFAULT_CONTENT_TYPE = "text/html"; //$NON-NLS-1$
-
- /**
- * XML content type for the VDBResourceServlet
- */
- public static final String XML_CONTENT_TYPE = "text/xml"; //$NON-NLS-1$
-
- /**
- * WSDL URL Generator keys
- */
- public static final String MMSERVER_HOST_PORT_KEY = "MMServerHostAndPort"; //$NON-NLS-1$
-
- public static final String TARGET_HOST_KEY = "TargetHost"; //$NON-NLS-1$
-
- public static final String TARGET_PORT_KEY = "TargetPort"; //$NON-NLS-1$
-
- public static final String SERVLET_PATH = "/servlet/ArtifactDocumentService"; //$NON-NLS-1$
-
- public static final String SQLQUERYWEBSERVICE_WSDL_PATH = "/services/SqlQueryWebService?wsdl"; //$NON-NLS-1$
-
- public static final String GENERATED_WSDL_NAME = "MetaMatrixDataServices"; //$NON-NLS-1$
-
- public static final String GENERATED_WSDL_FILENAME = GENERATED_WSDL_NAME + ".wsdl"; //$NON-NLS-1$
-
- public static final String COLON = ":"; //$NON-NLS-1$
-
- public static final String SLASH = "/"; //$NON-NLS-1$
-
- public static final String DOUBLE_SLASH = "//"; //$NON-NLS-1$
-
- public static final String AMP = "&"; //$NON-NLS-1$
-
- public static final String QUESTION_MARK = "?"; //$NON-NLS-1$
-
- public static final String EQUALS = "="; //$NON-NLS-1$
-
- public static final String COMMA = ","; //$NON-NLS-1$
-
- private static final String SQLQUERYWEBSERVICE_URL_FORMAT = "{0}://{1}:{2}/{3}"; //$NON-NLS-1$
-
- /*
- * this default value is based on Tomcat's default value in its server.xml file. This value can be overridden by setting the
- * com.metamatrix.webservice.dataservice.httpsport System property for the VM that this servlet is running in.
- */
- private static final String DEFAULT_HTTPS_PORT = "8443"; //$NON-NLS-1$
-
- private static final String DEFAULT_HTTP_PORT = "8080"; //$NON-NLS-1$
-
- private static final String HTTPS_PORT_PROPERTY_KEY = "com.metamatrix.webservice.dataservice.httpsport"; //$NON-NLS-1$
-
- private static final String HTTP_PORT_PROPERTY_KEY = "com.metamatrix.webservice.dataservice.httpport"; //$NON-NLS-1$
-
- /**
- * Returns the formatted url from the supplied info
- *
- * @param scheme the server scheme
- * @param host the server host name
- * @param port the server port
- * @param appContext the context of this application to use in the WSDL url
- * @param serverURLs the list of server url info, first url is full url including protocol. Subsequent items are just the
- * host:port strings.
- * @param vdbName the vdb name
- * @param vdbVersion the vdb version number
- */
- public static String formatURL( String scheme,
- String host,
- String port,
- String appContext,
- List serverURLs,
- String vdbName,
- String vdbVersion ) {
-
- StringBuffer result = new StringBuffer();
- try {
- boolean hasPort = true;
- boolean hasVDBVersion = true;
-
- if (port == null || port.length() == 0) {
- hasPort = false;
- }
-
- if (vdbVersion == null || vdbVersion.trim().length() == 0) {
- hasVDBVersion = false;
- }
-
- result.append(scheme).append(COLON).append(DOUBLE_SLASH).append(host);
-
- if (hasPort) {
- result.append(COLON).append(port);
- }
-
- result.append(appContext).append(SERVLET_PATH).append(SLASH).append(GENERATED_WSDL_FILENAME);
- result.append(QUESTION_MARK).append(SERVER_URL_KEY).append(EQUALS);
- // Append comma-delimited server urls
- Iterator iter = serverURLs.iterator();
- while (iter.hasNext()) {
- String serverURL = (String)iter.next();
- result.append(serverURL);
- // If there is another url coming, add an encoded comma
- if (iter.hasNext()) {
- result.append(URLEncoder.encode(COMMA, "UTF-8")); //$NON-NLS-1$
- }
- }
- result.append(AMP).append(VDB_NAME_KEY).append(EQUALS).append(vdbName);
- if (hasVDBVersion) {
- result.append(AMP).append(VDB_VERSION_KEY).append(EQUALS).append(vdbVersion);
- }
-
- } catch (UnsupportedEncodingException err) {
- // ignore
- }
-
- return result.toString();
- }
-
- /**
- * Returns the formatted wsdl url for the SqlQueryWebService
- *
- * @param server - server name
- * @param appContext the context of this application to use in the WSDL url
- * @param secure - secure ssl (true) or non-secure (false)
- * @return wsdlUrl - String
- * @since 4.3
- */
- public static String getSqlQueryWebServiceUrl( final String server,
- String appContext,
- final boolean secure ) {
-
- appContext=appContext.replace("/",""); //$NON-NLS-1$ //$NON-NLS-2$
- return MessageFormat.format(SQLQUERYWEBSERVICE_URL_FORMAT, new Object[] {secure ? HTTPS : HTTP, server,
- secure ? getHttpsPort() : getHttpPort(), appContext+SQLQUERYWEBSERVICE_WSDL_PATH});
- }
-
- public static final String getHttpsPort() {
- return System.getProperty(HTTPS_PORT_PROPERTY_KEY, DEFAULT_HTTPS_PORT);
- }
-
- public static final String getHttpPort() {
- return System.getProperty(HTTP_PORT_PROPERTY_KEY, DEFAULT_HTTP_PORT);
- }
-}
Modified: trunk/soap/src/test/java/com/metamatrix/soap/handler/TestActionUpdateHandler.java
===================================================================
--- trunk/soap/src/test/java/com/metamatrix/soap/handler/TestActionUpdateHandler.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/soap/src/test/java/com/metamatrix/soap/handler/TestActionUpdateHandler.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -29,7 +29,7 @@
import org.apache.axis2.context.MessageContext;
-import com.metamatrix.soap.util.WSDLServletUtil;
+import com.metamatrix.common.util.WSDLServletUtil;
public class TestActionUpdateHandler extends TestCase{
Modified: trunk/soap/src/test/java/com/metamatrix/soap/service/TestDataServiceWebServiceImpl.java
===================================================================
--- trunk/soap/src/test/java/com/metamatrix/soap/service/TestDataServiceWebServiceImpl.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/soap/src/test/java/com/metamatrix/soap/service/TestDataServiceWebServiceImpl.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -28,7 +28,7 @@
import org.apache.axis2.AxisFault;
-import com.metamatrix.soap.util.WSDLServletUtil;
+import com.metamatrix.common.util.WSDLServletUtil;
/**
*
Modified: trunk/soap/src/test/java/com/metamatrix/soap/servlet/TestMMGetVDBResourceServlet.java
===================================================================
--- trunk/soap/src/test/java/com/metamatrix/soap/servlet/TestMMGetVDBResourceServlet.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/soap/src/test/java/com/metamatrix/soap/servlet/TestMMGetVDBResourceServlet.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -25,7 +25,7 @@
import java.util.Map;
import java.util.TreeMap;
-import com.metamatrix.soap.util.WSDLServletUtil;
+import com.metamatrix.common.util.WSDLServletUtil;
import junit.framework.TestCase;
Modified: trunk/soap/src/test/java/com/metamatrix/soap/util/TestWSDLServletUtil.java
===================================================================
--- trunk/soap/src/test/java/com/metamatrix/soap/util/TestWSDLServletUtil.java 2009-05-13 17:45:21 UTC (rev 929)
+++ trunk/soap/src/test/java/com/metamatrix/soap/util/TestWSDLServletUtil.java 2009-05-13 18:07:37 UTC (rev 930)
@@ -25,7 +25,7 @@
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.soap.util.WSDLServletUtil;
+import com.metamatrix.common.util.WSDLServletUtil;
import junit.framework.TestCase;
15 years, 7 months
teiid SVN: r929 - in trunk/connectors/connector-jdbc/src: test/java/org/teiid/connector/jdbc/mysql and 1 other directory.
by teiid-commits@lists.jboss.org
Author: li.liang
Date: 2009-05-13 13:45:21 -0400 (Wed, 13 May 2009)
New Revision: 929
Modified:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
Log:
TEIID-591 Remove optional parenthesis for joins for all but MySql connector.
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java 2009-05-13 17:45:04 UTC (rev 928)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java 2009-05-13 17:45:21 UTC (rev 929)
@@ -103,4 +103,7 @@
return MySQLCapabilities.class;
}
+ public boolean useParensForJoins() {
+ return true;
+ }
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java 2009-05-13 17:45:04 UTC (rev 928)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java 2009-05-13 17:45:21 UTC (rev 929)
@@ -200,5 +200,13 @@
input,
output, TRANSLATOR);
}
-
+
+ @Test public void testJoins() throws Exception {
+ String input = "select smalla.intkey from bqt1.smalla inner join bqt1.smallb on smalla.stringkey=smallb.stringkey cross join bqt1.mediuma"; //$NON-NLS-1$
+ String output = "SELECT SmallA.IntKey FROM (SmallA INNER JOIN SmallB ON SmallA.StringKey = SmallB.StringKey) CROSS JOIN MediumA"; //$NON-NLS-1$
+
+ TestMySQLTranslator.helpTestVisitor(MetadataFactory.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
}
15 years, 7 months
teiid SVN: r928 - in trunk/connectors/connector-jdbc/src: test/java/org/teiid/connector/jdbc/oracle and 1 other directory.
by teiid-commits@lists.jboss.org
Author: li.liang
Date: 2009-05-13 13:45:04 -0400 (Wed, 13 May 2009)
New Revision: 928
Modified:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java
Log:
TEIID-591 Remove optional parenthesis for joins for all but MySql connector.
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java 2009-05-13 04:28:31 UTC (rev 927)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java 2009-05-13 17:45:04 UTC (rev 928)
@@ -300,5 +300,9 @@
protected void appendSetOperation(Operation operation) {
buffer.append(translator.getSetOperationString(operation));
}
-
+
+ @Override
+ protected boolean useParensForJoins() {
+ return translator.useParensForJoins();
+ }
}
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java 2009-05-13 04:28:31 UTC (rev 927)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java 2009-05-13 17:45:04 UTC (rev 928)
@@ -772,4 +772,12 @@
}
}
+ /**
+ * Set to true to indicate that every branch of a join
+ * should have parenthesis.
+ * @return
+ */
+ public boolean useParensForJoins() {
+ return false;
+ }
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java 2009-05-13 04:28:31 UTC (rev 927)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java 2009-05-13 17:45:04 UTC (rev 928)
@@ -27,6 +27,8 @@
import junit.framework.TestCase;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.jdbc.MetadataFactory;
+import org.teiid.connector.jdbc.mysql.TestMySQLTranslator;
import org.teiid.connector.jdbc.translator.TranslatedCommand;
import org.teiid.connector.jdbc.translator.Translator;
import org.teiid.connector.language.ICommand;
@@ -65,4 +67,22 @@
public void testInsertWithSequnce1() throws Exception {
helpTestVisitor("insert into test.group (e0, e1) values (1, 'x')", "INSERT INTO group (e0, e1) VALUES (1, 'x')");
}
+
+ public void testJoins() throws Exception {
+ String input = "select smalla.intkey from bqt1.smalla inner join bqt1.smallb on smalla.stringkey=smallb.stringkey cross join bqt1.mediuma"; //$NON-NLS-1$
+ String output = "SELECT SmallA.IntKey FROM SmallA INNER JOIN SmallB ON SmallA.StringKey = SmallB.StringKey CROSS JOIN MediumA"; //$NON-NLS-1$
+
+ TestMySQLTranslator.helpTestVisitor(MetadataFactory.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+
+ public void testJoins2() throws Exception {
+ String input = "select smalla.intkey from bqt1.smalla cross join (bqt1.smallb cross join bqt1.mediuma)"; //$NON-NLS-1$
+ String output = "SELECT SmallA.IntKey FROM SmallA CROSS JOIN (SmallB CROSS JOIN MediumA)"; //$NON-NLS-1$
+
+ TestMySQLTranslator.helpTestVisitor(MetadataFactory.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
}
15 years, 7 months
teiid SVN: r927 - in trunk/engine/src: main/java/com/metamatrix/query/sql/lang and 6 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-05-13 00:28:31 -0400 (Wed, 13 May 2009)
New Revision: 927
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectIntoNode.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java
trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStore.java
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/resources/com/metamatrix/query/execution/i18n.properties
trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestQuery.java
Log:
TEIID-585 fixes for temp table issue with prepared statements and query cloning
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectIntoNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectIntoNode.java 2009-05-13 04:18:28 UTC (rev 926)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectIntoNode.java 2009-05-13 04:28:31 UTC (rev 927)
@@ -25,7 +25,6 @@
package com.metamatrix.query.processor.relational;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -40,7 +39,6 @@
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
public class ProjectIntoNode extends RelationalNode {
@@ -115,7 +113,7 @@
currentBatch = getChildren()[0].nextBatch(); // can throw BlockedException
this.batchRow = currentBatch.getBeginRow();
- if(currentBatch.getRowCount() == 0) {
+ if(currentBatch.getRowCount() == 0 && !this.intoGroup.isImplicitTempGroupSymbol()) {
continue;
}
} else if (currentBatch.getTerminationFlag() && this.batchRow > currentBatch.getEndRow()) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java 2009-05-13 04:18:28 UTC (rev 926)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java 2009-05-13 04:28:31 UTC (rev 927)
@@ -34,6 +34,7 @@
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.GroupSymbol;
import com.metamatrix.query.sql.symbol.SelectSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
/**
@@ -366,6 +367,10 @@
}
}
+ if (into != null) {
+ copy.into = (Into)into.clone();
+ }
+
copyMetadataState(copy);
return copy;
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java 2009-05-13 04:18:28 UTC (rev 926)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java 2009-05-13 04:28:31 UTC (rev 927)
@@ -89,7 +89,7 @@
}
public Class<?> getType() {
- if (this.isPositional()) {
+ if (this.isPositional() && this.expression == null) {
return type;
}
return expression.getType();
Modified: trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStore.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStore.java 2009-05-13 04:18:28 UTC (rev 926)
+++ trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStore.java 2009-05-13 04:28:31 UTC (rev 927)
@@ -25,7 +25,7 @@
import java.util.Set;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.TupleSource;
import com.metamatrix.common.buffer.TupleSourceID;
import com.metamatrix.query.metadata.TempMetadataStore;
@@ -36,15 +36,13 @@
*/
public interface TempTableStore {
- void addTempTable(Command command, boolean removeExistingTable) throws MetaMatrixComponentException;
-
void removeTempTable(Command command) throws MetaMatrixComponentException;
void removeTempTables() throws MetaMatrixComponentException;
TempMetadataStore getMetadataStore();
- public TupleSource registerRequest(Command command) throws MetaMatrixComponentException, ExpressionEvaluationException;
+ public TupleSource registerRequest(Command command) throws MetaMatrixComponentException, MetaMatrixProcessingException;
public boolean hasTempTable(Command command);
Modified: trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java 2009-05-13 04:18:28 UTC (rev 926)
+++ trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java 2009-05-13 04:28:31 UTC (rev 927)
@@ -33,6 +33,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.api.exception.query.QueryProcessingException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
@@ -74,47 +75,13 @@
this.sessionID = sessionID;
this.parentTempTableStore = parentTempTableStore;
}
-
- public void addTempTable(Command command, boolean removeExistingTable) throws MetaMatrixComponentException{
- String tempTableName = null;
- List columns = null;
- switch (command.getType()) {
- case Command.TYPE_CREATE:
- tempTableName = ((Create)command).getTable().getName().toUpperCase();
- columns = ((Create)command).getColumns();
- break;
- case Command.TYPE_QUERY:
- Query query = (Query)command;
- if(query.getInto() != null) {
- tempTableName = query.getInto().getGroup().getName().toUpperCase();
- columns = query.getSelect().getSymbols();
- break;
- }else if(((GroupSymbol)query.getFrom().getGroups().get(0)).isTempGroupSymbol()) {
- tempTableName = ((GroupSymbol)query.getFrom().getGroups().get(0)).getNonCorrelationName().toUpperCase();
- columns = query.getSelect().getSymbols();
- break;
- }
- return;
- case Command.TYPE_INSERT:
- Insert insert = (Insert)command;
- GroupSymbol group = insert.getGroup();
- if(group.isTempGroupSymbol()) {
- tempTableName = group.getNonCorrelationName().toUpperCase();
- columns = insert.getVariables();
- break;
- }
- return;
- default:
- return;
- }
-
+ public void addTempTable(String tempTableName, List columns, boolean removeExistingTable) throws MetaMatrixComponentException, QueryProcessingException{
if(tempMetadataStore.getTempGroupID(tempTableName) != null) {
- if(removeExistingTable) {
- removeTempTableByName(tempTableName);
- }else {
- throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("TempTableStore.table_exist_error", tempTableName));//$NON-NLS-1$
+ if(!removeExistingTable) {
+ throw new QueryProcessingException(QueryExecPlugin.Util.getString("TempTableStore.table_exist_error", tempTableName));//$NON-NLS-1$
}
+ removeTempTableByName(tempTableName);
}
//add metadata
@@ -151,7 +118,7 @@
return tempMetadataStore;
}
- public TupleSource registerRequest(Command command) throws MetaMatrixComponentException, ExpressionEvaluationException{
+ public TupleSource registerRequest(Command command) throws MetaMatrixComponentException, ExpressionEvaluationException, QueryProcessingException{
if(!hasTempTable(command)) {
return null;
}
@@ -165,11 +132,16 @@
{
Query query = (Query)command;
GroupSymbol group = (GroupSymbol)query.getFrom().getGroups().get(0);
- return connectTupleSource(group.getNonCorrelationName(), command);
+ TupleSourceID tsId = getTupleSourceID(group.getNonCorrelationName().toUpperCase(), command);
+ try {
+ return buffer.getTupleSource(tsId);
+ }catch(TupleSourceNotFoundException e) {
+ throw new MetaMatrixComponentException(e);
+ }
}
case Command.TYPE_CREATE:
{
- addTempTable(command, false);
+ addTempTable(((Create)command).getTable().getName().toUpperCase(), ((Create)command).getColumns(), false);
return new UpdateCountTupleSource(0);
}
case Command.TYPE_DROP:
@@ -190,18 +162,9 @@
}
}
- private TupleSource connectTupleSource(String tableName, Command command) throws MetaMatrixComponentException{
- TupleSourceID tsId = getTupleSourceID(tableName, command);
- try {
- return buffer.getTupleSource(tsId);
- }catch(TupleSourceNotFoundException e) {
- throw new MetaMatrixComponentException(e);
- }
- }
-
- private TupleSourceID getTupleSourceID(String tempTableID, Command command) throws MetaMatrixComponentException{
+ private TupleSourceID getTupleSourceID(String tempTableID, Command command) throws MetaMatrixComponentException, QueryProcessingException{
- TupleSourceID tsID = (TupleSourceID)groupToTupleSourceID.get(tempTableID.toUpperCase());
+ TupleSourceID tsID = (TupleSourceID)groupToTupleSourceID.get(tempTableID);
if(tsID != null) {
return tsID;
}
@@ -211,14 +174,33 @@
return tsID;
}
}
- addTempTable(command, true);
- return (TupleSourceID)groupToTupleSourceID.get(tempTableID.toUpperCase());
+ //allow implicit temp group definition
+ List columns = null;
+ switch (command.getType()) {
+ case Command.TYPE_QUERY:
+ Query query = (Query)command;
+ if(query.getInto() != null && query.getInto().getGroup().isImplicitTempGroupSymbol()) {
+ columns = query.getSelect().getSymbols();
+ }
+ break;
+ case Command.TYPE_INSERT:
+ Insert insert = (Insert)command;
+ GroupSymbol group = insert.getGroup();
+ if(group.isImplicitTempGroupSymbol()) {
+ columns = insert.getVariables();
+ }
+ break;
+ }
+ if (columns == null) {
+ throw new QueryProcessingException(QueryExecPlugin.Util.getString("TempTableStore.table_doesnt_exist_error", tempTableID)); //$NON-NLS-1$
+ }
+ addTempTable(tempTableID, columns, true);
+ return (TupleSourceID)groupToTupleSourceID.get(tempTableID);
}
-
- private TupleSource addTuple(Insert insert) throws MetaMatrixComponentException, ExpressionEvaluationException {
+ private TupleSource addTuple(Insert insert) throws MetaMatrixComponentException, ExpressionEvaluationException, QueryProcessingException {
GroupSymbol group = insert.getGroup();
- TupleSourceID tsId = getTupleSourceID(group.getNonCorrelationName(), insert);
+ TupleSourceID tsId = getTupleSourceID(group.getNonCorrelationName().toUpperCase(), insert);
int tuplesAdded = 0;
try {
int rowCount = buffer.getRowCount(tsId);
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-05-13 04:18:28 UTC (rev 926)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-05-13 04:28:31 UTC (rev 927)
@@ -216,10 +216,7 @@
metadata = metadataService.lookupMetadata(vdbName, vdbVersion);
if (metadata == null) {
- Object[] params = new Object[] { this.vdbName, this.vdbVersion };
- String msg = DQPPlugin.Util.getString("DQPCore.Unable_to_load_metadata_for_VDB_name__{0},_version__{1}", params); //$NON-NLS-1$
- MetaMatrixComponentException e = new MetaMatrixComponentException(msg);
- throw e;
+ throw new MetaMatrixComponentException(DQPPlugin.Util.getString("DQPCore.Unable_to_load_metadata_for_VDB_name__{0},_version__{1}", this.vdbName, this.vdbVersion)); //$NON-NLS-1$
}
this.metadata = new TempMetadataAdapter(metadata, new TempMetadataStore());
Modified: trunk/engine/src/main/resources/com/metamatrix/query/execution/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/com/metamatrix/query/execution/i18n.properties 2009-05-13 04:18:28 UTC (rev 926)
+++ trunk/engine/src/main/resources/com/metamatrix/query/execution/i18n.properties 2009-05-13 04:28:31 UTC (rev 927)
@@ -184,6 +184,7 @@
RulePlanJoins.cantSatisfy=Join region with unsatisfied access patterns cannot be satisfied by the join criteria, Access patterns: {0}
TempTableStore.table_exist_error=Temporary table "{0}" already exists.
+TempTableStore.table_doesnt_exist_error=Temporary table "{0}" does not exist.
XMLQueryPlanner.cannot_plan=Cannot create a query for MappingClass with user criteria {0}
XMLQueryPlanner.staging_table_has_input_set=Staging table ''{0}'' is not allowed to have an input set.
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-05-13 04:18:28 UTC (rev 926)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-05-13 04:28:31 UTC (rev 927)
@@ -2009,7 +2009,7 @@
procedure.append("select e1 into t1 from pm1.g1;\n"); //$NON-NLS-1$
procedure.append("drop table t1;\n"); //$NON-NLS-1$
procedure.append("drop table t1;\n"); //$NON-NLS-1$
- procedure.append("SELECT e1 from t1;\n"); //$NON-NLS-1$
+ procedure.append("SELECT 1;\n"); //$NON-NLS-1$
procedure.append("END"); //$NON-NLS-1$
QueryNode sq2n1 = new QueryNode("pm1.sq1", procedure.toString()); //$NON-NLS-1$
@@ -2024,7 +2024,7 @@
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
- helpTestProcess(plan, new List[] {}, dataMgr);
+ helpTestProcess(plan, new List[] {Arrays.asList(1)}, dataMgr);
}
/**
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestQuery.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestQuery.java 2009-05-13 04:18:28 UTC (rev 926)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestQuery.java 2009-05-13 04:28:31 UTC (rev 927)
@@ -155,4 +155,11 @@
UnitTestUtil.helpTestEquivalence(equals, q, qclone);
assertEquals(projectedSymbols, qclone.getProjectedSymbols());
}
+
+ public void testClone3() {
+ Query q = sample2();
+ q.setInto(new Into(new GroupSymbol("#foo"))); //$NON-NLS-1$
+ Query qclone = (Query)q.clone();
+ assertNotNull(qclone.getInto());
+ }
}
15 years, 7 months
teiid SVN: r926 - trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-05-13 00:18:28 -0400 (Wed, 13 May 2009)
New Revision: 926
Modified:
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
Log:
TEIID-105 adding mysql support for bit operations and creating a mysql 5 specific translator/capabilities.
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java 2009-05-13 02:17:35 UTC (rev 925)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java 2009-05-13 04:18:28 UTC (rev 926)
@@ -62,7 +62,6 @@
TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), translator); //$NON-NLS-1$
tc.translateCommand(obj);
-
// Check stuff
assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
}
@@ -195,7 +194,7 @@
@Test public void testBitAnd() throws Exception {
String input = "select bitand(intkey, intnum) from bqt1.smalla"; //$NON-NLS-1$
- String output = "SELECT (SmallA.IntKey & SmallA.IntNum) FROM SmallA"; //$NON-NLS-1$
+ String output = "SELECT convert((SmallA.IntKey & SmallA.IntNum), SIGNED INTEGER) FROM SmallA"; //$NON-NLS-1$
TestMySQLTranslator.helpTestVisitor(MetadataFactory.BQT_VDB,
input,
15 years, 7 months
teiid SVN: r925 - in trunk/engine/src: test/java/com/metamatrix/query/optimizer/relational/rules and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-05-12 22:17:35 -0400 (Tue, 12 May 2009)
New Revision: 925
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java
Log:
TEIID-584 preventing access nodes from being accidently pushed across an access node.
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-05-13 01:45:00 UTC (rev 924)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-05-13 02:17:35 UTC (rev 925)
@@ -564,8 +564,13 @@
copyNode.setProperty(NodeConstants.Info.IS_HAVING, Boolean.TRUE);
}
- FrameUtil.convertNode(copyNode, sourceGroup, null, symbolMap.asMap());
- projectNode.getFirstChild().addAsParent(copyNode);
+ FrameUtil.convertNode(copyNode, sourceGroup, null, symbolMap.asMap());
+ PlanNode intermediateParent = NodeEditor.findParent(projectNode, NodeConstants.Types.ACCESS, NodeConstants.Types.SOURCE | NodeConstants.Types.SET_OP);
+ if (intermediateParent != null) {
+ intermediateParent.addAsParent(copyNode);
+ } else {
+ projectNode.getFirstChild().addAsParent(copyNode);
+ }
return true;
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java 2009-05-13 01:45:00 UTC (rev 924)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java 2009-05-13 02:17:35 UTC (rev 925)
@@ -22,27 +22,69 @@
package com.metamatrix.query.optimizer.relational.rules;
+import static org.junit.Assert.*;
+
import java.util.Arrays;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
-import junit.framework.TestCase;
+import org.junit.Test;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.optimizer.TestOptimizer;
+import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import com.metamatrix.query.optimizer.relational.GenerateCanonical;
+import com.metamatrix.query.optimizer.relational.PlanHints;
+import com.metamatrix.query.optimizer.relational.RuleStack;
+import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
+import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
+import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
+import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
+import com.metamatrix.query.optimizer.relational.plantree.NodeConstants.Info;
import com.metamatrix.query.parser.QueryParser;
+import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import com.metamatrix.query.sql.util.SymbolMap;
+import com.metamatrix.query.unittest.FakeMetadataFacade;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+import com.metamatrix.query.util.CommandContext;
-public class TestRulePushSelectCriteria extends TestCase {
+public class TestRulePushSelectCriteria {
- public void testElementsInCritieria() throws Exception {
+ @Test public void testElementsInCritieria() throws Exception {
String criteria = "e1 = '1' OR ((e1 = '2' OR e1 = '4') AND e2 = 3)"; //$NON-NLS-1$
Set<ElementSymbol> expected = new HashSet<ElementSymbol>(Arrays.asList(new ElementSymbol("e1"))); //$NON-NLS-1$
assertEquals(expected, RulePushSelectCriteria.getElementsIncriteria(QueryParser.getQueryParser().parseCriteria(criteria)));
}
- public void testElementsInCritieria1() throws Exception {
+ @Test public void testElementsInCritieria1() throws Exception {
String criteria = "e1 = '1' and ((e1 = '2' OR e1 = '4') AND e2 = 3) or e2 is null"; //$NON-NLS-1$
Set<ElementSymbol> expected = new HashSet<ElementSymbol>(Arrays.asList(new ElementSymbol("e2"))); //$NON-NLS-1$
assertEquals(expected, RulePushSelectCriteria.getElementsIncriteria(QueryParser.getQueryParser().parseCriteria(criteria)));
}
+
+ @Test public void testPushAcrossFrameWithAccessNode() throws Exception {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+ Command command = TestOptimizer.helpGetCommand("select * from (select * from pm1.g1 union select * from pm1.g2) x where e1 = 1", metadata, null); //$NON-NLS-1$
+ Command subCommand = TestOptimizer.helpGetCommand("select * from pm1.g1 union select * from pm1.g2", metadata, null); //$NON-NLS-1$
+ PlanNode root = GenerateCanonical.generatePlan(command, new PlanHints(), metadata);
+ PlanNode child = GenerateCanonical.generatePlan(subCommand, new PlanHints(), metadata);
+ PlanNode sourceNode = NodeEditor.findNodePreOrder(root, NodeConstants.Types.SOURCE);
+ sourceNode.addFirstChild(child);
+ sourceNode.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(sourceNode.getGroups().iterator().next(), (List<SingleElementSymbol>)child.getFirstChild().getProperty(Info.PROJECT_COLS)));
+ //add a dummy access node
+ PlanNode accessNode = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
+ accessNode.addGroups(child.getFirstChild().getGroups());
+ child.getFirstChild().addAsParent(accessNode);
+
+ new RulePushSelectCriteria().execute(root, metadata, new DefaultCapabilitiesFinder(), new RuleStack(), AnalysisRecord.createNonRecordingRecord(), new CommandContext());
+ // the select node should still be above the access node
+ accessNode = NodeEditor.findNodePreOrder(root, NodeConstants.Types.ACCESS);
+ assertEquals(NodeConstants.Types.SELECT, accessNode.getParent().getType());
+ assertNull(NodeEditor.findNodePreOrder(accessNode, NodeConstants.Types.SELECT));
+ }
}
15 years, 7 months
teiid SVN: r924 - in trunk/engine/src: test/java/org/teiid/dqp/internal/process/multisource and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-05-12 21:45:00 -0400 (Tue, 12 May 2009)
New Revision: 924
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
Log:
TEIID-583 ensuring that the connectorbindingid is passed by the access node.
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java 2009-05-13 01:37:34 UTC (rev 923)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java 2009-05-13 01:45:00 UTC (rev 924)
@@ -103,7 +103,7 @@
isUpdate = RelationalNodeUtil.isUpdate(atomicCommand);
if(needProcessing) {
- this.tupleSource = getDataManager().registerRequest(this.getContext().getProcessorID(), atomicCommand, modelName, null, getID());
+ this.tupleSource = getDataManager().registerRequest(this.getContext().getProcessorID(), atomicCommand, modelName, connectorBindingId, getID());
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2009-05-13 01:37:34 UTC (rev 923)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2009-05-13 01:45:00 UTC (rev 924)
@@ -77,7 +77,9 @@
}
public TupleSource registerRequest(Object processorID, Command command, String modelName, String connectorBindingId, int nodeID) throws com.metamatrix.api.exception.MetaMatrixComponentException {
- Collection elements = ElementCollectorVisitor.getElements(command, true, true);
+ assertNotNull(connectorBindingId);
+
+ Collection elements = ElementCollectorVisitor.getElements(command, true, true);
for (Iterator i = elements.iterator(); i.hasNext();) {
ElementSymbol symbol = (ElementSymbol)i.next();
15 years, 7 months
teiid SVN: r923 - in trunk/engine/src: main/java/com/metamatrix/query/rewriter and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-05-12 21:37:34 -0400 (Tue, 12 May 2009)
New Revision: 923
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionMappingVisitor.java
trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java
Log:
TEIID-582 fixing the expression mapping visitor to prevent recursive mappings.
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java 2009-05-13 01:01:53 UTC (rev 922)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java 2009-05-13 01:37:34 UTC (rev 923)
@@ -55,7 +55,6 @@
import com.metamatrix.query.sql.lang.QueryCommand;
import com.metamatrix.query.sql.lang.Select;
import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
@@ -264,24 +263,14 @@
return expression;
}
- if(expression instanceof ElementSymbol) {
+ if(expression instanceof SingleElementSymbol) {
Expression mappedSymbol = (Expression) symbolMap.get(expression);
if (mappedSymbol != null) {
return mappedSymbol;
}
return expression;
}
-
- if(expression instanceof AggregateSymbol) {
- AggregateSymbol aggSymbol = (AggregateSymbol) expression;
-
- // First try to replace the entire aggregate
- SingleElementSymbol replacement = (SingleElementSymbol) symbolMap.get(aggSymbol);
- if(replacement != null) {
- return replacement;
- }
- }
-
+
ExpressionMappingVisitor.mapExpressions(expression, symbolMap);
return expression;
@@ -507,7 +496,7 @@
if (project != null) {
return (List<SingleElementSymbol>)project.getProperty(NodeConstants.Info.PROJECT_COLS);
}
- Assertion.failed("no top cols in frame");
+ Assertion.failed("no top cols in frame"); //$NON-NLS-1$
return null;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-05-13 01:01:53 UTC (rev 922)
+++ trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-05-13 01:37:34 UTC (rev 923)
@@ -751,14 +751,14 @@
for (SingleElementSymbol symbol : (List<SingleElementSymbol>)query.getSelect().getProjectedSymbols()) {
expressionMap.put((Expression)SymbolMap.getExpression(symbol).clone(), (SingleElementSymbol)iter.next());
}
- ExpressionMappingVisitor.mapExpressions(groupBy, expressionMap, true);
+ ExpressionMappingVisitor.mapExpressions(groupBy, expressionMap);
outerQuery.setGroupBy(groupBy);
- ExpressionMappingVisitor.mapExpressions(having, expressionMap, true);
+ ExpressionMappingVisitor.mapExpressions(having, expressionMap);
outerQuery.setHaving(having);
- ExpressionMappingVisitor.mapExpressions(orderBy, expressionMap, true);
+ ExpressionMappingVisitor.mapExpressions(orderBy, expressionMap);
outerQuery.setOrderBy(orderBy);
outerQuery.setLimit(limit);
- ExpressionMappingVisitor.mapExpressions(select, expressionMap, true);
+ ExpressionMappingVisitor.mapExpressions(select, expressionMap);
outerQuery.setSelect(select);
outerQuery.setInto(into);
outerQuery.setOption(query.getOption());
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionMappingVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionMappingVisitor.java 2009-05-13 01:01:53 UTC (rev 922)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionMappingVisitor.java 2009-05-13 01:37:34 UTC (rev 923)
@@ -24,9 +24,11 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.LanguageVisitor;
@@ -47,7 +49,6 @@
import com.metamatrix.query.sql.lang.StoredProcedure;
import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.navigator.PostOrderNavigator;
import com.metamatrix.query.sql.navigator.PreOrderNavigator;
import com.metamatrix.query.sql.proc.AssignmentStatement;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
@@ -74,7 +75,7 @@
public ExpressionMappingVisitor(Map symbolMap) {
this.symbolMap = symbolMap;
}
-
+
protected boolean createAliases() {
return true;
}
@@ -293,27 +294,25 @@
}
/**
- * Take a language object (currently only criteria and expressions will be
- * properly mapped) and use the map to swap out expressions with new expressions.
- * If an expression is not found in the map, it is not swapped. The object
- * is modified in place, so is not returned.
+ * The object is modified in place, so is not returned.
* @param obj Language object
* @param exprMap Expression map, Expression to Expression
*/
public static void mapExpressions(LanguageObject obj, Map exprMap) {
- mapExpressions(obj, exprMap, false);
- }
-
- public static void mapExpressions(LanguageObject obj, Map exprMap, boolean preOrder) {
if(obj == null || exprMap == null || exprMap.isEmpty()) {
return;
}
- ExpressionMappingVisitor visitor = new ExpressionMappingVisitor(exprMap);
- if (preOrder) {
- PreOrderNavigator.doVisit(obj, visitor);
- } else {
- PostOrderNavigator.doVisit(obj, visitor);
- }
+ final Set reverseSet = new HashSet(exprMap.values());
+ final ExpressionMappingVisitor visitor = new ExpressionMappingVisitor(exprMap);
+ PreOrderNavigator pon = new PreOrderNavigator(visitor) {
+ @Override
+ protected void visitNode(LanguageObject obj) {
+ if (!(obj instanceof Expression) || !reverseSet.contains(obj)) {
+ super.visitNode(obj);
+ }
+ }
+ };
+ obj.acceptVisitor(pon);
}
protected void setVariableValues(Map variableValues) {
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java 2009-05-13 01:01:53 UTC (rev 922)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java 2009-05-13 01:37:34 UTC (rev 923)
@@ -22,18 +22,23 @@
package com.metamatrix.query.sql.visitor;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
+import org.junit.Test;
+import org.teiid.connector.api.SourceSystemFunctions;
import com.metamatrix.query.sql.LanguageObject;
+import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.Select;
import com.metamatrix.query.sql.lang.SetCriteria;
+import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.CaseExpression;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -44,19 +49,15 @@
import com.metamatrix.query.sql.symbol.TestSearchedCaseExpression;
-public class TestExpressionMappingVisitor extends TestCase {
+public class TestExpressionMappingVisitor {
- public TestExpressionMappingVisitor(String arg0) {
- super(arg0);
- }
-
public void helpTest(LanguageObject original, Map map, LanguageObject expected) {
ExpressionMappingVisitor.mapExpressions(original, map);
assertEquals("Did not get expected mapped expression", expected, original); //$NON-NLS-1$
}
- public void testCompareCriteria1() {
+ @Test public void testCompareCriteria1() {
ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
Function f = new Function("+", new Expression[] { new Constant(new Integer(2)), new Constant(new Integer(5)) }); //$NON-NLS-1$
Map map = new HashMap();
@@ -66,7 +67,7 @@
helpTest(before, map, after);
}
- public void testCompareCriteria2() {
+ @Test public void testCompareCriteria2() {
ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
Function f = new Function("+", new Expression[] { new Constant(new Integer(2)), new Constant(new Integer(5)) }); //$NON-NLS-1$
Map map = new HashMap();
@@ -76,7 +77,7 @@
helpTest(before, map, after);
}
- public void testFunction1() {
+ @Test public void testFunction1() {
ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
ElementSymbol e2 = new ElementSymbol("e2"); //$NON-NLS-1$
ElementSymbol e3 = new ElementSymbol("e3"); //$NON-NLS-1$
@@ -100,7 +101,7 @@
helpTest(f3, map, f7);
}
- public void testSetCriteria() {
+ @Test public void testSetCriteria() {
ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
ElementSymbol e2 = new ElementSymbol("e2"); //$NON-NLS-1$
Constant c1 = new Constant("xyz"); //$NON-NLS-1$
@@ -122,7 +123,7 @@
helpTest(before, map, after);
}
- public void testCaseExpression1() {
+ @Test public void testCaseExpression1() {
ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$
ElementSymbol y = new ElementSymbol("y"); //$NON-NLS-1$
Constant a = new Constant(String.valueOf('a'));
@@ -145,7 +146,7 @@
helpTest(TestCaseExpression.example(3), map, mapped);
}
- public void testCaseExpression2() {
+ @Test public void testCaseExpression2() {
ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$
ElementSymbol y = new ElementSymbol("y"); //$NON-NLS-1$
@@ -168,7 +169,7 @@
/**
* We do not need to create an alias if the canonical short names match
*/
- public void testSelectAlias() {
+ @Test public void testSelectAlias() {
ElementSymbol x = new ElementSymbol("y.x"); //$NON-NLS-1$
ElementSymbol y = new ElementSymbol("z.X"); //$NON-NLS-1$
@@ -181,6 +182,26 @@
assertEquals("Did not get expected mapped expression", "SELECT z.X", toMap.toString()); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+ /**
+ * we are not careful about ensuring that that every symbol is
+ * unique in a plan, so there's a chance mapping the expression in an
+ * aggregate in a project node will cause the same symbol to be
+ * updated in a sort node. to ensure that we don't get into
+ * recursion trouble we detect if we're replacing an expression
+ * that already exists as a mapping.
+ *
+ * we simulate that situation here using the same aggregate twice in
+ * a function.
+ */
+ @Test public void testRecursionDetection() {
+ ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
+ AggregateSymbol a1 = new AggregateSymbol("x", ReservedWords.SUM, false, e1); //$NON-NLS-1$
+ Function f = new Function(SourceSystemFunctions.ADD_OP, new Expression[] {a1, a1});
+ HashMap<AggregateSymbol, AggregateSymbol> map = new HashMap<AggregateSymbol, AggregateSymbol>();
+ map.put(a1, new AggregateSymbol("x", ReservedWords.SUM, false, a1)); //$NON-NLS-1$
+ ExpressionMappingVisitor.mapExpressions(f, map);
+ assertEquals("(SUM(SUM(e1)) + SUM(SUM(e1)))", f.toString()); //$NON-NLS-1$
+ }
+
}
15 years, 7 months