Search in sources :

Example 16 with IComponentFilter

use of org.talend.core.model.components.filters.IComponentFilter 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 17 with IComponentFilter

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

the class SetUrltStewardshipXXXTDI32354 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[] { "tStewardshipTaskInput", "tStewardshipTaskOutput", "tStewardshipTaskDelete" };
    IComponentConversion changeDeletEmptyFileValue = new IComponentConversion() {

        public void transform(NodeType node) {
            ElementParameterType host = ComponentUtilities.getNodeProperty(node, "HOST");
            ElementParameterType port = ComponentUtilities.getNodeProperty(node, "PORT");
            String url = "";
            if (host != null && port != null) {
                if ("tStewardshipTaskOutput".equals(node.getComponentName())) {
                    url = "\"http://\" + " + host.getValue() + " + \":\" + " + port.getValue() + " + \"/talendmdm/services/dsctaskloader\"";
                } else {
                    url = "\"http://\" + " + host.getValue() + " + \":\" + " + port.getValue() + " + \"/talendmdm/services/TDSCWS?wsdl\"";
                }
            }
            ElementParameterType serverVersion = ComponentUtilities.getNodeProperty(node, "URL");
            if (serverVersion == null) {
                ComponentUtilities.addNodeProperty(node, "URL", "TEXT");
                serverVersion = ComponentUtilities.getNodeProperty(node, "URL");
                serverVersion.setValue(url);
            }
        }
    };
    for (String name : componentsName) {
        //$NON-NLS-1$
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeDeletEmptyFileValue));
        } catch (PersistenceException e) {
            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) 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 18 with IComponentFilter

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

the class SettingValuesIntoHadoopPropertiesFortHiveConnection method execute.

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

            public void transform(NodeType node) {
                //$NON-NLS-1$ //$NON-NLS-2$
                ElementParameterType useExistingConn = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION");
                if (useExistingConn != null && "true".equalsIgnoreCase(useExistingConn.getValue())) {
                    //$NON-NLS-1$
                    ElementParameterType connNamePara = ComponentUtilities.getNodeProperty(node, "CONNECTION");
                    if (connNamePara != null) {
                        NodeType tHiveConnNode = searchNodeTypeByUniqName(processType, connNamePara.getValue());
                        moveValuesFromHiveMap2HiveConn(node, tHiveConnNode);
                    }
                }
            }
        }));
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (PersistenceException e) {
        // TODO Auto-generated catch block
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
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 19 with IComponentFilter

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

the class SetDefaultValue4tWriteJSONFieldGroupByOutput method execute.

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

            public void transform(NodeType node) {
                EList<ElementValueType> list = ComponentUtilities.getNodeProperty(node, "GROUPBYS").getElementValue();
                ElementValueType outputColumnPropertyElement = null;
                int size = list.size();
                if (list != null && size > 0) {
                    String outputFieldValue = ComponentUtilities.getNodeProperty(node, "JSONFIELD").getValue();
                    for (int i = 0, j = 0; i < size; i++) {
                        outputColumnPropertyElement = TalendFileFactory.eINSTANCE.createElementValueType();
                        //$NON-NLS-1$
                        outputColumnPropertyElement.setElementRef("OUTPUT_COLUMN");
                        outputColumnPropertyElement.setValue(outputFieldValue);
                        list.add(j, outputColumnPropertyElement);
                        j = j + 2;
                    }
                }
            }
        }));
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) 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 20 with IComponentFilter

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

the class SetDefaultVauleMDMServerVersionFeatureTDI31722 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[] { "tMDMInput", "tMDMOutput", "tMDMDelete", "tMDMConnection", "tMDMViewSearch", "tMDMSP" };
    IComponentConversion changeDeletEmptyFileValue = new IComponentConversion() {

        public void transform(NodeType node) {
            ElementParameterType serverVersion = ComponentUtilities.getNodeProperty(node, "SERVERVERSION");
            if (serverVersion == null) {
                ComponentUtilities.addNodeProperty(node, "SERVERVERSION", "CLOSED_LIST");
                serverVersion = ComponentUtilities.getNodeProperty(node, "SERVERVERSION");
                serverVersion.setValue("s56");
            }
        }
    };
    for (String name : componentsName) {
        //$NON-NLS-1$
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeDeletEmptyFileValue));
        } catch (PersistenceException e) {
            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) 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)

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