Search in sources :

Example 26 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 27 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 28 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 29 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)

Example 30 with IComponentFilter

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

the class CorrectBatchSizeForDBComponents method execute.

/*
     * (non-Javadoc)
     *
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    List<String> filterList = Arrays.asList("tAmazonOracleOutput", "tInformixOutput");
    IComponentConversion correctBatchModeForDBComponents = new IComponentConversion() {

        public void transform(NodeType node) {
            ElementParameterType useExistingConnPara = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION");
            if (useExistingConnPara == null) {
                ComponentUtilities.addNodeProperty(node, "USE_EXISTING_CONNECTION", "CHECK");
                ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").setValue("false");
            }
            ElementParameterType useBatchAndUseConnPara = ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN");
            if (useBatchAndUseConnPara == null) {
                ComponentUtilities.addNodeProperty(node, "USE_BATCH_AND_USE_CONN", "CHECK");
                ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN").setValue("false");
            }
            boolean useExistConn = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").getValue().equalsIgnoreCase("true");
            ElementParameterType elementParaType = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
            if (elementParaType == null) {
                ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
                ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
            }
            if (!useExistConn) {
                if (elementParaType != null && elementParaType.getValue().equalsIgnoreCase("true")) {
                    String batchSizeInStr = ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").getValue();
                    if (batchSizeInStr != null && !"".equals(batchSizeInStr)) {
                        int batchSize = Integer.valueOf(batchSizeInStr);
                        if (batchSize <= 0) {
                            ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").setValue("1");
                        }
                    }
                }
            }
        }
    };
    for (String componentName : filterList) {
        IComponentFilter filter = new NameComponentFilter(componentName);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(correctBatchModeForDBComponents));
        } 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) 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