Search in sources :

Example 21 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class MissingSettingsMultiThreadDynamicComposite method afterCreateMessagesComposite.

@Override
public void afterCreateMessagesComposite(MessagesComposite messComposite) {
    final Element ele = this.getElement();
    if (ele instanceof Node && isVisibleTopMessages()) {
        final IComponent component = ((Node) ele).getComponent();
        messComposite.updateTopMessages(//$NON-NLS-1$
        Messages.getString(//$NON-NLS-1$
        "MissingSettingsMultiThreadDynamicComposite_missingModulesMessages", component.getName()), IStatus.WARNING);
        if (messComposite instanceof MessagesWithActionComposite) {
            MessagesWithActionComposite messWithActionComposite = (MessagesWithActionComposite) messComposite;
            messWithActionComposite.updateActionButton(//$NON-NLS-1$
            Messages.getString("MissingSettingsMultiThreadDynamicComposite.installName") + "...", //$NON-NLS-1$
            null);
            messWithActionComposite.addActionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (!missModulesNeeded.isEmpty()) {
                        ModulesInstallerUtil.forceInstallModules(getShell(), component, missModulesNeeded);
                        checkVisibleTopMessages();
                    }
                }
            });
        }
    }
    super.afterCreateMessagesComposite(messComposite);
}
Also used : IComponent(org.talend.core.model.components.IComponent) Element(org.talend.core.model.process.Element) Node(org.talend.designer.core.ui.editor.nodes.Node) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MessagesWithActionComposite(org.talend.commons.ui.swt.composites.MessagesWithActionComposite)

Example 22 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class FixWrongDbTypesMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    boolean modified = false;
    for (Object nodeTypeObject : processType.getNode()) {
        NodeType nodeType = (NodeType) nodeTypeObject;
        IComponent component = ComponentsFactoryProvider.getInstance().get(nodeType.getComponentName(), ComponentCategory.CATEGORY_4_DI.getName());
        if (component == null) {
            // in case original component doesn't exist here
            continue;
        }
        FakeNode fNode = new FakeNode(component);
        IElementParameter mappingParameter = fNode.getElementParameterFromField(EParameterFieldType.MAPPING_TYPE);
        if (mappingParameter != null && mappingParameter.getValue() != null) {
            String mappingParameterValue = (String) mappingParameter.getValue();
            MappingTypeRetriever mtr = MetadataTalendType.getMappingTypeRetriever(mappingParameterValue);
            if (mtr == null) {
                continue;
            }
            for (Object metadataObject : nodeType.getMetadata()) {
                MetadataType metadataType = (MetadataType) metadataObject;
                for (Object columnObject : metadataType.getColumn()) {
                    ColumnType columnType = (ColumnType) columnObject;
                    if (columnType.getSourceType() != null && !"".equals(columnType.getSourceType())) {
                        if (mtr.isAdvicedTalendToDbType(columnType.getType(), columnType.getSourceType())) {
                            // correct type already, no need to do anything
                            continue;
                        }
                        List<MappingType> advicedTalendToDbTypes = mtr.getAdvicedTalendToDbTypes(columnType.getType());
                        if (advicedTalendToDbTypes == null) {
                            continue;
                        }
                        String dbType = columnType.getSourceType();
                        for (MappingType type : advicedTalendToDbTypes) {
                            if (type.getDbType().equalsIgnoreCase(dbType)) {
                                columnType.setSourceType(type.getDbType());
                                modified = true;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    if (modified) {
        try {
            ProxyRepositoryFactory.getInstance().save(item, true);
            return ExecutionResult.SUCCESS_NO_ALERT;
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : MappingType(org.talend.core.model.metadata.MappingType) ColumnType(org.talend.designer.core.model.utils.emf.talendfile.ColumnType) MappingTypeRetriever(org.talend.core.model.metadata.MappingTypeRetriever) IComponent(org.talend.core.model.components.IComponent) MetadataType(org.talend.designer.core.model.utils.emf.talendfile.MetadataType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 23 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class StatsAndLogsManager method createLogsNode.

private static DataNode createLogsNode(boolean useFile, boolean console, String dbOutput) {
    JobLogsComponent logsComponent = new JobLogsComponent(useFile, console, dbOutput);
    DataNode logsNode = new DataNode(logsComponent, LOG_UNIQUE_NAME);
    logsNode.setStart(true);
    logsNode.setSubProcessStart(true);
    logsNode.setActivate(true);
    logsNode.getMetadataList().clear();
    // load the tLogCatcher to get the schema.
    IComponent tmpComponent = ComponentsFactoryProvider.getInstance().get("tLogCatcher", //$NON-NLS-1$
    ComponentCategory.CATEGORY_4_DI.getName());
    //$NON-NLS-1$
    DataNode tmpNode = new DataNode(tmpComponent, "tmp");
    boolean found = false;
    for (int k = 0; k < tmpNode.getElementParameters().size() && !found; k++) {
        IElementParameter currentParam = tmpNode.getElementParameters().get(k);
        if (currentParam.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || currentParam.getFieldType().equals(EParameterFieldType.SCHEMA_REFERENCE)) {
            Object value = currentParam.getValue();
            if (value instanceof IMetadataTable) {
                IMetadataTable table = ((IMetadataTable) value).clone();
                table.setTableName(LOG_UNIQUE_NAME);
                table.setAttachedConnector(currentParam.getContext());
                logsNode.getMetadataList().add(table);
            }
            found = true;
        }
    }
    return logsNode;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) DataNode(org.talend.designer.core.model.process.DataNode) IComponent(org.talend.core.model.components.IComponent) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 24 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class StatsAndLogsManager method createStatsNode.

private static DataNode createStatsNode(boolean useFile, boolean console, String dbOutput) {
    JobStatsComponent statsComponent = new JobStatsComponent(useFile, console, dbOutput);
    DataNode statsNode = new DataNode(statsComponent, STAT_UNIQUE_NAME);
    statsNode.setStart(true);
    statsNode.setSubProcessStart(true);
    statsNode.setActivate(true);
    statsNode.getMetadataList().clear();
    // load the tStatCatcher to get the schema.
    IComponent tmpComponent = ComponentsFactoryProvider.getInstance().get("tStatCatcher", //$NON-NLS-1$
    ComponentCategory.CATEGORY_4_DI.getName());
    //$NON-NLS-1$
    DataNode tmpNode = new DataNode(tmpComponent, "tmp");
    boolean found = false;
    for (int k = 0; k < tmpNode.getElementParameters().size() && !found; k++) {
        IElementParameter currentParam = tmpNode.getElementParameters().get(k);
        if (currentParam.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || currentParam.getFieldType().equals(EParameterFieldType.SCHEMA_REFERENCE)) {
            Object value = currentParam.getValue();
            if (value instanceof IMetadataTable) {
                IMetadataTable table = ((IMetadataTable) value).clone();
                table.setTableName(STAT_UNIQUE_NAME);
                table.setAttachedConnector(currentParam.getContext());
                statsNode.getMetadataList().add(table);
            }
            found = true;
        }
    }
    return statsNode;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) DataNode(org.talend.designer.core.model.process.DataNode) IComponent(org.talend.core.model.components.IComponent) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 25 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class Connection method createParallelizeParameters.

private void createParallelizeParameters() {
    // flag for start the parlization or not for the inputs
    ElementParameter tmpParam = new ElementParameter(this);
    tmpParam.setName(EParameterName.PARTITIONER.getName());
    tmpParam.setValue(Boolean.FALSE);
    tmpParam.setDisplayName(EParameterName.PARTITIONER.getDisplayName());
    tmpParam.setFieldType(EParameterFieldType.RADIO);
    tmpParam.setCategory(EComponentCategory.PARALLELIZATION);
    tmpParam.setNumRow(1);
    tmpParam.setReadOnly(false);
    tmpParam.setRequired(false);
    //$NON-NLS-1$
    tmpParam.setGroup("TYPE");
    tmpParam.setGroupDisplayName("Type");
    tmpParam.setShowIf("(#NODE@OUT.END_OF_FLOW == 'false' OR #NODE@IN.SUBTREE_START == 'true')");
    tmpParam.setDefaultValue(tmpParam.getValue());
    addElementParameter(tmpParam);
    tmpParam = new ElementParameter(this);
    tmpParam.setName(EParameterName.DEPARTITIONER.getName());
    tmpParam.setValue(Boolean.FALSE);
    tmpParam.setDisplayName(EParameterName.DEPARTITIONER.getDisplayName());
    tmpParam.setFieldType(EParameterFieldType.RADIO);
    tmpParam.setCategory(EComponentCategory.PARALLELIZATION);
    tmpParam.setNumRow(2);
    tmpParam.setReadOnly(false);
    tmpParam.setRequired(false);
    tmpParam.setShowIf("#NODE@IN.SUBTREE_START == 'false'");
    //$NON-NLS-1$
    tmpParam.setGroup("TYPE");
    tmpParam.setGroupDisplayName("Type");
    tmpParam.setDefaultValue(tmpParam.getValue());
    addElementParameter(tmpParam);
    tmpParam = new ElementParameter(this);
    tmpParam.setName(EParameterName.REPARTITIONER.getName());
    tmpParam.setValue(Boolean.FALSE);
    tmpParam.setDisplayName(EParameterName.REPARTITIONER.getDisplayName());
    tmpParam.setFieldType(EParameterFieldType.RADIO);
    tmpParam.setCategory(EComponentCategory.PARALLELIZATION);
    tmpParam.setNumRow(3);
    tmpParam.setReadOnly(false);
    tmpParam.setRequired(false);
    tmpParam.setShowIf("(#NODE@IN.SUBTREE_START == 'false' AND #NODE@OUT.END_OF_FLOW == 'false')");
    //$NON-NLS-1$
    tmpParam.setGroup("TYPE");
    tmpParam.setGroupDisplayName("Type");
    tmpParam.setDefaultValue(tmpParam.getValue());
    addElementParameter(tmpParam);
    tmpParam = new ElementParameter(this);
    tmpParam.setName(EParameterName.NONE.getName());
    tmpParam.setValue(Boolean.TRUE);
    tmpParam.setDisplayName(EParameterName.NONE.getDisplayName());
    tmpParam.setFieldType(EParameterFieldType.RADIO);
    tmpParam.setCategory(EComponentCategory.PARALLELIZATION);
    tmpParam.setNumRow(4);
    tmpParam.setReadOnly(false);
    tmpParam.setRequired(false);
    tmpParam.setShow(true);
    //$NON-NLS-1$
    tmpParam.setGroup("TYPE");
    tmpParam.setGroupDisplayName("Type");
    tmpParam.setDefaultValue(tmpParam.getValue());
    addElementParameter(tmpParam);
    IComponent componentPar = ComponentsFactoryProvider.getInstance().get("tPartitioner", ComponentCategory.CATEGORY_4_DI.getName());
    INode tmpNode = new DataNode(componentPar, source.getUniqueName());
    tmpParam = (ElementParameter) tmpNode.getElementParameter("NUM_PARTITIONS");
    tmpParam.setCategory(EComponentCategory.PARALLELIZATION);
    tmpParam.setShowIf("(PARTITIONER == 'true' or REPARTITIONER=='true')");
    tmpParam.setDefaultValue(tmpParam.getValue());
    addElementParameter(tmpParam);
    tmpParam = new ElementParameter(this);
    tmpParam.setName("PART_QUEUE_SIZE");
    tmpParam.setValue("1000");
    tmpParam.setDisplayName(EParameterName.QUEUE_SIZE.getDisplayName());
    tmpParam.setFieldType(EParameterFieldType.TEXT);
    tmpParam.setNumRow(45);
    tmpParam.setReadOnly(false);
    tmpParam.setRequired(false);
    tmpParam.setCategory(EComponentCategory.PARALLELIZATION);
    tmpParam.setShowIf("(PARTITIONER == 'true' or REPARTITIONER=='true') and (DEPARTITIONER=='false')");
    tmpParam.setDefaultValue(tmpParam.getValue());
    addElementParameter(tmpParam);
    tmpParam = (ElementParameter) tmpNode.getElementParameter("HASH_PARTITION");
    tmpParam.setCategory(EComponentCategory.PARALLELIZATION);
    tmpParam.setShowIf("(PARTITIONER == 'true' or REPARTITIONER=='true')");
    tmpParam.setDefaultValue(tmpParam.getValue());
    addElementParameter(tmpParam);
    tmpParam = (ElementParameter) tmpNode.getElementParameter("HASH_KEYS");
    tmpParam.setCategory(EComponentCategory.PARALLELIZATION);
    tmpParam.setShowIf("(PARTITIONER == 'true' or REPARTITIONER=='true') and (HASH_PARTITION=='true')");
    tmpParam.setDefaultValue(tmpParam.getValue());
    addElementParameter(tmpParam);
    tmpParam = new ElementParameter(this);
    tmpParam.setName("DEPART_QUEUE_SIZE");
    tmpParam.setValue("1000");
    tmpParam.setDisplayName(EParameterName.QUEUE_SIZE.getDisplayName());
    tmpParam.setFieldType(EParameterFieldType.TEXT);
    tmpParam.setNumRow(45);
    tmpParam.setReadOnly(false);
    tmpParam.setRequired(false);
    tmpParam.setCategory(EComponentCategory.PARALLELIZATION);
    // "(DEPARTITIONER == 'true' or REPARTITIONER=='true')"
    tmpParam.setShowIf("(DEPARTITIONER == 'true' or REPARTITIONER=='true') and (PARTITIONER=='false')");
    tmpParam.setDefaultValue(tmpParam.getValue());
    addElementParameter(tmpParam);
    IComponent componentCol = ComponentsFactoryProvider.getInstance().get("tRecollector", ComponentCategory.CATEGORY_4_DI.getName());
    INode tmpNode1 = new DataNode(componentCol, source.getUniqueName());
    tmpParam = (ElementParameter) tmpNode1.getElementParameter("IS_SORTING");
    tmpParam.setCategory(EComponentCategory.PARALLELIZATION);
    tmpParam.setShowIf("(DEPARTITIONER == 'true' or REPARTITIONER=='true')");
    tmpParam.setDefaultValue(tmpParam.getValue());
    addElementParameter(tmpParam);
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) INode(org.talend.core.model.process.INode) IComponent(org.talend.core.model.components.IComponent) DataNode(org.talend.designer.core.model.process.DataNode)

Aggregations

IComponent (org.talend.core.model.components.IComponent)146 Node (org.talend.designer.core.ui.editor.nodes.Node)54 ArrayList (java.util.ArrayList)47 IElementParameter (org.talend.core.model.process.IElementParameter)36 Process (org.talend.designer.core.ui.editor.process.Process)36 Test (org.junit.Test)35 INode (org.talend.core.model.process.INode)33 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)22 List (java.util.List)15 Property (org.talend.core.model.properties.Property)15 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)15 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)13 IComponentsFactory (org.talend.core.model.components.IComponentsFactory)12 Connection (org.talend.designer.core.ui.editor.connections.Connection)12 HashMap (java.util.HashMap)11 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)10 DataNode (org.talend.designer.core.model.process.DataNode)10 HashSet (java.util.HashSet)9 IConnection (org.talend.core.model.process.IConnection)9 Rectangle (org.eclipse.swt.graphics.Rectangle)8