Search in sources :

Example 1 with DBConnectionFolderRepNode

use of org.talend.dq.nodes.DBConnectionFolderRepNode 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 2 with DBConnectionFolderRepNode

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

the class CatalogContentProvider method getChildren.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider#getChildren(java.lang.Object)
     */
@Override
public Object[] getChildren(Object parentElement) {
    // if (parentElement instanceof IContainer) {
    // try {
    // Object[] members = ((IContainer) parentElement).members();
    // if (parentElement.equals(ResourceManager.getConnectionFolder())) {
    // try {
    // members = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.METADATA_CONNECTIONS)
    // .toArray();
    // } catch (PersistenceException e) {
    // log.error(e, e);
    // }
    // }
    // return members;
    // } catch (CoreException e) {
    // log.error("Can't get the children of container:" + ((IContainer) parentElement).getLocation()); //$NON-NLS-1$
    // }
    // } else if (parentElement instanceof IRepositoryViewObject) {
    // IRepositoryViewObject repoistoryViewObj = (IRepositoryViewObject) parentElement;
    // Item item = repoistoryViewObj.getProperty().getItem();
    // if (item instanceof ConnectionItem) {
    // ((ConnectionItem) item).getConnection().getDataPackage();
    // return ComparatorsFactory.sort(((ConnectionItem) item).getConnection().getDataPackage().toArray(),
    // ComparatorsFactory.MODELELEMENT_COMPARATOR_ID);
    // }
    // }
    // else if (parentElement instanceof IFile) {
    // IFile prvFile = (IFile) parentElement;
    // if (FactoriesUtil.isProvFile(prvFile.getFileExtension())) {
    // parentElement = PrvResourceFileHelper.getInstance().getFileResource((IFile) parentElement);
    // return ComparatorsFactory.sort(super.getChildren(parentElement),
    // ComparatorsFactory.MODELELEMENT_COMPARATOR_ID);
    // }
    // }
    List<RepositoryNode> analyzeNode = new ArrayList<RepositoryNode>();
    if (parentElement instanceof IContainer) {
        if (ResourceManager.isMetadataFolder((IResource) parentElement)) {
            IFolder container = (IFolder) parentElement;
            IRepositoryViewObject viewObject = new Folder(((IFolder) container).getName(), ((IFolder) container).getName());
            RepositoryNode node = new RepositoryNode(viewObject, null, ENodeType.SYSTEM_FOLDER);
            viewObject.setRepositoryNode(node);
            Object[] children = super.getChildren(node);
            // if analyze Connection/Catalog/Schema,now only surpport DB type klliu 2011-01-28
            for (Object object : children) {
                if (object instanceof DBConnectionFolderRepNode) {
                    analyzeNode.add((RepositoryNode) object);
                }
            }
            return analyzeNode.toArray();
        }
    }
    return super.getChildren(parentElement);
}
Also used : ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IContainer(org.eclipse.core.resources.IContainer) IFolder(org.eclipse.core.resources.IFolder) Folder(org.talend.core.model.repository.Folder) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode) IFolder(org.eclipse.core.resources.IFolder)

Example 3 with DBConnectionFolderRepNode

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

the class ConnectionsContentProvider method getChildren.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider#getChildren(java.lang.Object)
     */
@Override
public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof IContainer) {
        IContainer container = (IContainer) parentElement;
        IRepositoryNode node = null;
        // IResource[] members = null;
        // try {
        // 
        // // if (ResourceManager.getConnectionFolder().equals(container)) {
        // // return
        // // ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.METADATA_CONNECTIONS).toArray();
        // // } else if (ResourceManager.getMDMConnectionFolder().equals(container)) {
        // // return
        // // ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.METADATA_CONNECTIONS).toArray();
        // // }
        // } catch (PersistenceException e) {
        // log.error(e, e);
        // }
        // try {
        // members = container.members();
        // } catch (CoreException e) {
        // log.error("Can't get the children of container:" + ((IContainer) parentElement).getLocation()); //$NON-NLS-1$
        // }
        List<RepositoryNode> analyzeNode = new ArrayList<RepositoryNode>();
        if (ResourceManager.isMetadataFolder(container)) {
            IRepositoryViewObject viewObject = new Folder(((IFolder) container).getName(), ((IFolder) container).getName());
            node = new RepositoryNode(viewObject, null, ENodeType.SYSTEM_FOLDER);
            viewObject.setRepositoryNode(node);
            Object[] children = super.getChildren(node);
            // if analyze Connection/Catalog/Schema,now only surpport DB type klliu 2011-01-28
            for (Object object : children) {
                if (object instanceof DBConnectionFolderRepNode) {
                    analyzeNode.add((RepositoryNode) object);
                }
            }
            return analyzeNode.toArray();
        }
    }
    return super.getChildren(parentElement);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IContainer(org.eclipse.core.resources.IContainer) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IFolder(org.eclipse.core.resources.IFolder) Folder(org.talend.core.model.repository.Folder) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode)

Example 4 with DBConnectionFolderRepNode

use of org.talend.dq.nodes.DBConnectionFolderRepNode 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)

Example 5 with DBConnectionFolderRepNode

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

the class RepositoryNodeHelper method getDBConnectionRepositoryNodes.

public static List<IRepositoryNode> getDBConnectionRepositoryNodes(boolean withDeleted) {
    RepositoryNode node = getRootNode(ERepositoryObjectType.METADATA);
    List<IRepositoryNode> connNodes = new ArrayList<IRepositoryNode>();
    if (node != null) {
        List<IRepositoryNode> childrens = node.getChildren();
        for (IRepositoryNode subNode : childrens) {
            if (subNode instanceof DBConnectionFolderRepNode) {
                connNodes.addAll(getModelElementFromFolder(subNode, withDeleted));
            }
        }
    }
    return connNodes;
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode)

Aggregations

DBConnectionFolderRepNode (org.talend.dq.nodes.DBConnectionFolderRepNode)9 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 ArrayList (java.util.ArrayList)5 RepositoryNode (org.talend.repository.model.RepositoryNode)5 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)4 IRepositoryNode (org.talend.repository.model.IRepositoryNode)4 IContainer (org.eclipse.core.resources.IContainer)3 IFolder (org.eclipse.core.resources.IFolder)3 Folder (org.talend.core.model.repository.Folder)3 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)3 DBColumnFolderRepNode (org.talend.dq.nodes.DBColumnFolderRepNode)3 DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)3 DBTableFolderRepNode (org.talend.dq.nodes.DBTableFolderRepNode)3 DBViewFolderRepNode (org.talend.dq.nodes.DBViewFolderRepNode)3 ExchangeCategoryRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode)2 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)2 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)2 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)2 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)2 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)2