use of org.talend.core.model.components.filters.NameComponentFilter 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;
}
use of org.talend.core.model.components.filters.NameComponentFilter 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));
}
use of org.talend.core.model.components.filters.NameComponentFilter 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));
}
}
use of org.talend.core.model.components.filters.NameComponentFilter 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;
}
}
use of org.talend.core.model.components.filters.NameComponentFilter 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;
}
Aggregations