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);
}
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);
}
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;
}
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()));
}
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);
}
Aggregations