Search in sources :

Example 11 with MetadataColumnRepositoryObject

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

the class AbstractPagePart method updateBindConnection.

/**
 * ADD mzhao 2009-05-05 bug:6587.
 */
protected void updateBindConnection(AbstractAnalysisMetadataPage masterPage, List<TableViewer> tableViewerPosStack) {
    boolean isEmpty1 = tableViewerPosStack.get(0) == null || tableViewerPosStack.get(0).getInput() == null || ((List) tableViewerPosStack.get(0).getInput()).size() == 0;
    boolean isEmpty2 = tableViewerPosStack.get(1) == null || tableViewerPosStack.get(1).getInput() == null || ((List) tableViewerPosStack.get(1).getInput()).size() == 0;
    if (isEmpty1 && isEmpty2) {
        return;
    } else {
        TableViewer columnsElementViewer = null;
        if (!isEmpty1) {
            columnsElementViewer = tableViewerPosStack.get(0);
        } else {
            columnsElementViewer = tableViewerPosStack.get(1);
        }
        Connection tdProvider = null;
        Object input = columnsElementViewer.getInput();
        List<DBColumnRepNode> columnSet = (List<DBColumnRepNode>) input;
        if (columnSet != null && columnSet.size() != 0) {
            TdColumn column = (TdColumn) ((MetadataColumnRepositoryObject) columnSet.get(0).getObject()).getTdColumn();
            if (column != null && column.eIsProxy()) {
                column = (TdColumn) EObjectHelper.resolveObject(column);
            }
            tdProvider = ConnectionHelper.getTdDataProvider(column);
            setConnectionState(masterPage, tdProvider);
        }
    }
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) Connection(org.talend.core.model.metadata.builder.connection.Connection) List(java.util.List) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 12 with MetadataColumnRepositoryObject

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

the class AnalysisColumnCompareTreeViewer method setColumnABForMatchingIndicator.

/**
 * DOC rli Comment method "setColumnAB".
 */
public void setColumnABForMatchingIndicator(RowMatchingIndicator rowMatchingIndicator, List<RepositoryNode> columnsA, List<RepositoryNode> columnsB) {
    if (columnsA.size() != 0 && columnsA.get(0).getObject() instanceof MetadataColumnRepositoryObject) {
        RepositoryNode node = columnsA.get(0);
        MetadataColumnRepositoryObject columnObject = (MetadataColumnRepositoryObject) node.getObject();
        TdColumn column = ((TdColumn) columnObject.getTdColumn());
        ColumnSet columnSetOwner = ColumnHelper.getColumnOwnerAsColumnSet(column);
        rowMatchingIndicator.setAnalyzedElement(columnSetOwner);
    }
    rowMatchingIndicator.getColumnSetA().clear();
    for (RepositoryNode reposNode : columnsA) {
        rowMatchingIndicator.getColumnSetA().add((TdColumn) ((MetadataColumnRepositoryObject) reposNode.getObject()).getTdColumn());
    }
    rowMatchingIndicator.getColumnSetB().clear();
    for (RepositoryNode reposNode : columnsB) {
        rowMatchingIndicator.getColumnSetB().add((TdColumn) ((MetadataColumnRepositoryObject) reposNode.getObject()).getTdColumn());
    }
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 13 with MetadataColumnRepositoryObject

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

the class AnalysisColumnNominalIntervalTreeViewer method dropModelElements.

@Override
public void dropModelElements(List<? extends IRepositoryNode> reposObjects, int index) {
    List<IRepositoryNode> columns = new ArrayList<IRepositoryNode>();
    for (IRepositoryNode element : reposObjects) {
        if (element.getObject() instanceof MetadataColumnRepositoryObject) {
            columns.add(element);
        }
    }
    this.addElements(columns, index);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)

Example 14 with MetadataColumnRepositoryObject

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

the class AnalysisColumnTreeViewer method isExpressionNull.

private String isExpressionNull(TreeItem item) {
    String expressContent = null;
    ModelElement me = null;
    IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
    ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
    if (indicatorUnit != null) {
        IRepositoryViewObject reposViewObj = meIndicator.getModelElementRepositoryNode().getObject();
        // MetadataXmlElementTypeRepositoryObject
        if (reposViewObj instanceof MetadataColumnRepositoryObject) {
            me = ((MetadataColumnRepositoryObject) reposViewObj).getTdColumn();
        }
        Connection dataprovider = ModelElementHelper.getTdDataProvider(me);
        DbmsLanguage dbmsLang = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
        Expression expression = dbmsLang.getInstantiatedExpression(indicatorUnit.getIndicator());
        if (expression != null) {
            expressContent = expression.getBody();
        }
    } else {
        IRepositoryNode parentNodeForColumnNode = RepositoryNodeHelper.getParentNodeForColumnNode(meIndicator.getModelElementRepositoryNode());
        expressContent = DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.columnParent", // $NON-NLS-1$ //;
        parentNodeForColumnNode.getObject().getLabel());
    }
    return expressContent;
}
Also used : DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Expression(orgomg.cwm.objectmodel.core.Expression) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Connection(org.talend.core.model.metadata.builder.connection.Connection) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 15 with MetadataColumnRepositoryObject

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

the class AnalysisColumnTreeViewer method canDrop.

@Override
public boolean canDrop(IRepositoryNode metadataRepositoryNode) {
    IRepositoryViewObject metadataRepObject = metadataRepositoryNode.getObject();
    ConnectionItem connItem = (ConnectionItem) metadataRepObject.getProperty().getItem();
    // MOD qiongli 2010-8-19,bug 14436:could not come from diffrent connection
    Connection tdProvider = connItem.getConnection();
    if (tdProvider == null) {
        return false;
    } else if (this.getAnalysis().getContext().getConnection() != null && !ResourceHelper.areSame(tdProvider, this.getAnalysis().getContext().getConnection())) {
        return false;
    }
    // MOD mzhao, 2010-07-23 bug 14014: If the editor is dirty, save it firstly before drag and drop an elements.
    if (masterPage.isDirty()) {
        masterPage.doSave(new NullProgressMonitor());
        return false;
    }
    List<ModelElement> existModelElements = new ArrayList<ModelElement>();
    for (ModelElementIndicator modelElementIndicator : this.getAllTheElementIndicator()) {
        ModelElement me = RepositoryNodeHelper.getModelElementFromRepositoryNode(modelElementIndicator.getModelElementRepositoryNode());
        existModelElements.add(me);
    }
    // MOD mzhao 9848 2010-01-14, allowing to drag and drop table.
    if (metadataRepObject instanceof MetadataTableRepositoryObject) {
        MetadataTableRepositoryObject tableRepObject = (MetadataTableRepositoryObject) metadataRepObject;
        return !existModelElements.containsAll(ColumnSetHelper.getColumns((TdTable) tableRepObject.getTable()));
    }
    if (metadataRepObject instanceof MetadataColumnRepositoryObject) {
        if (existModelElements.contains(((MetadataColumnRepositoryObject) metadataRepObject).getTdColumn())) {
            return false;
        }
    }
    if (metadataRepObject instanceof MetadataXmlElementTypeRepositoryObject) {
        return !metadataRepositoryNode.hasChildren();
    }
    return true;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ConnectionItem(org.talend.core.model.properties.ConnectionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Connection(org.talend.core.model.metadata.builder.connection.Connection) ArrayList(java.util.ArrayList) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataXmlElementTypeRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)

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