Search in sources :

Example 21 with MetadataColumnRepositoryObject

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

the class ExportItemWizardPage method checkElement.

private void checkElement(Object obj, Set<Object> nodes) {
    if (obj == null) {
        return;
    }
    if (obj instanceof RepositoryNode) {
        Object repositoryNode = null;
        RepositoryNode node = (RepositoryNode) obj;
        ERepositoryObjectType objectType = node.getObjectType();
        Property property = null;
        if (objectType != null) {
            if (objectType == ERepositoryObjectType.METADATA_CON_TABLE || objectType == ERepositoryObjectType.METADATA_CON_VIEW || objectType == ERepositoryObjectType.METADATA_CON_SYNONYM || objectType == ERepositoryObjectType.METADATA_CON_QUERY) {
                if (node.getObject() != null) {
                    property = node.getObject().getProperty();
                }
            } else if (objectType == ERepositoryObjectType.METADATA_CON_COLUMN) {
                if (node.getObject() != null && (node.getObject() instanceof MetadataColumnRepositoryObject)) {
                    IRepositoryViewObject viewObj = ((MetadataColumnRepositoryObject) node.getObject()).getViewObject();
                    if (viewObj != null) {
                        property = viewObj.getProperty();
                    }
                }
            }
        }
        if (property != null) {
            repositoryNode = RepositoryNodeUtilities.getRepositoryNode(property.getId(), false);
            if (repositoryNode != null) {
                nodes.add(repositoryNode);
            }
        } else {
            nodes.add(node);
        }
    } else {
        nodes.add(obj);
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Property(org.talend.core.model.properties.Property)

Example 22 with MetadataColumnRepositoryObject

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

the class GenericDragAndDropHandler method isValid.

private boolean isValid(RepositoryNode seletetedNode, IComponent component) {
    // TUP-4151
    IRepositoryViewObject object = seletetedNode.getObject();
    if (component == null || object == null) {
        return false;
    }
    ComponentProperties currentComponentProperties = null;
    if (object instanceof RepositoryViewObject) {
        RepositoryViewObject repositoryViewObj = (RepositoryViewObject) object;
        Connection connection = ((ConnectionItem) repositoryViewObj.getProperty().getItem()).getConnection();
        if (canHandle(connection)) {
            GenericConnection genericConnection = (GenericConnection) connection;
            currentComponentProperties = ComponentsUtils.getComponentPropertiesFromSerialized(genericConnection.getCompProperties(), connection);
        }
    } else if (object instanceof MetadataTableRepositoryObject) {
        MetadataTableRepositoryObject metaTableRepObj = (MetadataTableRepositoryObject) object;
        currentComponentProperties = SchemaUtils.getCurrentComponentProperties(metaTableRepObj);
    } else if (object instanceof MetadataColumnRepositoryObject) {
        MetadataColumnRepositoryObject metaColumnRepObj = (MetadataColumnRepositoryObject) object;
        ModelElement element = metaColumnRepObj.getTdColumn();
        if (element != null && element.eContainer() instanceof MetadataTable) {
            MetadataTable metadataTable = (MetadataTable) element.eContainer();
            IMetadataTable newTable = MetadataToolHelper.convert(metadataTable);
            currentComponentProperties = SchemaUtils.getCurrentComponentProperties(newTable);
        }
    }
    if (currentComponentProperties != null) {
        try {
            List<ComponentDefinition> possibleComponents = ComponentsUtils.getComponentService().getPossibleComponents(currentComponentProperties);
            if (component instanceof Component) {
                ComponentDefinition componentDefinition = ((Component) component).getComponentDefinition();
                return possibleComponents.contains(componentDefinition);
            }
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    return false;
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) IComponent(org.talend.core.model.components.IComponent) Component(org.talend.designer.core.generic.model.Component) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) ComponentDefinition(org.talend.components.api.component.ComponentDefinition)

Example 23 with MetadataColumnRepositoryObject

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

the class RepositoryNodeHelper method getColumnOwner.

public static ColumnSet getColumnOwner(RepositoryNode node) {
    if (node == null) {
        return null;
    }
    MetadataColumnRepositoryObject columnObject = (MetadataColumnRepositoryObject) node.getObject();
    TdColumn column = ((TdColumn) columnObject.getTdColumn());
    if (column != null && column.eIsProxy()) {
        column = (TdColumn) EObjectHelper.resolveObject(column);
    }
    return ColumnHelper.getColumnOwnerAsColumnSet(column);
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)

Example 24 with MetadataColumnRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject 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 25 with MetadataColumnRepositoryObject

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

the class RepositoryNodeHelper method createMetadataColumnRepNode.

/**
 * create a temp RepNode there is a lack of parent attribute
 *
 * @param findColumn
 */
private static DBColumnRepNode createMetadataColumnRepNode(TdColumn findColumn, IRepositoryViewObject lastVersion) {
    MetadataColumnRepositoryObject metadataColumn = new MetadataColumnRepositoryObject(lastVersion, findColumn);
    metadataColumn.setId(findColumn.getName());
    metadataColumn.setLabel(findColumn.getName());
    DBColumnRepNode columnNode = new DBColumnRepNode(metadataColumn, null, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
    columnNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_COLUMN);
    columnNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_COLUMN);
    metadataColumn.setRepositoryNode(columnNode);
    return columnNode;
}
Also used : MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode)

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