use of org.talend.core.model.components.filters.NameComponentFilter in project tdi-studio-se by Talend.
the class ChangeActiveMqJarName4MOMComponents method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
//$NON-NLS-1$
String[] tmomCompNames = { "tMomInput", "tMomInputLoop", "tMomOutput" };
IComponentConversion changeActiveMqDriverJarType = new IComponentConversion() {
public void transform(NodeType node) {
//$NON-NLS-2$
ElementParameterType mq_drivers = ComponentUtilities.getNodeProperty(node, PROPERTY_TO_REMOVE);
if (mq_drivers != null) {
ComponentUtilities.removeNodeProperty(node, PROPERTY_TO_REMOVE);
}
}
};
for (String name : tmomCompNames) {
//$NON-NLS-4$
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeActiveMqDriverJarType));
} 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 ChangeBagName4tPigCode method execute.
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
//$NON-NLS-1$
String[] compNames = { "tPigCode" };
IComponentConversion changeBagName4tPigCode = new IComponentConversion() {
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType pigScript = ComponentUtilities.getNodeProperty(node, "SCRIPT_CODE");
if (pigScript != null) {
String content = pigScript.getValue();
if (content == null) {
return;
}
//$NON-NLS-1$
Pattern pattern = Pattern.compile("tPig[a-zA-Z]+_\\d+_RESULT");
//$NON-NLS-1$
String end = "_RESULT";
Matcher matcher = pattern.matcher(content);
boolean matches = matcher.find();
if (matches) {
//replace the pigscript
StringBuffer sb = new StringBuffer();
do {
String group = matcher.group();
String uniqueNameOfComponent = group.substring(0, group.lastIndexOf(end));
String outputConnectionName = null;
if (processType != null) {
List connections = processType.getConnection();
if (connections != null) {
for (Object connection : connections) {
ConnectionType currentConnection = (ConnectionType) connection;
String source = currentConnection.getSource();
if (uniqueNameOfComponent != null && uniqueNameOfComponent.equals(source)) {
//find the unique output connection
for (Object paramObject : currentConnection.getElementParameter()) {
ElementParameterType paramType = (ElementParameterType) paramObject;
if ("UNIQUE_NAME".equals(paramType.getName())) {
//$NON-NLS-1$
outputConnectionName = paramType.getValue();
}
}
break;
}
}
}
}
if (outputConnectionName == null) {
//not find
matcher.appendReplacement(sb, group);
} else {
//$NON-NLS-1$
matcher.appendReplacement(sb, uniqueNameOfComponent + "_" + outputConnectionName + end);
}
matches = matcher.find();
} while (matches);
matcher.appendTail(sb);
pigScript.setValue(sb.toString());
}
}
}
};
for (String name : compNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeBagName4tPigCode));
} 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 ChangeBatchParameter4SomeDBComponents method execute.
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
String[] compNames = { "tFirebirdOutput", "tGreenplumOutput", "tIngresOutput", "tInterbaseOutput", "tParAccelOutput", "tPostgresPlusOutput", "tSQLiteOutput", "tRedshiftOutput" };
IComponentConversion conversion = new IComponentConversion() {
@Override
public void transform(NodeType node) {
if (node == null) {
return;
}
ElementParameterType parameter = ComponentUtilities.getNodeProperty(node, "USE_BATCH");
if (parameter == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH", "CHECK");
ComponentUtilities.setNodeValue(node, "USE_BATCH", "false");
}
}
};
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 ChangeDBName4Hive method execute.
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
String[] compNames = { "tHiveConnection", "tHiveRow", "tHiveInput", "tHiveLoad", "tHiveCreateTable", "tELTHiveMap" };
IComponentConversion changeDBName4Hive = new IComponentConversion() {
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType database = ComponentUtilities.getNodeProperty(node, "DBNAME");
if (database == null) {
return;
}
String dbname = database.getValue();
if (dbname == null) {
return;
}
String value = dbname.trim();
if ("".equals(value) || "\"\"".equals(value) || "\"default\"".equals(value)) {
//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
return;
}
//$NON-NLS-1$
database.setValue("\"\"");
}
};
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 ChangeDBVersionValue4BonitaComponents method execute.
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
String[] compNames = { "tBonitaDeploy", "tBonitaInstantiateProcess" };
IComponentConversion conversion = new IComponentConversion() {
public void transform(NodeType node) {
if (node == null) {
return;
}
ElementParameterType parameter = ComponentUtilities.getNodeProperty(node, "DB_VERSION");
if (parameter != null) {
String value = parameter.getValue();
if (value == null) {
return;
}
String oldValueFor531 = "novaBpmIdentity-1.0.jar;novaBpmPerf-1.0.jar;novaBpmUtil-1.0.jar;hibernate-core-3.5.6-Final.jar;commons-collections-3.1.jar;ehcache-core-2.2.0.jar;hibernate-commons-annotations-3.2.0.Final.jar;hibernate-search-3.2.1.Final.jar;javassist-3.8.0.GA.jar;lucene-core-2.9.3.jar;slf4j-api-1.6.1.jar;dom4j-1.6.1.jar;h2-1.2.132.jar;jta-1.1.jar;antlr-2.7.6.jar;commons-logging-1.1.1.jar";
if (oldValueFor531.equals(value)) {
String newValue = "novaBpmIdentity-1.0.jar;novaBpmPerf-1.0.jar;novaBpmUtil-1.0.jar;hibernate-core-3.5.6-Final.jar;commons-collections-3.2.2.jar;ehcache-core-2.2.0.jar;hibernate-commons-annotations-3.2.0.Final.jar;hibernate-search-3.2.1.Final.jar;javassist-3.8.0.GA.jar;lucene-core-2.9.3.jar;slf4j-api-1.6.1.jar;dom4j-1.6.1.jar;h2-1.2.132.jar;jta-1.1.jar;antlr-2.7.6.jar;commons-logging-1.1.1.jar";
ComponentUtilities.setNodeValue(node, "DB_VERSION", newValue);
}
}
}
};
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;
}
Aggregations