Search in sources :

Example 6 with TdViewRepositoryObject

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

the class AbstractPredefinedTableActionProvider method fillContextMenu.

@Override
public void fillContextMenu(IMenuManager menu) {
    // MOD mzhao user readonly role on svn repository mode.
    if (!isShowMenu()) {
        return;
    }
    TreeSelection currentSelection = ((TreeSelection) this.getContext().getSelection());
    Object fe = currentSelection.getFirstElement();
    if (fe instanceof IRepositoryNode) {
        IRepositoryViewObject object = ((IRepositoryNode) fe).getObject();
        if (object instanceof TdTableRepositoryObject || object instanceof TdViewRepositoryObject) {
            action.setSelection(currentSelection);
            if (action.isAllowed()) {
                menu.add(action);
            }
        }
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject)

Example 7 with TdViewRepositoryObject

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

the class CreatePatternAnalysis 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 TdTableRepositoryObject) {
                TdTableRepositoryObject tableObject = (TdTableRepositoryObject) object;
                modelElement = tableObject.getTdTable();
            } else if (object instanceof TdViewRepositoryObject) {
                TdViewRepositoryObject viewObject = (TdViewRepositoryObject) object;
                modelElement = viewObject.getTdView();
            } else 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) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject) ICommonViewerWorkbenchSite(org.eclipse.ui.navigator.ICommonViewerWorkbenchSite)

Example 8 with TdViewRepositoryObject

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

the class CreateTableAnalysis 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 TdTableRepositoryObject) {
                TdTableRepositoryObject tableObject = (TdTableRepositoryObject) object;
                modelElement = tableObject.getTdTable();
            } else if (object instanceof TdViewRepositoryObject) {
                TdViewRepositoryObject viewObject = (TdViewRepositoryObject) object;
                modelElement = viewObject.getTdView();
            }
        }
    }
    super.init(site);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject) ICommonViewerWorkbenchSite(org.eclipse.ui.navigator.ICommonViewerWorkbenchSite)

Example 9 with TdViewRepositoryObject

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

the class RepositoryNodeHelperRealTest method testCreateMysqlViewRepositoryNode.

/**
 * Test method for
 * {@link org.talend.dq.helper.RepositoryNodeHelper#createRepositoryNode(orgomg.cwm.objectmodel.core.ModelElement)}.
 * mysql case find View node
 */
@Test
public void testCreateMysqlViewRepositoryNode() {
    // $NON-NLS-1$
    DatabaseConnectionItem createConnectionItem = createDataBaseConnection("conn1", null, false);
    // $NON-NLS-1$
    Catalog addCatalog = this.addCatalog(createConnectionItem.getConnection(), "catalog1");
    // $NON-NLS-1$
    TdView addView = this.addView(addCatalog, "view1");
    try {
        ProxyRepositoryFactory.getInstance().save(createConnectionItem, null);
    } catch (PersistenceException e) {
        log.error(e, e);
        Assert.fail(e.getMessage());
    }
    RepositoryNode createRepositoryNode = RepositoryNodeHelper.createRepositoryNode(addView);
    if (createRepositoryNode != null) {
        IRepositoryViewObject object = createRepositoryNode.getObject();
        Assert.assertTrue(createRepositoryNode instanceof DBViewRepNode);
        Assert.assertTrue(object != null);
        Assert.assertTrue(object instanceof TdViewRepositoryObject);
        Assert.assertTrue(object.getId().equals(addView.getName()));
        Assert.assertTrue(object.getLabel().equals(addView.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() != null);
    }
}
Also used : TdView(org.talend.cwm.relational.TdView) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject) Catalog(orgomg.cwm.resource.relational.Catalog) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) Test(org.junit.Test)

Example 10 with TdViewRepositoryObject

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

the class AnalysisSubFolderRepNode method doSwichNode.

/**
 * DOC klliu Comment method "doSwichNode".
 *
 * @param analyzedElement
 * @return
 */
private IRepositoryNode doSwichNode(ModelElement analyzedElement, AnalysisSubFolderRepNode childNodeFolder) {
    Property anaEleProperty = PropertyHelper.getProperty(analyzedElement);
    IRepositoryViewObject medataViewObject = null;
    try {
        medataViewObject = ProxyRepositoryFactory.getInstance().getLastVersion(anaEleProperty.getId());
    } catch (Exception e) {
        log.error(e);
    }
    // }
    if (medataViewObject != null) {
        if (analyzedElement instanceof DatabaseConnection) {
            DBConnectionRepNode connNode = new DBConnectionRepNode(medataViewObject, this, ENodeType.REPOSITORY_ELEMENT, getProject());
            connNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CONNECTIONS);
            connNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CONNECTIONS);
            medataViewObject.setRepositoryNode(connNode);
            return connNode;
        } else if (analyzedElement instanceof Catalog) {
            RepositoryNode catalogNode = DQRepNodeCreateFactory.createDBCatalogRepNode(new MetadataCatalogRepositoryObject(medataViewObject, (Catalog) analyzedElement), this, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            catalogNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_CATALOG);
            catalogNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_CATALOG);
            medataViewObject.setRepositoryNode(catalogNode);
            return catalogNode;
        } else if (analyzedElement instanceof Schema) {
            RepositoryNode schemaNode = new DBSchemaRepNode(new MetadataSchemaRepositoryObject(medataViewObject, (Schema) analyzedElement), this, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            schemaNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_SCHEMA);
            schemaNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_SCHEMA);
            medataViewObject.setRepositoryNode(schemaNode);
            return schemaNode;
        } else if (analyzedElement instanceof TdTable) {
            DBTableRepNode tableNode = new DBTableRepNode(new TdTableRepositoryObject(medataViewObject, (TdTable) analyzedElement), childNodeFolder, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            tableNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_TABLE);
            tableNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_TABLE);
            medataViewObject.setRepositoryNode(tableNode);
            return tableNode;
        } else if (analyzedElement instanceof TdView) {
            DBViewRepNode viewNode = new DBViewRepNode(new TdViewRepositoryObject(medataViewObject, (TdView) analyzedElement), childNodeFolder, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            viewNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_VIEW);
            viewNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_VIEW);
            medataViewObject.setRepositoryNode(viewNode);
            return viewNode;
        } else if (analyzedElement instanceof MetadataColumn) {
            RepositoryNode columnNode = null;
            if (analyzedElement instanceof TdColumn) {
                columnNode = new DBColumnRepNode(new MetadataColumnRepositoryObject(medataViewObject, (MetadataColumn) analyzedElement), childNodeFolder, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            } else {
                columnNode = new DFColumnRepNode(new MetadataColumnRepositoryObject(medataViewObject, (MetadataColumn) analyzedElement), this, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            }
            columnNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_COLUMN);
            columnNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_COLUMN);
            medataViewObject.setRepositoryNode(columnNode);
            return columnNode;
        }
    }
    return null;
}
Also used : TdTable(org.talend.cwm.relational.TdTable) Schema(orgomg.cwm.resource.relational.Schema) MetadataCatalogRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataCatalogRepositoryObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject) Catalog(orgomg.cwm.resource.relational.Catalog) MetadataSchemaRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataSchemaRepositoryObject) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn) TdView(org.talend.cwm.relational.TdView) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) Property(org.talend.core.model.properties.Property)

Aggregations

TdViewRepositoryObject (org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject)11 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)8 TdTableRepositoryObject (org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject)8 IRepositoryNode (org.talend.repository.model.IRepositoryNode)7 TdView (org.talend.cwm.relational.TdView)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 ICommonViewerWorkbenchSite (org.eclipse.ui.navigator.ICommonViewerWorkbenchSite)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)2 TdColumn (org.talend.cwm.relational.TdColumn)2 TdTable (org.talend.cwm.relational.TdTable)2 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)2 Catalog (orgomg.cwm.resource.relational.Catalog)2 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 Test (org.junit.Test)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 ConnectionItem (org.talend.core.model.properties.ConnectionItem)1