Search in sources :

Example 1 with DBSchemaRepNode

use of org.talend.dq.nodes.DBSchemaRepNode in project tdq-studio-se by Talend.

the class AbstractCommonActionProviderRealProjectTest method testGetConnectionCase5.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.ui.action.provider.AbstractCommonActionProvider#getConnection(java.lang.Object)}
 * . case5 :input parameter is DBSchemaRepNode
 */
@Test
public void testGetConnectionCase5() {
    // create FileConnection
    // connection
    IRepositoryViewObject lastVersion = null;
    String propertyID = createConnectionItem(connectionName, null, null);
    // $NON-NLS-1$
    Schema createSchema = createSchema("Schema1");
    try {
        lastVersion = factory.getLastVersion(propertyID);
        lastVersion = new MetadataSchemaRepositoryObject(lastVersion, createSchema);
    } catch (PersistenceException e) {
        log.error(e, e);
        Assert.fail(e.getMessage());
    }
    // ~connection data
    // ~FileConnection
    // create DFColumnFolderRepNode
    Assert.assertFalse(lastVersion == null);
    DBSchemaRepNode dbSchemaRepNode = new DBSchemaRepNode(lastVersion, null, null, null);
    // ~DFColumnFolderRepNode
    AbstractCommonActionProvider provider = new AbstractCommonActionProvider();
    Connection connection = provider.getConnection(dbSchemaRepNode);
    Assert.assertTrue(connection != null);
}
Also used : DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) Schema(orgomg.cwm.resource.relational.Schema) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) MetadataSchemaRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataSchemaRepositoryObject) Test(org.junit.Test)

Example 2 with DBSchemaRepNode

use of org.talend.dq.nodes.DBSchemaRepNode in project tdq-studio-se by Talend.

the class RepNodeUtilsTest method testIsValidSelectionForMatchAnalysis.

/**
 * Test: 1) when the selected node is: connection, catalog,schema, folder, will not be valid; 2) when the selected
 * nodes are: multiple table/views, multiple columns from different table/view, will not be valid; 3) when the
 * selected node is: one single table/view/file table,will be valid; 4) when the selected nodes are: multiple
 * columns from one same table/view, will be valid.
 */
@Test
public void testIsValidSelectionForMatchAnalysis() {
    // 1) when the selected node is: connection, catalog,schema, folder, will not be valid;
    List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
    ConnectionRepNode cNode = mock(ConnectionRepNode.class);
    nodes.add(cNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBConnectionRepNode dbNode = mock(DBConnectionRepNode.class);
    nodes.clear();
    nodes.add(dbNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBConnectionFolderRepNode dbfNode = mock(DBConnectionFolderRepNode.class);
    nodes.clear();
    nodes.add(dbfNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DQDBFolderRepositoryNode folderNode = mock(DQDBFolderRepositoryNode.class);
    nodes.clear();
    nodes.add(folderNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBCatalogRepNode catalogNode = mock(DBCatalogRepNode.class);
    nodes.clear();
    nodes.add(catalogNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBSchemaRepNode schemaNode = mock(DBSchemaRepNode.class);
    nodes.clear();
    nodes.add(schemaNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) ConnectionRepNode(org.talend.dq.nodes.ConnectionRepNode) DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ArrayList(java.util.ArrayList) DQDBFolderRepositoryNode(org.talend.dq.nodes.DQDBFolderRepositoryNode) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with DBSchemaRepNode

use of org.talend.dq.nodes.DBSchemaRepNode in project tdq-studio-se by Talend.

the class SelectedCompareUIProvider method fillContextMenu.

@Override
public void fillContextMenu(IMenuManager menu) {
    // TDQ-9394 hide all "Reload" menu.
    if (!isShowMenu()) {
        return;
    }
    if (isShowMenu()) {
        return;
    }
    Iterator<?> iter = ((TreeSelection) this.getContext().getSelection()).iterator();
    while (iter.hasNext()) {
        Object obj = iter.next();
        if (!(obj instanceof RepositoryNode)) {
            return;
        }
    }
    TreeSelection treeSelection = (TreeSelection) getContext().getSelection();
    if (treeSelection == null) {
        return;
    }
    Object firstElement = treeSelection.getFirstElement();
    RepositoryNode rNode = (RepositoryNode) firstElement;
    IFolder folder = WorkbenchUtils.getFolder(rNode);
    IFolder metadataFolder = ResourceManager.getMetadataFolder();
    if (!folder.getFullPath().toOSString().startsWith(metadataFolder.getFullPath().toOSString())) {
        return;
    }
    Object[] selectedObj = treeSelection.toArray();
    if (selectedObj.length < 2) {
        return;
    }
    List<Object> objects = new ArrayList<Object>();
    for (Object obj : selectedObj) {
        Connection conn = getConnection(obj);
        if (!MetadataConnectionUtils.isTDQSupportDBTemplate(conn)) {
            return;
        }
        RepositoryNode node = (RepositoryNode) obj;
        if (node instanceof DBConnectionRepNode) {
            Property property = ((DBConnectionRepNode) node).getObject().getProperty();
            DatabaseConnectionItem databaseConnectionItem = (DatabaseConnectionItem) property.getItem();
            Connection databaseConnection = databaseConnectionItem.getConnection();
            objects.add(databaseConnection);
        } else if (node instanceof DBCatalogRepNode) {
            Catalog catalog = ((DBCatalogRepNode) node).getCatalog();
            objects.add(catalog);
        } else if (node instanceof DBSchemaRepNode) {
            Schema schema = ((DBSchemaRepNode) node).getSchema();
            objects.add(schema);
        } else if (node instanceof DBTableRepNode) {
            TdTable tdTable = ((DBTableRepNode) node).getTdTable();
            objects.add(tdTable);
        } else if (node instanceof DBColumnRepNode) {
            TdColumn tdColumn = ((DBColumnRepNode) node).getTdColumn();
            objects.add(tdColumn);
        }
    }
    // MOD yyi 2011-03-22 17871:hide compare action for flat file column
    if (2 == objects.size()) {
        selectionCompareAction.refreshSelectedObj(objects.get(0), objects.get(1));
        menu.add(selectionCompareAction);
    }
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) TdTable(org.talend.cwm.relational.TdTable) Schema(orgomg.cwm.resource.relational.Schema) ArrayList(java.util.ArrayList) Connection(org.talend.core.model.metadata.builder.connection.Connection) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) Catalog(orgomg.cwm.resource.relational.Catalog) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) TdColumn(org.talend.cwm.relational.TdColumn) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Property(org.talend.core.model.properties.Property) IFolder(org.eclipse.core.resources.IFolder)

Example 4 with DBSchemaRepNode

use of org.talend.dq.nodes.DBSchemaRepNode in project tdq-studio-se by Talend.

the class SchemaAnalysisWizard method initCWMResourceBuilder.

@Override
public ModelElement initCWMResourceBuilder() {
    Analysis analysis = (Analysis) super.initCWMResourceBuilder();
    if (getAnalysisBuilder() != null) {
        // MOD klliu 15750 2011-1-05 add the repnode on parameter
        PackagesAnalyisParameter packageParameter = getParameter();
        IRepositoryNode connectionRepNode = getParameter().getConnectionRepNode();
        ConnectionItem item = (ConnectionItem) connectionRepNode.getObject().getProperty().getItem();
        Connection tdProvider = item.getConnection();
        // Connection tdProvider = packageParameter.getTdDataProvider();
        getAnalysisBuilder().setAnalysisConnection(tdProvider);
        Indicator[] indicators = new Indicator[packageParameter.getPackages().size()];
        ModelElement[] modelElement = new ModelElement[packageParameter.getPackages().size()];
        int i = 0;
        for (IRepositoryNode node : packageParameter.getPackages()) {
            SchemaIndicator createSchemaIndicator = SchemaFactory.eINSTANCE.createSchemaIndicator();
            DBSchemaRepNode catalogNode = (DBSchemaRepNode) node;
            Schema schema = ((MetadataSchemaRepositoryObject) catalogNode.getObject()).getSchema();
            modelElement[i] = schema;
            DefinitionHandler.getInstance().setDefaultIndicatorDefinition(createSchemaIndicator);
            createSchemaIndicator.setAnalyzedElement(schema);
            indicators[i] = createSchemaIndicator;
            i++;
        }
        getAnalysisBuilder().addElementsToAnalyze(modelElement, indicators);
    }
    return analysis;
}
Also used : SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Schema(orgomg.cwm.resource.relational.Schema) Connection(org.talend.core.model.metadata.builder.connection.Connection) SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) Indicator(org.talend.dataquality.indicators.Indicator) MetadataSchemaRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataSchemaRepositoryObject) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) PackagesAnalyisParameter(org.talend.dq.analysis.parameters.PackagesAnalyisParameter) Analysis(org.talend.dataquality.analysis.Analysis)

Example 5 with DBSchemaRepNode

use of org.talend.dq.nodes.DBSchemaRepNode in project tdq-studio-se by Talend.

the class TableAnalysisDPSelectionPage method addListeners.

@Override
protected void addListeners() {
    addListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (object instanceof NamedColumnSet) {
                advanceToNextPageOrFinish();
            }
        }
    });
    addListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            // Connection oldTdDataProvider = null;
            NamedColumnSetAnalysisParameter paraneter = (NamedColumnSetAnalysisParameter) getConnectionParams();
            List tempList = ((IStructuredSelection) event.getSelection()).toList();
            List<NamedColumnSet> setList = new ArrayList<NamedColumnSet>();
            for (Object object : tempList) {
                if (object instanceof DBTableRepNode) {
                    DBTableRepNode tableNode = (DBTableRepNode) object;
                    // MOD klliu if table node is not initialized , then init that . bug 20097 2011-03-31
                    if (!tableNode.isInitialized()) {
                        tableNode.getChildren().get(0).getChildren();
                    }
                    // ~
                    setList.add(tableNode.getTdTable());
                }
            // if (object instanceof NamedColumnSet) {
            // NamedColumnSet set = (NamedColumnSet) object;
            // Connection tdProvider = ConnectionHelper.getTdDataProvider(TableHelper
            // .getParentCatalogOrSchema(set));
            // oldTdDataProvider = oldTdDataProvider == null ? tdProvider : oldTdDataProvider;
            // if (oldTdDataProvider != null && !oldTdDataProvider.equals(tdProvider)) {
            // MessageUI.openWarning(DefaultMessagesImpl
            // .getString("TableAnalysisDPSelectionPage.TableSelectWarning")); //$NON-NLS-1$
            // } else if (tdProvider != null && paraneter != null) {
            // setList.add(set);
            // paraneter.setTdDataProvider(oldTdDataProvider);
            // }
            // }
            }
            if (setList.size() > 0 && paraneter != null) {
                paraneter.setNamedColumnSets(setList.toArray(new NamedColumnSet[setList.size()]));
                DBTableRepNode recursiveFind = (DBTableRepNode) RepositoryNodeHelper.recursiveFind((TdTable) setList.get(0));
                RepositoryNode parent = recursiveFind.getParent().getParent();
                // MOD qiongli 2011-3-16 bug 19475
                RepositoryNode catalogNode = parent;
                if (parent instanceof DBCatalogRepNode) {
                    parent = parent.getParent();
                } else if (parent instanceof DBSchemaRepNode) {
                    parent = parent.getParent();
                    if (parent instanceof DBCatalogRepNode) {
                        catalogNode = parent;
                        parent = parent.getParent();
                    }
                }
                // TdTableRepositoryObject tableViewObject = (TdTableRepositoryObject) recursiveFind.getObject();
                // IRepositoryViewObject viewObject = parent.getObject();
                DBConnectionRepNode connNode = (DBConnectionRepNode) parent;
                paraneter.setConnectionRepNode(connNode);
                Connection connection = ConnectionHelper.getConnection((TdTable) setList.get(0));
                paraneter.setTdDataProvider(connection);
                List<IRepositoryNode> packagesNode = new ArrayList<IRepositoryNode>();
                packagesNode.add(catalogNode);
                paraneter.setPackages(packagesNode);
                setPageComplete(true);
            } else {
                setPageComplete(false);
            }
        }
    });
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) TdTable(org.talend.cwm.relational.TdTable) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Connection(org.talend.core.model.metadata.builder.connection.Connection) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) NamedColumnSetAnalysisParameter(org.talend.dq.analysis.parameters.NamedColumnSetAnalysisParameter) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayList(java.util.ArrayList) List(java.util.List) NamedColumnSet(orgomg.cwm.resource.relational.NamedColumnSet)

Aggregations

DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)15 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)13 IRepositoryNode (org.talend.repository.model.IRepositoryNode)9 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)8 ArrayList (java.util.ArrayList)6 Connection (org.talend.core.model.metadata.builder.connection.Connection)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)6 RepositoryNode (org.talend.repository.model.RepositoryNode)6 Schema (orgomg.cwm.resource.relational.Schema)5 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)4 PackagesAnalyisParameter (org.talend.dq.analysis.parameters.PackagesAnalyisParameter)4 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)4 List (java.util.List)3 ConnectionItem (org.talend.core.model.properties.ConnectionItem)3 ExchangeCategoryRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode)3 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)3 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)3 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)2 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)2