Search in sources :

Example 6 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)

Aggregations

IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)6 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)3 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)2 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)2 ComponentDefinition (org.talend.components.api.component.ComponentDefinition)1 ComponentProperties (org.talend.components.api.properties.ComponentProperties)1 IComponent (org.talend.core.model.components.IComponent)1 Connection (org.talend.core.model.metadata.builder.connection.Connection)1 SAPFunctionUnit (org.talend.core.model.metadata.builder.connection.SAPFunctionUnit)1 SAPTable (org.talend.core.model.metadata.builder.connection.SAPTable)1 ConnectionItem (org.talend.core.model.properties.ConnectionItem)1 Property (org.talend.core.model.properties.Property)1 RepositoryObject (org.talend.core.model.repository.RepositoryObject)1 RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)1 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)1 SAPFunctionRepositoryObject (org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject)1 SAPIDocRepositoryObject (org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject)1 ICDCProviderService (org.talend.core.ui.ICDCProviderService)1