Search in sources :

Example 31 with MetadataColumnRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdq-studio-se by Talend.

the class CreateNominalAnalysis method init.

@Override
public void init(ICommonActionExtensionSite site) {
    if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
        StructuredSelection selection = (StructuredSelection) site.getStructuredViewer().getSelection();
        Object fe = selection.getFirstElement();
        if (fe instanceof IRepositoryNode) {
            IRepositoryViewObject object = ((IRepositoryNode) fe).getObject();
            if (object instanceof MetadataColumnRepositoryObject) {
                MetadataColumnRepositoryObject columnObject = (MetadataColumnRepositoryObject) object;
                modelElement = columnObject.getTdColumn();
            }
        }
    }
    super.init(site);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ICommonViewerWorkbenchSite(org.eclipse.ui.navigator.ICommonViewerWorkbenchSite)

Example 32 with MetadataColumnRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdq-studio-se by Talend.

the class ResourceViewContentProvider method hasChildren.

@Override
public boolean hasChildren(Object element) {
    try {
        if (element instanceof IRepositoryNode) {
            IRepositoryNode node = (IRepositoryNode) element;
            IRepositoryViewObject viewObject = node.getObject();
            if (viewObject instanceof MetadataColumnRepositoryObject) {
                return false;
            } else if (node instanceof ExchangeFolderRepNode || node instanceof ExchangeCategoryRepNode || node instanceof SysIndicatorFolderRepNode || element instanceof DBTableRepNode || element instanceof DBViewRepNode || element instanceof DBCatalogRepNode || element instanceof DBSchemaRepNode) {
                // ExchangeCategoryRepNode always have children
                return true;
            } else if (node instanceof ExchangeComponentRepNode) {
                // ExchangeComponentRepNode always don't have children
                return false;
            } else if (element instanceof DBTableFolderRepNode) {
                // MOD gdbu 2011-9-1 TDQ-3457
                if (DQRepositoryNode.isOnFilterring()) {
                    return true;
                }
                DBTableFolderRepNode dbTableFolder = (DBTableFolderRepNode) element;
                return dbTableFolder.hasChildren();
            } else if (element instanceof DBViewFolderRepNode) {
                if (DQRepositoryNode.isOnFilterring()) {
                    return true;
                }
                DBViewFolderRepNode dbViewFolder = (DBViewFolderRepNode) element;
                return dbViewFolder.hasChildren();
            // ~TDQ-3457
            }
        } else if (element instanceof IEcosCategory) {
            return true;
        }
    // // MOD qiongli feature 9486
    // if (element instanceof IFolder) {
    // // MOD yyi 2010-09-30 15271: svn project can't load exchange nodes
    // if (ResourceManager.isExchangeFolder((IFolder) element)) {
    // return true;
    // }
    // // ~15271
    // List<Object> obsLs = Arrays.asList(super.getChildren(element));
    // if (obsLs.size() == 1) {
    // Object obj = (Object) obsLs.get(0);
    // if (obj instanceof IFolder && ((IFolder) obj).getName().equals(PluginConstant.SVN_SUFFIX))
    // return false;
    // }
    // } else if (element instanceof DQRecycleBinNode) {
    // DQRecycleBinNode rbn = (DQRecycleBinNode) element;
    // Object obj = rbn.getObject();
    // if (obj instanceof IFolder) {
    // try {
    // return ((IFolder) obj).members().length > 0;
    // } catch (CoreException e) {
    // log.error(e);
    // }
    // }
    // return false;
    // }
    } catch (MissingDriverException e) {
        if (PluginChecker.isOnlyTopLoaded()) {
            MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), // $NON-NLS-1$
            DefaultMessagesImpl.getString("ResourceViewContentProvider.warining"), e.getErrorMessage());
        } else {
            log.error(e, e);
        }
        return false;
    }
    return super.hasChildren(element);
}
Also used : DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ExchangeFolderRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeFolderRepNode) IEcosCategory(org.talend.dataprofiler.ecos.model.IEcosCategory) DBViewFolderRepNode(org.talend.dq.nodes.DBViewFolderRepNode) SysIndicatorFolderRepNode(org.talend.dq.nodes.SysIndicatorFolderRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) MissingDriverException(org.talend.utils.exceptions.MissingDriverException) ExchangeCategoryRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ExchangeComponentRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Example 33 with MetadataColumnRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdq-studio-se by Talend.

the class RepNodeUtils method isSupportPatternFrequency.

/**
 * check whether the nodes can support pattern Frequency indicator for sql engine.
 *
 * @param nodes
 * @return
 */
public static boolean isSupportPatternFrequency(List<IRepositoryNode> nodes) {
    if (nodes != null && !nodes.isEmpty()) {
        Connection connection = null;
        if (nodes.get(0) instanceof ColumnRepNode) {
            MetadataColumn column = ((MetadataColumnRepositoryObject) nodes.get(0).getObject()).getTdColumn();
            connection = ConnectionHelper.getTdDataProvider(column);
        } else if (nodes.get(0) instanceof ColumnSetRepNode) {
            MetadataTable table = ((MetadataTableRepositoryObject) nodes.get(0).getObject()).getTable();
            connection = ConnectionHelper.getTdDataProvider(table);
        }
        if (connection != null && (ConnectionHelper.isTeradata(connection) || ConnectionHelper.isIngress(connection) || ConnectionHelper.isSybase(connection))) {
            return false;
        }
    }
    return true;
}
Also used : DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) Connection(org.talend.core.model.metadata.builder.connection.Connection) ColumnSetRepNode(org.talend.dq.nodes.ColumnSetRepNode) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)

Example 34 with MetadataColumnRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdq-studio-se by Talend.

the class RepositoryNodeHelperRealTest method testCreateMssqlRepositoryNode.

/**
 * Test method for
 * {@link org.talend.dq.helper.RepositoryNodeHelper#createRepositoryNode(orgomg.cwm.objectmodel.core.ModelElement)}.
 * mssql case
 */
@Test
public void testCreateMssqlRepositoryNode() {
    // $NON-NLS-1$
    DatabaseConnectionItem createConnectionItem = createDataBaseConnection("conn1", null, false);
    // $NON-NLS-1$
    Catalog addCatalog = this.addCatalog(createConnectionItem.getConnection(), "catalog1");
    // $NON-NLS-1$
    Schema addSchema = this.addSchema(addCatalog, "schema1");
    // $NON-NLS-1$
    TdTable addTable = this.addTable(addSchema, "table1");
    // $NON-NLS-1$
    TdColumn addColumn = this.addColumn(addTable, "column1");
    try {
        ProxyRepositoryFactory.getInstance().save(createConnectionItem, null);
    } catch (PersistenceException e) {
        log.error(e, e);
        Assert.fail(e.getMessage());
    }
    RepositoryNode createRepositoryNode = RepositoryNodeHelper.createRepositoryNode(addColumn);
    if (createRepositoryNode != null) {
        IRepositoryViewObject object = createRepositoryNode.getObject();
        Assert.assertTrue(createRepositoryNode instanceof DBColumnRepNode);
        Assert.assertTrue(object != null);
        Assert.assertTrue(object instanceof MetadataColumnRepositoryObject);
        Assert.assertTrue(object.getId().equals(addColumn.getName()));
        Assert.assertTrue(object.getLabel().equals(addColumn.getName()));
        Assert.assertTrue(object.getRepositoryNode() != null);
        Assert.assertTrue(createRepositoryNode.getProperties(EProperties.LABEL).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
        Assert.assertTrue(createRepositoryNode.getProperties(EProperties.CONTENT_TYPE).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
        Assert.assertTrue(createRepositoryNode.getParent().getParent().getParent().getParent().getParent().getParent() != null);
    }
}
Also used : TdTable(org.talend.cwm.relational.TdTable) TdColumn(org.talend.cwm.relational.TdColumn) Schema(orgomg.cwm.resource.relational.Schema) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Catalog(orgomg.cwm.resource.relational.Catalog) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) Test(org.junit.Test)

Example 35 with MetadataColumnRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdq-studio-se by Talend.

the class RepositoryNodeHelperRealTest method testCreateMysqlColumnRepositoryNode.

/**
 * Test method for
 * {@link org.talend.dq.helper.RepositoryNodeHelper#createRepositoryNode(orgomg.cwm.objectmodel.core.ModelElement)}.
 * mysql case find column node
 */
@Test
public void testCreateMysqlColumnRepositoryNode() {
    // $NON-NLS-1$
    DatabaseConnectionItem createConnectionItem = createDataBaseConnection("conn1", null, false);
    // $NON-NLS-1$
    Catalog addCatalog = this.addCatalog(createConnectionItem.getConnection(), "catalog1");
    // $NON-NLS-1$
    TdTable addTable = this.addTable(addCatalog, "table1");
    // $NON-NLS-1$
    TdColumn addColumn = this.addColumn(addTable, "column1");
    try {
        ProxyRepositoryFactory.getInstance().save(createConnectionItem, null);
    } catch (PersistenceException e) {
        log.error(e, e);
        Assert.fail(e.getMessage());
    }
    RepositoryNode createRepositoryNode = RepositoryNodeHelper.createRepositoryNode(addColumn);
    if (createRepositoryNode != null) {
        IRepositoryViewObject object = createRepositoryNode.getObject();
        Assert.assertTrue(createRepositoryNode instanceof DBColumnRepNode);
        Assert.assertTrue(object != null);
        Assert.assertTrue(object instanceof MetadataColumnRepositoryObject);
        Assert.assertTrue(object.getId().equals(addColumn.getName()));
        Assert.assertTrue(object.getLabel().equals(addColumn.getName()));
        Assert.assertTrue(object.getRepositoryNode() != null);
        Assert.assertTrue(createRepositoryNode.getProperties(EProperties.LABEL).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
        Assert.assertTrue(createRepositoryNode.getProperties(EProperties.CONTENT_TYPE).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
        Assert.assertTrue(createRepositoryNode.getParent().getParent().getParent().getParent().getParent() != null);
    }
}
Also used : TdTable(org.talend.cwm.relational.TdTable) TdColumn(org.talend.cwm.relational.TdColumn) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Catalog(orgomg.cwm.resource.relational.Catalog) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) Test(org.junit.Test)

Aggregations

MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)46 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)30 IRepositoryNode (org.talend.repository.model.IRepositoryNode)27 RepositoryNode (org.talend.repository.model.RepositoryNode)14 TdColumn (org.talend.cwm.relational.TdColumn)13 ArrayList (java.util.ArrayList)10 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)10 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)9 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)9 Connection (org.talend.core.model.metadata.builder.connection.Connection)8 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)7 TdTable (org.talend.cwm.relational.TdTable)7 List (java.util.List)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 ICommonViewerWorkbenchSite (org.eclipse.ui.navigator.ICommonViewerWorkbenchSite)5 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)5 ReturnCode (org.talend.utils.sugars.ReturnCode)5 Test (org.junit.Test)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)3