use of org.talend.core.model.components.filters.NameComponentFilter in project tdi-studio-se by Talend.
the class ChangeJavaAPIAsDefault4SqoopMigrationTask method AddExecuteMode.
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("tSqoopImport"));
//$NON-NLS-1$
filters.add(new NameComponentFilter("tSqoopExport"));
//$NON-NLS-1$
filters.add(new NameComponentFilter("tSqoopImportAllTables"));
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 ChangeLogLevel4tRedshiftInput 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 (processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
//$NON-NLS-1$
String[] componentsName = new String[] { "tRedshiftInput" };
try {
for (String element : componentsName) {
IComponentFilter filter = new NameComponentFilter(element);
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
@Override
public void transform(NodeType node) {
//$NON-NLS-1$
ElementParameterType ept = ComponentUtilities.getNodeProperty(node, "LOG_LEVEL");
if (ept == null) {
return;
}
String value = ept.getValue();
if (value == null) {
return;
}
if (Integer.parseInt(value) > 2) {
//$NON-NLS-1$//$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "LOG_LEVEL", "2");
}
}
}));
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.core.model.components.filters.NameComponentFilter in project tdi-studio-se by Talend.
the class ChangeMappingParameter4Redshift method execute.
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
//$NON-NLS-1$ //$NON-NLS-2$
String[] compNames = { "tRedshiftInput", "tRedshiftOutput" };
IComponentConversion changeDBName4Hive = new IComponentConversion() {
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType dbId = ComponentUtilities.getNodeProperty(node, "MAPPING");
if (dbId == null) {
return;
}
//$NON-NLS-1$
dbId.setValue("redshift_id");
}
};
for (String name : compNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeDBName4Hive));
} 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 ChangeOptionDefaultValueFortNormalize method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
IComponentFilter filter = new NameComponentFilter("tNormalize");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
if (ComponentUtilities.getNodeProperty(node, "DISCARD_TRAILING_EMPTY_STR") == null) {
ComponentUtilities.addNodeProperty(node, "DISCARD_TRAILING_EMPTY_STR", "CHECK");
ElementParameterType useCSVOption = ComponentUtilities.getNodeProperty(node, "CSV_OPTION");
if (useCSVOption != null && "false".equals(useCSVOption.getValue())) {
ComponentUtilities.getNodeProperty(node, "DISCARD_TRAILING_EMPTY_STR").setValue("true");
}
}
}
}));
} 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 ChangeOracleJarName4OracleComponents method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
String[] oracleCompNames = { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleBulkExec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleClose", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleCommit", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleOutputBulk", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleOutputBulkExec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleRollback", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleRow", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleSCD", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleSCDELT", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleSP", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleTableList", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tAmazonOracleClose", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"tAmazonOracleCommit", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"tAmazonOracleConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"tAmazonOracleInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tAmazonOracleOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tAmazonOracleRollback", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tAmazonOracleRow", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tMondrianInput", //$NON-NLS-1$ //$NON-NLS-2$
"tCreateTable", //$NON-NLS-1$ //$NON-NLS-2$
"tOracleInvalidRows", "tOracleValidRows", "tELTOracleMap", "tOracleCDC", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tOracleSCDELT" };
IComponentConversion changeOracleDriverJarType = new IComponentConversion() {
public void transform(NodeType node) {
//$NON-NLS-1$
ElementParameterType dbVersion = ComponentUtilities.getNodeProperty(node, "DB_VERSION");
if (dbVersion != null) {
String jarValue = dbVersion.getValue();
if ("ojdbc6-11g.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("ojdbc6.jar");
} else if ("ojdbc5-11g.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("ojdbc5.jar");
} else if ("ojdbc14-10g.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("ojdbc14.jar");
} else if ("ojdbc14-9i.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
// db_version.setValue("ojdbc14-9i.jar");
} else if ("ojdbc12-8i.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("ojdbc12.jar");
}
}
}
};
for (String name : oracleCompNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeOracleDriverJarType));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
Aggregations