Skip to content

Commit

Permalink
Backport BIRT-711
Browse files Browse the repository at this point in the history
Signed-off-by: xinzhao-acutate <xzhao@actuate.com>
  • Loading branch information
xinzhao-actuate authored and greatyan committed Sep 21, 2015
1 parent eeb5543 commit 1047294
Showing 1 changed file with 55 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*******************************************************************************
* Copyright (c) 2008, 2011 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Actuate Corporation - initial API and implementation
*******************************************************************************/
* Copyright (c) 2008, 2011 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Actuate Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.birt.report.data.oda.jdbc.dbprofile.ui.internal.sqb;

import java.lang.reflect.InvocationTargetException;
Expand All @@ -18,8 +18,12 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.internal.ConnectionProfile;
import org.eclipse.datatools.connectivity.internal.ManagedConnection;
import org.eclipse.datatools.connectivity.internal.ui.dialogs.ExceptionHandler;
import org.eclipse.datatools.connectivity.oda.IConnection;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.datatools.connectivity.oda.consumer.helper.OdaConnection;
import org.eclipse.datatools.connectivity.oda.design.DataSetDesign;
import org.eclipse.datatools.connectivity.oda.design.DesignFactory;
import org.eclipse.datatools.connectivity.oda.design.DesignerState;
Expand Down Expand Up @@ -55,32 +59,50 @@

public class SQBDataSetWizardPage extends DataSetWizardPage
{
private static final String NEWLINE_CHAR = "\n"; //$NON-NLS-1$
private static final String EMPTY_STR = ""; //$NON-NLS-1$
private static final String DEFAULT_MESSAGE = Messages.sqbWizPage_defaultMessage;
private static final String NEWLINE_CHAR = "\n"; //$NON-NLS-1$
private static final String EMPTY_STR = ""; //$NON-NLS-1$
private static final String DEFAULT_MESSAGE = Messages.sqbWizPage_defaultMessage;

private IConnectionProfile m_dataSourceProfile;
private CustomSQLBuilderDialog m_sqbDialog;
private boolean m_updatedQueryInput = false;
private SortSpecification m_initQuerySortSpec;

private IConnectionProfile m_dataSourceProfile;
private CustomSQLBuilderDialog m_sqbDialog;
private boolean m_updatedQueryInput = false;
private SortSpecification m_initQuerySortSpec;

public SQBDataSetWizardPage( String pageName )
{
super( pageName );
setMessage( DEFAULT_MESSAGE, IMessageProvider.NONE );
}
public SQBDataSetWizardPage( String pageName )
{
super( pageName );
setMessage( DEFAULT_MESSAGE, IMessageProvider.NONE );
}

private IConnectionProfile getConnectionProfile( boolean raiseErrorIfNull, boolean refreshProfileStore )
{
if( m_dataSourceProfile == null )
{
if( refreshProfileStore )
OdaProfileExplorer.getInstance().refresh();

java.util.Properties connProps = DesignUtil.convertDataSourceProperties(
getEditingDesign().getDataSourceDesign() );
m_dataSourceProfile = loadConnectionProfile( connProps,
getEditingDesign().getDataSourceDesign().getHostResourceIdentifiers() );
private IConnectionProfile getConnectionProfile( boolean raiseErrorIfNull, boolean refreshProfileStore )
{
if( m_dataSourceProfile == null )
{
if( refreshProfileStore )
OdaProfileExplorer.getInstance().refresh();

java.util.Properties connProps = DesignUtil.convertDataSourceProperties(
getEditingDesign().getDataSourceDesign() );
m_dataSourceProfile = loadConnectionProfile( connProps,
getEditingDesign().getDataSourceDesign().getHostResourceIdentifiers() );

// If we have ManagedConnection whose key is IConnection, that means it is a ConnectionProfile to
// ConnectionProfile repository, rather than the wanted one to a database,
// so try to get the wanted profile inside.
ManagedConnection mc = (ManagedConnection) m_dataSourceProfile
.getManagedConnection( IConnection.class.getName( ) );
if ( mc != null )
{
try
{
m_dataSourceProfile = Connection.loadProfileFromProperties( mc
.getConnectionProfile( ).getBaseProperties( ) );
}
catch ( OdaException e )
{
}
}

if( m_dataSourceProfile == null && raiseErrorIfNull )
MessageDialog.openError( getShell(), Messages.sqbWizPage_dataSourceDesignError,
Messages.sqbWizPage_noConnProfileMsg );
Expand Down

0 comments on commit 1047294

Please sign in to comment.