Search in sources :

Example 16 with MetadataCatalogRepositoryObject

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

the class DBTableFolderRepNode method createRepositoryNodeTableFolderNode.

/**
 * Create TableFolderNodeRepositoryNode.
 *
 * @param metadataObject parent CatalogViewObject or SchemaViewObject
 */
private void createRepositoryNodeTableFolderNode(IRepositoryViewObject metadataObject) {
    List<TdTable> tables = new ArrayList<TdTable>();
    String filterCharacter = null;
    try {
        if (metadataObject instanceof MetadataCatalogRepositoryObject) {
            viewObject = ((MetadataCatalogRepositoryObject) metadataObject).getViewObject();
            setItem((ConnectionItem) viewObject.getProperty().getItem());
            setConnection(getItem().getConnection());
            if (((MetadataCatalogRepositoryObject) metadataObject).getCatalog().eIsProxy()) {
                // reload the connection to make sure the connection(and all it's owned elements) is not proxy
                reloadConnectionViewObject();
            }
            catalog = ((MetadataCatalogRepositoryObject) metadataObject).getCatalog();
            tables = PackageHelper.getTables(catalog);
            filterCharacter = RepositoryNodeHelper.getTableFilter(catalog, schema);
            // select dialog cares about if connect to DB or not.
            if (tables.isEmpty()) {
                if (isCallingFromColumnDialog()) {
                    tables = DqRepositoryViewService.getTables(getConnection(), catalog, null, isLoadDBFromDialog(), true);
                } else if (!isOnFilterring()) {
                    // MOD mzhao 0022204 : when the tree is rendering with a filter, do not loading from db.
                    tables = DqRepositoryViewService.getTables(getConnection(), catalog, null, true, true);
                }
                if (tables != null && tables.size() > 0) {
                    ProxyRepositoryFactory.getInstance().save(getItem(), false);
                }
            }
        } else {
            viewObject = ((MetadataSchemaRepositoryObject) metadataObject).getViewObject();
            setItem((ConnectionItem) viewObject.getProperty().getItem());
            setConnection(getItem().getConnection());
            if (((MetadataSchemaRepositoryObject) metadataObject).getSchema().eIsProxy()) {
                // reload the connection to make sure the connection(and all it's owned elements) is not proxy
                reloadConnectionViewObject();
            }
            schema = ((MetadataSchemaRepositoryObject) metadataObject).getSchema();
            tables = PackageHelper.getTables(schema);
            filterCharacter = RepositoryNodeHelper.getTableFilter(catalog, schema);
            RepositoryNode parent = metadataObject.getRepositoryNode().getParent();
            IRepositoryViewObject object = parent.getObject();
            if (object instanceof MetadataCatalogRepositoryObject && filterCharacter.equals(PluginConstant.EMPTY_STRING)) {
                filterCharacter = RepositoryNodeHelper.getTableFilter(((MetadataCatalogRepositoryObject) object).getCatalog(), null);
            }
            if (tables.isEmpty()) {
                if (isCallingFromColumnDialog()) {
                    tables = DqRepositoryViewService.getTables(getConnection(), schema, null, isLoadDBFromDialog(), true);
                } else if (!isOnFilterring()) {
                    // MOD mzhao 0022204 : when the tree is rendering with a filter, do not loading from db.
                    tables = DqRepositoryViewService.getTables(getConnection(), schema, null, true, true);
                }
                if (tables != null && tables.size() > 0) {
                    ProxyRepositoryFactory.getInstance().save(getItem(), false);
                }
            }
        }
        ConnectionUtils.retrieveColumn(tables);
    } catch (Exception e) {
        log.error(e, e);
    }
    if (filterCharacter != null && !filterCharacter.equals(PluginConstant.EMPTY_STRING)) {
        tables = RepositoryNodeHelper.filterTables(tables, filterCharacter);
    }
    createTableRepositoryNode(tables, children);
}
Also used : TdTable(org.talend.cwm.relational.TdTable) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataCatalogRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataCatalogRepositoryObject) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 17 with MetadataCatalogRepositoryObject

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

the class DBViewFolderRepNode method createParentNode.

/**
 * create the node of parent.
 *
 * @return
 */
private RepositoryNode createParentNode() {
    RepositoryNode dbParentRepNode = null;
    if (viewObject instanceof MetadataCatalogRepositoryObject) {
        dbParentRepNode = DQRepNodeCreateFactory.createDBCatalogRepNode(viewObject, null, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
    } else if (viewObject instanceof MetadataSchemaRepositoryObject) {
        dbParentRepNode = new DBSchemaRepNode(viewObject, null, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
    }
    viewObject.setRepositoryNode(dbParentRepNode);
    return dbParentRepNode;
}
Also used : MetadataCatalogRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataCatalogRepositoryObject) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) MetadataSchemaRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataSchemaRepositoryObject)

Example 18 with MetadataCatalogRepositoryObject

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

the class DBViewFolderRepNode method createRepositoryNodeViewFolderNode.

/**
 * Create ViewFolderNodeRepositoryNode.
 *
 * @param metadataObject parent CatalogViewObject or SchemaViewObject
 */
private void createRepositoryNodeViewFolderNode(IRepositoryViewObject metadataObject) {
    List<TdView> views = new ArrayList<TdView>();
    String filterCharacter = null;
    try {
        if (metadataObject instanceof MetadataCatalogRepositoryObject) {
            viewObject = ((MetadataCatalogRepositoryObject) metadataObject).getViewObject();
            setItem((ConnectionItem) viewObject.getProperty().getItem());
            setConnection(getItem().getConnection());
            if (((MetadataCatalogRepositoryObject) metadataObject).getCatalog().eIsProxy()) {
                // reload the connection to make sure the connection(and all it's owned elements) is not proxy
                reloadConnectionViewObject();
            }
            catalog = ((MetadataCatalogRepositoryObject) metadataObject).getCatalog();
            views = PackageHelper.getViews(catalog);
            filterCharacter = RepositoryNodeHelper.getViewFilter(catalog, schema);
            // select dialog cares about if connect to DB or not.
            if (views.isEmpty()) {
                if (isCallingFromColumnDialog()) {
                    views = DqRepositoryViewService.getViews(getConnection(), catalog, null, isLoadDBFromDialog(), true);
                } else if (!isOnFilterring()) {
                    // MOD gdbu 2011-7-21 bug 23220
                    views = DqRepositoryViewService.getViews(getConnection(), catalog, null, true, true);
                }
                if (views != null && views.size() > 0) {
                    ProxyRepositoryFactory.getInstance().save(getItem(), false);
                }
            }
        } else {
            viewObject = ((MetadataSchemaRepositoryObject) metadataObject).getViewObject();
            setItem((ConnectionItem) viewObject.getProperty().getItem());
            setConnection(getItem().getConnection());
            if (((MetadataSchemaRepositoryObject) metadataObject).getSchema().eIsProxy()) {
                // reload the connection to make sure the connection(and all it's owned elements) is not proxy
                reloadConnectionViewObject();
            }
            schema = ((MetadataSchemaRepositoryObject) metadataObject).getSchema();
            views = PackageHelper.getViews(schema);
            filterCharacter = RepositoryNodeHelper.getViewFilter(catalog, schema);
            RepositoryNode parent = metadataObject.getRepositoryNode().getParent();
            IRepositoryViewObject object = parent.getObject();
            if (object instanceof MetadataCatalogRepositoryObject && filterCharacter.equals(PluginConstant.EMPTY_STRING)) {
                filterCharacter = RepositoryNodeHelper.getViewFilter(((MetadataCatalogRepositoryObject) object).getCatalog(), null);
            }
            // MOD gdbu 2011-6-29 bug : 22204
            if (views.isEmpty()) {
                if (isCallingFromColumnDialog()) {
                    views = DqRepositoryViewService.getViews(getConnection(), schema, null, isLoadDBFromDialog(), true);
                } else if (!isOnFilterring()) {
                    // MOD gdbu 2011-7-21 bug 23220
                    views = DqRepositoryViewService.getViews(getConnection(), schema, null, true, true);
                }
                if (views != null && views.size() > 0) {
                    ProxyRepositoryFactory.getInstance().save(getItem(), false);
                }
            }
        // ~22204
        }
        ConnectionUtils.retrieveColumn(views);
    } catch (Exception e) {
        log.error(e, e);
    }
    if (filterCharacter != null && !filterCharacter.equals(PluginConstant.EMPTY_STRING)) {
        views = RepositoryNodeHelper.filterViews(views, filterCharacter);
    }
    createViewRepositoryNode(views, children);
}
Also used : TdView(org.talend.cwm.relational.TdView) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataCatalogRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataCatalogRepositoryObject) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 19 with MetadataCatalogRepositoryObject

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

the class DBViewFolderRepNode method getChildrenCount.

/*
     * ADD gdbu 2011-7-25 bug : 23220
     * 
     * children count : only read from the file
     */
private int getChildrenCount() {
    List<TdView> tables = new ArrayList<TdView>();
    IRepositoryViewObject object = this.getParent().getObject();
    if (object instanceof MetadataCatalogRepositoryObject) {
        catalog = ((MetadataCatalogRepositoryObject) object).getCatalog();
        tables = PackageHelper.getViews(catalog);
    } else {
        schema = ((MetadataSchemaRepositoryObject) object).getSchema();
        tables = PackageHelper.getViews(schema);
    }
    return tables.size();
}
Also used : TdView(org.talend.cwm.relational.TdView) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataCatalogRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataCatalogRepositoryObject)

Example 20 with MetadataCatalogRepositoryObject

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

the class DBTableRepNode method getParentViewObject.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.nodes.DQRepositoryNode#getParentViewObject()
     */
@Override
protected IRepositoryViewObject getParentViewObject() {
    IRepositoryViewObject packageViewObject = null;
    Package parentPackage = PackageHelper.getParentPackage(this.tdTableRepositoryObject.getTdTable());
    if (parentPackage instanceof Catalog) {
        packageViewObject = new MetadataCatalogRepositoryObject(tdTableRepositoryObject.getViewObject(), (Catalog) parentPackage);
    } else if (parentPackage instanceof Schema) {
        packageViewObject = new MetadataSchemaRepositoryObject(tdTableRepositoryObject.getViewObject(), (Schema) parentPackage);
    }
    return packageViewObject;
}
Also used : Schema(orgomg.cwm.resource.relational.Schema) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Package(orgomg.cwm.objectmodel.core.Package) MetadataCatalogRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataCatalogRepositoryObject) Catalog(orgomg.cwm.resource.relational.Catalog) MetadataSchemaRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataSchemaRepositoryObject)

Aggregations

MetadataCatalogRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataCatalogRepositoryObject)20 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 RepositoryNode (org.talend.repository.model.RepositoryNode)12 Catalog (orgomg.cwm.resource.relational.Catalog)12 IRepositoryNode (org.talend.repository.model.IRepositoryNode)9 ArrayList (java.util.ArrayList)6 Connection (org.talend.core.model.metadata.builder.connection.Connection)6 MetadataSchemaRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataSchemaRepositoryObject)6 PersistenceException (org.talend.commons.exception.PersistenceException)4 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)4 Schema (orgomg.cwm.resource.relational.Schema)4 Test (org.junit.Test)3 TdTable (org.talend.cwm.relational.TdTable)3 TdView (org.talend.cwm.relational.TdView)3 Package (orgomg.cwm.objectmodel.core.Package)3 Indicator (org.talend.dataquality.indicators.Indicator)2 CatalogIndicator (org.talend.dataquality.indicators.schema.CatalogIndicator)2 PackagesAnalyisParameter (org.talend.dq.analysis.parameters.PackagesAnalyisParameter)2 List (java.util.List)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1