Search in sources :

Example 76 with IComponentFilter

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

the class SetTPigStoreResultAssociatedTPigLoad method execute.

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

            @Override
            public void transform(NodeType node) {
                ComponentUtilities.addNodeProperty(node, "ASSOCIATED_PIG_LOAD", "COMPONENT_LIST");
                ComponentUtilities.getNodeProperty(node, "ASSOCIATED_PIG_LOAD").setValue("UNRELEVANT");
            }
        }));
        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 77 with IComponentFilter

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

the class SetTrim4tFileOutputXML method execute.

@Override
public ExecutionResult execute(Item item) {
    final ProcessType processType = getProcessType(item);
    //$NON-NLS-1$
    String[] compNames = { "tFileOutputXML" };
    IComponentConversion action = new IComponentConversion() {

        public void transform(NodeType node) {
            if (node == null) {
                return;
            }
            if (ComponentUtilities.getNodeProperty(node, "TRIM") == null) {
                //$NON-NLS-1$
                //$NON-NLS-1$ //$NON-NLS-2$
                ComponentUtilities.addNodeProperty(node, "TRIM", "CHECK");
                //$NON-NLS-1$ //$NON-NLS-2$
                ComponentUtilities.getNodeProperty(node, "TRIM").setValue("true");
            }
        }
    };
    for (String name : compNames) {
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(action));
        } catch (PersistenceException e) {
            // TODO Auto-generated catch block
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : 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 IComponentFilter

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

the class SetTrimToTrueAppendModeAdvancedFileOutputXMLComponentsMigrationTask method setTrimToTrue.

private void setTrimToTrue(Item item) throws Exception {
    ProcessType processType = getProcessType(item);
    IComponentConversion addTrim = new AddTrimOption();
    IComponentFilter filter = new NameComponentFilter("tAdvancedFileOutputXML");
    ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(addTrim));
}
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 IComponentFilter

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

the class SetTypeToStagingForMDMComponent method addType.

private void addType(Item item) throws Exception {
    ProcessType processType = getProcessType(item);
    java.util.List<IComponentFilter> filters = new java.util.ArrayList<IComponentFilter>();
    filters.add(new NameComponentFilter("tMDMBulkLoad"));
    filters.add(new NameComponentFilter("tMDMInput"));
    filters.add(new NameComponentFilter("tMDMOutput"));
    filters.add(new NameComponentFilter("tMDMDelete"));
    filters.add(new NameComponentFilter("tMDMRouteRecord"));
    filters.add(new NameComponentFilter("tMDMSP"));
    filters.add(new NameComponentFilter("tMDMViewSearch"));
    filters.add(new NameComponentFilter("tMDMReadConf"));
    filters.add(new NameComponentFilter("tMDMWriteConf"));
    IComponentConversion addOption = new AddType();
    java.util.Iterator<IComponentFilter> iter = filters.iterator();
    while (iter.hasNext()) {
        IComponentFilter filter = iter.next();
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(addOption));
    }
}
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 IComponentFilter

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

the class RenametParseXMLRowTotExtractXMLFieldMigrationTask method execute.

public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() == ECodeLanguage.JAVA && processType != null) {
        try {
            //$NON-NLS-1$
            IComponentFilter filter1 = new NameComponentFilter("tParseXMLRow");
            IComponentConversion changeNodeNameConversion = new IComponentConversion() {

                public void transform(NodeType node) {
                    ProcessType item = (ProcessType) node.eContainer();
                    for (Object o : item.getNode()) {
                        NodeType nt = (NodeType) o;
                        for (Object o1 : nt.getElementParameter()) {
                            ElementParameterType t = (ElementParameterType) o1;
                            String value = t.getValue();
                            if (value != null) {
                                if (value.contains("tParseXMLRow")) {
                                    //$NON-NLS-1$
                                    //$NON-NLS-1$ //$NON-NLS-2$
                                    String replaceAll = value.replaceAll("tParseXMLRow", "tExtractXMLField");
                                    t.setValue(replaceAll);
                                }
                            }
                        }
                    }
                }
            };
            // bug 22125
            ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(new RenameComponentConversion("tExtractXMLField")));
            return ExecutionResult.SUCCESS_WITH_ALERT;
        } catch (Exception e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    } else {
        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) RenameComponentConversion(org.talend.core.model.components.conversions.RenameComponentConversion) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Aggregations

IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)154 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)153 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)151 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)145 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)111 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)84 PersistenceException (org.talend.commons.exception.PersistenceException)78 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