use of org.talend.core.model.components.filters.NameComponentFilter in project tdi-studio-se by Talend.
the class ChangeDefaultValueForCassandra3Version method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
String[] compNames = { "tCassandraConnection", "tCassandraInput", "tCassandraOutput", "tCassandraRow", "tCassandraOutputBulk", "tCassandraOutputBulkExec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
"tCassandraBulkExec" };
IComponentConversion conversion = new IComponentConversion() {
@Override
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType parameter = ComponentUtilities.getNodeProperty(node, "DB_VERSION");
if (parameter == null) {
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "DB_VERSION", "CLOSED_LIST");
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "DB_VERSION", "CASSANDRA_1_1_2");
}
}
};
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;
}
use of org.talend.core.model.components.filters.NameComponentFilter in project tdi-studio-se by Talend.
the class ChangeDefaultEncodingMigrationTask method AddExecuteMode.
@SuppressWarnings("cast")
private void AddExecuteMode(Item item) throws Exception {
ProcessType processType = getProcessType(item);
java.util.List<IComponentFilter> filters = new java.util.ArrayList<IComponentFilter>();
//$NON-NLS-1$
filters.add(new NameComponentFilter("tSybaseBulkExec"));
//$NON-NLS-1$
filters.add(new NameComponentFilter("tSybaseOutputBulkExec"));
//$NON-NLS-1$
filters.add(new NameComponentFilter("tOracleBulkExec"));
//$NON-NLS-1$
filters.add(new NameComponentFilter("tOracleOutputBulkExec"));
//$NON-NLS-1$
IComponentConversion addOption = new AddExecuteMode();
java.util.Iterator<IComponentFilter> iter = filters.iterator();
while (iter.hasNext()) {
IComponentFilter filter = (IComponentFilter) 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 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;
}
use of org.talend.core.model.components.filters.NameComponentFilter 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;
}
use of org.talend.core.model.components.filters.NameComponentFilter 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;
}
}
Aggregations