Search in sources :

Example 1 with ITDQRepositoryService

use of org.talend.core.ITDQRepositoryService in project tdi-studio-se by Talend.

the class ExportRulesToRepository method widgetSelected.

public void widgetSelected(SelectionEvent e) {
    IElementParameter elementParameter = node.getElementParameter("RULE_TABLE");
    ArrayList<HashMap<String, Object>> value = (ArrayList<HashMap<String, Object>>) elementParameter.getValue();
    ;
    ITDQRepositoryService tdqRepService = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
        tdqRepService = (ITDQRepositoryService) GlobalServiceRegister.getDefault().getService(ITDQRepositoryService.class);
    }
    String elementName = node.getProcess().getName() + "_" + node.getNodeLabel().getElementName();
    tdqRepService.createParserRuleItem(value, elementName);
}
Also used : ITDQRepositoryService(org.talend.core.ITDQRepositoryService) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 2 with ITDQRepositoryService

use of org.talend.core.ITDQRepositoryService in project tdq-studio-se by Talend.

the class ConnectionsView method init.

@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
    super.init(site, memento);
    // MOD qiongli 2012-11-9 TDQ-6166,init the propertyFileMap when this view init and the map is empty.
    ITDQRepositoryService tdqRepService = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
        tdqRepService = (ITDQRepositoryService) GlobalServiceRegister.getDefault().getService(ITDQRepositoryService.class);
        if (tdqRepService != null) {
            tdqRepService.initAllConnectionsToSQLExplorer();
        }
    }
}
Also used : ITDQRepositoryService(org.talend.core.ITDQRepositoryService)

Example 3 with ITDQRepositoryService

use of org.talend.core.ITDQRepositoryService in project tdq-studio-se by Talend.

the class User method createNewConnection.

/**
 * Creates a new connection, MOD xqliu 2013-04-03 TDQ-7003
 *
 * @return
 * @throws ExplorerException
 * @throws SQLException
 */
protected synchronized SQLConnection createNewConnection() throws SQLException {
    SQLConnection connection = null;
    // need use DynamicClassLoader to deal with it
    if (databaseConnection != null && EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(databaseConnection.getDatabaseType())) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
            ITDQRepositoryService tdqRepService = (ITDQRepositoryService) GlobalServiceRegister.getDefault().getService(ITDQRepositoryService.class);
            if (tdqRepService != null) {
                IMetadataConnection mdConn = ConvertionHelper.convert(databaseConnection);
                Connection hiveConnection = tdqRepService.createHiveConnection(mdConn);
                if (hiveConnection != null) {
                    connection = new SQLConnection(this, hiveConnection, alias.getDriver(), "HiveConnection");
                }
            }
        }
    } else {
        connection = alias.getDriver().getConnection(this);
    }
    return connection;
}
Also used : ITDQRepositoryService(org.talend.core.ITDQRepositoryService) Connection(java.sql.Connection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection)

Example 4 with ITDQRepositoryService

use of org.talend.core.ITDQRepositoryService in project tdq-studio-se by Talend.

the class NewDatabaseStructureViewAction method setMetadataToUserAndUpdateDriver.

/**
 * set the MetadataConnection To User and Update Driver if needed.
 *
 * @param user
 */
protected void setMetadataToUserAndUpdateDriver(User user) {
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
        ITDQRepositoryService tdqRepService = (ITDQRepositoryService) GlobalServiceRegister.getDefault().getService(ITDQRepositoryService.class);
        if (tdqRepService != null) {
            Collection<Connection> allDataProviders = tdqRepService.getAllDataProviders();
            for (Connection connection : allDataProviders) {
                if (user.getAlias().getName().equals(connection.getName())) {
                    // set IMetadataConnection into the user, if the db type is hive, should use
                    // IMetadataConnection to create the hive connection
                    DatabaseConnection databaseConnection = SwitchHelpers.DATABASECONNECTION_SWITCH.doSwitch(connection);
                    if (databaseConnection != null) {
                        user.setDatabaseConnection(databaseConnection);
                        // if ManagedDriver class is not Loaded,check if it lack jars then update the
                        // realted jar.
                        SqlexplorerService.getInstance().updateDriverIfClassNotLoad(databaseConnection);
                    }
                    break;
                }
            }
        }
    }
}
Also used : ITDQRepositoryService(org.talend.core.ITDQRepositoryService) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection)

Example 5 with ITDQRepositoryService

use of org.talend.core.ITDQRepositoryService in project tdq-studio-se by Talend.

the class ColumnAnalysisSqlExecutor method executeQuery.

/**
 * DOC scorreia Comment method "executeQuery".
 *
 * @param indicator
 * @param connection
 * @param queryStmt
 * @return
 * @throws SQLException
 */
protected boolean executeQuery(final Indicator indicator, Connection connection, String queryStmt) throws SQLException {
    String cat = getCatalogOrSchemaName(indicator.getAnalyzedElement());
    if (log.isInfoEnabled()) {
        log.info(Messages.getString("ColumnAnalysisSqlExecutor.COMPUTINGINDICATOR", // $NON-NLS-1$
        AnalysisExecutorHelper.getIndicatorName(indicator)) + "\t" + // $NON-NLS-1$ //$NON-NLS-2$
        Messages.getString("ColumnAnalysisSqlExecutor.EXECUTINGQUERY", queryStmt));
    }
    // give result to indicator so that it handles the results
    boolean ret = false;
    // MOD qiongli 2012-3-7 TDQ-4632 delete some redundancy code for DistinctIndicator.modify directly the sql
    // expression in definition file.
    List<Object[]> myResultSet = executeQuery(cat, connection, queryStmt);
    if (!continueRun()) {
        return false;
    }
    ret = indicator.storeSqlResults(myResultSet);
    // Added TDQ-8787 publish the related event when one indicator is finished: to refresh the chart with new result
    // of the current indicator
    final ITDQRepositoryService tdqRepositoryService = AnalysisExecutorHelper.getTDQService();
    if (tdqRepositoryService != null) {
        Display.getDefault().asyncExec(new Runnable() {

            public void run() {
                tdqRepositoryService.publishDynamicEvent(indicator, IndicatorCommonUtil.getIndicatorValue(indicator));
            }
        });
    }
    // MOD delete the try/catch TDQ-8388
    return ret;
}
Also used : ITDQRepositoryService(org.talend.core.ITDQRepositoryService)

Aggregations

ITDQRepositoryService (org.talend.core.ITDQRepositoryService)9 ArrayList (java.util.ArrayList)2 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)2 Connection (java.sql.Connection)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Alias (net.sourceforge.sqlexplorer.dbproduct.Alias)1 User (net.sourceforge.sqlexplorer.dbproduct.User)1 DatabaseNode (net.sourceforge.sqlexplorer.dbstructure.nodes.DatabaseNode)1 INode (net.sourceforge.sqlexplorer.dbstructure.nodes.INode)1 SchemaNode (net.sourceforge.sqlexplorer.dbstructure.nodes.SchemaNode)1 TableFolderNode (net.sourceforge.sqlexplorer.dbstructure.nodes.TableFolderNode)1 OpenPasswordConnectDialogAction (net.sourceforge.sqlexplorer.plugin.actions.OpenPasswordConnectDialogAction)1 SQLExplorerPluginPerspective (net.sourceforge.sqlexplorer.plugin.perspectives.SQLExplorerPluginPerspective)1 DatabaseStructureView (net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1