Skip to content

Commit

Permalink
Merge pull request #118 from mdrillin/TEIIDDES-226
Browse files Browse the repository at this point in the history
TEIIDDES-226 Enables import of Oracle synonyms
  • Loading branch information
blafond committed Mar 27, 2013
2 parents dc841e3 + d0128f5 commit 4c0b78f
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.eclipse.datatools.connectivity.drivers.DriverInstance;
import org.eclipse.datatools.connectivity.drivers.DriverManager;
import org.teiid.core.designer.util.CoreArgCheck;
import org.teiid.core.designer.util.CoreStringUtil;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.jdbc.impl.JdbcFactoryImpl;

Expand Down Expand Up @@ -77,6 +78,10 @@ public class JdbcManagerImpl implements JdbcManager {
public static final int AVAILABLE_CLASSES_WITH_ERRORS = 1103;
public static final int AVAILABLE_CLASSES_WITH_WARNINGS_AND_ERRORS = 1104;

private final static String DATATOOLS_ORACLE_CP = "org.eclipse.datatools.enablement.oracle.connectionProfile"; //$NON-NLS-1$
private final static String DATATOOLS_CONNECTION_PROPS_KEY = "org.eclipse.datatools.connectivity.db.connectionProperties"; //$NON-NLS-1$
private final static String ORACLE_INCLUDE_SYNONYMS_PROP = "includeSynonyms"; //$NON-NLS-1$

/**
* @since 5.0
*/
Expand Down Expand Up @@ -169,6 +174,26 @@ public Connection createConnection( final JdbcSource jdbcSource,
final String factoryId = profile.getProvider().getConnectionFactory("java.sql.Connection").getId(); //$NON-NLS-1$
// override the pw in the ConnectionProfile with one supplied in the importer.
// IConnection connection = profile.createConnection(factoryId, jdbcSource.getUsername(), password);

// ------------------------------------------------
// For Oracle db, ensure that includeSynonyms=true
// ------------------------------------------------
String providerId = profile.getProviderId();
if(providerId!=null && providerId.equalsIgnoreCase(DATATOOLS_ORACLE_CP)) {
Properties baseProps = profile.getBaseProperties();
String connectionProps = baseProps.getProperty(DATATOOLS_CONNECTION_PROPS_KEY);
// No connection properties - set new 'includeSynonyms=true'
if(CoreStringUtil.isEmpty(connectionProps)) {
baseProps.setProperty(DATATOOLS_CONNECTION_PROPS_KEY, ORACLE_INCLUDE_SYNONYMS_PROP+"=true"); //$NON-NLS-1$
profile.setBaseProperties(baseProps);
// Has connection properties - append 'includeSynonyms=true' if not found
} else if(connectionProps.indexOf(ORACLE_INCLUDE_SYNONYMS_PROP)==-1) {
connectionProps = connectionProps+","+ORACLE_INCLUDE_SYNONYMS_PROP+"=true"; //$NON-NLS-1$ //$NON-NLS-2$
baseProps.setProperty(DATATOOLS_CONNECTION_PROPS_KEY, connectionProps);
profile.setBaseProperties(baseProps);
}
}

final IConnection connection = profile.createConnection(factoryId);

final Connection sqlConnection = (Connection)connection.getRawConnection();
Expand Down

0 comments on commit 4c0b78f

Please sign in to comment.