Search in sources :

Example 16 with GenericConnection

use of org.talend.repository.generic.model.genericMetadata.GenericConnection in project tdi-studio-se by Talend.

the class GenericDragAndDropHandler method getCorrespondingComponentName.

@Override
public IComponentName getCorrespondingComponentName(Item item, ERepositoryObjectType type) {
    RepositoryComponentSetting setting = null;
    List<Class<Item>> list = new ArrayList<Class<Item>>();
    if (item instanceof GenericConnectionItem) {
        GenericConnection connection = (GenericConnection) ((GenericConnectionItem) item).getConnection();
        setting = new RepositoryComponentSetting();
        setting.setWithSchema(true);
        String componentMainName = getComponentMainName(connection);
        setting.setInputComponent(getInputComponentName(componentMainName));
        setting.setOutputComponent(getOutputComponentName(componentMainName));
        Class clazz = null;
        try {
            clazz = Class.forName(GenericConnectionItem.class.getName());
        } catch (ClassNotFoundException e) {
            ExceptionHandler.process(e);
        }
        list.add(clazz);
        setting.setClasses(list.toArray(new Class[0]));
    }
    return setting;
}
Also used : GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) RepositoryComponentSetting(org.talend.core.repository.RepositoryComponentSetting) ArrayList(java.util.ArrayList) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem)

Example 17 with GenericConnection

use of org.talend.repository.generic.model.genericMetadata.GenericConnection 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 18 with GenericConnection

use of org.talend.repository.generic.model.genericMetadata.GenericConnection in project tdi-studio-se by Talend.

the class GenericWizardService method getConnectionProperties.

@Override
public String getConnectionProperties(Connection connection) {
    if (isGenericConnection(connection)) {
        GenericConnection genericConnection = (GenericConnection) connection;
        String compProperties = genericConnection.getCompProperties();
        return compProperties;
    }
    return null;
}
Also used : GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection)

Example 19 with GenericConnection

use of org.talend.repository.generic.model.genericMetadata.GenericConnection in project tdi-studio-se by Talend.

the class GenericWizardService method getAllComponentProperties.

@Override
public List<ComponentProperties> getAllComponentProperties(Connection connection, String tableLabel) {
    List<ComponentProperties> componentProperties = new ArrayList<>();
    if (isGenericConnection(connection)) {
        GenericConnection genericConnection = (GenericConnection) connection;
        String compProperties = genericConnection.getCompProperties();
        ComponentProperties cp = ComponentsUtils.getComponentPropertiesFromSerialized(compProperties, connection, false);
        if (cp != null) {
            componentProperties.add(cp);
        }
        List<MetadataTable> metadataTables;
        if (tableLabel == null) {
            metadataTables = SchemaUtils.getMetadataTables(genericConnection, SubContainer.class);
        } else {
            metadataTables = Arrays.asList(SchemaUtils.getMetadataTable(genericConnection, tableLabel, SubContainer.class));
        }
        for (MetadataTable metadataTable : metadataTables) {
            if (metadataTable == null) {
                continue;
            }
            for (TaggedValue taggedValue : metadataTable.getTaggedValue()) {
                if (IComponentConstants.COMPONENT_PROPERTIES_TAG.equals(taggedValue.getTag())) {
                    ComponentProperties compPros = ComponentsUtils.getComponentPropertiesFromSerialized(taggedValue.getValue(), connection, false);
                    if (compPros != null && !componentProperties.contains(compPros)) {
                        compPros.updateNestedProperties(cp);
                        componentProperties.add(compPros);
                    }
                }
            }
        }
    }
    return componentProperties;
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) TaggedValue(orgomg.cwm.objectmodel.core.TaggedValue) ArrayList(java.util.ArrayList) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) SubContainer(org.talend.repository.generic.model.genericMetadata.SubContainer)

Example 20 with GenericConnection

use of org.talend.repository.generic.model.genericMetadata.GenericConnection in project tdi-studio-se by Talend.

the class GenericConnectionUtil method synNamePropertyWithItem.

/**
     * Syncronize the value of <code>name</code> property between component properties and connection item.
     * 
     * @param item the item which name property belong to.
     * @return return true if property is updated, otherwise return false;
     */
public static boolean synNamePropertyWithItem(GenericConnectionItem item) {
    GenericConnection connection = (GenericConnection) item.getConnection();
    String compPropertiesStr = connection.getCompProperties();
    if (compPropertiesStr == null) {
        return false;
    }
    ComponentProperties componentProperties = ComponentsUtils.getComponentPropertiesFromSerialized(compPropertiesStr, connection);
    if (componentProperties == null) {
        return false;
    }
    Property nameProperty = (Property) componentProperties.getProperty(IGenericConstants.NAME_PROPERTY);
    if (nameProperty == null) {
        return false;
    }
    Object namePropertyVal = nameProperty.getValue();
    String newName = item.getProperty().getLabel();
    if (newName != null && !newName.equals(namePropertyVal)) {
        nameProperty.setValue(newName);
        connection.setCompProperties(componentProperties.toSerialized());
        return true;
    }
    return false;
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) Property(org.talend.daikon.properties.property.Property)

Aggregations

GenericConnection (org.talend.repository.generic.model.genericMetadata.GenericConnection)24 ComponentProperties (org.talend.components.api.properties.ComponentProperties)11 GenericConnectionItem (org.talend.repository.generic.model.genericMetadata.GenericConnectionItem)10 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 ConnectionItem (org.talend.core.model.properties.ConnectionItem)5 IComponent (org.talend.core.model.components.IComponent)4 Connection (org.talend.core.model.metadata.builder.connection.Connection)4 IConnParamName (org.talend.metadata.managment.ui.model.IConnParamName)4 Path (org.eclipse.core.runtime.Path)3 ComponentService (org.talend.components.api.service.ComponentService)3 ComponentWizard (org.talend.components.api.wizard.ComponentWizard)3 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)3 INode (org.talend.core.model.process.INode)3 Property (org.talend.core.model.properties.Property)3 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)3 Node (org.talend.designer.core.ui.editor.nodes.Node)3 Process (org.talend.designer.core.ui.editor.process.Process)3 GenericConnParamName (org.talend.metadata.managment.ui.utils.GenericConnParamName)3