use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class ChangeDefaultValue4JSONComponents method execute.
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
String[] compNames = { "tFileInputJSON", "tExtractJSONFields", "tExtractAbstractJSONFields", "tFileInputJSON", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tInputFormatJSON" };
IComponentConversion conversion = new IComponentConversion() {
@Override
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType parameter = ComponentUtilities.getNodeProperty(node, "READ_BY");
if (parameter == null) {
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "READ_BY", "CLOSED_LIST");
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "READ_BY", "XPATH");
}
}
};
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.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class ChangeDefaultValue4tLogRow method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
IComponentFilter filter = new NameComponentFilter("tLogRow");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType printContent = ComponentUtilities.getNodeProperty(node, "PRINT_CONTENT_WITH_LOG4J");
if (printContent == null) {
ComponentUtilities.addNodeProperty(node, "PRINT_CONTENT_WITH_LOG4J", "CHECK");
ComponentUtilities.getNodeProperty(node, "PRINT_CONTENT_WITH_LOG4J").setValue("false");
}
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class ResetValuetInfiniteLoop 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[] { "tInfiniteLoop" };
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, "WAIT") != null) {
int time = Integer.valueOf(ComponentUtilities.getNodeProperty(node, "WAIT").getValue());
ComponentUtilities.addNodeProperty(node, "WAIT_MS", "TEXT");
ComponentUtilities.getNodeProperty(node, "WAIT_MS").setValue(String.valueOf(time * 1000));
ComponentUtilities.removeNodeProperty(node, "WAIT");
}
}
}));
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class ReviewPigLoadLayout method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType != null) {
try {
//$NON-NLS-1$
IComponentFilter filter = new NameComponentFilter("tPigLoad");
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
@Override
public void transform(NodeType node) {
//$NON-NLS-1$
ElementParameterType mr = ComponentUtilities.getNodeProperty(node, "MAPREDUCE");
//$NON-NLS-1$
ElementParameterType tez = ComponentUtilities.getNodeProperty(node, "TEZ");
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "ENGINE", "CLOSED_LIST");
if ("true".equalsIgnoreCase(mr.getValue())) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.getNodeProperty(node, "ENGINE").setValue("MAPREDUCE");
} else if ("true".equalsIgnoreCase(tez.getValue())) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.getNodeProperty(node, "ENGINE").setValue("TEZ");
}
//$NON-NLS-1$
ComponentUtilities.removeNodeProperty(node, "MAPREDUCE");
//$NON-NLS-1$
ComponentUtilities.removeNodeProperty(node, "TEZ");
}
}));
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
CommonExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class ReplaceRunJobLabelVariableMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
try {
List<NodeType> nodes = null;
if (item instanceof ProcessItem) {
nodes = ((ProcessItem) item).getProcess().getNode();
} else if (item instanceof JobletProcessItem) {
nodes = ((JobletProcessItem) item).getJobletProcess().getNode();
}
if (nodes != null) {
boolean modified = false;
for (NodeType node : nodes) {
if (ModifyComponentsAction.searchAndModify(node, filter, Arrays.<IComponentConversion>asList(replaceConversion))) {
modified = true;
}
}
if (modified) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
}
}
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
Aggregations