Search in sources :

Example 36 with IComponentFilter

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

the class MigrationTaskForIssue11632 method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    IComponentFilter filter = new NameComponentFilter("tLDAPOutput");
    try {
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

            public void transform(NodeType node) {
                if (ComponentUtilities.getNodeProperty(node, "USE_ATTRIBUTE_OPTIONS") == null) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$ //$NON-NLS-2$
                    ComponentUtilities.addNodeProperty(node, "USE_ATTRIBUTE_OPTIONS", "CHECK");
                }
                ElementParameterType useAttributeOptions = ComponentUtilities.getNodeProperty(node, //$NON-NLS-1$
                "USE_ATTRIBUTE_OPTIONS");
                //$NON-NLS-1$
                ElementParameterType attributeOptions = ComponentUtilities.getNodeProperty(node, "ATTRIBUTE_OPTIONS");
                if (attributeOptions == null) {
                    //$NON-NLS-1$
                    useAttributeOptions.setValue("false");
                } else {
                    if (attributeOptions.getElementValue().size() == 0) {
                        //$NON-NLS-1$
                        useAttributeOptions.setValue("false");
                    } else {
                        //$NON-NLS-1$
                        useAttributeOptions.setValue("true");
                    }
                }
            }
        }));
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 37 with IComponentFilter

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

the class MigrationTaskForIssue18419 method execute.

@Override
public ExecutionResult execute(final Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    //$NON-NLS-1$
    IComponentFilter filter = new NameComponentFilter("tFileUnarchive");
    try {
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

            @Override
            public void transform(NodeType node) {
                Project pro = ProxyRepositoryFactory.getInstance().getProject(item);
                String proName = pro.getLabel();
                //$NON-NLS-1$
                ElementParameterType zipFile = ComponentUtilities.getNodeProperty(node, "ZIPFILE");
                String zipFileName = zipFile.getValue();
                final String oldValues = getOldValues();
                if (proName != null && !proName.equals(getDemoProjectName()) && zipFileName != null && zipFileName.equals(oldValues)) {
                    zipFile.setValue(oldValues.replaceFirst(getDemoProjectName(), proName));
                }
            }
        }));
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) Project(org.talend.core.model.properties.Project) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 38 with IComponentFilter

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

the class MigrationTaskForIssue4449 method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    String[] componentsName = new String[] { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tMSSqlOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tMaxDBOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tMysqlOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tInformixOutput", "tOracleOutput", "tPostgresqlOutput", "tPostgresPlusOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tSybaseOutput" };
    IComponentConversion updateTableActionOption = new UpdatePropertyTruncateOptionConversion();
    for (String name : componentsName) {
        //$NON-NLS-1$
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(updateTableActionOption));
        } catch (PersistenceException e) {
            // TODO Auto-generated catch block
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.SUCCESS_WITH_ALERT;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) UpdatePropertyTruncateOptionConversion(org.talend.core.model.components.conversions.UpdatePropertyTruncateOptionConversion) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 39 with IComponentFilter

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

the class MigrationTaskForIssue7547 method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    //$NON-NLS-1$
    IComponentFilter filter = new NameComponentFilter("tAlfrescoOutput");
    try {
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

            public void transform(NodeType node) {
                //$NON-NLS-1$
                ElementParameterType url = ComponentUtilities.getNodeProperty(node, "ALFRESCO_SERVER_URL");
                //$NON-NLS-1$
                ElementParameterType userLogin = ComponentUtilities.getNodeProperty(node, "ALFRESCO_USER_LOGIN");
                ElementParameterType userPassword = ComponentUtilities.getNodeProperty(node, //$NON-NLS-1$
                "ALFRESCO_USER_PASSWORD");
                //$NON-NLS-1$ //$NON-NLS-2$
                url.setValue("\"" + url.getValue() + "\"");
                //$NON-NLS-1$ //$NON-NLS-2$
                userLogin.setValue("\"" + userLogin.getValue() + "\"");
                //$NON-NLS-1$ //$NON-NLS-2$
                userPassword.setValue("\"" + userPassword.getValue() + "\"");
            }
        }));
    } catch (PersistenceException e) {
        // TODO Auto-generated catch block
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.SUCCESS_WITH_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 40 with IComponentFilter

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

the class MigrateDeprecatedHadoopDistribution1 method searchAndModify.

private void searchAndModify(String[] components, Item item, ProcessType processType, IComponentConversion conversion) throws PersistenceException {
    for (String name : components) {
        IComponentFilter filter = new NameComponentFilter(name);
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(conversion));
    }
}
Also used : IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter)

Aggregations

IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)152 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)151 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)150 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)143 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)109 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)83 PersistenceException (org.talend.commons.exception.PersistenceException)76 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)15 RenameComponentConversion (org.talend.core.model.components.conversions.RenameComponentConversion)12 ArrayList (java.util.ArrayList)10 RemovePropertyComponentConversion (org.talend.core.model.components.conversions.RemovePropertyComponentConversion)9 List (java.util.List)7 PropertyComponentFilter (org.talend.core.model.components.filters.PropertyComponentFilter)6 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)5 HashMap (java.util.HashMap)3 EConnectionType (org.talend.core.model.process.EConnectionType)3 MetadataType (org.talend.designer.core.model.utils.emf.talendfile.MetadataType)3 ComponentProperties (org.talend.components.api.properties.ComponentProperties)2 AddPropertyCSVOptionConversion (org.talend.core.model.components.conversions.AddPropertyCSVOptionConversion)2 AddPropertyLoopTypeConversion (org.talend.core.model.components.conversions.AddPropertyLoopTypeConversion)2