Search in sources :

Example 76 with ProcessType

use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.

the class UpdateJobSettingsForOracleMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType.getParameters() != null) {
        @SuppressWarnings("rawtypes") EList elementParameter = processType.getParameters().getElementParameter();
        boolean modified = false;
        for (int i = 0; i < elementParameter.size(); i++) {
            final Object object = elementParameter.get(i);
            if (object instanceof ElementParameterTypeImpl) {
                ElementParameterTypeImpl parameterType = (ElementParameterTypeImpl) object;
                String name = parameterType.getName();
                if ("DB_VERSION_IMPLICIT_CONTEXT".equals(name)) {
                    //$NON-NLS-1$
                    modified = updateJarValue(parameterType) || modified;
                }
                if ("DB_VERSION".equals(name)) {
                    //$NON-NLS-1$
                    modified = updateJarValue(parameterType) || modified;
                }
            }
        }
        if (modified) {
            try {
                FACTORY.save(item, true);
                return ExecutionResult.SUCCESS_NO_ALERT;
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) EList(org.eclipse.emf.common.util.EList) PersistenceException(org.talend.commons.exception.PersistenceException) ElementParameterTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl)

Example 77 with ProcessType

use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.

the class UnifyParameterOfDatastaxAndHectorForCassandra method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    final ProcessType processType = getProcessType(item);
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
    String[] compNames = { "tCassandraInput", "tCassandraOutput", "tCassandraRow", "tCassandraLookupInput" };
    IComponentConversion conversion = new IComponentConversion() {

        @Override
        public void transform(NodeType node) {
            if (node == null) {
                return;
            }
            //$NON-NLS-1$
            ElementParameterType cf = ComponentUtilities.getNodeProperty(node, "TABLE");
            if (cf != null) {
                if (ComponentUtilities.getNodeProperty(node, "COLUMN_FAMILY") == null) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$ //$NON-NLS-2$
                    ComponentUtilities.addNodeProperty(node, "COLUMN_FAMILY", "TEXT");
                }
                //$NON-NLS-1$ 
                ComponentUtilities.getNodeProperty(node, "COLUMN_FAMILY").setValue(cf.getValue());
            }
            //$NON-NLS-1$
            ElementParameterType actionForCF = ComponentUtilities.getNodeProperty(node, "TABLE_ACTION");
            if (actionForCF != null) {
                if (ComponentUtilities.getNodeProperty(node, "ACTION_ON_COLUMN_FAMILY") == null) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$ //$NON-NLS-2$
                    ComponentUtilities.addNodeProperty(node, "ACTION_ON_COLUMN_FAMILY", "TEXT");
                }
                //$NON-NLS-1$ 
                ComponentUtilities.getNodeProperty(node, "ACTION_ON_COLUMN_FAMILY").setValue(actionForCF.getValue());
            }
        }
    };
    for (String name : compNames) {
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(conversion));
        } catch (PersistenceException e) {
            // TODO Auto-generated catch block
            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) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) 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 78 with ProcessType

use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.

the class UpdateKakfaInputConsumerTimeoutAndAutoOffsetTask method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    try {
        //$NON-NLS-1$
        IComponentFilter filter = new NameComponentFilter("tKafkaInput");
        IComponentConversion addOption = new UpdateKakfaInputConversion();
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(addOption));
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 79 with ProcessType

use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.

the class StripslachesOnQuotesForTCollectAndCheck method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    try {
        IComponentFilter filter = new NameComponentFilter("tCollectAndCheck");
        IComponentConversion addOption = new StripslachesOnQuotesForTCollectAndCheckConversion();
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(addOption));
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 80 with ProcessType

use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.

the class UpgradetAdvancedFileOutputXMLMigrationTask method execute.

public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        //$NON-NLS-1$
        IComponentFilter filter1 = new NameComponentFilter("tAdvancedFileOutputXML");
        //$NON-NLS-1$
        IComponentConversion removeQuotes1 = new UpdateMappingFortAdvancedXMLConversion();
        ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(removeQuotes1));
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) UpdateMappingFortAdvancedXMLConversion(org.talend.core.model.components.conversions.UpdateMappingFortAdvancedXMLConversion) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Aggregations

ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)244 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)157 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)155 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)153 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)145 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)115 PersistenceException (org.talend.commons.exception.PersistenceException)109 ProcessItem (org.talend.core.model.properties.ProcessItem)29 ArrayList (java.util.ArrayList)24 EList (org.eclipse.emf.common.util.EList)23 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)22 List (java.util.List)18 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)16 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)14 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)14 RenameComponentConversion (org.talend.core.model.components.conversions.RenameComponentConversion)12 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)12 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)12 HashMap (java.util.HashMap)10 IComponent (org.talend.core.model.components.IComponent)10