use of org.talend.core.model.components.filters.NameComponentFilter in project tdi-studio-se by Talend.
the class RenametForForPerl method execute.
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
if (getProject().getLanguage().equals(ECodeLanguage.PERL)) {
//$NON-NLS-1$
IComponentFilter filter1 = new NameComponentFilter("tFor");
IComponentConversion addProperty = new AddPropertyLoopTypeConversion();
//$NON-NLS-1$
IComponentConversion renameComponent = new RenameComponentConversion("tLoop");
ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(addProperty, renameComponent));
return ExecutionResult.SUCCESS_WITH_ALERT;
} else {
// do nothing
return ExecutionResult.NOTHING_TO_DO;
}
} 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 SetDefineRegisterJarToTrueForPigLoadMigrationTask method setDefineRegisterJar.
private void setDefineRegisterJar(Item item) throws Exception {
ProcessType processType = getProcessType(item);
java.util.List<IComponentFilter> filters = new java.util.ArrayList<IComponentFilter>();
filters.add(new NameComponentFilter("tPigLoad"));
filters.add(new NameComponentFilter("tPigStoreResult"));
IComponentConversion addOption = new AddDefineJarOption();
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 AddNewFieldsForTDQHadoopComponentsTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
* ProcessItem)
*/
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
IComponentConversion changeNamenodeURIValue = new IComponentConversion() {
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType namenodeURI = ComponentUtilities.getNodeProperty(node, "FS_DEFAULT_NAME");
if (namenodeURI == null) {
//$NON-NLS-1$
ElementParameterType host = ComponentUtilities.getNodeProperty(node, "HOST");
//$NON-NLS-1$
ElementParameterType port = ComponentUtilities.getNodeProperty(node, "PORT");
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "FS_DEFAULT_NAME", "TEXT");
ComponentUtilities.setNodeValue(node, "FS_DEFAULT_NAME", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"\"hdfs://\" + " + host.getValue() + " + \":\" + " + port.getValue() + " + \"/\"");
}
//$NON-NLS-1$
ElementParameterType distribution = ComponentUtilities.getNodeProperty(node, "DISTRIBUTION");
if (distribution == null) {
//$NON-NLS-1$
ElementParameterType dbVersion = ComponentUtilities.getNodeProperty(node, "DB_VERSION");
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "DISTRIBUTION", "TEXT");
String dbVersionValue = dbVersion.getValue();
if (dbVersionValue.endsWith("_EMR")) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "DISTRIBUTION", "AMAZON_EMR");
} else if (dbVersionValue.startsWith("HDP_")) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "DISTRIBUTION", "HORTONWORKS");
} else if (dbVersionValue.startsWith("Cloudera_")) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "DISTRIBUTION", "CLOUDERA");
} else if (dbVersionValue.startsWith("MAPR")) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "DISTRIBUTION", "MAPR");
} else if (dbVersionValue.startsWith("APACHE_")) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "DISTRIBUTION", "APACHE");
}
}
}
};
try {
List<IComponentFilter> filters = new ArrayList<IComponentFilter>();
filters.add(new NameComponentFilter("tGenKeyHadoop"));
filters.add(new NameComponentFilter("tMatchGroupHadoop"));
Iterator<IComponentFilter> iter = filters.iterator();
while (iter.hasNext()) {
IComponentFilter filter = (IComponentFilter) iter.next();
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeNamenodeURIValue));
}
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 AddTableActionForUpdateCassandraDatastax 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);
//$NON-NLS-1$
String[] compNames = { "tCassandraOutput" };
IComponentConversion conversion = new IComponentConversion() {
@Override
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType dataAction = ComponentUtilities.getNodeProperty(node, "DATA_ACTION");
if (dataAction != null && "UPDATA".equals(dataAction.getValue())) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "TABLE_ACTION", "NONE");
}
}
};
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 AddTransmitOriginalContextFortRunJobMigrationTask method execute.
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() == ECodeLanguage.PERL || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
//$NON-NLS-1$
IComponentFilter filter = new NameComponentFilter("tRunJob");
IComponentConversion addNewProperty = new IComponentConversion() {
public void transform(NodeType node) {
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "TRANSMIT_ORIGINAL_CONTEXT", "CHECK");
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "TRANSMIT_ORIGINAL_CONTEXT", "false");
}
};
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(addNewProperty));
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
Aggregations