Search in sources :

Example 71 with NodeType

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

the class ChangeDefaultValue4JSONComponents method execute.

@Override
public ExecutionResult execute(Item item) {
    final ProcessType processType = getProcessType(item);
    String[] compNames = { "tFileInputJSON", "tExtractJSONFields", "tExtractAbstractJSONFields", "tFileInputJSON", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tInputFormatJSON" };
    IComponentConversion conversion = new IComponentConversion() {

        @Override
        public void transform(NodeType node) {
            if (node == null) {
                return;
            }
            //$NON-NLS-1$
            ElementParameterType parameter = ComponentUtilities.getNodeProperty(node, "READ_BY");
            if (parameter == null) {
                //$NON-NLS-1$ //$NON-NLS-2$
                ComponentUtilities.addNodeProperty(node, "READ_BY", "CLOSED_LIST");
                //$NON-NLS-1$ //$NON-NLS-2$
                ComponentUtilities.setNodeValue(node, "READ_BY", "XPATH");
            }
        }
    };
    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 72 with NodeType

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

the class ChangeDefaultValue4tLogRow method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    IComponentFilter filter = new NameComponentFilter("tLogRow");
    try {
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

            public void transform(NodeType node) {
                ElementParameterType printContent = ComponentUtilities.getNodeProperty(node, "PRINT_CONTENT_WITH_LOG4J");
                if (printContent == null) {
                    ComponentUtilities.addNodeProperty(node, "PRINT_CONTENT_WITH_LOG4J", "CHECK");
                    ComponentUtilities.getNodeProperty(node, "PRINT_CONTENT_WITH_LOG4J").setValue("false");
                }
            }
        }));
    } 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 73 with NodeType

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

the class ResetValuetInfiniteLoop method execute.

/*
     * (non-Javadoc)
     * 
     * @seeorg.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
     * ProcessItem)
     */
@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[] { "tInfiniteLoop" };
    try {
        for (int i = 0; i < componentsName.length; i++) {
            IComponentFilter filter = new NameComponentFilter(componentsName[i]);
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

                public void transform(NodeType node) {
                    if (ComponentUtilities.getNodeProperty(node, "WAIT") != null) {
                        int time = Integer.valueOf(ComponentUtilities.getNodeProperty(node, "WAIT").getValue());
                        ComponentUtilities.addNodeProperty(node, "WAIT_MS", "TEXT");
                        ComponentUtilities.getNodeProperty(node, "WAIT_MS").setValue(String.valueOf(time * 1000));
                        ComponentUtilities.removeNodeProperty(node, "WAIT");
                    }
                }
            }));
        }
        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) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 74 with NodeType

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

the class ReviewPigLoadLayout method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType != null) {
        try {
            //$NON-NLS-1$
            IComponentFilter filter = new NameComponentFilter("tPigLoad");
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

                @Override
                public void transform(NodeType node) {
                    //$NON-NLS-1$
                    ElementParameterType mr = ComponentUtilities.getNodeProperty(node, "MAPREDUCE");
                    //$NON-NLS-1$
                    ElementParameterType tez = ComponentUtilities.getNodeProperty(node, "TEZ");
                    //$NON-NLS-1$ //$NON-NLS-2$
                    ComponentUtilities.addNodeProperty(node, "ENGINE", "CLOSED_LIST");
                    if ("true".equalsIgnoreCase(mr.getValue())) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$ //$NON-NLS-2$
                        ComponentUtilities.getNodeProperty(node, "ENGINE").setValue("MAPREDUCE");
                    } else if ("true".equalsIgnoreCase(tez.getValue())) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$ //$NON-NLS-2$
                        ComponentUtilities.getNodeProperty(node, "ENGINE").setValue("TEZ");
                    }
                    //$NON-NLS-1$
                    ComponentUtilities.removeNodeProperty(node, "MAPREDUCE");
                    //$NON-NLS-1$
                    ComponentUtilities.removeNodeProperty(node, "TEZ");
                }
            }));
            return ExecutionResult.SUCCESS_NO_ALERT;
        } catch (Exception e) {
            CommonExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
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) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 75 with NodeType

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

the class ReplaceRunJobLabelVariableMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
    try {
        List<NodeType> nodes = null;
        if (item instanceof ProcessItem) {
            nodes = ((ProcessItem) item).getProcess().getNode();
        } else if (item instanceof JobletProcessItem) {
            nodes = ((JobletProcessItem) item).getJobletProcess().getNode();
        }
        if (nodes != null) {
            boolean modified = false;
            for (NodeType node : nodes) {
                if (ModifyComponentsAction.searchAndModify(node, filter, Arrays.<IComponentConversion>asList(replaceConversion))) {
                    modified = true;
                }
            }
            if (modified) {
                IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                factory.save(item, true);
            }
        }
        return ExecutionResult.SUCCESS_WITH_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) MalformedPatternException(org.apache.oro.text.regex.MalformedPatternException)

Aggregations

NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)198 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)157 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)127 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)112 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)111 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)110 PersistenceException (org.talend.commons.exception.PersistenceException)93 ProcessItem (org.talend.core.model.properties.ProcessItem)25 ArrayList (java.util.ArrayList)24 EList (org.eclipse.emf.common.util.EList)23 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)21 List (java.util.List)20 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)19 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)18 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)13 MetadataType (org.talend.designer.core.model.utils.emf.talendfile.MetadataType)13 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)13 IComponent (org.talend.core.model.components.IComponent)10 ColumnType (org.talend.designer.core.model.utils.emf.talendfile.ColumnType)9 Property (org.talend.core.model.properties.Property)8