Search in sources :

Example 1 with MetadataXmlElementType

use of org.talend.core.model.metadata.MetadataXmlElementType in project tdq-studio-se by Talend.

the class RepositoryNodeHelper method getAllColumnNodes.

/**
 * get All the Column level Nodes.
 *
 * @param selectedNodes
 * @return
 */
public static IRepositoryNode[] getAllColumnNodes(Object[] selectedNodes) {
    List<IRepositoryNode> list = new ArrayList<IRepositoryNode>();
    if (selectedNodes == null || selectedNodes.length == 0) {
        return list.toArray(new IRepositoryNode[list.size()]);
    }
    Object firstElement = selectedNodes[0];
    if (firstElement instanceof IRepositoryNode) {
        IRepositoryNode repNode = (IRepositoryNode) firstElement;
        IRepositoryViewObject repViewObject = repNode.getObject();
        if (repViewObject instanceof MetadataColumnRepositoryObject || repViewObject instanceof MetadataXmlElementType) {
            IRepositoryNode[] column = new IRepositoryNode[selectedNodes.length];
            for (int i = 0; i < selectedNodes.length; i++) {
                column[i] = (IRepositoryNode) selectedNodes[i];
            }
            return column;
        } else if (repViewObject instanceof MetadataTableRepositoryObject) {
            for (Object currentObj : selectedNodes) {
                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()]);
        }
    } else if (firstElement instanceof TdTable) {
        TdTable table = (TdTable) firstElement;
        EList<MetadataColumn> columns = table.getColumns();
        for (MetadataColumn column : columns) {
            RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(column);
            list.add(recursiveFind);
        }
        return list.toArray(new IRepositoryNode[list.size()]);
    } else if (firstElement instanceof WhereRuleChartDataEntity) {
        // ADD msjian 2012-2-9 TDQ-4470: get columns from the join conditions
        EList<JoinElement> joinConditions = ((WhereRuleChartDataEntity) firstElement).getIndicator().getJoinConditions();
        if (joinConditions != null && joinConditions.size() > 0) {
            JoinElement joinElement = joinConditions.get(0);
            list.add(RepositoryNodeHelper.recursiveFind(joinElement.getColA()));
            list.add(RepositoryNodeHelper.recursiveFind(joinElement.getColB()));
            return list.toArray(new IRepositoryNode[list.size()]);
        }
    // TDQ-4470 ~
    } else if (firstElement instanceof TdView) {
        // Added yyin 20120522 TDQ-4945, support tdView
        TdView view = (TdView) firstElement;
        EList<MetadataColumn> columns = view.getColumns();
        for (MetadataColumn column : columns) {
            RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(column);
            list.add(recursiveFind);
        }
        return list.toArray(new IRepositoryNode[list.size()]);
    }
    // ~
    return null;
}
Also used : TdTable(org.talend.cwm.relational.TdTable) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) JoinElement(org.talend.dataquality.rules.JoinElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) EList(org.eclipse.emf.common.util.EList) WhereRuleChartDataEntity(org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity) TdView(org.talend.cwm.relational.TdView) MetadataXmlElementType(org.talend.core.model.metadata.MetadataXmlElementType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ISubRepositoryObject(org.talend.core.model.repository.ISubRepositoryObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) EObject(org.eclipse.emf.ecore.EObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ArrayList(java.util.ArrayList) List(java.util.List) EList(org.eclipse.emf.common.util.EList)

Example 2 with MetadataXmlElementType

use of org.talend.core.model.metadata.MetadataXmlElementType 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)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 MetadataXmlElementType (org.talend.core.model.metadata.MetadataXmlElementType)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)2 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)2 IRepositoryNode (org.talend.repository.model.IRepositoryNode)2 EList (org.eclipse.emf.common.util.EList)1 EObject (org.eclipse.emf.ecore.EObject)1 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)1 ISubRepositoryObject (org.talend.core.model.repository.ISubRepositoryObject)1 RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)1 TdTableRepositoryObject (org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject)1 TdViewRepositoryObject (org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject)1 TdTable (org.talend.cwm.relational.TdTable)1 TdView (org.talend.cwm.relational.TdView)1 JoinElement (org.talend.dataquality.rules.JoinElement)1 WhereRuleChartDataEntity (org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity)1 DQRepositoryNode (org.talend.dq.nodes.DQRepositoryNode)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1