Search in sources :

Example 1 with TalendProblem

use of org.talend.core.model.process.TalendProblem in project tdi-studio-se by Talend.

the class JobErrorsChecker method checkRoutinesCompilationError.

private static void checkRoutinesCompilationError() throws ProcessorException {
    Set<String> dependentRoutines = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(LastGenerationInfo.getInstance().getLastMainJob().getJobId(), LastGenerationInfo.getInstance().getLastMainJob().getJobVersion());
    // from Problems
    List<Problem> errors = Problems.getProblemList().getProblemsBySeverity(ProblemStatus.ERROR);
    for (Problem p : errors) {
        if (p instanceof TalendProblem) {
            TalendProblem talendProblem = (TalendProblem) p;
            if (talendProblem.getType() == ProblemType.ROUTINE && dependentRoutines.contains(talendProblem.getJavaUnitName())) {
                int line = talendProblem.getLineNumber();
                String errorMessage = talendProblem.getDescription();
                throw new ProcessorException(Messages.getString("JobErrorsChecker_routines_compile_errors", talendProblem.getJavaUnitName()) + //$NON-NLS-1$
                '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + //$NON-NLS-1$
                '\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + //$NON-NLS-1$
                errorMessage);
            }
        } else {
        // for now not to check components errors when building jobs in studio/commandline
        // throw new ProcessorException(Messages.getString("JobErrorsChecker_jobDesign_errors", p.getType().getTypeName(), //$NON-NLS-1$
        //      p.getJobInfo().getJobName(), p.getComponentName(), p.getDescription()));
        }
    }
    // if can't find the routines problem, try to check the file directly(mainly for commandline)
    try {
        final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
        IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
        List<IRepositoryViewObject> routinesObjects = factory.getAll(ERepositoryObjectType.ROUTINES, false);
        if (routinesObjects != null) {
            for (IRepositoryViewObject obj : routinesObjects) {
                Property property = obj.getProperty();
                if (!dependentRoutines.contains(property.getLabel())) {
                    continue;
                }
                Item routinesitem = property.getItem();
                IFile routinesFile = synchronizer.getFile(routinesitem);
                IMarker[] markers = routinesFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
                for (IMarker marker : markers) {
                    Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
                    String message = (String) marker.getAttribute(IMarker.MESSAGE);
                    Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
                    Integer start = (Integer) marker.getAttribute(IMarker.CHAR_START);
                    Integer end = (Integer) marker.getAttribute(IMarker.CHAR_END);
                    if (lineNr != null && message != null && severity != null && start != null && end != null) {
                        switch(severity) {
                            case IMarker.SEVERITY_ERROR:
                                throw new ProcessorException(//$NON-NLS-1$
                                Messages.getString("JobErrorsChecker_routines_compile_errors", property.getLabel()) + '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + lineNr + //$NON-NLS-1$
                                '\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + //$NON-NLS-1$
                                message);
                            default:
                                break;
                        }
                    }
                }
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    } catch (SystemException e) {
        ExceptionHandler.process(e);
    } catch (CoreException e) {
        ExceptionHandler.process(e);
    }
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) IFile(org.eclipse.core.resources.IFile) TalendProblem(org.talend.core.model.process.TalendProblem) Item(org.talend.core.model.properties.Item) SystemException(org.talend.commons.exception.SystemException) CoreException(org.eclipse.core.runtime.CoreException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) TalendProblem(org.talend.core.model.process.TalendProblem) Problem(org.talend.core.model.process.Problem) IMarker(org.eclipse.core.resources.IMarker) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 2 with TalendProblem

use of org.talend.core.model.process.TalendProblem in project tdi-studio-se by Talend.

the class Problems method add.

public static void add(ProblemStatus status, IMarker marker, Item item, String markerErrorMessage, Integer lineN, String uniName, Integer charStart, Integer charEnd, ProblemType type) {
    Problem problem = new TalendProblem(status, item, marker, markerErrorMessage, lineN, uniName, charStart, charEnd, type);
    add(problem);
}
Also used : TalendProblem(org.talend.core.model.process.TalendProblem) Problem(org.talend.core.model.process.Problem) IProblem(org.eclipse.jdt.core.compiler.IProblem) TalendProblem(org.talend.core.model.process.TalendProblem)

Example 3 with TalendProblem

use of org.talend.core.model.process.TalendProblem in project tdi-studio-se by Talend.

the class Problems method add.

public static void add(ProblemStatus status, IMarker marker, String javaUnitName, String markerErrorMessage, Integer lineN, String uniName, Integer charStart, Integer charEnd, ProblemType type, String version) {
    Problem problem = new TalendProblem(status, javaUnitName, marker, markerErrorMessage, lineN, uniName, charStart, charEnd, type, version);
    add(problem);
// addErrorMark();
}
Also used : TalendProblem(org.talend.core.model.process.TalendProblem) Problem(org.talend.core.model.process.Problem) IProblem(org.eclipse.jdt.core.compiler.IProblem) TalendProblem(org.talend.core.model.process.TalendProblem)

Example 4 with TalendProblem

use of org.talend.core.model.process.TalendProblem in project tdi-studio-se by Talend.

the class Problems method removeProblemsByProcess.

/**
     * 
     * DOC hcyi Comment method "removeProblemsByProcess".
     * 
     * @param process
     * @param isDeleted
     */
public static void removeProblemsByProcess(IProcess process, boolean isDeleted) {
    for (Iterator<Problem> iter = problemList.getProblemList().iterator(); iter.hasNext(); ) {
        Problem problem = iter.next();
        if (problem == null) {
            continue;
        }
        if (problem.getJobInfo() != null && (problem.getJobInfo().getJobId().equals(process.getId()) && problem.getJobInfo().getJobVersion().equals(process.getVersion()))) {
            iter.remove();
        }
        // if not open editor then run job , will not fill the JobInfo .
        if (problem.getJobInfo() == null && problem instanceof TalendProblem) {
            TalendProblem talendProblem = (TalendProblem) problem;
            String jobName = talendProblem.getJavaUnitName();
            if (jobName != null && jobName.equals(process.getName()) && talendProblem.getVersion().equals(process.getVersion())) {
                iter.remove();
            }
        }
    }
    refreshProblemTreeView();
}
Also used : TalendProblem(org.talend.core.model.process.TalendProblem) Problem(org.talend.core.model.process.Problem) IProblem(org.eclipse.jdt.core.compiler.IProblem) TalendProblem(org.talend.core.model.process.TalendProblem)

Example 5 with TalendProblem

use of org.talend.core.model.process.TalendProblem in project tdi-studio-se by Talend.

the class ErrorDetailTreeBuilder method createTreeInput.

/**
     * DOC chuang Comment method "createTreeInput".
     * 
     * @param errors
     * @param jobNames
     * @return
     */
public List<JobErrorEntry> createTreeInput(List<Problem> errors, Set<String> jobIds) {
    for (Problem error : errors) {
        if (error instanceof TalendProblem) {
            TalendProblem talendProblem = (TalendProblem) error;
            if (talendProblem != null && talendProblem.getJobInfo() != null) {
                if (talendProblem.getType() == ProblemType.ROUTINE) {
                    JobErrorEntry routineEntry = getJobEntry(ROUTINE_ERROR);
                    routineEntry.addItem(talendProblem.getJavaUnitName(), talendProblem);
                } else {
                    String jobId = talendProblem.getJobInfo().getJobId();
                    if (!jobIds.contains(jobId)) {
                        continue;
                    }
                    String componentName = GENERAL_ERROR;
                    JobErrorEntry jobEntry = getJobEntry(talendProblem.getJavaUnitName());
                    jobEntry.addItem(componentName, talendProblem);
                }
            }
        } else {
            if (error != null && error.getJobInfo() != null) {
                String jobId = error.getJobInfo().getJobId();
                if (!jobIds.contains(jobId)) {
                    continue;
                }
                String componentName = error.getNodeName();
                JobErrorEntry jobEntry = getJobEntry(error.getJobInfo().getJobName());
                jobEntry.addItem(componentName, error);
            }
        }
    }
    return new ArrayList<JobErrorEntry>(jobs.values());
}
Also used : TalendProblem(org.talend.core.model.process.TalendProblem) ArrayList(java.util.ArrayList) TalendProblem(org.talend.core.model.process.TalendProblem) Problem(org.talend.core.model.process.Problem)

Aggregations

Problem (org.talend.core.model.process.Problem)10 TalendProblem (org.talend.core.model.process.TalendProblem)10 IProblem (org.eclipse.jdt.core.compiler.IProblem)6 ArrayList (java.util.ArrayList)2 IProcess (org.talend.core.model.process.IProcess)2 Property (org.talend.core.model.properties.Property)2 Entry (java.util.Map.Entry)1 IFile (org.eclipse.core.resources.IFile)1 IMarker (org.eclipse.core.resources.IMarker)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)1 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 Tree (org.eclipse.swt.widgets.Tree)1 TreeColumn (org.eclipse.swt.widgets.TreeColumn)1