use of org.talend.designer.runprocess.IProcessMessage in project tdi-studio-se by Talend.
the class TraceDebugProcessComposite method addPerlMark.
protected void addPerlMark(IProcessMessage psMess) {
if (psMess.getType().equals(MsgType.STD_ERR)) {
String content = psMess.getContent();
String path = null;
String uniName = null;
int lineNo = -1;
//$NON-NLS-1$
Pattern errorPattern = Pattern.compile("(.*) at (\\S+) line (\\d+)[\\.,]");
Matcher m = errorPattern.matcher(content);
String matchContent = null;
while (m.find()) {
path = m.group(2);
lineNo = parseInt(m.group(3));
matchContent = m.group();
if ((!("".equals(path)) && path != null) && lineNo > 0) {
//$NON-NLS-1$
uniName = Problems.setErrorMark(path, lineNo);
}
if (uniName != null) {
if (!errorMessMap.containsKey(uniName)) {
errorMessMap.put(uniName, new ProcessMessage(MsgType.STD_ERR, matchContent));
} else {
String uniMess = errorMessMap.get(uniName).getContent();
errorMessMap.put(uniName, new ProcessMessage(MsgType.STD_ERR, uniMess.concat(matchContent)));
}
}
}
}
refreshNode(psMess);
}
use of org.talend.designer.runprocess.IProcessMessage in project tdi-studio-se by Talend.
the class TraceDebugProcessComposite method runProcessContextChanged.
private void runProcessContextChanged(final PropertyChangeEvent evt) {
String propName = evt.getPropertyName();
if (ProcessMessageManager.PROP_MESSAGE_ADD.equals(propName) || ProcessMessageManager.PROP_DEBUG_MESSAGE_ADD.equals(propName)) {
IProcessMessage psMess = (IProcessMessage) evt.getNewValue();
if (errorMessMap.size() <= CorePlugin.getDefault().getPreferenceStore().getInt(ITalendCorePrefConstants.PREVIEW_LIMIT)) {
if (!(LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL))) {
getAllErrorMess(psMess);
} else {
addPerlMark(psMess);
}
}
appendToConsole(psMess);
} else if (ProcessMessageManager.PROP_MESSAGE_CLEAR.equals(propName)) {
getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (!consoleText.isDisposed()) {
//$NON-NLS-1$
consoleText.setText("");
}
}
});
} else if (RunProcessContext.PROP_MONITOR.equals(propName)) {
// perfBtn.setSelection(((Boolean) evt.getNewValue()).booleanValue());
} else if (RunProcessContext.TRACE_MONITOR.equals(propName)) {
// traceBtn.setSelection(((Boolean) evt.getNewValue()).booleanValue());
} else if (RunProcessContext.PROP_RUNNING.equals(propName)) {
getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (isDisposed()) {
return;
}
boolean running = ((Boolean) evt.getNewValue()).booleanValue();
setRunnable(!running);
killBtn.setEnabled(running);
// previousRow.setEnabled(running);
// nextRow.setEnabled(running);
// nextBreakPoint.setEnabled(running);
}
});
}
}
use of org.talend.designer.runprocess.IProcessMessage in project tdi-studio-se by Talend.
the class ProcessComposite method processNextMessage.
protected void processNextMessage() {
// don't try to display once the list to display is not finished to handle.
if (messagesToDisplay.isEmpty() && !newMessages.isEmpty()) {
IProcessMessage message = newMessages.poll();
if (message == null) {
return;
}
messagesToDisplay.add(message);
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
List<IProcessMessage> messages = new ArrayList<IProcessMessage>();
// only do a peek here, to get the first message, but without remove it (to make sure nothing else
// call the appendConsole)
IProcessMessage msg = messagesToDisplay.peek();
if (msg != null) {
messages.add(msg);
doAppendToConsole(messages);
scrollToEnd();
}
// do a poll here to remove the first element that we just displayed.
messagesToDisplay.poll();
}
});
}
}
use of org.talend.designer.runprocess.IProcessMessage in project tdi-studio-se by Talend.
the class ProcessErrorUtil method getAllErrorMess.
public static HashMap<String, IProcessMessage> getAllErrorMess(IProcessMessage psMess, RunProcessContext processContext) {
HashMap<String, IProcessMessage> errorMessMap = new HashMap<String, IProcessMessage>();
if (psMess.getType().equals(MsgType.STD_ERR)) {
String mess = psMess.getContent();
//$NON-NLS-1$
String[] linesMess = mess.split("\n");
StringBuffer currentMess = new StringBuffer();
String currenctJobName = processContext.getProcess().getName();
for (int i = 0; i < linesMess.length; i++) {
String tRunJobName = currenctJobName;
String linemess = linesMess[i].trim();
//$NON-NLS-1$
Pattern pattern = Pattern.compile("^Exception\\s*in\\s*component\\s*(\\w)+_(\\d)+\\s*\\((\\w)+\\)$");
Matcher m = pattern.matcher(linemess);
if (m.find()) {
//$NON-NLS-1$
String[] allwords = linemess.split("\\s");
if (allwords.length == 5) {
String componentName = allwords[3];
tRunJobName = allwords[4].substring(1, allwords[4].length() - 1);
if (tRunJobName != null && tRunJobName.equals(currenctJobName)) {
if (i == 0) {
errorMessMap.put(componentName, psMess);
} else {
for (int j = i; j < linesMess.length; j++) {
//$NON-NLS-1$
currentMess.append(linesMess[j] + "\n");
}
IProcessMessage currentProMess = new ProcessMessage(MsgType.STD_ERR, currentMess.toString());
errorMessMap.put(componentName, currentProMess);
}
}
}
}
}
}
return errorMessMap;
}
use of org.talend.designer.runprocess.IProcessMessage in project tdi-studio-se by Talend.
the class ProcessErrorUtilTest method testGetAllErrorMess.
/**
* Test method for
* {@link org.talend.designer.runprocess.ui.ProcessComposite#getAllErrorMess(org.talend.designer.runprocess.IProcessMessage)}
* .
*/
@Test
public void testGetAllErrorMess() {
Property property1 = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property1.setId("property1");
//$NON-NLS-1$
property1.setVersion("0.1");
//$NON-NLS-1$
property1.setLabel("ParentJob");
Process process = new Process(property1);
IComponent tOracleSPComponent = ComponentsFactoryProvider.getInstance().get("tOracleSP", ComponentCategory.CATEGORY_4_DI.getName());
Node tOracleSP_1 = new Node(tOracleSPComponent, process);
process.addNodeContainer(new NodeContainer(tOracleSP_1));
RunProcessContext context = new RunProcessContext(process);
String errorMessage1 = "Exception in component tOracleSP_1 (ParentJob)\njava.sql.SQLException: ORA-20000: Failed to execute one or more sql statements";
ProcessMessage message1 = new ProcessMessage(MsgType.STD_ERR, errorMessage1);
HashMap<String, IProcessMessage> errorMessMap = ProcessErrorUtil.getAllErrorMess(message1, context);
Assert.assertEquals(errorMessMap.get(tOracleSP_1.getUniqueName()).getContent(), errorMessage1);
String errorMessage2 = "Exception in component tOracleSP_1 (ChildJob)\njava.sql.SQLException: ORA-20000: Failed to execute one or more sql statements";
ProcessMessage message2 = new ProcessMessage(MsgType.STD_ERR, errorMessage2);
HashMap<String, IProcessMessage> errorMessMap2 = ProcessErrorUtil.getAllErrorMess(message2, context);
Assert.assertNull(errorMessMap2.get(tOracleSP_1.getUniqueName()));
}
Aggregations