Search in sources :

Example 1 with ProcessMessage

use of org.talend.designer.runprocess.ProcessMessage in project tdi-studio-se by Talend.

the class TraceDebugProcessComposite method getAllErrorMess.

public void getAllErrorMess(IProcessMessage psMess) {
    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$");
            Matcher m = pattern.matcher(linemess);
            if (m.find()) {
                List<Node> runjobList = getTRunjobList(processContext.getProcess());
                //$NON-NLS-1$
                String[] allwords = linemess.split("\\s");
                String componentName = allwords[allwords.length - 1];
                if (runjobList.size() > 0) {
                    int currentI = i;
                    if (currentI + 1 < linesMess.length - 1) {
                        // && currentI < linesMess.length - 1);
                        for (int j = currentI + 1; j < linesMess.length - 1; j++) {
                            tRunJobName = linesMess[j];
                            if ((tRunJobName.contains(componentName))) {
                                break;
                            }
                        }
                        if (tRunJobName.lastIndexOf("(") != -1 && tRunJobName.lastIndexOf(".java") != -1) {
                            tRunJobName = tRunJobName.substring(tRunJobName.lastIndexOf("(") + 1, tRunJobName.lastIndexOf(".java"));
                        } else {
                            tRunJobName = currenctJobName;
                        }
                    }
                }
                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);
                    }
                }
            // break;
            }
        }
    }
    refreshNode(psMess);
}
Also used : Pattern(java.util.regex.Pattern) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) Matcher(java.util.regex.Matcher) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) ProcessMessage(org.talend.designer.runprocess.ProcessMessage) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) Point(org.eclipse.swt.graphics.Point)

Example 2 with ProcessMessage

use of org.talend.designer.runprocess.ProcessMessage 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);
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ProcessMessage(org.talend.designer.runprocess.ProcessMessage) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) Point(org.eclipse.swt.graphics.Point)

Example 3 with ProcessMessage

use of org.talend.designer.runprocess.ProcessMessage 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;
}
Also used : Pattern(java.util.regex.Pattern) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) HashMap(java.util.HashMap) Matcher(java.util.regex.Matcher) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) ProcessMessage(org.talend.designer.runprocess.ProcessMessage)

Example 4 with ProcessMessage

use of org.talend.designer.runprocess.ProcessMessage 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()));
}
Also used : RunProcessContext(org.talend.designer.runprocess.RunProcessContext) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) ProcessMessage(org.talend.designer.runprocess.ProcessMessage) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 5 with ProcessMessage

use of org.talend.designer.runprocess.ProcessMessage in project tdi-studio-se by Talend.

the class DebugProcessTosComposite method addPerlMark.

@Override
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);
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) ProcessMessage(org.talend.designer.runprocess.ProcessMessage) Point(org.eclipse.swt.graphics.Point)

Aggregations

IProcessMessage (org.talend.designer.runprocess.IProcessMessage)11 ProcessMessage (org.talend.designer.runprocess.ProcessMessage)11 Point (org.eclipse.swt.graphics.Point)8 Matcher (java.util.regex.Matcher)6 Pattern (java.util.regex.Pattern)6 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3 Process (org.talend.designer.core.ui.editor.process.Process)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 MessageFormat (java.text.MessageFormat)2 Date (java.util.Date)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 DebugException (org.eclipse.debug.core.DebugException)2 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)2 IProcess (org.eclipse.debug.core.model.IProcess)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 IProgressService (org.eclipse.ui.progress.IProgressService)2 IContext (org.talend.core.model.process.IContext)2 Processor (org.talend.designer.core.runprocess.Processor)2