use of org.talend.core.model.components.filters.NameComponentFilter in project tdi-studio-se by Talend.
the class ChangeValueTDIBug19870 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[] { "tHDFSOutput" };
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, "FILE_ACTION") == null || "false".equals(ComponentUtilities.getNodeProperty(node, "FILE_ACTION").getValue())) {
ComponentUtilities.getNodeProperty(node, "FILE_ACTION").setValue("CREATE");
} else if ("true".equals(ComponentUtilities.getNodeProperty(node, "FILE_ACTION").getValue())) {
ComponentUtilities.getNodeProperty(node, "FILE_ACTION").setValue("OVERWRITE");
}
}
}));
}
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 UpdateLookupColumnMigrationTask 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;
}
// TODO Auto-generated method stub
try {
// 1.tFuzzyMatch:
//$NON-NLS-1$
IComponentFilter filter1 = new NameComponentFilter("tFuzzyMatch");
//$NON-NLS-1$
IComponentConversion lookupProperty = new UpdateLookupColumnConversion("LOOKUP_COLUMN");
ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(lookupProperty));
// 2.tIntervalMatch
//$NON-NLS-1$
IComponentFilter filter2 = new NameComponentFilter("tIntervalMatch");
ModifyComponentsAction.searchAndModify(item, processType, filter2, Arrays.<IComponentConversion>asList(lookupProperty));
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 UpgradeAttributestAdvancedXMLMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
//$NON-NLS-1$
IComponentFilter filter1 = new NameComponentFilter("tAdvancedFileOutputXML");
IComponentConversion removeQuotes1 = new UpdateAttributesFortAdvancedXMLConversion();
ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(removeQuotes1));
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 UnifyParameterOfDatastaxAndHectorForCassandra 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$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
String[] compNames = { "tCassandraInput", "tCassandraOutput", "tCassandraRow", "tCassandraLookupInput" };
IComponentConversion conversion = new IComponentConversion() {
@Override
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType cf = ComponentUtilities.getNodeProperty(node, "TABLE");
if (cf != null) {
if (ComponentUtilities.getNodeProperty(node, "COLUMN_FAMILY") == null) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "COLUMN_FAMILY", "TEXT");
}
//$NON-NLS-1$
ComponentUtilities.getNodeProperty(node, "COLUMN_FAMILY").setValue(cf.getValue());
}
//$NON-NLS-1$
ElementParameterType actionForCF = ComponentUtilities.getNodeProperty(node, "TABLE_ACTION");
if (actionForCF != null) {
if (ComponentUtilities.getNodeProperty(node, "ACTION_ON_COLUMN_FAMILY") == null) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "ACTION_ON_COLUMN_FAMILY", "TEXT");
}
//$NON-NLS-1$
ComponentUtilities.getNodeProperty(node, "ACTION_ON_COLUMN_FAMILY").setValue(actionForCF.getValue());
}
}
};
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 UpdateKakfaInputConsumerTimeoutAndAutoOffsetTask method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
try {
//$NON-NLS-1$
IComponentFilter filter = new NameComponentFilter("tKafkaInput");
IComponentConversion addOption = new UpdateKakfaInputConversion();
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(addOption));
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
Aggregations