use of org.talend.core.model.components.filters.IComponentFilter in project tdi-studio-se by Talend.
the class ChangeHadoopVersionsOfReferenceComponentsMigrationTask 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;
}
String[] componentsName = new String[] { //$NON-NLS-1$
"tPigLoad", //$NON-NLS-1$
"tHDFSCompare", //$NON-NLS-1$
"tHDFSConnection", //$NON-NLS-1$
"tHDFSCopy", //$NON-NLS-1$
"tHDFSDelete", //$NON-NLS-1$
"tHDFSExist", //$NON-NLS-1$
"tHDFSGet", //$NON-NLS-1$
"tHDFSInput", //$NON-NLS-1$
"tHDFSList", //$NON-NLS-1$
"tHDFSOutput", //$NON-NLS-1$
"tHDFSProperties", //$NON-NLS-1$
"tHDFSPut", //$NON-NLS-1$
"tHDFSRename", //$NON-NLS-1$
"tHDFSRowCount", //$NON-NLS-1$
"tPigStoreResult", //$NON-NLS-1$
"tSqoopExport", //$NON-NLS-1$
"tSqoopImport", //$NON-NLS-1$
"tSqoopImportAllTables", //$NON-NLS-1$
"tGenKeyHadoop", //$NON-NLS-1$
"tMatchGroupHadoop" };
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$ //$NON-NLS-2$ //$NON-NLS-3$
String[] params = { "PIG_VERSION", "DB_VERSION", /* "MR_VERSION", */
"HBASE_VERSION" };
ElementParameterType ept = null;
for (String param : params) {
ept = ComponentUtilities.getNodeProperty(node, param);
if (ept != null) {
setValue(node, ept, param);
break;
}
}
}
}));
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (java.lang.Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.core.model.components.filters.IComponentFilter in project tdi-studio-se by Talend.
the class ChangeJDBCDriverJarTypeForFeature12879 method execute.
@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[] { "tJDBCConnection", "tJDBCInput", "tJDBCOutput", "tJDBCRow", "tJDBCSP", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tELTJDBCMap" };
IComponentConversion changeJDBCDriverJarType = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType driverType = ComponentUtilities.getNodeProperty(node, "DRIVER_JAR");
if (driverType != null) {
String value = driverType.getValue();
if (value != null && !"".equals(value)) {
value = TalendTextUtils.removeQuotes(value);
}
driverType.setField("TABLE");
driverType.setValue(null);
ElementValueType valueType = TalendFileFactory.eINSTANCE.createElementValueType();
valueType.setElementRef("JAR_NAME");
valueType.setValue(value);
driverType.getElementValue().add(valueType);
}
}
};
for (String name : componentsName) {
//$NON-NLS-1$
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeJDBCDriverJarType));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_WITH_ALERT;
}
use of org.talend.core.model.components.filters.IComponentFilter in project tdi-studio-se by Talend.
the class ChangeMongoDBMinimalVersion method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
IComponentFilter filterConnection = new NameComponentFilter("tMongoDBConnection");
IComponentFilter filterInput = new NameComponentFilter("tMongoDBInput");
IComponentFilter filterOutput = new NameComponentFilter("tMongoDBOutput");
IComponentFilter filterRow = new NameComponentFilter("tMongoDBRow");
IComponentFilter filterWriteConf = new NameComponentFilter("tMongoDBWriteConf");
try {
ModifyComponentsAction.searchAndModify(item, processType, filterConnection, Arrays.<IComponentConversion>asList(new ChangeDeprecatedVersion()));
ModifyComponentsAction.searchAndModify(item, processType, filterInput, Arrays.<IComponentConversion>asList(new ChangeDeprecatedVersion()));
ModifyComponentsAction.searchAndModify(item, processType, filterOutput, Arrays.<IComponentConversion>asList(new ChangeDeprecatedVersion()));
ModifyComponentsAction.searchAndModify(item, processType, filterRow, Arrays.<IComponentConversion>asList(new ChangeDeprecatedVersion()));
ModifyComponentsAction.searchAndModify(item, processType, filterWriteConf, Arrays.<IComponentConversion>asList(new ChangeDeprecatedVersion()));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
// return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.core.model.components.filters.IComponentFilter in project tdi-studio-se by Talend.
the class ChangeMysqlJarReference4MysqlComponents method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
String[] mysqlCompNames = { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tAmazonMysqlConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tAmazonMysqlInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tAmazonMysqlOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tAmazonMysqlRow", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tCreateTable", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tELTMysqlMap", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tMondrianInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tMysqlBulkExec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tMysqlConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"tMysqlInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"tMysqlOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"tMysqlOutputBulkExec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"tMysqlRow", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"tMysqlSCD", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"tMysqlSCDELT", "tMysqlSP", "tMySQLInvalidRows", "tMySQLValidRows", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tMysqlCDC" };
IComponentConversion changeOracleDriverJarType = new IComponentConversion() {
public void transform(NodeType node) {
if (node == null) {
return;
}
if ("tCreateTable".equals(node.getComponentName())) {
//$NON-NLS-1$
//$NON-NLS-1$
ElementParameterType dbVersion = ComponentUtilities.getNodeProperty(node, "DB_MYSQL_VERSION");
if (dbVersion != null) {
String jarValue = dbVersion.getValue();
if ("mysql-connector-java-5.1.0-bin.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("MYSQL_5");
} else if ("mysql-connector-java-3.1.14-bin.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("MYSQL_4");
}
}
}
//$NON-NLS-1$
ElementParameterType dbVersion = ComponentUtilities.getNodeProperty(node, "DB_VERSION");
if (dbVersion != null) {
String jarValue = dbVersion.getValue();
if ("mysql-connector-java-5.1.0-bin.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("MYSQL_5");
} else if ("mysql-connector-java-3.1.14-bin.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("MYSQL_4");
}
}
}
};
for (String name : mysqlCompNames) {
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;
}
use of org.talend.core.model.components.filters.IComponentFilter in project tdi-studio-se by Talend.
the class ChangeOptionDefaultValueForFileArchive method execute.
@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[] { "tFileArchive", "tFileUnarchive" };
IComponentConversion changeJDBCDriverJarType = new IComponentConversion() {
public void transform(NodeType node) {
if ("tFileArchive".equals(node.getComponentName())) {
ElementParameterType encryptMethod = ComponentUtilities.getNodeProperty(node, "ENCRYPT_METHOD");
if (encryptMethod != null) {
if ("DEFAULT".equals(encryptMethod.getValue())) {
ComponentUtilities.setNodeValue(node, "ENCRYPT_METHOD", "JAVA_ENCRYPT");
}
if ("AES256".equals(encryptMethod.getValue())) {
ComponentUtilities.setNodeValue(node, "ENCRYPT_METHOD", "ENC_METHOD_AES");
}
}
}
if ("tFileUnarchive".equals(node.getComponentName())) {
ElementParameterType encryptMethod = ComponentUtilities.getNodeProperty(node, "DECRYPT_METHOD");
if (encryptMethod != null) {
if ("DEFAULT".equals(encryptMethod.getValue())) {
ComponentUtilities.setNodeValue(node, "DECRYPT_METHOD", "JAVA_DECRYPT");
}
if ("AES256".equals(encryptMethod.getValue())) {
ComponentUtilities.setNodeValue(node, "DECRYPT_METHOD", "ZIP4J_DECRYPT");
}
}
}
}
};
for (String name : componentsName) {
//$NON-NLS-1$
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeJDBCDriverJarType));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_WITH_ALERT;
}
Aggregations