Search in sources :

Example 21 with Problem

use of org.talend.core.model.process.Problem 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)

Example 22 with Problem

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

the class ProblemsAnalyser method checkOutputTablesProblems.

/**
     * DOC amaumont Comment method "checkOutputTablesProblems".
     * 
     * @param extOutputTables
     */
private void checkOutputTablesProblems(List<ExternalMapperTable> extOutputTables) {
    ArrayList<ExternalMapperTable> rejectTables = new ArrayList<ExternalMapperTable>();
    ArrayList<ExternalMapperTable> normalTables = new ArrayList<ExternalMapperTable>();
    ArrayList<ExternalMapperTable> normalTablesWithFilter = new ArrayList<ExternalMapperTable>();
    for (ExternalMapperTable outputTable : extOutputTables) {
        if (outputTable.isReject()) {
            rejectTables.add(outputTable);
        } else if (!outputTable.isRejectInnerJoin()) {
            if (outputTable.getExpressionFilter() != null && outputTable.isActivateExpressionFilter() && //$NON-NLS-1$
            !outputTable.getExpressionFilter().trim().equals("") || outputTable.getConstraintTableEntries() != null && outputTable.getConstraintTableEntries().size() > 0) {
                normalTablesWithFilter.add(outputTable);
            } else {
                normalTables.add(outputTable);
            }
        }
    }
    if (rejectTables.size() > 0 && normalTables.size() > 0) {
        //$NON-NLS-1$
        String tables = "";
        int normalTablesListSize = normalTables.size();
        for (int i = 0; i < normalTablesListSize; i++) {
            ExternalMapperTable normalOutputTable = normalTables.get(i);
            if (i > 0) {
                //$NON-NLS-1$
                tables += ", ";
            }
            //$NON-NLS-1$ //$NON-NLS-2$
            tables += "\"" + normalOutputTable.getName() + "\"";
        }
        //$NON-NLS-1$
        String description = Messages.getString("Problem.warning.unusableReject", new Object[] { tables });
        addProblem(new Problem(null, description, ProblemStatus.WARNING));
    }
}
Also used : ArrayList(java.util.ArrayList) Problem(org.talend.core.model.process.Problem) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable)

Example 23 with Problem

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

the class JobLaunchShortcutManager method resetJobProblemList.

/**
     * 
     * ldong Comment method "resetJobProblemList".
     */
public static void resetJobProblemList(IRepositoryViewObject obj, String oldLabel) {
    if (obj == null) {
        return;
    }
    Property property = obj.getProperty();
    if (property == null || !(property.getItem() instanceof ProcessItem)) {
        return;
    }
    String newLabel = property.getLabel();
    if (!newLabel.equals(oldLabel)) {
        for (Iterator<Problem> iter = Problems.getProblemList().getProblemList().iterator(); iter.hasNext(); ) {
            Problem problem = iter.next();
            if (problem instanceof TalendProblem) {
                TalendProblem routineProblem = (TalendProblem) problem;
                if (routineProblem.getJavaUnitName() != null && (routineProblem.getJavaUnitName().equals(oldLabel))) {
                    // TDI-24683:if rename the jobItem,need clear the problem view to avoid use the old
                    // problem list
                    iter.remove();
                }
            }
        }
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) TalendProblem(org.talend.core.model.process.TalendProblem) TalendProblem(org.talend.core.model.process.TalendProblem) Problem(org.talend.core.model.process.Problem) Property(org.talend.core.model.properties.Property)

Example 24 with Problem

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

the class Problems method computeCompilationUnit.

@SuppressWarnings("restriction")
private static List<Problem> computeCompilationUnit(IFile file, ProblemType type, Item item) throws CoreException {
    ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
    // FIXME, only for standard job first, also for JobLaunchShortcut.launch
    if (itemType == null || !itemType.equals(ERepositoryObjectType.PROCESS)) {
        return Collections.emptyList();
    }
    List<Problem> compilProblems = new ArrayList<Problem>();
    final ICompilationUnit unit = JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(new FileEditorInput(file), false);
    if (unit != null) {
        CompilationUnit ast = unit.reconcile(ASTProvider.SHARED_AST_LEVEL, ICompilationUnit.FORCE_PROBLEM_DETECTION, null, null);
        IProblem[] problems = ast.getProblems();
        if (problems != null) {
            for (IProblem p : problems) {
                String[] arguments = p.getArguments();
                int id = p.getID();
                String message = p.getMessage();
                int sourceLineNumber = p.getSourceLineNumber();
                int sourceStart = p.getSourceStart();
                int sourceEnd = p.getSourceEnd();
                String uniName = null;
                IPath location = file.getLocation();
                if (location != null) {
                    String path = location.toString();
                    uniName = setErrorMark(path, sourceLineNumber);
                }
                ProblemStatus status = ProblemStatus.WARNING;
                if (p.isError()) {
                    status = ProblemStatus.ERROR;
                }
                TalendProblem tp = new TalendProblem(status, item, null, message, sourceLineNumber, uniName, sourceStart, sourceEnd, type);
                compilProblems.add(tp);
            }
        }
    }
    return compilProblems;
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPath(org.eclipse.core.runtime.IPath) TalendProblem(org.talend.core.model.process.TalendProblem) ArrayList(java.util.ArrayList) IProblem(org.eclipse.jdt.core.compiler.IProblem) ProblemStatus(org.talend.core.model.process.Problem.ProblemStatus) FileEditorInput(org.eclipse.ui.part.FileEditorInput) Problem(org.talend.core.model.process.Problem) IProblem(org.eclipse.jdt.core.compiler.IProblem) TalendProblem(org.talend.core.model.process.TalendProblem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 25 with Problem

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

the class Problems method refreshNodeStatus.

/**
     * DOC bqian Comment method "refreshNodeStatus".
     * 
     * @param node
     * @param problemList2
     */
private static void refreshNodeStatus(Node node, List<Problem> problemList) {
    boolean hasWarning = false;
    boolean hasError = false;
    boolean hasInfo = false;
    IProcess process = node.getProcess();
    if (process == null) {
        return;
    }
    for (Problem problem : problemList) {
        // if problem not instanceof TalendProblem ,node don't operate it.for bug 23088
        if (problem.getJobInfo() != null && problem.getJobInfo().getJobId() != null && problem.getJobInfo().getJobId().equals(process.getId()) && !(problem instanceof TalendProblem)) {
            if (problem.getJobInfo().getJobVersion() != null && problem.getJobInfo().getJobVersion().equals(process.getVersion())) {
                if (problem.getNodeName() == null) {
                    continue;
                } else if (problem.getNodeName() != null && (!problem.getNodeName().equals(node.getUniqueName()))) {
                    continue;
                }
                if (problem.getStatus().equals(ProblemStatus.INFO)) {
                    hasInfo = true;
                    node.addStatus(Process.INFO_STATUS);
                } else if (problem.getStatus().equals(ProblemStatus.WARNING)) {
                    hasWarning = true;
                    node.addStatus(Process.WARNING_STATUS);
                } else if (problem.getStatus().equals(ProblemStatus.ERROR)) {
                    hasError = true;
                    node.addStatus(Process.ERROR_STATUS);
                }
            }
        }
    }
    if (!hasWarning) {
        node.removeStatus(Process.WARNING_STATUS);
    }
    if (!hasError) {
        node.removeStatus(Process.ERROR_STATUS);
    }
    if (!hasInfo) {
        node.removeStatus(Process.INFO_STATUS);
    }
    node.updateStatus();
}
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) IProcess(org.talend.core.model.process.IProcess)

Aggregations

Problem (org.talend.core.model.process.Problem)34 TalendProblem (org.talend.core.model.process.TalendProblem)15 ArrayList (java.util.ArrayList)10 IProblem (org.eclipse.jdt.core.compiler.IProblem)9 PersistenceException (org.talend.commons.exception.PersistenceException)4 IProcess (org.talend.core.model.process.IProcess)4 IFile (org.eclipse.core.resources.IFile)3 CoreException (org.eclipse.core.runtime.CoreException)3 SystemException (org.talend.commons.exception.SystemException)3 Item (org.talend.core.model.properties.Item)3 ITalendSynchronizer (org.talend.designer.codegen.ITalendSynchronizer)3 HashSet (java.util.HashSet)2 List (java.util.List)2 IMarker (org.eclipse.core.resources.IMarker)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 ProblemStatus (org.talend.core.model.process.Problem.ProblemStatus)2 Property (org.talend.core.model.properties.Property)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)2