Search in sources :

Example 36 with MetadataColumnRepositoryObject

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

the class AnalysisColumnCompareTreeViewer method createTreeViewer.

private TableViewer createTreeViewer(final List<RepositoryNode> columnList, Composite columsComp) {
    TableViewer columnsElementViewer = new TableViewer(columsComp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.MULTI);
    Table table = columnsElementViewer.getTable();
    GridDataFactory.fillDefaults().grab(true, true).applyTo(table);
    ((GridData) table.getLayoutData()).heightHint = 280;
    table.setHeaderVisible(true);
    table.setDragDetect(true);
    // $NON-NLS-1$
    table.setToolTipText(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.reorderElementsByDragAnddrop"));
    final TableColumn columnHeader = new TableColumn(table, SWT.CENTER);
    columnHeader.setWidth(260);
    columnHeader.setAlignment(SWT.CENTER);
    if (columnList.size() > 0) {
        RepositoryNode column = columnList.get(0);
        if (column != null) {
            MetadataColumnRepositoryObject colObject = (MetadataColumnRepositoryObject) column.getObject();
            String tableName = ColumnHelper.getColumnOwnerAsColumnSet(colObject.getTdColumn()).getName();
            // $NON-NLS-1$
            columnHeader.setText(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.element", tableName));
        } else {
            columnList.remove(column);
            // $NON-NLS-1$
            columnHeader.setText("The connection is not available now!");
        }
    }
    ColumnsElementViewerProvider provider = new ColumnsElementViewerProvider();
    columnsElementViewer.setContentProvider(provider);
    columnsElementViewer.setLabelProvider(provider);
    columnsElementViewer.setInput(columnList);
    return columnsElementViewer;
}
Also used : Table(org.eclipse.swt.widgets.Table) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) RepositoryNode(org.talend.repository.model.RepositoryNode) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 37 with MetadataColumnRepositoryObject

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

the class AnalysisColumnNominalIntervalTreeViewer method canDrop.

@Override
public boolean canDrop(IRepositoryNode modelElement) {
    List<TdColumn> existColumns = new ArrayList<TdColumn>();
    for (RepositoryNode columnFromMultiValueList : this.getColumnSetMultiValueList()) {
        IRepositoryViewObject repObject = columnFromMultiValueList.getObject();
        existColumns.add((TdColumn) ((MetadataColumnRepositoryObject) repObject).getTdColumn());
    }
    if (existColumns.contains(modelElement)) {
        return false;
    }
    // MOD qiongli 2010-8-19,bug 14436:if come from diffrent table,can not drop
    IRepositoryViewObject repObject = modelElement.getObject();
    existColumns.add((TdColumn) ((MetadataColumnRepositoryObject) repObject).getTdColumn());
    if (!existColumns.isEmpty() && !ColumnHelper.isFromSameTable(existColumns)) {
        return false;
    }
    return true;
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 38 with MetadataColumnRepositoryObject

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

the class JoinConditionTableViewer method dropModelElements.

@Override
public void dropModelElements(List<? extends IRepositoryNode> modelElements, int index) {
    List<TdColumn> columns = new ArrayList<TdColumn>();
    for (IRepositoryNode repNode : modelElements) {
        if (repNode.getObject() instanceof MetadataColumnRepositoryObject) {
            TdColumn column = (TdColumn) ((MetadataColumnRepositoryObject) repNode.getObject()).getTdColumn();
            if (column != null) {
                columns.add(column);
            }
        }
    }
    JoinElementColumnDialog joinElementColumnDialog = new JoinElementColumnDialog(null);
    if (joinElementColumnDialog.open() == Window.OK) {
        JoinElement join = (JoinElement) this.myTableViewer.getElementAt(index);
        if (join == null) {
            join = this.addJoinElement();
        }
        if (join != null) {
            boolean dirty = false;
            for (TdColumn column : columns) {
                if (column != null) {
                    if (!updateColumnSetPackage(column)) {
                        break;
                    }
                    if (COLUMN_A.equals(joinElementColumnDialog.getAb())) {
                        join.setColA(column);
                        join.setColumnAliasA(column.getName());
                        join.setTableAliasA(ColumnHelper.getColumnSetFullName(column));
                        dirty = true;
                    } else {
                        join.setColB(column);
                        join.setColumnAliasB(column.getName());
                        join.setTableAliasB(ColumnHelper.getColumnSetFullName(column));
                        dirty = true;
                    }
                }
            }
            if (dirty) {
                this.masterPage.setDirty(true);
                this.myTableViewer.update(join, null);
            }
        }
    }
}
Also used : JoinElement(org.talend.dataquality.rules.JoinElement) TdColumn(org.talend.cwm.relational.TdColumn) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)

Example 39 with MetadataColumnRepositoryObject

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

the class MatchAnalysisAction method getColumns.

protected IRepositoryNode[] getColumns() {
    List<IRepositoryNode> list = new ArrayList<IRepositoryNode>();
    Object firstElement = getSelection().getFirstElement();
    if (firstElement instanceof IRepositoryNode) {
        IRepositoryNode repNode = (IRepositoryNode) firstElement;
        IRepositoryViewObject repViewObject = repNode.getObject();
        if (repViewObject instanceof MetadataColumnRepositoryObject || repViewObject instanceof MetadataXmlElementType) {
            IRepositoryNode[] column = new IRepositoryNode[getSelection().size()];
            for (int i = 0; i < getSelection().size(); i++) {
                column[i] = (IRepositoryNode) getSelection().toArray()[i];
            }
            return column;
        } else if (repViewObject instanceof MetadataTableRepositoryObject) {
            Object[] selections = getSelection().toArray();
            for (Object currentObj : selections) {
                IRepositoryNode columnSetNode = (IRepositoryNode) currentObj;
                List<IRepositoryNode> children = columnSetNode.getChildren();
                if (children.size() > 0) {
                    list.addAll(children.get(0).getChildren());
                }
            }
            return list.toArray(new IRepositoryNode[list.size()]);
        }
    }
    return null;
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) MetadataXmlElementType(org.talend.core.model.metadata.MetadataXmlElementType) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ArrayList(java.util.ArrayList) List(java.util.List) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)

Example 40 with MetadataColumnRepositoryObject

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

the class AbstractPredefinedAnalysisAction method composePredefinedColumnIndicator.

protected ModelElementIndicator[] composePredefinedColumnIndicator(IndicatorEnum[] allowedEnum) {
    IRepositoryNode[] columns = getColumns();
    ModelElementIndicator[] predefinedColumnIndicator = new ModelElementIndicator[columns.length];
    ExecutionLanguage language = ExecutionLanguage.get(getMasterPage().getExecCombo().getText());
    for (int i = 0; i < columns.length; i++) {
        IRepositoryNode columnNode = columns[i];
        ModelElementIndicator columnIndicator = ModelElementIndicatorHelper.createModelElementIndicator(columnNode);
        for (IndicatorEnum oneEnum : allowedEnum) {
            columnIndicator.addTempIndicatorEnum(oneEnum);
            if (oneEnum.getChildren() != null) {
                for (IndicatorEnum childEnum : oneEnum.getChildren()) {
                    // MOD by zshen:need language to decide DatePatternFrequencyIndicator whether can be choose by
                    // user.
                    IRepositoryViewObject object = columnNode.getObject();
                    ModelElement element = null;
                    if (object instanceof MetadataColumnRepositoryObject) {
                        element = ((MetadataColumnRepositoryObject) object).getTdColumn();
                    } else if (object instanceof MetadataXmlElementTypeRepositoryObject) {
                        element = ((MetadataXmlElementTypeRepositoryObject) object).getModelElement();
                    }
                    if (element != null && ModelElementIndicatorRule.patternRule(childEnum, element, language)) {
                        columnIndicator.addTempIndicatorEnum(childEnum);
                    }
                }
            }
        }
        columnIndicator.storeTempIndicator();
        predefinedColumnIndicator[i] = columnIndicator;
    }
    return predefinedColumnIndicator;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ExecutionLanguage(org.talend.dataquality.analysis.ExecutionLanguage) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataXmlElementTypeRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

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