Search in sources :

Example 1 with DBColumnFolderRepNode

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

the class AbstractCommonActionProviderRealProjectTest method testGetConnectionCase8.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.ui.action.provider.AbstractCommonActionProvider#getConnection(java.lang.Object)}
 * . case8 :input parameter is DBColumnFolderRepNode
 */
@Test
public void testGetConnectionCase8() {
    // create FileConnection
    // connection
    IRepositoryViewObject lastVersion = null;
    String propertyID = createConnectionItem(connectionName, null, null);
    TdTable createTdTable = RelationalFactoryImpl.eINSTANCE.createTdTable();
    RepositoryNode dbCatalogRepNode = null;
    // $NON-NLS-1$
    createTdTable.setName("table1");
    try {
        lastVersion = factory.getLastVersion(propertyID);
        dbCatalogRepNode = DQRepNodeCreateFactory.createDBCatalogRepNode(lastVersion, null, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
        lastVersion = new TdTableRepositoryObject(lastVersion, createTdTable);
    } catch (PersistenceException e) {
        log.error(e, e);
        Assert.fail(e.getMessage());
    }
    // ~connection data
    // ~FileConnection
    // create DFColumnFolderRepNode
    Assert.assertFalse(lastVersion == null);
    DBTableRepNode dbTableRepNode = new DBTableRepNode(lastVersion, dbCatalogRepNode, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
    DBColumnFolderRepNode dbColumnFolderRepNode = new DBColumnFolderRepNode(null, dbTableRepNode, null, null);
    // ~DFColumnFolderRepNode
    AbstractCommonActionProvider provider = new AbstractCommonActionProvider();
    Connection connection = provider.getConnection(dbColumnFolderRepNode);
    Assert.assertTrue(connection != null);
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) TdTable(org.talend.cwm.relational.TdTable) 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) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) RepositoryNode(org.talend.repository.model.RepositoryNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) Test(org.junit.Test)

Example 2 with DBColumnFolderRepNode

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

the class ResourceViewContentProvider method getRepositoryNodeChildren.

/**
 * DOC talend Comment method "getRepositoryNodeChildren".
 *
 * @param element
 * @param instance
 * @return
 * @throws PersistenceException
 * @throws CoreException
 */
private Object[] getRepositoryNodeChildren(Object element) throws PersistenceException, CoreException {
    final DQRepositoryNode node = (DQRepositoryNode) element;
    // MOD gdbu 2011-7-20 bug : 23220
    DQRepositoryNode.setIsReturnAllNodesWhenFiltering(false);
    List<IRepositoryNode> children = node.getChildren();
    DQRepositoryNode.setIsReturnAllNodesWhenFiltering(true);
    if ((node instanceof DBTableFolderRepNode || node instanceof DBViewFolderRepNode || node instanceof DBColumnFolderRepNode) && !DQRepositoryNode.isOnFilterring()) {
        if (0 < children.size()) {
            try {
                StructuredSelection structSel = new StructuredSelection(node);
                if (null != treeViewer) {
                    ISelection tempSelection = treeViewer.getSelection();
                    treeViewer.setSelection(structSel);
                    TreeItem[] selectionItems = treeViewer.getTree().getSelection();
                    if (0 != selectionItems.length) {
                        selectionItems[0].setText(node.getLabel());
                        treeViewer.setSelection(tempSelection);
                    }
                } else {
                    ISelection dqTreeSelection = RepositoryNodeHelper.getDQCommonViewer().getSelection();
                    RepositoryNodeHelper.getDQCommonViewer().setSelection(structSel);
                    TreeItem[] selections = RepositoryNodeHelper.getDQCommonViewer().getTree().getSelection();
                    if (0 != selections.length) {
                        selections[0].setText(node.getLabel());
                    }
                    RepositoryNodeHelper.getDQCommonViewer().setSelection(dqTreeSelection);
                }
            } catch (Exception e) {
                log.error(e.toString());
            }
        }
    }
    if (children.size() <= 0) {
        // ~23220
        List<EResourceConstant> resContants = new ArrayList<EResourceConstant>();
        IRepositoryViewObject viewObject = node.getObject();
        String label = viewObject == null ? null : viewObject.getLabel();
        if (EResourceConstant.DATA_PROFILING.getName().equals(label)) {
            resContants.add(EResourceConstant.ANALYSIS);
            if (PluginChecker.isTDQLoaded()) {
                resContants.add(EResourceConstant.REPORTS);
            }
        } else if (EResourceConstant.LIBRARIES.getName().equals(label)) {
            // MOD TDQ-10933 msjian 20150915: Hide the Exchange node
            if (!TalendPropertiesUtil.isHideExchange()) {
                resContants.add(EResourceConstant.EXCHANGE);
            }
            // TDQ-10933~
            resContants.add(EResourceConstant.INDICATORS);
            if (PluginChecker.isTDQLoaded()) {
                resContants.add(EResourceConstant.JRXML_TEMPLATE);
            }
            resContants.add(EResourceConstant.PATTERNS);
            resContants.add(EResourceConstant.RULES);
            resContants.add(EResourceConstant.SOURCE_FILES);
        } else if (EResourceConstant.METADATA.getName().equals(label)) {
            resContants.add(EResourceConstant.DB_CONNECTIONS);
            resContants.add(EResourceConstant.FILEDELIMITED);
            if (PluginChecker.isTDQLoaded() && HadoopClusterUtils.getDefault().isServiceInstalled()) {
                resContants.add(EResourceConstant.HADOOP_CLUSTER);
            }
        }
        if (resContants.size() > 0) {
            RepositoryNodeBuilder.getInstance().createRepositoryNodeSystemFolders(node, resContants, node.getProject());
        }
    } else {
        // to avoid can not get reference project nodes when open the select udi/pattern/rule dialog
        if (EResourceConstant.REFERENCED_PROJECT.getName().equals(node.getProperties(EProperties.LABEL))) {
            if (!ProxyRepositoryManager.getInstance().isMergeRefProject()) {
                for (IRepositoryNode refProjectNode : node.getChildren()) {
                    for (IRepositoryNode refProjectItemNode : refProjectNode.getChildren()) {
                        getRepositoryNodeChildren(refProjectItemNode);
                    }
                }
            }
        }
    }
    if (node instanceof ContextFolderRepNode) {
        children = ((ContextFolderRepNode) node).getChildren();
    }
    return sortRepositoryNode(children.toArray());
}
Also used : DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) EResourceConstant(org.talend.resource.EResourceConstant) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreeItem(org.eclipse.swt.widgets.TreeItem) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) DBViewFolderRepNode(org.talend.dq.nodes.DBViewFolderRepNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) CoreException(org.eclipse.core.runtime.CoreException) MissingDriverException(org.talend.utils.exceptions.MissingDriverException) PersistenceException(org.talend.commons.exception.PersistenceException) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) ISelection(org.eclipse.jface.viewers.ISelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ContextFolderRepNode(org.talend.dq.nodes.ContextFolderRepNode)

Example 3 with DBColumnFolderRepNode

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

the class TableViewComparisonLevel method compareWithReloadObject.

@Override
protected boolean compareWithReloadObject() throws ReloadCompareException {
    // remove the jrxml from the ResourceSet before doMatch
    Map<ResourceSet, List<Resource>> rsJrxmlMap = removeJrxmlsFromResourceSet();
    DBColumnFolderRepNode columnFolderRepNode = (DBColumnFolderRepNode) selectedObj;
    // Compare the two models
    EMFCompare comparator = createDefaultEMFCompare();
    IComparisonScope scope = new DefaultComparisonScope(columnFolderRepNode.getColumnSet(), getSavedReloadObject(), null);
    Comparison compare = comparator.compare(scope);
    // add the jrxml into the ResourceSet after doMatch
    addJrxmlsIntoResourceSet(rsJrxmlMap);
    EList<Diff> differences = compare.getDifferences();
    for (Diff diff : differences) {
        // ignore the move Kind
        if (diff.getKind() == DifferenceKind.MOVE) {
            continue;
        }
        // copy right to left
        copyRightToLeft(diff);
    }
    return true;
}
Also used : DefaultComparisonScope(org.eclipse.emf.compare.scope.DefaultComparisonScope) EMFCompare(org.eclipse.emf.compare.EMFCompare) Comparison(org.eclipse.emf.compare.Comparison) Diff(org.eclipse.emf.compare.Diff) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IComparisonScope(org.eclipse.emf.compare.scope.IComparisonScope) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode)

Example 4 with DBColumnFolderRepNode

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

the class TableViewComparisonLevel method getLeftResource.

@Override
protected Resource getLeftResource() throws ReloadCompareException {
    ColumnSet selectedColumnSet = null;
    if (selectedObj instanceof DBColumnFolderRepNode) {
        DBColumnFolderRepNode columnFolderRepNode = (DBColumnFolderRepNode) selectedObj;
        selectedColumnSet = columnFolderRepNode.getColumnSet();
    } else if (selectedObj instanceof RepositoryNode) {
        selectedColumnSet = (ColumnSet) RepositoryNodeHelper.getMetadataElement((RepositoryNode) selectedObj);
    } else {
        selectedColumnSet = (ColumnSet) selectedObj;
    }
    ColumnSet findMatchedColumnSet = DQStructureComparer.findMatchedColumnSet(selectedColumnSet, copyedDataProvider);
    List<TdColumn> columnList = new ArrayList<TdColumn>();
    columnList.addAll(ColumnSetHelper.getColumns(findMatchedColumnSet));
    Resource leftResource = copyedDataProvider.eResource();
    leftResource.getContents().clear();
    for (TdColumn column : columnList) {
        DQStructureComparer.clearSubNode(column);
        leftResource.getContents().add(column);
    }
    EMFSharedResources.getInstance().saveResource(leftResource);
    return upperCaseResource(leftResource);
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) ArrayList(java.util.ArrayList) Resource(org.eclipse.emf.ecore.resource.Resource) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) RepositoryNode(org.talend.repository.model.RepositoryNode) DQDBFolderRepositoryNode(org.talend.dq.nodes.DQDBFolderRepositoryNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode)

Example 5 with DBColumnFolderRepNode

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

the class ImageLib method getImageNameByRepositoryNode.

public static String getImageNameByRepositoryNode(IRepositoryNode node) {
    String imageName = null;
    IRepositoryViewObject viewObject = node.getObject();
    ENodeType type = node.getType();
    if (node instanceof ReportAnalysisRepNode) {
        imageName = ImageLib.ANALYSIS_OBJECT;
    } else if (node instanceof RecycleBinRepNode) {
        imageName = ImageLib.RECYCLEBIN_EMPTY;
    } else if (type.equals(ENodeType.SYSTEM_FOLDER)) {
        String label = viewObject.getLabel();
        if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
            imageName = ImageLib.DATA_PROFILING;
        } else if (label.equals(EResourceConstant.METADATA.getName())) {
            imageName = ImageLib.METADATA;
        } else if (node instanceof DBConnectionFolderRepNode) {
            imageName = ImageLib.CONNECTION;
        } else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
            imageName = ImageLib.FILE_DELIMITED;
        } else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
            imageName = ImageLib.HADOOP_CLUSTER;
        } else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
            imageName = ImageLib.LIBRARIES;
        } else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
            imageName = ImageLib.EXCHANGE;
        } else {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        }
    } else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
        imageName = ImageLib.FOLDERNODE_IMAGE;
    } else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
        if (node instanceof DBConnectionRepNode) {
            imageName = ImageLib.TD_DATAPROVIDER;
        } else if (node instanceof DFConnectionRepNode) {
            imageName = ImageLib.FILE_DELIMITED;
        } else if (node instanceof AnalysisRepNode) {
            imageName = ImageLib.ANALYSIS_OBJECT;
        } else if (node instanceof ReportRepNode) {
            imageName = ImageLib.REPORT_OBJECT;
        } else if (node instanceof SysIndicatorDefinitionRepNode) {
            imageName = ImageLib.IND_DEFINITION;
        } else if (node instanceof PatternRepNode) {
            imageName = ImageLib.PATTERN_REG;
        } else if (node instanceof RuleRepNode) {
            imageName = ImageLib.DQ_RULE;
        } else if (node instanceof SourceFileRepNode) {
            imageName = ImageLib.SOURCE_FILE;
        } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
            imageName = ImageLib.EXCHANGE;
        } else if (node instanceof JrxmlTempleteRepNode) {
            imageName = ImageLib.JRXML_ICON;
        }
    } else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
        if (node instanceof DBCatalogRepNode) {
            imageName = ImageLib.CATALOG;
        } else if (node instanceof DBSchemaRepNode) {
            imageName = ImageLib.SCHEMA;
        } else if (node instanceof DBTableFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        } else if (node instanceof DBViewFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        } else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
            imageName = ImageLib.TABLE;
        } else if (node instanceof DBViewRepNode) {
            imageName = ImageLib.VIEW;
        } else if (node instanceof DBColumnRepNode) {
            if (((DBColumnRepNode) node).isKey()) {
                imageName = ImageLib.PK_COLUMN;
            } else {
                imageName = ImageLib.TD_COLUMN;
            }
        } else if (node instanceof DFColumnRepNode) {
            imageName = ImageLib.TD_COLUMN;
        } else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        }
    }
    return imageName;
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) DBViewFolderRepNode(org.talend.dq.nodes.DBViewFolderRepNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) ExchangeComponentRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PatternRepNode(org.talend.dq.nodes.PatternRepNode) DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) DFColumnFolderRepNode(org.talend.dq.nodes.DFColumnFolderRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode) JrxmlTempleteRepNode(org.talend.dq.nodes.JrxmlTempleteRepNode) RecycleBinRepNode(org.talend.dq.nodes.RecycleBinRepNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) ExchangeCategoryRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode)

Aggregations

DBColumnFolderRepNode (org.talend.dq.nodes.DBColumnFolderRepNode)14 RepositoryNode (org.talend.repository.model.RepositoryNode)9 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 DBTableFolderRepNode (org.talend.dq.nodes.DBTableFolderRepNode)6 DBViewFolderRepNode (org.talend.dq.nodes.DBViewFolderRepNode)6 ArrayList (java.util.ArrayList)4 Connection (org.talend.core.model.metadata.builder.connection.Connection)4 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)4 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)3 DBConnectionFolderRepNode (org.talend.dq.nodes.DBConnectionFolderRepNode)3 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)3 DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)3 ColumnSet (orgomg.cwm.resource.relational.ColumnSet)3 List (java.util.List)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 TreeSelection (org.eclipse.jface.viewers.TreeSelection)2 Test (org.junit.Test)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2 Item (org.talend.core.model.properties.Item)2